/* ══════════════════════════════════════════════════════════════
   Brickyard — Protest 001 Dashboard
   Light Professional Theme
   ══════════════════════════════════════════════════════════════ */

:root {
    /* ── Base palette ── */
    --bg-deep: #f0f1f4;
    --bg-surface: #f6f7f9;
    --bg-elevated: #ebedf2;
    --bg-card: #ffffff;
    --bg-hover: #eef0f5;
    --bg-active: #e3e7f0;

    /* ── Borders ── */
    --border: #d4d8e1;
    --border-bright: #b8bfcc;
    --border-focus: #8093ad;

    /* ── Text hierarchy ── */
    --text: #1e2a36;
    --text-bright: #0d1117;
    --text-dim: #475569;
    --text-muted: #7c8a9a;

    /* ── Party colors ── */
    --color-wsdot: #0e7a50;
    --color-wsdot-bg: rgba(14,122,80,0.06);
    --color-wsdot-border: rgba(14,122,80,0.18);
    --color-skanska: #1a5fb4;
    --color-skanska-bg: rgba(26,95,180,0.06);
    --color-skanska-border: rgba(26,95,180,0.18);
    --color-aecom: #6c4fb8;
    --color-aecom-bg: rgba(108,79,184,0.06);
    --color-aecom-border: rgba(108,79,184,0.18);
    --color-deny: #c42b2b;
    --color-deny-bg: rgba(196,43,43,0.06);
    --color-warn: #a35d00;
    --color-warn-bg: rgba(163,93,0,0.07);
    --color-warn-border: rgba(163,93,0,0.2);

    /* ── Semantic aliases (preserve existing class compat) ── */
    --color-bg: var(--bg-card);
    --color-surface: var(--bg-surface);
    --color-border: var(--border);
    --color-text: var(--text);
    --color-text-light: var(--text-dim);
    --color-text-lighter: var(--text-muted);
    --color-sidebar-bg: #ffffff;
    --color-sidebar-active: var(--bg-active);
    --color-sidebar-hover: var(--bg-hover);

    /* ── Structure ── */
    --sidebar-width: 260px;
    --viewer-width: 44%;
    --radius: 0;
    --radius-lg: 0;

    /* ── Fonts ── */
    --font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-condensed: 'IBM Plex Sans Condensed', 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;

    /* ── Text zoom (Ctrl+scroll to adjust) ── */
    --text-scale: 1.1;
}

/* ── Reset & Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-family);
    background: var(--bg-deep);
    color: var(--text);
    line-height: 1.65;
    font-weight: 450;
    font-size: 14.5px;
}

::selection { background: rgba(26,95,180,0.18); color: var(--text-bright); }

/* ── Layout ── */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    position: relative;
}

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    z-index: 10;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.dashboard-link {
    display: block;
    font-size: 11px;
    font-family: var(--font-condensed);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 8px;
    padding: 0 20px;
    transition: color 0.15s;
}
.dashboard-link:hover { color: var(--color-skanska); }

.sidebar-logo {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    opacity: 1;
}

.sidebar-header {
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.sidebar-header h1 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.35;
}
.sidebar-header .meta {
    font-size: 11.5px;
    font-family: var(--font-mono);
    color: var(--text-dim);
    margin-top: 4px;
}
.sidebar-header .status {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 10px;
    font-family: var(--font-condensed);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 6px 10px;
    border-radius: var(--radius);
    margin-top: 8px;
    background: var(--color-warn-bg);
    color: var(--color-warn);
    border: 1px solid var(--color-warn-border);
}
.sidebar-header .status.dispute {
    background: var(--color-deny-bg);
    color: var(--color-deny);
    border: 1px solid rgba(196,43,43,0.2);
}

