/* Phase 19 / D-05 — the design-token source of truth for the DASHBOARD.
 * This :root block is the single CSS Custom Properties source consumed by the
 * dashboard templates. It mirrors the :root block in PRINT_CSS
 * (cysecwatch/core/services/report_render.py) so a score ring, status badge, or
 * heatmap resolves to the SAME values whether it renders on screen or in the
 * regulator/management PDF. Every value mirrors a locked Phase 15/16 token. */
:root {
  /* ---- Status semantics (LOCKED five — Phase 15/16, unchanged) ---- */
  --csw-pass-fill:        #d1fae5;
  --csw-pass-text:        #065f46;
  --csw-pass-edge:        #047857;

  --csw-partial-fill:     #fef3c7;
  --csw-partial-text:     #92400e;
  --csw-partial-edge:     #b45309;

  --csw-fail-fill:        #ffe4e6;
  --csw-fail-text:        #9f1239;
  --csw-fail-edge:        #9f1239;

  --csw-unavailable-fill: #fef3c7;
  --csw-unavailable-text: #92400e;
  --csw-unavailable-edge: #b45309;

  --csw-progress-fill:    #e0f2fe;
  --csw-progress-text:    #075985;
  --csw-progress-edge:    #0369a1;

  /* ---- Accent (emerald, Phase 15/16 lock) ---- */
  --csw-accent:           #047857;
  --csw-accent-tint:      #ecfdf5;

  /* ---- Neutrals (slate ink family, Phase 15/16 lock) ---- */
  --csw-ink:              #0f172a;
  --csw-muted:            #475569;
  --csw-subtle:           #64748b;
  --csw-hairline:         #e2e8f0;
  --csw-track:            #e2e8f0;
  --csw-border-strong:    #cbd5e1;
  --csw-zebra:            #fafafa;
  --csw-neutral-fill:     #f1f5f9;
  --csw-surface:          #ffffff;
  --csw-surface-muted:    #f8fafc;

  /* ---- Typography ----
   * The dashboard loads IBM Plex via the same bundled woff2 fonts as the PDF
   * (see base.html / static/fonts/ibm-plex/). On screen a generic fallback is
   * safe and conventional, so the dashboard token may carry one; the PDF token
   * block in PRINT_CSS does not (SC#3a scan). */
  --csw-font-sans:        'IBM Plex Sans', system-ui, sans-serif;
  --csw-font-mono:        'IBM Plex Mono', 'SF Mono', monospace;

  /* ---- Print spacing rhythm (2mm ladder, Phase 15/16 lock) ---- */
  --csw-space-xs:         1mm;
  --csw-space-sm:         2mm;
  --csw-space-md:         4mm;
  --csw-space-lg:         6mm;
  --csw-space-xl:         8mm;
  --csw-space-2xl:        14mm;

  /* ---- Screen spacing scale (8px grid, dashboard) ---- */
  --csw-screen-xs:        4px;
  --csw-screen-sm:        8px;
  --csw-screen-md:        16px;
  --csw-screen-lg:        24px;
  --csw-screen-xl:        32px;
  --csw-screen-2xl:       48px;
  --csw-screen-3xl:       64px;
}

body {
  font-feature-settings: "ss01" on, "cv02" on, "cv03" on;
}

/* Phase 19 / D-06 — shared status-pill + letter-badge resolution for the
 * dashboard. The shared component builders (shared_components.py) emit these
 * class names; these rules paint them on screen using the same token values the
 * PDF PRINT_CSS uses. The >=4px left border preserves the grayscale-survival
 * contract (a fail must never read as a pass once colour is stripped). */
.status-pill {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  /* Compact + single-line: without nowrap a long label ("Data unavailable")
   * wraps to two lines and balloons the pill, breaking the card grid rhythm. */
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  padding: var(--csw-screen-xs) var(--csw-screen-sm);
  border-radius: var(--csw-screen-xs);
  border-left: 4px solid var(--csw-border-strong);
}
.status-pill--pass         { background: var(--csw-pass-fill); color: var(--csw-pass-text); border-left-color: var(--csw-pass-edge); }
.status-pill--partial      { background: var(--csw-partial-fill); color: var(--csw-partial-text); border-left-color: var(--csw-partial-edge); }
.status-pill--fail         { background: var(--csw-fail-fill); color: var(--csw-fail-text); border-left-color: var(--csw-fail-edge); }
.status-pill--unavailable  { background: var(--csw-unavailable-fill); color: var(--csw-unavailable-text); border-left-color: var(--csw-unavailable-edge); }
.status-pill--in-progress  { background: var(--csw-progress-fill); color: var(--csw-progress-text); border-left-color: var(--csw-progress-edge); }

