/* [scaffold:fw=nist-csf] generated by scripts/scaffold-framework.js */
:root {
    --nist-csf-primary:   #0079c1;
    --nist-csf-secondary: #00529b;
    --bg-1: #0b1220;
    --bg-2: #131b2e;
    --text-1: #e2e8f0;
    --text-2: #94a3b8;
    --border: rgba(255,255,255,.08);
    /* Alias so shared modules (evidence-upload.js etc.) that fall back to
       var(--accent, #hex) when the host page doesn't define --accent pick up
       the real NIST blue instead of their generic cyan fallback. */
    --accent: var(--nist-csf-primary);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-1);
    color: var(--text-1);
    line-height: 1.5;
}

.assessment-container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }

.header {
    position: sticky; top: 40px; z-index: 10;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    display: flex; align-items: center; gap: 16px;
}
.header h1 { margin: 0; font-size: 20px; flex: 1; }
.header input[type="text"] {
    background: rgba(255,255,255,.06); border: 1px solid var(--border);
    color: var(--text-1); padding: 8px 12px; border-radius: 6px; width: 280px;
}
.save-notice { margin-top: 6px; font-size: .72rem; color: var(--text-2); transition: color .3s; }
.save-notice.just-saved { color: rgba(39,174,96,.95); }

/* ── MAIN LAYOUT — progress sidebar + content ── */
.main-content {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
    margin-top: 16px;
}
.assessment-sections { min-width: 0; }