.issue-select {
    width: 100%;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 28px 8px 10px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%235c6b7f' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    line-height: 1.3;
    transition: border-color 0.15s;
}
.issue-select:hover { border-color: var(--border-bright); }
.issue-select:focus { border-color: var(--color-skanska); outline: none; box-shadow: 0 0 0 2px rgba(26,95,180,0.12); }
.issue-select option { background: var(--bg-card); color: var(--text); }

/* ── Nav ── */
.nav-section { padding: 6px 0; }
.nav-section-label {
    font-size: 10px;
    font-family: var(--font-condensed);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 4px 20px;
}
.nav-item {
    display: block;
    padding: 7px 20px;
    font-size: 13px;
    color: var(--text-dim);
    text-decoration: none;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.12s ease;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
    background: var(--bg-active);
    color: var(--color-skanska);
    border-left-color: var(--color-skanska);
    font-weight: 600;
}

/* ── Expanded sidebar sub-nav (p001) ── */
.nav-sub {
    display: block;
    padding: 5px 20px 5px 36px;
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.12s ease;
}
.nav-sub:hover { background: var(--bg-hover); color: var(--text); }
.nav-sub.active { color: var(--color-skanska); border-left-color: var(--color-skanska); font-weight: 600; }

.nav-assertion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 20px 4px 44px;
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.12s ease;
}
.nav-assertion:hover { background: var(--bg-hover); color: var(--text); }
.nav-assertion .nav-badge {
    font-size: 9px; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase;
    padding: 1px 5px; border-radius: 3px; letter-spacing: 0.03em;
}
.nav-badge.strong { background: var(--color-wsdot-bg); color: var(--color-wsdot); }
.nav-badge.moderate { background: var(--color-warn-bg); color: var(--color-warn); }
.nav-badge.available { background: var(--bg-elevated); color: var(--text-muted); }

.nav-docs { padding: 4px 0; }
.nav-group { margin-bottom: 2px; }
.nav-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 20px;
    font-size: 11px;
    font-family: var(--font-condensed);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    transition: all 0.12s;
}
.nav-group-label:hover { background: var(--bg-hover); color: var(--text); }
.nav-group-label .chevron { font-size: 9px; color: var(--text-muted); transition: transform 0.2s ease; }
.nav-group.open .nav-group-label .chevron { transform: rotate(90deg); }
.nav-group-items { display: none; padding: 0; }
.nav-group.open .nav-group-items { display: block; }
.nav-doc {
    display: block;
    padding: 4px 20px 4px 32px;
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.12s;
}
.nav-doc:hover { background: var(--bg-hover); color: var(--text); }
.nav-doc.viewing { color: var(--color-skanska); background: var(--bg-active); font-weight: 600; }
.nav-doc.indent { padding-left: 44px; }
.nav-subgroup { margin-top: 2px; }
.nav-subgroup-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px 2px 24px;
    font-size: 10px;
    font-family: var(--font-condensed);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    opacity: 0.7;
    cursor: pointer;
    user-select: none;
}
.nav-subgroup-label:hover { opacity: 1; }
.nav-subgroup-label .chevron { font-size: 8px; transition: transform 0.2s ease; }
.nav-subgroup.open .nav-subgroup-label .chevron { transform: rotate(90deg); }
.nav-subgroup-items { display: none; }
.nav-subgroup.open .nav-subgroup-items { display: block; }

/* ── Main content ── */
.main { padding: 28px 48px; max-width: 920px; font-size: calc(14.5px * var(--text-scale)); }
.section { margin-bottom: 0; scroll-margin-top: 24px; }
h3 {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-bright);
    margin: 24px 0 12px;
    letter-spacing: -0.01em;
}
h4 {
    font-size: 0.83em;
    font-family: var(--font-condensed);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 16px 0 8px;
}
p { margin-bottom: 10px; }
strong { font-weight: 500; color: var(--text-bright); }
a { color: var(--color-skanska); text-decoration: none; }
a:hover { text-decoration: underline; }
blockquote {
    border-left: 3px solid var(--color-skanska);
    padding: 12px 16px;
    margin: 12px 0;
    background: transparent;
    font-size: 1em;
    color: var(--text);
}