.letter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--csw-font-sans);
  font-weight: 600;
  line-height: 1.2;
  padding: var(--csw-screen-xs) var(--csw-screen-md);
  border-radius: var(--csw-screen-xs);
  border: 2px solid var(--csw-border-strong);
}
.letter-badge--pass    { background: var(--csw-pass-fill); color: var(--csw-pass-text); border-color: var(--csw-pass-edge); }
.letter-badge--partial { background: var(--csw-partial-fill); color: var(--csw-partial-text); border-color: var(--csw-partial-edge); }
.letter-badge--fail    { background: var(--csw-fail-fill); color: var(--csw-fail-text); border-color: var(--csw-fail-edge); }

/* ===========================================================================
 * Phase 19 / Plan 19-03 — Dashboard layout rules (D-07, Vanta/Drata pattern).
 * Single-viewport 1920x1080 above the fold. Minimal chrome: csw-* tokens,
 * hairline borders, whitespace separation — no heavy shadows. All status
 * colour comes ONLY from the shared csw-* tokens (DASH-15).
 * ========================================================================= */

/* The score-ring gauge: a fixed 180px box with the score number absolutely
 * centred over the SVG. The SVG itself carries no <text> (D-06 contract) —
 * the number is HTML overlaid here in IBM Plex Mono / emerald accent. */
.csw-gauge-ring {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  position: relative;
}
.csw-gauge-ring > svg {
  display: block;
  width: 180px;
  height: 180px;
}
.csw-gauge-overlay {
  pointer-events: none;
}

/* "What needs attention" section — the 3-column action grid. Cards stretch
 * to equal height so the section reads as a unified band. */
.csw-attention-grid > div {
  display: flex;
}
.csw-attention-grid article {
  width: 100%;
}

/* Stat strip — compact big-number tiles, borderless (whitespace separation). */
.csw-stat-tile {
  text-align: left;
}
.csw-stat-number {
  line-height: 1;
}

/* Domain grid cards — subtle surface-muted fill, hairline border. The status
 * badge (shared component) carries the status colour; the card itself stays
 * neutral so the badge is the single colour signal. */
.csw-domain-card {
  transition: border-color 0.15s ease;
}
.csw-domain-card:hover {
  border-color: var(--csw-border-strong);
}
/* Reserve a CONSTANT 3-line title box (clamp long titles, pad short ones to the
 * same height). This makes the score row start at the same Y and the findings
 * line end at the same Y on every card — independent of grid stretch / mt-auto
 * (Tailwind's mt-3 utility beats margin-top:auto in the cascade). */
.csw-domain-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3.75rem;
}
.csw-domain-score,
.csw-gauge-score {
  line-height: 1;
  /* Plain (un-slashed) tabular zero — the Plex Mono slashed zero reads as a
   * glitch at large sizes, especially the lone "0" of an empty score. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 0;
}

/* ==== Output Center on-screen report (.report-screen) — screen skin for the
 * rich report body (same section builders as the PDF; PRINT_CSS not loaded here). ==== */
/* Screen skin for the rich report body (the SAME section builders the PDF uses).
 * Scoped under .report-screen so it never touches the dashboard or the PDF
 * (PRINT_CSS is not loaded on screen). Uses the shared csw-* tokens. */

.report-screen {
  --gap: 1.25rem;
  max-width: 64rem;
  margin: 0 auto;
  color: var(--csw-ink);
  font-family: var(--csw-font-sans, 'IBM Plex Sans', system-ui, sans-serif);
  line-height: 1.55;
}

/* Every top-level report section becomes a clean card. */
.report-screen > section {
  background: var(--csw-surface);
  border: 1px solid var(--csw-hairline);
  border-radius: 1rem;
  padding: 1.5rem 1.75rem;
  margin-bottom: var(--gap);
}
.report-screen h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--csw-ink);
  margin: 0 0 0.85rem;
  letter-spacing: -0.01em;
}
.report-screen h3 { font-size: 0.95rem; font-weight: 600; margin: 1rem 0 0.5rem; }
.report-screen p { margin: 0 0 0.6rem; color: var(--csw-muted); }

