:root {
    --nav: #12282d;
    --nav-hover: #1c3a40;
    --nav-muted: #9eb0b4;
    --canvas: #f5f7f7;
    --surface: #ffffff;
    --surface-subtle: #eef3f3;
    --line: #d8e0e1;
    --line-strong: #b7c5c8;
    --ink: #16282d;
    --muted: #66777b;
    --accent: #0a756c;
    --accent-hover: #075e58;
    --accent-soft: #e5f3f1;
    --positive: #137a52;
    --warning: #a86608;
    --negative: #a83d46;
    --focus: #2f85da;
    --sidebar-width: 272px;
    --content-max: 1560px;
    --radius-sm: 8px;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(9, 35, 40, .05), 0 8px 24px rgba(9, 35, 40, .04);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 65%, transparent); outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 50; display: flex; flex-direction: column; padding: 18px 14px; background: var(--nav); color: #fff; overflow-y: auto; border: 0; }
.brand { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 0 7px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand > span:nth-child(2) { display: grid; line-height: 1.2; }
.brand strong { font-size: 13px; letter-spacing: .13em; }
.brand small { color: var(--nav-muted); font-size: 11px; letter-spacing: 0; margin-top: 3px; }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 32px; height: 32px; border-radius: 9px; color: #fff; background: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.sidebar-close { display: none; margin-left: auto; width: 36px; height: 36px; border: 0; color: #fff; background: transparent; font-size: 24px; }
.security-switcher { display: grid; grid-template-columns: 36px minmax(0,1fr) 18px; align-items: center; gap: 10px; width: 100%; margin: 14px 0 17px; padding: 10px; color: #fff; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); text-align: left; text-decoration: none; cursor: pointer; }
.security-switcher:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.2); }
.security-switcher > span:nth-child(2) { display: grid; min-width: 0; }
.security-switcher strong, .security-switcher small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.security-switcher strong { font-size: 13px; }
.security-switcher small { color: var(--nav-muted); font-size: 11px; margin-top: 2px; }
.security-switcher svg { width: 17px; stroke: var(--nav-muted); fill: none; stroke-width: 1.8; }
.security-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent); font-size: 11px; font-weight: 800; }
.security-switcher.empty .security-avatar { background: rgba(255,255,255,.11); font-size: 20px; font-weight: 400; }
.sidebar-label { margin: 0 9px 7px; color: #769096; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.sidebar-label.model-label { margin-top: 18px; }
.side-nav { display: grid; gap: 3px; }
.side-nav-item { display: flex; align-items: center; gap: 10px; min-height: 39px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: #c7d3d5; text-decoration: none; font-size: 13px; text-align: left; cursor: pointer; }
.side-nav-item:hover { color: #fff; background: var(--nav-hover); }
.side-nav-item.active { color: #fff; background: #21454b; box-shadow: inset 3px 0 var(--accent); }
.side-nav-item svg { flex: 0 0 17px; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-footer { display: flex; align-items: flex-start; gap: 9px; margin-top: auto; padding: 16px 8px 2px; border-top: 1px solid rgba(255,255,255,.1); color: #c5d0d2; font-size: 11px; line-height: 1.4; }
.sidebar-footer small { color: #80979c; }
.connection-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; margin: 5px 6px 0 0; border-radius: 50%; background: var(--warning); }

.main-canvas { grid-column: 2; width: 100%; min-width: 0; padding: 0 34px 48px; background: transparent; }
.topbar { position: sticky; top: 0; z-index: 35; display: flex; justify-content: space-between; align-items: center; min-height: 58px; margin: 0 -34px; padding: 0 34px; background: rgba(245,247,247,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); color: var(--muted); font-size: 12px; }
.topbar > div:last-child { display: flex; align-items: center; gap: 4px; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs strong { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs b { color: var(--line-strong); }
.mobile-brand { display: none; align-items: center; gap: 8px; }
.menu-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); }
.menu-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-scrim { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(5,20,24,.48); }

.workspace-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; max-width: var(--content-max); margin: 0 auto; padding: 36px 0 24px; border: 0; }
.workspace-heading h1 { margin: 3px 0 6px; color: var(--ink); font-size: clamp(25px, 2.4vw, 38px); line-height: 1.15; letter-spacing: -.03em; }
.workspace-heading .subtitle { margin: 0; color: var(--muted); max-width: 760px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.heading-actions, .quick-actions, .actions, .gordon-actions, .multi-actions, .reit-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.heading-actions { flex-wrap: nowrap; }
.workspace-heading .heading-actions { position: sticky; top: 70px; z-index: 20; }

.primary-button, .quiet-button, button.primary-button, button.quiet-button { display: inline-flex; justify-content: center; align-items: center; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); text-decoration: none; font-weight: 650; cursor: pointer; box-shadow: none; }
.primary-button, button.primary-button { border-color: var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover, button.primary-button:hover { background: var(--accent-hover); }
.quiet-button:hover, button.quiet-button:hover { border-color: #8ca3a7; background: var(--surface-subtle); }
button:disabled, .primary-button:disabled, .quiet-button:disabled { opacity: .48; cursor: not-allowed; }

.context-notice { display: flex; justify-content: space-between; align-items: center; gap: 24px; max-width: var(--content-max); margin: 0 auto 18px; padding: 16px 18px; border: 1px solid #c7d9d7; border-radius: var(--radius); background: var(--accent-soft); }
.context-notice p { margin: 3px 0 0; color: var(--muted); }
.model-tabs { position: sticky; top: 58px; z-index: 30; display: flex; flex-wrap: wrap; gap: 2px; max-width: var(--content-max); margin: 0 auto 22px; padding: 0 0 1px; overflow-x: auto; border: 0; border-bottom: 1px solid var(--line); background: var(--canvas); scrollbar-width: thin; }
.workspace-action-bar { display: flex; gap: 7px; max-width: var(--content-max); margin: -8px auto 18px; padding: 10px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.9); box-shadow: var(--shadow); }
.workspace-action-bar > * { flex: 0 0 auto; min-height: 36px; padding: 7px 11px; font-size: 12px; }
.model-tab { flex: 0 0 auto; min-height: 43px; padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.model-tab:hover { color: var(--ink); background: var(--surface-subtle); }
.model-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }
.model-mode-chip { display: inline-flex; align-items: center; min-height: 32px; margin: 0 0 12px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 700; }
.context-conflict-notice { max-width: var(--content-max); margin: -10px auto 16px; padding: 10px 14px; border: 1px solid #e5c27d; border-radius: 9px; background: #fff8e8; color: #714600; font-size: 13px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.section-view, body .section-view, .workspace-section { display: none; max-width: var(--content-max); margin: 0 auto; padding: 0; }
.section-view.active, body .section-view.active, .workspace-section.active { display: block; }
.section-intro { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin: 0 0 16px; padding: 0; border: 0; }
.section-intro h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.015em; }
.section-intro p { margin: 0; color: var(--muted); }
.as-of { color: var(--muted); text-align: right; font-size: 11px; }
.panel, .detail-card, .launch-card, .result-card, .phase-card, .nav-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel { margin: 0 0 16px; padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 0 0 16px; padding: 0 0 14px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .panel-heading h3 { margin: 0 0 3px; color: var(--ink); }
.panel-heading h3 { font-size: 15px; }
.panel-heading p { margin: 0; color: var(--muted); }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.two-column .panel { min-width: 0; }
.result-grid, .phase-grid, .nav-grid, .dashboard-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.result-card, .phase-card, .nav-card { display: grid; gap: 6px; min-height: 116px; padding: 16px; }
.result-card > span, .phase-card > span, .nav-card > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.result-card strong, .phase-card strong, .nav-card strong { color: var(--ink); font-size: 22px; font-variant-numeric: tabular-nums; }
.result-card small, .phase-card small, .nav-card small { color: var(--muted); }
.result-card.key { border-color: #a9d2cc; background: var(--accent-soft); }
.status-badge, .api-pill, .badge { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 999px; background: var(--surface-subtle); color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .04em; }
.api-pill { background: var(--accent-soft); color: var(--accent); }
.status { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-subtle); color: var(--muted); }
.status.error { background: #fbecee; color: var(--negative); }
.empty-state, .empty { display: grid; justify-items: center; gap: 8px; padding: 54px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); text-align: center; }
.empty-state h2, .empty h2 { margin: 0; color: var(--ink); }
.empty-state p, .empty p { margin: 0; max-width: 540px; }
.empty-icon svg { width: 30px; fill: none; stroke: var(--accent); stroke-width: 1.5; }
.input-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
label { color: var(--muted); font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 40px; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 20%, transparent); }
.table-wrap, .library-table { max-width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
table { border-collapse: separate; border-spacing: 0; width: 100%; color: var(--ink); font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; z-index: 2; background: #eaf0f0; color: #496065; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; background: inherit; text-align: left; }
tbody tr:hover td { background: #f7fafa; }

.launch-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.launch-card { position: relative; display: grid; align-content: start; gap: 9px; min-height: 160px; padding: 20px; color: var(--ink); text-decoration: none; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.launch-card:hover { transform: translateY(-2px); border-color: #a4babd; box-shadow: 0 10px 28px rgba(9,35,40,.09); }
.launch-card h3, .launch-card p { margin: 0; }
.launch-card p { color: var(--muted); }
.dashboard-strip > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dashboard-strip span, .dashboard-strip strong { display: block; }
.dashboard-strip span { color: var(--muted); font-size: 11px; }
.dashboard-strip strong { margin-top: 4px; }
.dashboard-company { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr) auto; align-items: center; gap: 24px; }
.dashboard-company h2, .dashboard-company p { margin: 0; }
.dashboard-company h2 { margin-top: 3px; font-size: 22px; }
.dashboard-company > div:first-child > p:last-child { color: var(--muted); }
.dashboard-company-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dashboard-company-meta span { display: grid; }
.dashboard-company-meta small { color: var(--muted); }
.search-panel, .detail-card { max-width: 980px; margin: 0 auto 18px; }
.detail-card { padding: 22px; }
.library-controls { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(180px, 260px); gap: 10px; }
.library-controls input, .library-controls select { margin: 0; }
.library-cards { display: none; }
.library-table td:nth-child(3) strong, .library-table td:nth-child(3) small { display: block; }
.library-table td:nth-child(3) small { color: var(--muted); margin-top: 2px; }
.library-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.library-card h3, .library-card p { margin: 0; }
.library-card h3 { margin-top: 4px; }
.library-card p { color: var(--muted); }
.library-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.library-card dl div { display: grid; }
.library-card dt { color: var(--muted); font-size: 11px; }
.library-card dd { margin: 2px 0 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
@media (max-width: 1100px) {
    .result-grid, .phase-grid, .nav-grid, .dashboard-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .launch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .input-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { transform: translateX(-105%); width: min(88vw, 304px); transition: transform .2s ease; box-shadow: 14px 0 40px rgba(5,20,24,.25); }
    .nav-open .sidebar { transform: translateX(0); }
    .nav-open .nav-scrim { display: block; }
    .sidebar-close { display: block; }
    .main-canvas { width: 100%; padding: 0 18px 40px; }
    .topbar { margin: 0 -18px; padding: 0 18px; min-height: 58px; }
    .mobile-brand { display: flex; }
    .topbar .crumbs { display: none; }
    .topbar > div:last-child { max-width: 46%; }
    .workspace-heading { align-items: flex-start; padding: 26px 0 20px; }
    .workspace-heading .heading-actions { position: static; }
    .model-tabs { top: 58px; flex-wrap: nowrap; margin-right: -18px; margin-left: -18px; padding-left: 18px; }
    .two-column { grid-template-columns: 1fr; }
    .context-notice { align-items: flex-start; }
    .dashboard-company { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .workspace-heading { display: grid; gap: 16px; }
    .workspace-heading h1 { font-size: 28px; }
    .heading-actions { width: 100%; }
    .heading-actions > * { flex: 1; }
    .result-grid, .phase-grid, .nav-grid, .dashboard-strip, .launch-grid, .input-grid, .library-controls { grid-template-columns: 1fr; }
    .result-card, .phase-card, .nav-card { min-height: 96px; }
    .panel { padding: 16px; }
    .panel-heading, .section-intro, .context-notice { display: grid; gap: 12px; }
    .as-of { text-align: left; }
    .context-notice .primary-button { width: 100%; }
    .topbar > div:last-child { font-size: 0; }
    #connection-label { display: none; }
    .library-table table { display: none; }
    .library-cards { display: grid; gap: 12px; }
}

.preparation-panel { margin: 0 32px 24px; }
.preparation-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.preparation-status-grid span { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-subtle); }
.preparation-status-grid small, .preparation-status-grid strong { display: block; }
.preparation-status-grid small { color: var(--text-muted); margin-bottom: 4px; }
@media (max-width: 768px) { .preparation-panel { margin: 0 16px 20px; } .preparation-status-grid { grid-template-columns: 1fr 1fr; } }

/* Model workspaces use the full analytical canvas; reading pages keep their bounded widths. */
.model-workspace-page .workspace-heading,
.model-workspace-page .model-tabs,
.model-workspace-page .workspace-action-bar,
.model-workspace-page .context-notice,
.model-workspace-page .context-conflict-notice,
.model-workspace-page .section-view,
.model-workspace-page .workspace-section { max-width: none; width: 100%; }
.model-workspace-page .preparation-panel { width: 100%; margin: 0 0 24px; }
.two-column.single-visible { grid-template-columns: minmax(0, 1fr); }
.two-column.single-visible > .panel:not([hidden]) { grid-column: 1 / -1; width: 100%; }
.model-workspace-page .panel,
.model-workspace-page .table-panel,
.model-workspace-page .table-wrap { min-width: 0; }
.model-workspace-page .analytical-table table,
.model-workspace-page .table-panel table { width: 100%; }
.canonical-history-panel { margin-top: 18px; }
.history-controls { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.history-controls label { min-width: min(220px, 100%); }
.quality-rejected td { background: #fff6f0; color: #7b4435; }
@media (min-width: 1200px) {
    .model-workspace-page .analytical-table table { min-width: 100%; table-layout: auto; }
}
@media (max-width: 768px) {
    .model-workspace-page .preparation-panel { margin: 0 0 20px; }
    .model-workspace-page .analytical-table table { min-width: 860px; }
}