/* ── Section heading (p001) ── */
.section > h2 {
    font-size: 1.4em; font-weight: 700; color: var(--text-bright);
    margin-bottom: 20px; padding-bottom: 8px; border-bottom: 2px solid var(--border);
}

/* ── Quick facts (p001) ── */
.facts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.fact-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.fact-card .label { font-size: 11px; font-family: var(--font-condensed); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.fact-card .value { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.fact-card .value.deny { color: var(--color-deny); }
.fact-card .value.warn { color: var(--color-warn); }

.detail-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 24px; }
.detail-facts .fact-card { padding: 10px 14px; opacity: 0.85; }
.detail-facts .fact-card .label { font-size: 10px; }
.detail-facts .fact-card .value { font-size: 15px; }

/* ── Recommendation box (p001) ── */
.recommendation-box {
    background: var(--color-deny-bg);
    border: 1px solid rgba(196,43,43,0.2);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
}
.recommendation-box .rec-label {
    font-size: 12px; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--color-deny); margin-bottom: 4px;
}
.recommendation-box .rec-text { font-size: 1em; color: var(--text); }

.rec-stats { display: flex; gap: 12px; margin-bottom: 14px; }
.rec-stat {
    background: var(--bg-card); border: 1px solid rgba(196,43,43,0.2);
    border-radius: var(--radius-lg); padding: 8px 14px;
}
.rec-stat .stat-label {
    font-size: 10px; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted);
}
.rec-stat .stat-value { font-size: 16px; font-weight: 700; color: var(--text-bright); }

.rec-bullets { padding-left: 20px; margin: 10px 0 12px; font-size: 0.93em; }
.rec-bullets li { margin-bottom: 4px; }
.rec-note { font-size: 0.9em; color: var(--text-dim); margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(196,43,43,0.2); }
.rec-counter { font-size: 0.9em; color: var(--text-dim); margin-top: 8px; }