/* ── PROGRESS SIDEBAR ── */
.progress-tracker {
    /* .header above is itself sticky at top:40px (below the 40px nav bar) and
       is roughly 64px tall (16px+16px padding + ~32px tallest child, the
       org-name input) — so this sidebar has to clear both, unlike CAF's
       progress-tracker (top:40px alone), whose .header is position:relative
       and simply scrolls away. */
    position: sticky;
    top: 104px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.progress-overview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.progress-ring { width: 72px; height: 72px; }
.progress-ring-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.progress-ring-fill {
    fill: none;
    stroke: var(--nist-csf-primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 213.6;
    stroke-dashoffset: 213.6;
    transform: rotate(-90deg);
    transform-origin: 40px 40px;
    transition: stroke-dashoffset .4s ease;
}
.progress-ring-label { font-size: 1.1rem; font-weight: 700; color: var(--nist-csf-primary); }
.progress-ring-sub { font-size: .72rem; color: var(--text-2); text-align: center; }
.progress-sections { display: flex; flex-direction: column; gap: 2px; }
.progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
    font-size: .83rem;
}
.progress-row:hover { background: rgba(255,255,255,.06); }
.progress-row-badge {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    flex-shrink: 0;
}
.progress-row-badge.complete { background: #22c55e; }
.progress-row-badge.partial  { background: #f59e0b; }
.progress-row-badge.started  { background: var(--nist-csf-secondary); }
.progress-row-name  { flex: 1; color: var(--text-1); }
.progress-row-count { font-size: .75rem; color: var(--text-2); white-space: nowrap; }

.control-section {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 16px 0;
    overflow: hidden;
}
.control-header {
    padding: 14px 18px;
    background: rgba(255,255,255,.03);
    cursor: pointer;
    display: flex; align-items: center; gap: 16px;
    border-bottom: 1px solid var(--border);
}
.control-title { flex: 1; font-weight: 600; color: var(--nist-csf-primary); }
.control-progress { color: var(--text-2); font-size: 13px; }
.control-content { padding: 16px 18px; }

.question {
    padding: 14px 0;
    border-bottom: 1px dashed var(--border);
}
.question:last-child { border-bottom: none; }
.question-text { font-weight: 500; margin-bottom: 6px; }
.question-help { color: var(--text-2); font-size: 13px; margin-bottom: 10px; }

.options { display: grid; gap: 6px; }
.option {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}
.option:hover { background: rgba(255,255,255,.06); }
.option input[type="radio"]:checked + span { color: var(--nist-csf-primary); font-weight: 600; }

.save-bar {
    position: sticky; bottom: 0;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 24px;
}
.save-bar button {
    padding: 10px 18px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--border);
    color: var(--text-1);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.save-bar .primary-btn {
    background: var(--nist-csf-primary);
    border-color: var(--nist-csf-primary);
    color: #0b1220;
}
.save-bar .primary-btn:disabled { cursor: default; opacity: .85; }

/* Analyse button spinner + elapsed-time countdown — matches CAF's
   .caf-analysis-spinner/.caf-elapsed pattern exactly. Deep Analysis can take
   2-4 minutes; without this the button gives no feedback and a slow run is
   indistinguishable from a stuck one. */
@keyframes nistCsfSpin { to { transform: rotate(360deg); } }
.nist-csf-analysis-spinner {
    display: inline-block;
    width: 13px; height: 13px;
    border: 2px solid rgba(11,18,32,.3);
    border-top-color: #0b1220;
    border-radius: 50%;
    animation: nistCsfSpin .7s linear infinite;
    vertical-align: text-bottom;
    margin-right: 6px;
}
.nist-csf-elapsed {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    margin: 0 4px;
}

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    display: none; align-items: center; justify-content: center;
    z-index: 100;
}
.modal-overlay[style*="flex"] { display: flex !important; }
.modal-panel {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    max-width: 540px;
    width: calc(100% - 40px);
}
.modal-panel h2 { margin-top: 0; color: var(--nist-csf-primary); }
.modal-panel button {
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--nist-csf-primary);
    color: #0b1220;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* Results overlay — matches CAF's .results-panel exactly (fixed, full-viewport
   takeover below the 40px nav bar), not a plain in-flow section. Unlike the rest
   of this (dark-themed) page, the results panel is deliberately light — matching
   every other shipped framework's white results background. The four variables
   below are redeclared for this subtree only: every existing var(--bg-1)/
   var(--text-1)/var(--text-2)/var(--border) reference used by descendants (close
   button, summary text, function-analysis rows, bar values, etc.) picks up the
   light values automatically via CSS custom-property cascading. Elements with a
   hardcoded dark-panel colour (radar chart SVG, .bar-track) are fixed separately,
   see below.
   The explicit `color:` below is not redundant with the --text-1 redeclaration
   above it — redeclaring a custom property only changes what var(--text-1)
   RESOLVES TO for a rule that explicitly references it; it does nothing for an
   element that has no color rule of its own and is simply inheriting `color`
   from body (body { color: var(--text-1) }, using the DARK root value, computed
   once at body and passed down as an already-resolved value — not re-evaluated
   per descendant). Most of the injected report text (critical gaps, strengths,
   next steps, warnings, summary paragraphs) is exactly this: plain <li>/<p>
   elements with no per-element color rule. Without this line they silently
   inherited body's near-white text color straight onto the new white panel
   background — legible on the old dark panel, almost invisible on this one.
   Setting color here gives .results-panel itself a correctly dark computed
   color, which then inherits normally into everything that doesn't override it. */
.results-panel {
    position: fixed;
    inset: 40px 0 0 0;
    background: #fff;
    z-index: 500;
    overflow-y: auto;
    padding: 28px 32px;
    --bg-1: #ffffff;
    --bg-2: #f4f6f8;
    --text-1: #1c2a38;
    --text-2: #5a6a7a;
    --border: #dde3ea;
    color: var(--text-1);
}
.results-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.results-header h2 { flex: 1; font-size: 1.4rem; color: var(--nist-csf-primary); margin: 0; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.export-btn {
    background: var(--nist-csf-primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: .85rem;
    cursor: pointer;
    transition: background .15s;
}
.export-btn:hover { background: var(--nist-csf-secondary); }
.close-results-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-2);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: .85rem;
    cursor: pointer;
}
.close-results-btn:hover { color: var(--text-1); border-color: var(--text-2); }
.results-summary-text, .results-timeline-text {
    color: var(--text-2);
    font-size: .9rem;
    line-height: 1.5;
    margin: 4px 0 16px;
}
#exec-summary-text { color: var(--text-1); font-size: .95rem; line-height: 1.6; }
.fn-analysis-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.fn-analysis-block:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.fn-analysis-heading { color: var(--nist-csf-primary); font-weight: 700; margin-bottom: 4px; }
.fn-analysis-row { font-size: .87rem; color: var(--text-1); margin: 2px 0; }
.fn-analysis-row strong { color: var(--text-2); font-weight: 600; }

.score-circle {
    width: 140px; height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--nist-csf-primary) 0%, var(--nist-csf-secondary) 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    margin: 16px auto;
    color: #0b1220;
}
.score-num { font-size: 36px; font-weight: 800; }
.score-label { font-size: 13px; font-weight: 600; }

#radar-chart { display: block; max-width: 560px; margin: 0 auto; }