/* --- Status pills / letter badges (shared classes) --- */
.report-screen .status-pill {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  line-height: 1; white-space: nowrap; padding: 4px 8px; border-radius: 4px;
  border-left: 4px solid var(--csw-border-strong);
}
.report-screen .status-pill--pass { background: var(--csw-pass-fill); color: var(--csw-pass-text); border-left-color: var(--csw-pass-edge); }
.report-screen .status-pill--partial { background: var(--csw-partial-fill); color: var(--csw-partial-text); border-left-color: var(--csw-partial-edge); }
.report-screen .status-pill--fail { background: var(--csw-fail-fill); color: var(--csw-fail-text); border-left-color: var(--csw-fail-edge); }
.report-screen .status-pill--unavailable { background: var(--csw-neutral-fill); color: var(--csw-muted); border-left-color: var(--csw-border-strong); }
.report-screen .letter-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; padding: 2px 10px; border-radius: 6px; border: 2px solid var(--csw-border-strong);
}
.report-screen .letter-badge--pass { background: var(--csw-pass-fill); color: var(--csw-pass-text); border-color: var(--csw-pass-edge); }
.report-screen .letter-badge--partial { background: var(--csw-partial-fill); color: var(--csw-partial-text); border-color: var(--csw-partial-edge); }
.report-screen .letter-badge--fail { background: var(--csw-fail-fill); color: var(--csw-fail-text); border-color: var(--csw-fail-edge); }

/* --- Executive summary + verdict panel (hero) --- */
.report-screen .exec-summary-page { }
.report-screen .verdict-panel {
  background: var(--csw-accent-tint);
  border: 1px solid var(--csw-hairline);
  border-radius: 0.85rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.report-screen .verdict-panel__title {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.2em;
  font-weight: 600; color: var(--csw-accent); margin-bottom: 0.75rem;
}
.report-screen .verdict-panel__readiness { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.report-screen .verdict-panel__score { font-family: var(--csw-font-mono); font-size: 3rem; font-weight: 600; line-height: 1; color: var(--csw-accent); font-variant-numeric: tabular-nums; font-feature-settings: "zero" 0; }
.report-screen .verdict-panel__score-unit { font-size: 0.85rem; font-weight: 600; color: var(--csw-subtle); }
.report-screen .verdict-panel__letter { margin-left: 0.5rem; }
.report-screen .verdict-panel__caption { flex-basis: 100%; font-size: 0.75rem; color: var(--csw-subtle); margin: 0.25rem 0 0; }

.report-screen .verdict-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-top: 1rem; }
.report-screen .verdict-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem;
  background: var(--csw-surface); border: 1px solid var(--csw-hairline);
  border-left: 4px solid var(--csw-border-strong); border-radius: 0.6rem; padding: 0.75rem 0.9rem;
}
.report-screen .verdict-tile--pass { border-left-color: var(--csw-pass-edge); }
.report-screen .verdict-tile--partial { border-left-color: var(--csw-partial-edge); }
.report-screen .verdict-tile--fail { border-left-color: var(--csw-fail-edge); }
.report-screen .verdict-tile--unavailable { border-left-color: var(--csw-border-strong); }
.report-screen .verdict-tile__glyph svg { width: 16px; height: 16px; }
.report-screen .verdict-tile__count { font-family: var(--csw-font-mono); font-size: 1.6rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.report-screen .verdict-tile__label { font-size: 0.75rem; color: var(--csw-muted); font-weight: 500; }
.report-screen .verdict-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; font-size: 0.8rem; color: var(--csw-muted); }
.report-screen .verdict-panel__legend, .report-screen .verdict-legend__item { font-size: 0.72rem; color: var(--csw-subtle); }

.report-screen .exec-prose, .report-screen .recommendation { color: var(--csw-muted); font-size: 0.9rem; }
.report-screen .exec-trend { font-size: 0.85rem; color: var(--csw-subtle); }