/* ── Argument flow (p001) ── */
.argument-flow { display: flex; gap: 0; margin: 20px 0 28px; overflow-x: auto; }
.flow-step {
    flex: 1; min-width: 140px; position: relative; text-align: center;
    padding: 16px 14px 14px; background: var(--bg-card); border: 1px solid var(--border);
}
.flow-step:first-child { border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.flow-step:last-child { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.flow-step:not(:first-child) { border-left: none; }
.flow-step .flow-num { font-size: 10px; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.flow-step .flow-label { font-size: 0.9em; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; line-height: 1.3; }
.flow-step .flow-cite { font-size: 0.76em; color: var(--text-dim); line-height: 1.3; }
.flow-step.flow-result { background: var(--color-deny-bg); border-color: rgba(196,43,43,0.2); }
.flow-step.flow-result .flow-label { color: var(--color-deny); }
.flow-arrow { display: flex; align-items: center; color: var(--text-muted); font-size: 18px; padding: 0; flex-shrink: 0; margin: 0 -1px; z-index: 1; }

/* ── Correspondence list (p001) ── */
.correspondence-list { list-style: none; padding: 0; }
.correspondence-list li { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.93em; display: flex; align-items: baseline; gap: 10px; }
.correspondence-list li:last-child { border-bottom: none; }
.correspondence-list li.corr-outbound { border-left: 3px solid var(--color-wsdot); }
.correspondence-list li.corr-inbound { border-left: 3px solid var(--color-skanska); }
.correspondence-list li.corr-draft { border-left: 3px solid var(--color-deny); background: var(--color-deny-bg); }
.corr-date { font-size: 0.83em; font-family: var(--font-mono); font-weight: 500; color: var(--text-dim); white-space: nowrap; min-width: 70px; }
.corr-ref { flex: 1; }
.corr-direction { font-size: 11px; font-family: var(--font-condensed); font-weight: 600; white-space: nowrap; padding: 1px 6px; border-radius: var(--radius); }
.corr-direction.outbound { color: var(--color-wsdot); background: var(--color-wsdot-bg); }
.corr-direction.inbound { color: var(--color-skanska); background: var(--color-skanska-bg); }
.corr-draft-badge { font-size: 10px; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-deny); background: rgba(196,43,43,0.15); padding: 1px 6px; border-radius: var(--radius); white-space: nowrap; }
.correspondence-list a { color: var(--color-skanska); text-decoration: none; cursor: pointer; }
.correspondence-list a:hover { text-decoration: underline; }
.correspondence-list .ref-meta { font-size: 0.83em; color: var(--text-muted); margin-left: 8px; }

/* ── Layer badges (p001) ── */
.layer-badge { font-size: 11px; font-family: var(--font-condensed); font-weight: 700; padding: 2px 8px; border-radius: var(--radius); display: inline-block; }
.layer-badge.primary { background: var(--color-deny-bg); color: var(--color-deny); }
.layer-badge.secondary { background: var(--color-warn-bg); color: var(--color-warn); }
.layer-badge.tertiary { background: var(--color-skanska-bg); color: var(--color-skanska); }
.layer-badge.structural { background: var(--color-wsdot-bg); color: var(--color-wsdot); }
.layer-badge.reserve { background: var(--bg-elevated); color: var(--text-muted); }

/* ── References (p001) ── */
.ref-group { margin-bottom: 24px; }
.ref-group h3 { font-size: 0.83em; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px; }
.ref-list { list-style: none; padding: 0; }
.ref-list li { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.93em; }
.ref-list li:last-child { border-bottom: none; }
.ref-list a { color: var(--color-skanska); text-decoration: none; }
.ref-list a:hover { text-decoration: underline; }
.ref-list .ref-meta { font-size: 0.83em; color: var(--text-muted); margin-left: 8px; }

/* ── Viewing highlight (p001) ── */
.ref-list a.viewing,
.correspondence-list a.viewing,
.timeline-table a.viewing { background: var(--color-skanska-bg); border-radius: var(--radius); padding: 1px 6px; margin: -1px -6px; }
.ref-list a, .correspondence-list a, .timeline-table a { cursor: pointer; }

/* ── Lifecycle status (p001) ── */
.lifecycle-status { font-size: 0.9em; color: var(--text-dim); margin-top: 4px; margin-bottom: 24px; }
.lifecycle-status strong { color: var(--text-bright); }

/* ── Lifecycle bar ── */
.lifecycle-bar {
    display: flex;
    align-items: stretch;
    gap: 3px;
    margin-bottom: 20px;
    padding: 0;
}
.lifecycle-step {
    flex: 1 1 0;
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-align: center;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    clip-path: none;
}
.lifecycle-step:first-child,
.lifecycle-step:not(:first-child),
.lifecycle-step:last-child { clip-path: none; padding: 8px 4px; }

.lifecycle-step.complete {
    background: rgba(14,122,80,0.14);
    border: 1px solid rgba(14,122,80,0.35);
}
.lifecycle-step.current {
    background: rgba(26,95,180,0.14);
    border: 1.5px solid rgba(26,95,180,0.45);
    box-shadow: 0 1px 8px rgba(26,95,180,0.15);
}
.lifecycle-step.future {
    background: var(--bg-surface);
    border: 1px solid var(--border);
}
.lifecycle-step .step-label {
    font-size: 11px;
    font-family: var(--font-condensed);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
}
.lifecycle-step.complete .step-label { color: var(--color-wsdot); }
.lifecycle-step.current .step-label { color: var(--color-skanska); }
.lifecycle-step.future .step-label { color: var(--text-muted); }

/* ── Memo sections ── */
.memo-section {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    scroll-margin-top: 24px;
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.memo-section-title {
    padding: 14px 20px;
    background: var(--bg-surface);
    font-size: 0.97em;
    font-family: var(--font-condensed);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-bright);
    border-bottom: 1px solid var(--border);
    margin: 0;
    cursor: pointer;
    transition: background 0.12s;
}
.memo-section-title:hover { background: var(--bg-hover); }
.memo-section-title { position: relative; padding-right: 40px; user-select: none; }
.section-chevron::after {
    content: '\25B6';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.memo-section.open .section-chevron::after {
    transform: translateY(-50%) rotate(90deg);
}
.memo-section-body {
    display: none;
    padding: 16px 20px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    font-size: 1em;
}
.memo-section.open .memo-section-body { display: block; }
.memo-section-body a { color: var(--color-skanska); text-decoration: none; cursor: pointer; transition: color 0.12s; }
.memo-section-body a:hover { text-decoration: underline; }
.memo-section-body ul { padding-left: 20px; margin: 8px 0; }
.memo-section-body li { margin-bottom: 6px; }

/* ── Matrix cards ── */
.matrix-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    overflow: hidden;
    scroll-margin-top: 24px;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.matrix-card:hover { border-color: var(--border-bright); }
.matrix-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}
.matrix-card.open .matrix-header { border-bottom-color: var(--border); }
.matrix-header:hover { background: var(--bg-hover); }
.matrix-id {
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-muted);
    min-width: 22px;
}
.matrix-summary {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-left: 10px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.matrix-strength {
    font-size: 10px;
    font-family: var(--font-condensed);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: var(--radius);
}
.matrix-strength.strong { background: var(--color-wsdot-bg); color: var(--color-wsdot); border: 1px solid var(--color-wsdot-border); }
.matrix-strength.moderate { background: var(--color-warn-bg); color: var(--color-warn); border: 1px solid var(--color-warn-border); }
.matrix-strength.favorable { background: var(--color-skanska-bg); color: var(--color-skanska); border: 1px solid var(--color-skanska-border); }
.matrix-card .matrix-body { display: none; }
.matrix-card.open .matrix-body { display: block; }
.matrix-header .chevron { font-size: 10px; color: var(--text-muted); transition: transform 0.2s ease; margin-left: 8px; }
.matrix-card.open .matrix-header .chevron { transform: rotate(90deg); }
.matrix-body { padding: 14px 16px; }
.matrix-body h4 { font-size: 0.76em; font-family: var(--font-condensed); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 12px 0 6px; }
.matrix-body h4:first-child { margin-top: 0; }
.matrix-body p { font-size: 1em; margin-bottom: 8px; }
.matrix-authority {
    font-size: 11.5px;
    font-family: var(--font-mono);
    color: var(--text-dim);
    background: var(--bg-surface);
    padding: 5px 10px;
    border-radius: var(--radius);
    display: inline-block;
    margin-top: 4px;
    border: 1px solid var(--border);
}

/* ── Tables ── */
.defense-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.93em; }
.defense-table th {
    text-align: left; padding: 9px 14px; background: var(--bg-surface);
    border-bottom: 2px solid var(--border-bright);
    font-size: 0.74em; font-family: var(--font-condensed); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
}
.defense-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.defense-table tr:last-child td { border-bottom: none; }
.defense-table tr:hover td { background: var(--bg-hover); }

.cost-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.93em; }
.cost-table th {
    text-align: left; padding: 8px 12px; background: var(--bg-surface);
    border-bottom: 2px solid var(--border-bright);
    font-size: 0.74em; font-family: var(--font-condensed); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
}
.cost-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.cost-table tr:last-child td { border-bottom: none; }
.cost-table tr:hover td { background: var(--bg-hover); }

