:root {
    --sidebar-background: #183039;
    --sidebar-active: #284a51;
    --workspace-background: #f3f6f7;
    --panel-background: #ffffff;
    --panel-border: #dbe3e6;
    --primary-text: #17242b;
    --secondary-text: #65747c;
    --teal-action: #13776e;
    --teal-hover: #0d635b;
    --success-badge: #dcefe4;
    --success-text: #185e3d;
    --warning-badge: #fff0c9;
    --warning-text: #785000;
    --danger-badge: #f8dfe1;
    --danger-text: #8e242c;
    --neutral-badge: #e7edef;
    --neutral-text: #4d5d65;
    --safety-background: #fff1bf;
    --safety-text: #473400;
    --purple: #6961ae;
    --source-accent: #7b929b;
    --review-accent: #318864;
    --sidebar-width: 230px;
    --banner-height: 39px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--workspace-background); }
body { min-height: 100vh; margin: 0; color: var(--primary-text); background: var(--workspace-background); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea, summary { outline-offset: 2px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid #57b8ad; }
a { color: #096b63; text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: 22px; }
h2 { font-size: 26px; }
h3 { font-size: 15px; }
h4 { font-size: 12px; }
small, .muted { color: var(--secondary-text); }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.safety-banner { position: sticky; top: 0; z-index: 40; min-height: var(--banner-height); padding: 9px 20px; border-bottom: 1px solid #dfc259; color: var(--safety-text); background: var(--safety-background); font-size: 12px; font-weight: 800; letter-spacing: .01em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-sidebar { position: fixed; z-index: 30; top: var(--banner-height); bottom: 0; left: 0; display: flex; width: var(--sidebar-width); flex-direction: column; padding: 25px 17px 17px; color: #eaf4f2; background: var(--sidebar-background); overflow-y: auto; }
.sidebar-brand h1 { margin: 0; color: #fff; font-size: 17px; line-height: 1.25; }
.sidebar-brand small { display: block; margin: 6px 0 25px; color: #9dc2bd; line-height: 1.4; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: block; padding: 11px; border-radius: 8px; color: #e2eeec; font-weight: 500; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--sidebar-active); text-decoration: none; }
.sidebar-account { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid rgba(221, 239, 236, .16); }
.account-name, .account-role { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name { color: #fff; font-size: 13px; font-weight: 700; }
.account-role { margin-top: 2px; color: #9dc2bd; font-size: 11px; }
.sidebar-account form { margin-top: 10px; }
.sidebar-logout { width: 100%; padding: 8px 9px; border: 1px solid rgba(229, 242, 240, .2); border-radius: 7px; color: #e2eeec; background: transparent; text-align: left; cursor: pointer; }
.sidebar-logout:hover { background: var(--sidebar-active); }
.sidebar-toggle { display: none; }
.workspace-main { width: calc(100% - var(--sidebar-width)); min-width: 0; max-width: 1600px; min-height: calc(100vh - var(--banner-height)); margin-left: var(--sidebar-width); padding: 28px; overflow: visible; }
.workspace-footer { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--panel-border); color: var(--secondary-text); font-size: 11px; }

.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.workspace-heading h2 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; }
.workspace-heading p { margin: 4px 0 0; color: var(--secondary-text); }
.panel { padding: 17px; border: 1px solid var(--panel-border); border-radius: 11px; background: var(--panel-background); box-shadow: 0 1px 2px rgba(23, 36, 43, .07); }
.workspace-section { margin: 14px 0; }
.workspace-section > h3 { margin: 0 0 9px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 13px; }
.metric-panel span { display: block; color: var(--secondary-text); }
.metric-panel strong { display: block; margin-top: 4px; font-size: 27px; font-variant-numeric: tabular-nums; }
.overview-details { margin: 15px 0 0; }
.overview-details div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--panel-border); }
.overview-details div:last-child { border-bottom: 0; }
.overview-details dt { font-weight: 700; }
.overview-details dd { margin: 0; color: var(--secondary-text); }

.badge, .pill { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--neutral-badge); color: var(--neutral-text); font-size: 11px; font-weight: 750; line-height: 1.35; text-transform: capitalize; }
.badge { padding: 5px 9px; }
.badge-neutral { background: #dfeeea; color: #0b5a52; }
.badge-approved, .pill.ok, .status-approved { background: var(--success-badge); color: var(--success-text); }
.pill.bad, .status-rejected { background: var(--danger-badge); color: var(--danger-text); }
.pill.warn, .status-changes_requested { background: var(--warning-badge); color: var(--warning-text); }
.status-unreviewed { background: var(--neutral-badge); color: var(--neutral-text); }
.status-generated { background: #e9e7f8; color: #514a93; }

.notice { margin: 0 0 14px; padding: 11px; border: 0; border-radius: 8px; background: #e8f3f1; color: #285d57; }
.notice-success, .notice-info { background: #e8f3f1; color: #285d57; }
.notice-warning { background: var(--warning-badge); color: var(--warning-text); }
.notice-error { background: #fae3e5; color: #90262e; }
.notice-purple { background: #efedfb; color: #514a93; }

.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 8px 12px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.button:hover { text-decoration: none; }
.button-primary { border: 1px solid var(--teal-action); color: #fff; background: var(--teal-action); }
.button-primary:hover { border-color: var(--teal-hover); background: var(--teal-hover); }
.button-secondary { border: 1px solid var(--panel-border); color: var(--primary-text); background: #fff; }
.button-secondary:hover { background: #f8fafb; }
.button-danger { border: 1px solid #e0a8ad; color: #a12c35; background: #fff4f4; }
.button-full { width: 100%; }
.button.disabled, button:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.is-loading { opacity: .65; pointer-events: none; }

.field { display: flex; min-width: 0; flex-direction: column; gap: 5px; color: #4d5d65; font-size: 12px; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--panel-border); border-radius: 8px; color: var(--primary-text); background: #fff; }
.field input, .field select { min-height: 40px; }
.field textarea { min-height: 110px; resize: vertical; }
.field textarea.long-editor { min-height: 240px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.field textarea.attributes-editor { min-height: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.field input:disabled, .field textarea:disabled { background: #f3f5f6; }
.stack-form { display: flex; flex-direction: column; gap: 13px; }
.field-help { min-height: 18px; color: var(--secondary-text); font-size: 12px; font-weight: 400; }
.field-help.is-error { color: var(--danger-text); }
.form-footnote { margin: 12px 0 0; color: var(--secondary-text); font-size: 12px; }
.two-column-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.filter-panel { margin-bottom: 14px; }
.search-row { display: grid; grid-template-columns: minmax(250px, 480px) auto; align-items: end; gap: 8px; margin-bottom: 12px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; }
.compact-filters { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)) auto; align-items: end; gap: 10px; }
.compact-filters .button { margin: 0; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; border: 1px solid var(--panel-border); background: #fff; }
th, td { padding: 10px; border-bottom: 1px solid var(--panel-border); text-align: left; vertical-align: top; }
th { color: #5d6a70; background: #f8fafb; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
tr:hover td { background: #f9fbfb; }
td { font-size: 13px; }
.product-table { min-width: 950px; }
.product-table th:first-child { width: 32%; }
.product-table th:nth-child(4) { width: 22%; }
.product-identity-cell a { display: inline-block; margin-bottom: 2px; }
.product-identity-cell span { color: var(--primary-text); }
.status-cell { line-height: 1.75; }
.count { font-variant-numeric: tabular-nums; }
.empty-table { padding: 28px; color: var(--secondary-text); text-align: center; }
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.pagination > span:not(.button) { padding: 0 6px; }

.product-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(350px, 430px); align-items: start; gap: 18px; }
.product-main-column { min-width: 0; }
.review-sidebar { position: sticky; top: 57px; max-height: calc(100vh - 74px); padding-right: 2px; overflow: auto; }
.source-panel { border-left: 4px solid var(--source-accent); }
.generated-panel { border-left: 4px solid var(--purple); }
.effective-panel { border-left: 4px solid var(--review-accent); }
.feedback-panel { border-left: 4px solid var(--teal-action); }
.preview { max-height: 380px; padding: 12px; overflow: auto; border: 1px solid var(--panel-border); border-radius: 8px; background: #fff; }
.text-preview { min-height: 74px; }
.html-content h2 { font-size: 18px; }
.html-content h3 { font-size: 15px; }
.html-content h4 { font-size: 13px; }
.html-content p:last-child, .html-content ul:last-child { margin-bottom: 0; }
.raw { max-height: 270px; margin: 8px 0 0; padding: 12px; overflow: auto; border-radius: 8px; color: #d8e6e4; background: #152329; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
details { margin: 8px 0; }
summary { cursor: pointer; font-weight: 650; }
.gallery { display: flex; gap: 8px; padding-bottom: 4px; overflow-x: auto; }
.image-group { margin-top: 12px; }
.image-group h4 { margin: 0 0 7px; color: var(--secondary-text); }
.gallery figure { width: 125px; flex: 0 0 125px; margin: 0; }
.gallery img { width: 125px; height: 125px; object-fit: contain; border: 1px solid var(--panel-border); border-radius: 8px; background: #fff; }
.gallery figcaption { padding-top: 5px; color: var(--secondary-text); font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.metadata-footer { margin: 12px 0 0; color: var(--secondary-text); font-size: 12px; }
.saved { color: var(--success-text); font-weight: 750; }
.identity-panel .button { width: 100%; }
.workflow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0; }
.workflow-grid dt { font-weight: 700; }
.workflow-grid dd { margin: 0; }
.workflow-message { margin: 10px 0 0; padding: 10px; border-radius: 8px; }
.review-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.review-panel[open] > summary { margin-bottom: 13px; }
.review-panel .stack-form { margin-top: 4px; }
.acknowledgement { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.acknowledgement input { width: auto; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.local-only-notice { margin: 0; font-size: 11px; font-weight: 700; }
.history-list { display: flex; flex-direction: column; }
.history-item { padding: 9px 0; border-bottom: 1px solid var(--panel-border); font-size: 12px; }
.history-item:last-child { border: 0; }
.history-review { padding-left: 10px; border-left: 3px solid #cddbd1; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.history-item p { margin: 0 0 3px; }
.quality-panel p { margin: 9px 0; }
.danger-panel { border-color: #e8c2c5; }
.danger-content { padding-top: 8px; }
.danger-form { display: grid; max-width: 620px; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }

.feedback-form-panel { max-width: 1000px; }
.admin-metrics { grid-template-columns: repeat(4, 1fr); }
.admin-actions .actions { margin-bottom: 0; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > h3 { padding: 17px 17px 8px; }
.table-panel td:last-child { min-width: 300px; }
.table-panel td p { margin: 3px 0 10px; }

.auth-main { display: grid; width: 100%; min-height: calc(100vh - var(--banner-height)); margin: 0; padding: 34px 18px; place-items: start center; }
.login-panel { width: min(430px, 100%); margin-top: 34px; padding: 25px; }
.login-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-heading h1 { margin: 0 0 3px; font-size: 20px; }
.login-heading p { margin: 0; color: var(--secondary-text); }
.login-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 8px; color: #fff; background: var(--sidebar-background); font-size: 13px; font-weight: 800; }
.installer-panel { width: min(520px, 100%); margin-top: 0; }
.state-panel { width: min(620px, 100%); margin: 35px auto; text-align: left; }
.state-panel h1 { margin: 15px 0 8px; }

@media (max-width: 1200px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
    .compact-filters { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

@media (max-width: 1050px) {
    .product-layout { grid-template-columns: 1fr; }
    .review-sidebar { position: static; max-height: none; overflow: visible; }
}

@media (max-width: 820px) {
    :root { --banner-height: 48px; }
    .safety-banner { padding: 8px 12px; white-space: normal; font-size: 10px; line-height: 1.35; }
    .workspace-sidebar { position: static; display: none; width: 100%; min-height: auto; padding: 10px; }
    .workspace-sidebar.is-open { display: flex; }
    .sidebar-brand { display: none; }
    .sidebar-nav { flex-direction: row; gap: 5px; overflow-x: auto; }
    .sidebar-nav a { width: auto; flex: 0 0 auto; padding: 9px 11px; white-space: nowrap; }
    .sidebar-account { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 8px 2px 0; }
    .account-role { margin: 0; }
    .sidebar-account form { margin: 0 0 0 auto; }
    .sidebar-logout { width: auto; }
    .sidebar-toggle { display: block; width: 100%; padding: 9px 14px; border: 0; color: #fff; background: var(--sidebar-background); text-align: left; font-weight: 700; cursor: pointer; }
    .workspace-main { width: 100%; margin: 0; padding: 17px; }
    .filter-grid, .compact-filters { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
    .two-column-fields { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .workspace-heading { align-items: flex-start; flex-direction: column; }
    .workspace-heading h2 { font-size: 23px; }
    .metric-grid, .admin-metrics, .filter-grid, .compact-filters { grid-template-columns: 1fr; }
    .search-row { grid-template-columns: 1fr; }
    .search-row .button { width: 100%; }
    .overview-details div { grid-template-columns: 1fr; gap: 2px; }
    .danger-form { grid-template-columns: 1fr; }
    .review-actions .button { width: 100%; }
}