/* --- Header gauge (big ring + A-F letter) --- */
.report-screen .header-gauge { display: flex; align-items: center; gap: 1.5rem; justify-content: center; padding: 0.5rem 0; }
.report-screen .header-gauge__ring { position: relative; display: inline-flex; }
.report-screen .header-gauge__center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--csw-font-mono); font-size: 1.9rem; font-weight: 600; color: var(--csw-accent); font-feature-settings: "zero" 0; }
.report-screen .header-gauge__letter { font-size: 1.5rem; }

/* --- Per-domain sections: responsive 2-col grid of compact cards --- */
.report-screen .domain-section {
  border: 1px solid var(--csw-hairline); border-radius: 0.85rem; padding: 1.1rem 1.25rem;
  background: var(--csw-surface-muted); margin: 0;
  display: grid; grid-template-columns: auto 1fr;
  grid-template-areas: "title title" "over over" "gauge meta" "spark spark";
  gap: 0.5rem 1rem; align-items: center;
}
.report-screen .domain-section h2 { grid-area: title; font-size: 0.9rem; line-height: 1.3; margin: 0; align-self: start; }
.report-screen .domain-section__overview { grid-area: over; margin: 0; align-self: start; }
.report-screen .domain-section__gauge { grid-area: gauge; }
.report-screen .domain-section__ring { position: relative; display: inline-flex; }
.report-screen .domain-section__ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--csw-font-mono); font-weight: 600; font-size: 1.1rem; color: var(--csw-ink); font-feature-settings: "zero" 0; }
.report-screen .domain-section__metrics { grid-area: meta; display: flex; flex-direction: column; gap: 0.25rem; }
.report-screen .metric { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.8rem; }
.report-screen .metric__label { color: var(--csw-subtle); }
.report-screen .metric__value { color: var(--csw-ink); font-weight: 500; }
.report-screen .domain-sparkline { grid-area: spark; display: flex; align-items: center; gap: 0.75rem; }
.report-screen .domain-sparkline__svg { width: 120px; height: 28px; color: var(--csw-accent); }
.report-screen .domain-sparkline__meta { font-size: 0.72rem; color: var(--csw-subtle); }

/* The domain sections live inside their own grid wrapper we inject. */
.report-screen .domain-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; margin-bottom: var(--gap); }

/* --- Risk heatmap --- */
.report-screen .risk-heatmap { border-collapse: separate; border-spacing: 3px; width: 100%; }
.report-screen .risk-heatmap th { font-size: 0.72rem; font-weight: 600; color: var(--csw-subtle); padding: 0.35rem; text-align: center; }
.report-screen .risk-heatmap__axis-y, .report-screen .risk-heatmap__value { text-align: left; color: var(--csw-muted); }
.report-screen .risk-heatmap__cell { background: var(--csw-neutral-fill); border-radius: 6px; text-align: center; padding: 0.6rem; min-width: 3rem; }
.report-screen .risk-heatmap__cell--fail { background: var(--csw-fail-fill); }
.report-screen .risk-heatmap__cell--partial { background: var(--csw-partial-fill); }
.report-screen .risk-heatmap__count { font-family: var(--csw-font-mono); font-weight: 600; }

/* --- All-domains ratings table --- */
.report-screen table:not(.risk-heatmap) { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.report-screen table:not(.risk-heatmap) th, .report-screen table:not(.risk-heatmap) td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--csw-hairline); }
.report-screen table:not(.risk-heatmap) th { color: var(--csw-subtle); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- Trends & landscape (asset tiles + age bars) --- */
.report-screen .asset-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.75rem; }

/* --- Methodology + evidence + explanations --- */
.report-screen .methodology__spread { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.report-screen .status-legend__item, .report-screen .finding-explanation__section { font-size: 0.85rem; }
.report-screen .evidence-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.report-screen .evidence-table th, .report-screen .evidence-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--csw-hairline); text-align: left; word-break: break-all; }

/* Hide print-only chrome if it leaks into the screen body. */
.report-screen .report-meta, .report-screen .cover, .report-screen .signature-page, .report-screen .logo-header { display: none; }

/* Responsive: collapse the multi-col grids on narrow screens. */
@media (max-width: 48rem) {
  .report-screen .verdict-tiles { grid-template-columns: repeat(2, 1fr); }
  .report-screen .domain-grid { grid-template-columns: 1fr; }
  .report-screen .methodology__spread { grid-template-columns: 1fr; }
}