/* ── Timeline table ── */
.timeline-table { width: 100%; border-collapse: collapse; font-size: 0.9em; margin-top: 12px; }
.timeline-table th {
    text-align: left; padding: 8px 10px; background: var(--bg-surface);
    border-bottom: 2px solid var(--border-bright);
    font-size: 0.77em; font-family: var(--font-condensed); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); user-select: none;
}
.timeline-table th.sortable { cursor: pointer; }
.timeline-table th.sortable:hover { color: var(--text); }
.timeline-table th.sortable::after { content: ' \2195'; font-size: 10px; opacity: 0.4; }
.timeline-table th.sort-asc::after { content: ' \2191'; opacity: 0.8; }
.timeline-table th.sort-desc::after { content: ' \2193'; opacity: 0.8; }
.timeline-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.timeline-table td:first-child { white-space: nowrap; font-family: var(--font-mono); font-size: 0.92em; color: var(--text-dim); }
.timeline-table tr:hover td { background: var(--bg-hover); }
.timeline-table .tl-wsdot { border-left: 3px solid var(--color-wsdot); }
.timeline-table .tl-skanska { border-left: 3px solid var(--color-skanska); }
.timeline-table .tl-neutral { border-left: 3px solid var(--text-muted); }
.timeline-table .tl-aecom { border-left: 3px solid var(--color-aecom); }
.timeline-table .tl-milestone { border-left: 3px solid var(--color-warn); }
.timeline-table .tl-draft { border-left: 3px solid var(--color-deny); background: var(--color-deny-bg); }
.timeline-table .tl-draft td:first-child { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-deny); }
.timeline-table a { color: var(--color-skanska); text-decoration: none; cursor: pointer; }
.timeline-table a:hover { text-decoration: underline; }