.section-bar { display: grid; grid-template-columns: 200px 1fr 60px; gap: 12px; align-items: center; margin: 8px 0; }
/* Hardcoded rather than var(--border)-driven — a translucent black reads correctly
   against the results panel's white background (a translucent white, the dark-page
   convention used elsewhere in this file, would be nearly invisible here). This
   class only ever renders inside .results-content (section score bars). */
.bar-track { background: rgba(0,0,0,.08); border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--nist-csf-primary); }
.bar-value { color: var(--text-2); font-size: 13px; text-align: right; }

/* Implementation Tier (indicative) — a distinct card, not "just another
   section score": categorical Tier badges rather than a percentage bar, so
   it reads as a qualitative judgement about process maturity, not a fifth
   axis of the radar chart above. Colour ramps red(1)->green(4) matching the
   RAG convention used elsewhere in this codebase for maturity ladders. */
.tier-heading { color: var(--nist-csf-primary); margin: 28px 0 6px; font-size: 1.05rem; }
.tier-disclaimer { color: var(--text-2); font-size: .82rem; line-height: 1.5; margin: 0 0 14px; max-width: 640px; }

.tier-overall {
    display: flex; flex-direction: column; gap: 4px;
    padding: 14px 18px; border-radius: 10px; margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--bg-2);
}
.tier-overall-label { font-size: .78rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.tier-overall-value { font-size: 1.15rem; font-weight: 700; }
.tier-overall-desc  { font-size: .85rem; color: var(--text-2); line-height: 1.4; }
.tier-overall--pending .tier-overall-value { color: var(--text-2); font-weight: 500; font-size: .95rem; }
.tier-overall--1 { border-left: 4px solid #ef4444; } .tier-overall--1 .tier-overall-value { color: #b91c1c; }
.tier-overall--2 { border-left: 4px solid #f59e0b; } .tier-overall--2 .tier-overall-value { color: #b45309; }
.tier-overall--3 { border-left: 4px solid var(--nist-csf-primary); } .tier-overall--3 .tier-overall-value { color: var(--nist-csf-primary); }
.tier-overall--4 { border-left: 4px solid #16a34a; } .tier-overall--4 .tier-overall-value { color: #15803d; }

.tier-dims { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.tier-dim-row {
    display: grid; grid-template-columns: 1fr auto 56px; gap: 12px; align-items: center;
    padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.tier-dim-row:last-child { border-bottom: none; }
.tier-dim-label { font-size: .88rem; color: var(--text-1); }
.tier-dim-score { font-size: .82rem; color: var(--text-2); text-align: right; }
.tier-dim-score--empty { color: var(--border); }

.tier-badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.tier-badge--1 { background: #fee2e2; color: #b91c1c; }
.tier-badge--2 { background: #fef3c7; color: #b45309; }
.tier-badge--3 { background: #dbeafe; color: #1d4ed8; }
.tier-badge--4 { background: #dcfce7; color: #15803d; }
.tier-badge--unassessed { background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border); }

.results-issues { margin-top: 24px; }
.results-issues h3 { color: var(--nist-csf-primary); margin-top: 20px; }

/* ── EVIDENCE COMMENT FIELD ── */
.evidence-comment { margin-top: 8px; margin-bottom: 6px; }
.evidence-comment label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 3px;
}
.evidence-comment textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255,255,255,.06);
    color: var(--text-1);
    font-size: .82rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color .15s;
}
.evidence-comment textarea:focus { outline: none; border-color: var(--nist-csf-primary); }
.evidence-comment textarea::placeholder { color: var(--text-2); opacity: .8; }
@media print { .evidence-comment textarea { border: 1px solid #ccc; background: #fff; color: #000; } }

.size-hidden { display: none !important; }

@media (max-width: 900px) {
    .main-content { grid-template-columns: 1fr; }
    .progress-tracker { position: static; max-height: none; }
}

@media print {
    #sch-nav-bar, .header, .save-bar, .progress-tracker, .main-content, .results-actions { display: none !important; }
    .control-content { display: block !important; }
    .assessment-container { padding: 0; max-width: none; }
    body { background: white; color: black; }
    /* Results panel only — matches CAF's print pattern. It's reachable only via
       the "Save as PDF" button inside the panel itself, so .main-content (the
       questionnaire) being hidden above is always correct at print time. */
    .results-panel {
        position: static !important;
        display: block !important;
        inset: auto;
        padding: 0 !important;
        background: #fff !important;
        color: #000 !important;
        overflow: visible !important;
    }
    .results-panel * { color: #000 !important; }
    @page { size: A4; margin: 18mm 20mm; }
}