.chronology-scroll {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}
.chronology-scroll::-webkit-scrollbar { width: 6px; }
.chronology-scroll::-webkit-scrollbar-track { background: var(--bg-card); }
.chronology-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chronology-scroll .timeline-table { margin-top: 0; }
.chronology-scroll .timeline-table thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-surface); }

/* ── Legend & compact gantt ── */
.timeline-legend { display: flex; gap: 16px; margin-bottom: 12px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }
.legend-dot.wsdot { background: var(--color-wsdot); }
.legend-dot.skanska { background: var(--color-skanska); }
.legend-dot.aecom { background: var(--color-aecom); }
.legend-dot.neutral { background: var(--text-muted); }
.legend-dot.milestone { background: var(--color-warn); }
.legend-dot.draft { background: var(--color-deny); }

.compact-tl {
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px 10px;
    background: var(--bg-card);
}
.compact-tl-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
    font-size: 11px; font-family: var(--font-condensed); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim);
}
.compact-tl-head a { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.compact-tl svg { display: block; width: 100%; height: auto; }

/* ── Viewer panel ── */
.viewer-panel {
    display: none; position: sticky; top: 0; height: 100vh;
    background: var(--bg-card); border-left: 1px solid var(--border);
    flex-direction: column; min-width: 0; overflow: hidden;
}
.layout.viewer-open { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--viewer-width); }
.layout.viewer-open .viewer-panel { display: flex; }
.layout.viewer-open .main { max-width: none; padding-right: 32px; }
.viewer-iframe { flex: 1; width: 100%; border: none; background: #fff; }
.viewer-handle {
    position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 15;
    width: 22px; height: 52px;
    border: 1px solid var(--border); border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    background: var(--bg-card); color: var(--text-dim);
    font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: -2px 0 8px rgba(0,0,0,0.06);
    transition: all 0.12s ease; padding: 0; line-height: 1;
}
.viewer-handle:hover { background: var(--bg-hover); color: var(--color-skanska); }
.layout.viewer-open .viewer-handle { display: none; }
.viewer-close {
    position: absolute; top: 6px; left: 6px; z-index: 20;
    width: 28px; height: 28px; border: none; border-radius: var(--radius);
    background: rgba(0,0,0,0.5); color: #fff; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s; line-height: 1;
}
.viewer-panel:hover .viewer-close { opacity: 1; }
.viewer-close:hover { background: rgba(0,0,0,0.7); }
.viewer-maximize {
    position: absolute; top: 6px; left: 40px; z-index: 20;
    width: 28px; height: 28px; border: none; border-radius: var(--radius);
    background: rgba(0,0,0,0.5); color: #fff; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s; line-height: 1;
}
.viewer-panel:hover .viewer-maximize { opacity: 1; }
.viewer-maximize:hover { background: rgba(0,0,0,0.7); }
.layout.viewer-max { grid-template-columns: var(--sidebar-width) 0 1fr !important; }
.layout.viewer-max .main { overflow: hidden; visibility: hidden; padding: 0; min-width: 0; }
.viewer-divider {
    position: absolute; left: -4px; top: 0; bottom: 0; width: 8px;
    cursor: col-resize; z-index: 20; background: transparent;
}
.viewer-divider::after {
    content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
    width: 2px; height: 40px; border-radius: 1px;
    background: var(--border); transition: all 0.15s;
}
.viewer-divider:hover::after { background: var(--color-skanska); height: 60px; }
body.viewer-dragging { cursor: col-resize !important; user-select: none !important; }
body.viewer-dragging iframe { pointer-events: none !important; }

/* ── Sidebar collapse (desktop) ── */
.sidebar-collapse-btn {
    position: absolute; bottom: 8px; right: 8px; z-index: 11;
    width: 26px; height: 26px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-surface);
    color: var(--text-muted); font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; line-height: 1; padding: 0;
}
.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-bright); }

.layout { transition: grid-template-columns 0.25s ease; }
.sidebar { transition: transform 0.25s ease, opacity 0.2s ease; }

.layout.sidebar-collapsed { grid-template-columns: 0 1fr; }
.layout.sidebar-collapsed .sidebar { transform: translateX(-100%); opacity: 0; pointer-events: none; overflow: hidden; }
.layout.sidebar-collapsed.viewer-open { grid-template-columns: 0 minmax(0, 1fr) var(--viewer-width); }
.layout.sidebar-collapsed.viewer-max { grid-template-columns: 0 0 1fr !important; }

.sidebar-expand-btn {
    position: fixed; top: 12px; left: 12px; z-index: 100;
    width: 32px; height: 32px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg-card);
    color: var(--text-dim); font-size: 14px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: all 0.15s;
    line-height: 1; padding: 0;
}
.sidebar-expand-btn:hover { background: var(--bg-hover); color: var(--color-skanska); border-color: var(--border-bright); }
.layout.sidebar-collapsed ~ .sidebar-expand-btn { display: flex; }

/* ── Mobile ── */
.menu-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 100;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 8px 12px; cursor: pointer;
    font-size: 18px; color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: -280px; top: 0; width: 280px;
        transition: left 0.25s ease; box-shadow: 4px 0 16px rgba(0,0,0,0.1);
    }
    .sidebar.open { left: 0; }
    .menu-toggle { display: block; }
    .main { padding: 20px 16px; padding-top: 56px; }
    .detail-facts { grid-template-columns: repeat(2, 1fr); }
    .viewer-panel { display: none !important; }
    .viewer-handle { display: none; }
    .layout.viewer-open { grid-template-columns: 1fr; }
    .sidebar-collapse-btn, .sidebar-expand-btn { display: none !important; }
    .layout.sidebar-collapsed { grid-template-columns: 1fr; }
}

@media print {
    .sidebar, .menu-toggle, .viewer-panel, .viewer-handle { display: none !important; }
    .layout { grid-template-columns: 1fr; }
    .main { padding: 0; max-width: none; }
    .memo-section-body { display: block !important; }
    .matrix-card .matrix-body { display: block !important; }
    .section { page-break-inside: avoid; margin-bottom: 24px; }
    .timeline-table, .matrix-card, .memo-section { break-inside: avoid; }
    .detail-facts { grid-template-columns: repeat(4, 1fr); }
    .rec-stats { gap: 8px; }
    body { font-size: 12px; background: white; color: #000; }
    strong { color: inherit; }
}
