:root {
  --yellow: #ffe600;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --sidebar-bg: #1a1a1a;
  --sidebar-ink: #d1d5db;
  --section-grey: #e5e7eb;
  --row-grey: #f3f4f6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

body { display: flex; }

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.18s ease;
}

/* Collapse toggle (top of sidebar) */
.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #2a2a2a;
  background: #2a2a2a;
  color: #d1d5db;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
}
.sidebar-toggle:hover { background: #3a3a3a; color: #fff; }

/* Collapsed state — keep only the toggle visible */
.sidebar.collapsed {
  width: 52px;
  padding: 24px 0;
}
.sidebar.collapsed .sidebar-toggle {
  right: 12px;
}
.sidebar.collapsed .brand,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed nav { display: none; }

.brand {
  font-weight: 700;
  font-size: 22px;
  padding: 0 24px;
  letter-spacing: 0.5px;
}
.brand-mark { background: var(--yellow); color: #000; padding: 2px 6px; border-radius: 3px; }
.brand-dot  { color: var(--yellow); margin: 0 2px; }
.brand-ai   { color: #fff; }
.brand-sub  { padding: 4px 24px 0; font-size: 12px; color: #9ca3af; text-transform: lowercase; }

.sidebar nav { margin-top: 28px; }

.nav-section {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6b7280;
  padding: 18px 24px 8px;
}

.nav-item {
  display: block;
  padding: 10px 24px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: #2a2a2a; color: #fff; }
.nav-item.active { background: #ffffff; color: #000; border-left-color: var(--yellow); font-weight: 600; }
.nav-item.disabled { color: #6b7280; pointer-events: none; }

.main {
  flex: 1;
  padding: 32px 40px 64px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.page-head .muted { margin: 0; color: var(--muted); font-size: 14px; max-width: 720px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #374151; }

.endpoints { list-style: none; padding: 0; margin: 0; }
.endpoints li { padding: 6px 0; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.method { display: inline-block; min-width: 44px; font-weight: 600; color: var(--muted); }
code { font-family: 'JetBrains Mono', monospace; font-size: 13px; background: #f3f4f6; padding: 1px 6px; border-radius: 3px; }

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { background: #f9fafb; }

.btn-primary {
  background: var(--yellow);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.file-list { display: grid; gap: 6px; }
.file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.file-row:hover { background: #fffbe6; border-color: #f5d300; }
.file-name { font-weight: 500; }
.file-size { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 12px; }

.sheet-block { margin-bottom: 28px; }
.sheet-block h3 { margin: 0 0 4px; font-size: 16px; }
.section-label { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--border);
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
.data-table th, .data-table td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.data-table th { background: #f9fafb; font-weight: 600; font-size: 11px; }
.data-table td.t-number { text-align: right; }
.data-table td.t-empty { color: #d1d5db; }
.data-table td.bold { font-weight: 700; }

/* --- Upload page ----------------------------------------------------- */

.link-btn {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 10px;
  border-radius: 4px;
}
.link-btn:hover { background: #f3f4f6; }

.hero {
  background: #1a1a1a;
  color: #fff;
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 20px;
}
.hero h2 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.hero p  { margin: 0; color: #d1d5db; font-size: 14px; line-height: 1.55; max-width: 880px; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 1180px) { .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .slot-grid { grid-template-columns: 1fr; } }

/* Compact 4-up row for the optional / recommended secondary slots. */
.slot-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .slot-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .slot-grid--four { grid-template-columns: 1fr; } }

.slot--compact { padding: 10px 12px; }
.slot--compact .slot-title { font-size: 12.5px; }
.slot--compact .slot-desc  { font-size: 11px; line-height: 1.35; }
.slot--compact .slot-head  { margin-bottom: 8px; }
.slot--compact .tag        { font-size: 9px; padding: 2px 6px; }
.slot--compact .dropzone   { min-height: 64px; padding: 10px 8px; }
.slot--compact .dz-plus    { font-size: 16px; }
.slot--compact .dz-text    { font-size: 11px; }

.slot {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  /* Make every card the same height in a row and push the dropzone to the
     bottom so all dropzones line up regardless of description length. */
  display: flex;
  flex-direction: column;
}
.slot-grid { align-items: stretch; }
.slot > .dropzone { margin-top: auto; }
.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.slot-title { font-weight: 600; font-size: 13px; }
.slot-desc  { color: var(--muted); font-size: 11.5px; margin-top: 3px; line-height: 1.4; }

.tag {
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag-required { background: #fff4cc; color: #854d0e; border: 1px solid #fcd34d; }
.tag-recommended { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.tag-optional { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }

/* Data Ingestion Agent overlay (brief progress modal before /scoping) */
.ingest-agent-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  animation: iaFade 0.2s ease-out both;
}
@keyframes iaFade { from { opacity: 0; } to { opacity: 1; } }
.ingest-agent-card {
  width: min(480px, 92vw);
  background: #fff; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.35), 0 4px 12px rgba(15,23,42,0.18);
  padding: 22px 24px 24px;
}
.ingest-agent-head {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px;
}
.ingest-agent-spark {
  width: 34px; height: 34px; flex-shrink: 0;
  background: #ffe600; color: #0f172a;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.ingest-agent-text { flex: 1; min-width: 0; }
.ingest-agent-title { font-weight: 600; font-size: 15px; color: #0f172a;
  transition: opacity 0.18s ease; }
.ingest-agent-sub   { margin-top: 2px; transition: opacity 0.18s ease; }
.ingest-agent-pct {
  font-variant-numeric: tabular-nums; font-weight: 700; color: #0f172a;
  font-size: 15px; min-width: 44px; text-align: right;
}
.ingest-agent-bar {
  position: relative;
  height: 12px; border-radius: 999px; background: #eef2f7; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15,23,42,0.08);
}
.ingest-agent-fill {
  position: relative; overflow: hidden;
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #ffe600 0%, #f59e0b 55%, #047857 100%);
  border-radius: 999px;
  transition: width 0.12s linear;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.55);
}
/* Diagonal moving stripes for "in progress" feel. */
.ingest-agent-shimmer {
  position: absolute; inset: 0;
  background-image: linear-gradient(
    45deg,
    rgba(255,255,255,0.35) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,0.35) 50%,
    rgba(255,255,255,0.35) 75%, transparent 75%, transparent
  );
  background-size: 18px 18px;
  animation: iaStripes 0.9s linear infinite;
  mix-blend-mode: overlay;
  opacity: 0.55;
}
@keyframes iaStripes {
  from { background-position: 0 0; }
  to   { background-position: 18px 0; }
}
/* Soft white glow at the leading edge of the fill. */
.ingest-agent-glow {
  position: absolute; top: 0; right: 0; bottom: 0; width: 28px;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.85) 100%);
  filter: blur(3px);
  pointer-events: none;
}

/* Step pills underneath the bar -------------------------------------- */
.ingest-agent-steps {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px; margin-top: 14px;
}
.ia-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
}
.ia-step-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid #e5e7eb; color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  position: relative; transition: all 0.25s ease;
}
.ia-step-num, .ia-step-check {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ia-step-check { opacity: 0; transform: scale(0.6); color: #fff; }
.ia-step-label {
  font-size: 11px; color: #6b7280; font-weight: 500;
  transition: color 0.2s ease;
}
.ia-step.is-active .ia-step-dot {
  border-color: #f59e0b; color: #b45309;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
  animation: iaPulse 1.1s ease-in-out infinite;
}
.ia-step.is-active .ia-step-label { color: #0f172a; font-weight: 600; }
.ia-step.is-done .ia-step-dot {
  background: #047857; border-color: #047857; color: #fff;
}
.ia-step.is-done .ia-step-num   { opacity: 0; transform: scale(0.6); }
.ia-step.is-done .ia-step-check { opacity: 1; transform: scale(1); }
.ia-step.is-done .ia-step-label { color: #047857; font-weight: 600; }
@keyframes iaPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18); }
  50%      { box-shadow: 0 0 0 7px rgba(245, 158, 11, 0.06); }
}
/* Qualitative Risk Assessment review modal --------------------------- */
.risk-review-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: iaFade 0.18s ease-out both;
}
.risk-review-card {
  width: min(1080px, 96vw); max-height: 88vh;
  background: #fff; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.35), 0 4px 12px rgba(15,23,42,0.18);
  display: flex; flex-direction: column; overflow: hidden;
}
.risk-review-head {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid #eef2f7;
}
.risk-review-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  color: #6b7280; text-transform: uppercase;
}
.risk-review-title { margin: 4px 0 6px; font-size: 17px; font-weight: 600; color: #0f172a; }
.risk-review-sub   { margin: 0; font-size: 12.5px; line-height: 1.5; color: #4b5563; max-width: 820px; }
.risk-review-close {
  background: transparent; border: 0; cursor: pointer;
  font-size: 24px; line-height: 1; color: #6b7280;
  padding: 4px 8px; border-radius: 6px;
}
.risk-review-close:hover { background: #f1f5f9; color: #0f172a; }
/* Note: no top/bottom padding on the scroll container — sticky thead must
   anchor at the very top of its scroll viewport, otherwise the first body
   row scrolls *over* the header during scroll. */
.risk-review-body { padding: 0 22px; overflow: auto; }
.risk-review-body > .risk-review-empty { margin: 14px 0; }
.risk-review-empty {
  padding: 32px; text-align: center; color: #6b7280;
  background: #f9fafb; border: 1px dashed #e5e7eb; border-radius: 10px;
}
.risk-review-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font: 500 13px/1.4 Inter, sans-serif;
}
.risk-review-table thead th {
  text-align: left; font: 600 11px/1.2 Inter, sans-serif;
  color: #374151; text-transform: uppercase; letter-spacing: 0.04em;
  background: #f9fafb; padding: 12px 12px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 5;
  box-shadow: 0 1px 0 #e5e7eb;
}
/* Solid backdrop so body rows can never bleed through the sticky header. */
.risk-review-table thead::after {
  content: ""; position: absolute; inset: 0; background: #f9fafb; z-index: -1;
}
.risk-review-table thead { position: relative; }
.risk-review-table tbody td {
  padding: 10px 12px; border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}
.risk-review-table tbody tr:hover td { background: #fafbfc; }
.risk-review-table .rr-comp     { width: 22%; }
.risk-review-table .rr-dim      { width: 11%; text-align: center; }
.risk-review-table .rr-rationale { width: 24%; }
.risk-review-table .rr-weighted { width: 12%; text-align: center; }
.risk-review-table td.rr-rationale {
  font: 500 12px/1.45 Inter, sans-serif; color: #374151;
  white-space: normal; cursor: help;
}
.rr-rationale-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.rr-comp-label { font-weight: 600; color: #0f172a; }
.rr-comp-sub   { font-size: 11.5px; color: #6b7280; margin-top: 2px; }
.rr-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font: 600 11.5px/1 Inter, sans-serif; white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer; transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
button.rr-pill { font-family: inherit; }
.rr-pill:hover  { filter: brightness(0.97); box-shadow: 0 1px 4px rgba(15,23,42,0.12); transform: translateY(-1px); }
.rr-pill:active { transform: translateY(0); }
.rr-pill:focus-visible { outline: 2px solid #ffe600; outline-offset: 2px; }
.rr-pill-low    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.rr-pill-medium { background: #fffbeb; color: #b45309; border-color: #fcd34d; }
.rr-pill-high   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.rr-pill-strong { font-weight: 700; padding: 4px 12px; }
.risk-review-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px; border-top: 1px solid #eef2f7; background: #fafbfc;
}
.risk-review-foot .btn-primary {
  background: #ffe600; color: #0f172a; border: 0; padding: 8px 18px;
  border-radius: 7px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.risk-review-foot .btn-primary:hover { background: #f5d300; }

/* Agent Scores modal (Review scores from AI Confidence) -------------- */
.agent-scores-card { width: min(1180px, 96vw); }
.agent-scores-body { padding: 18px 22px 22px; }
.agent-scores-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 980px) {
  .agent-scores-grid { grid-template-columns: 1fr; }
}
.agent-score-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 18px 16px; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.agent-score-title {
  margin: 0; font: 700 14.5px/1.35 Inter, sans-serif; color: #0f172a;
  min-height: 38px;
}
.agent-score-meter {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "spark label label"
    "bar   bar   pct";
  align-items: center; column-gap: 8px; row-gap: 6px;
}
.agent-score-spark { grid-area: spark; color: #6366f1; font-size: 14px; }
.agent-score-meter-label {
  grid-area: label;
  font: 600 12.5px/1.2 Inter, sans-serif; color: #1e293b;
}
.agent-score-bar {
  grid-area: bar;
  height: 4px; background: #f1f5f9; border-radius: 999px; overflow: hidden;
}
.agent-score-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f97316 60%, #f59e0b 100%);
  border-radius: 999px;
}
.agent-score-pct {
  grid-area: pct;
  font: 700 12.5px/1 Inter, sans-serif; color: #ef4444;
}
.agent-score-config {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.agent-score-config-btn {
  flex: 1 1 0; min-width: 0;
  padding: 8px 10px; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 8px;
  font: 500 11.5px/1.3 Inter, sans-serif; color: #0f172a;
  text-align: center; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.agent-score-config-btn:hover { background: #f9fafb; border-color: #cbd5e1; }
.agent-score-config-btn:focus-visible { outline: 2px solid #ffe600; outline-offset: 2px; }
.agent-score-section {
  display: flex; flex-direction: column; gap: 6px;
}
.agent-score-section-head {
  font: 700 12.5px/1.3 Inter, sans-serif; color: #2563eb;
  display: flex; align-items: baseline; gap: 6px;
}
.agent-score-sources-head {
  font-style: italic; font-weight: 600; color: #6b7280;
  font-size: 11.5px; text-transform: none;
}
.ag-required {
  font: 600 10.5px/1 Inter, sans-serif; color: #ef4444;
  font-style: italic;
}
.ag-required-mark { color: #ef4444; font-weight: 700; }
.agent-score-recs, .agent-score-sources {
  margin: 0; padding: 0 0 0 18px;
  font: 500 12.5px/1.55 Inter, sans-serif; color: #374151;
}
.agent-score-recs li { margin-bottom: 6px; }
.agent-score-recs li:last-child { margin-bottom: 0; }
.agent-score-sources { color: #4b5563; }
.agent-score-sources li { margin-bottom: 3px; }

/* Entry animation: cascade upward fade for scoping console blocks --- */
@keyframes scopeRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.scope-rise {
  animation: scopeRise 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
  will-change: transform, opacity;
}
/* Stagger rows of the scoping table on first render. */
@keyframes scopeRowRise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.scope-table tbody tr.sc-row-rise {
  animation: scopeRowRise 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

/* Materiality Agent variant: solid green progress + green spark badge. */
.mat-agent-overlay .ingest-agent-spark {
  background: #047857; color: #fff;
}
.mat-agent-overlay .ingest-agent-fill {
  background: linear-gradient(90deg, #34d399 0%, #10b981 50%, #047857 100%);
}

.dropzone {
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  background: #fafafa;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  /* Keep all dropzones the same visual height across the grid. */
  min-height: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.dropzone:hover, .dropzone:focus, .dropzone.hover {
  background: #fffbe6;
  border-color: #f5d300;
  outline: none;
}
.dropzone.filled {
  background: #f0fdf4;
  border: 1px solid #86efac;
  cursor: default;
  padding: 14px 16px;
  text-align: left;
}
.dz-plus { font-size: 18px; color: #6b7280; margin-bottom: 2px; line-height: 1; }
.dz-text { font-size: 12px; color: var(--muted); }

/* Upload coverage progress -------------------------------------------- */
.upload-progress {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.up-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.up-title { font-weight: 600; font-size: 13px; }
.up-pct { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: #111; }
.up-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #f3f4f6;
}
.up-bar-seg {
  transition: flex-grow 0.25s ease;
}
.up-bar-seg.tb     { background: #1d4ed8; }
.up-bar-seg.coa    { background: #047857; }
.up-bar-seg.tenk   { background: #b45309; }
.up-bar-seg.org    { background: #7c3aed; }
.up-bar-seg.prior  { background: #db2777; }
.up-bar-seg.racm   { background: #ca8a04; }
.up-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
}
.up-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f9fafb;
  border: 1px solid var(--border);
  color: #4b5563;
}
.up-chip .dot {
  width: 8px; height: 8px; border-radius: 999px; display: inline-block;
}
.up-chip.on { background: #fff; color: #111; border-color: #d1d5db; }
.up-chip.off { opacity: 0.6; }
.up-chip .count { font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: 10.5px; }

.file-pill {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fp-icon {
  background: #16a34a;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.fp-meta { flex: 1; min-width: 0; }
.fp-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-size { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.fp-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.fp-remove:hover { color: #dc2626; }

.file-list-stack { display: flex; flex-direction: column; gap: 6px; }
.file-list-stack .file-pill {
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 6px;
  padding: 8px 10px;
}
.dz-add-more {
  margin-top: 10px;
  background: none;
  border: 1px dashed #86efac;
  color: #15803d;
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  width: 100%;
}
.dz-add-more:hover { background: #ecfdf5; }

.sample-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.sample-checkbox-list label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}
.sample-checkbox-list label:hover { background: #f9fafb; }
.sample-checkbox-list .samp-size { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* ---- Confirm Structure page ---- */
.job-badge {
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}
.job-badge code { color: #111827; font-weight: 600; }

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px;
  color: #991b1b;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.kpi.warn { border-color: #fcd34d; background: #fffbeb; }
.kpi-value { font-size: 22px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.card-head p { margin: 0; }

.count-badge {
  background: #f3f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
  font-family: 'JetBrains Mono', monospace;
}
.count-badge.warn { background: #fef3c7; color: #92400e; }

.filter-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  width: 220px;
}

.file-card { border-bottom: 1px solid var(--border); }
.file-card:last-child { border-bottom: none; }
.file-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
}
.file-card-head:hover { background: #f9fafb; }
.file-name { font-weight: 500; font-size: 13px; }
.file-toggle { color: var(--muted); transition: transform 0.15s; }
.file-card.open .file-toggle { transform: rotate(180deg); }
.file-card-body { display: none; padding: 0 20px 16px; }
.file-card.open .file-card-body { display: block; }

.col-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  background: #f9fafb;
  border-radius: 6px;
  padding: 10px 14px;
}
.col-row { display: grid; grid-template-columns: 130px 16px 1fr; align-items: center; font-size: 12px; }
.col-role { color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.col-arrow { color: #d1d5db; }
.col-name { color: #111827; font-weight: 500; }

.file-warns {
  margin: 10px 0 0;
  padding: 8px 12px 8px 28px;
  background: #fffbeb;
  border-left: 3px solid #fcd34d;
  border-radius: 4px;
  color: #78350f;
  font-size: 12px;
}

.table-wrap { max-height: 480px; overflow-y: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 8px 16px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}
.data-table tbody tr:hover { background: #fafafa; }
.data-table .num { text-align: right; font-family: 'JetBrains Mono', monospace; }
.data-table code { font-size: 12px; color: #4b5563; }

.fsli-pending {
  display: inline-block;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
}

.warning-list { margin: 0; padding: 12px 20px 16px 36px; }
.warning-list li { font-size: 13px; color: #78350f; margin-bottom: 4px; }

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.primary-btn {
  background: var(--accent, #ffe600);
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.primary-btn:hover { background: #fff066; }
.primary-btn:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }
.primary-btn-lg { font-size: 16px; padding: 16px 28px; display: inline-block; }

.success-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  border-radius: 10px;
  padding: 18px 22px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.success-head { display: flex; align-items: flex-start; gap: 14px; }
.success-check {
  background: #16a34a;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 999px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  flex-shrink: 0;
}
.success-title { font-size: 16px; font-weight: 700; color: #14532d; }
.success-stats { font-size: 13px; color: #166534; margin-top: 2px; }
.success-stats strong { font-family: 'JetBrains Mono', monospace; color: #14532d; }

.action-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.primary-btn.is-disabled,
.primary-btn[aria-disabled="true"] {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  pointer-events: auto;
}
.primary-btn.is-disabled:hover,
.primary-btn[aria-disabled="true"]:hover { background: #e5e7eb; }

.note-info {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  color: #1e3a8a;
  margin: 16px 0;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

/* --- Modal ----------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: 10px;
  padding: 22px 26px;
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
}
.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.modal-card h3 { margin: 0; font-size: 16px; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
.sample-row { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 14px 0; }
.sample-row select {
  padding: 8px 10px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.sample-row-label { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ---- Confirm structure: hierarchy layout ---- */
.hierarchies-card { padding-bottom: 8px; }
.hierarchies-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  margin-top: 12px;
}
.hierarchy-col { min-width: 0; }
@media (max-width: 1100px) {
  .hierarchies-grid { grid-template-columns: 1fr; }
}
.hierarchy-col { display: flex; flex-direction: column; gap: 12px; }
.hierarchy-head h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}
.tree-box {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  font-size: 13px;
}
.tree-empty { padding: 24px; text-align: center; }

ul.tree { list-style: none; margin: 0; padding-left: 0; }
ul.tree ul.tree { padding-left: 18px; border-left: 1px dashed #e5e7eb; margin-left: 6px; }
ul.tree li { padding: 2px 0; }
ul.tree li.collapsed > ul { display: none; }
ul.tree li.collapsed > .node-row .tree-toggle { transform: rotate(-90deg); }
.node-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: default;
  min-width: 0;
}
.node-row:hover { background: #f3f4f6; }
.tree-toggle {
  display: inline-block;
  width: 14px;
  text-align: center;
  cursor: pointer;
  color: #6b7280;
  font-size: 11px;
  user-select: none;
  transition: transform 0.15s;
}
.tree-toggle.empty { cursor: default; visibility: hidden; }
.node-name {
  font-weight: 500;
  color: #111827;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1 1 auto;
}
li.is-leaf .node-name { font-weight: 400; color: #374151; }
.node-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.node-tag-leaf { background: #e5e7eb; color: #4b5563; font-weight: 500; }
.node-meta { font-size: 11px; font-family: 'JetBrains Mono', monospace; }

/* Level editors */
.level-editors {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}
.level-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
}
.level-tag {
  font-size: 11px;
  font-weight: 700;
  background: #111827;
  color: #fff;
  text-align: center;
  padding: 4px 0;
  border-radius: 4px;
}
.level-input {
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  width: 100%;
}
.level-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,230,0,0.25); }
.level-count { white-space: nowrap; }

/* Files block */
.file-block {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fff;
}
.file-block[open] { border-color: #d1d5db; }
.file-block summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-block summary::-webkit-details-marker { display: none; }
.file-body { padding: 0 14px 14px; border-top: 1px solid #f3f4f6; }
.file-body p { margin: 8px 0; }
.slot-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
  background: #1f2937;
  color: #fff;
}
.slot-tb { background: #1d4ed8; }
.slot-coa { background: #047857; }
.slot-org { background: #7c3aed; }
.slot-prior { background: #b45309; }
.file-name { font-weight: 500; color: #111827; flex: 1; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.mini-table th, .mini-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #f3f4f6; }
.mini-table th { color: #6b7280; font-weight: 500; background: #fafafa; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
}
.kpi-warn { border-color: #fcd34d; background: #fffbeb; }
.kpi-value { font-size: 22px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: #111827; }
.kpi-label { font-size: 12px; color: #6b7280; margin-top: 2px; }

.warning-list { margin: 0; padding-left: 18px; }
.warning-list li { color: #92400e; font-size: 13px; padding: 2px 0; }
.count-badge { display: inline-block; font-size: 11px; background: #e5e7eb; color: #374151; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; font-weight: 600; }
.count-badge.warn { background: #fef3c7; color: #92400e; }

.nav-item.done .nav-badge {
  background: var(--accent); color: #111; font-size: 10px; padding: 1px 6px;
  border-radius: 3px; margin-left: 6px; font-weight: 700;
}
.page-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; padding-top: 16px; border-top: 1px solid #e5e7eb; }
.error-banner { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 12px; border-radius: 6px; }

/* ============================ Output page ============================ */

/* KPI strip - flex layout */
.kpi-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } }

/* Progress bar */
.progress-bar { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; margin-top: 14px; }
.progress-fill { height: 100%; width: 5%; background: var(--accent); transition: width .6s ease; }

/* Tabs */
.tabs {
  display: flex; align-items: center; gap: 4px; margin-bottom: 14px;
  border-bottom: 1px solid #e5e7eb;
}
.tab {
  background: transparent; border: 0; padding: 10px 16px; font: inherit;
  font-weight: 600; font-size: 14px; color: #6b7280; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: #111827; }
.tab.active { color: #111827; border-bottom-color: var(--accent); }
.tab-actions { margin-left: auto; display: flex; gap: 8px; }
.ghost-btn {
  background: #fff; border: 1px solid #e5e7eb; padding: 8px 14px;
  border-radius: 6px; font-weight: 600; font-size: 13px; cursor: pointer;
  color: #374151;
}
.ghost-btn:hover { border-color: #9ca3af; }

/* Statement table */
.table-scroll { max-height: 70vh; overflow: auto; border: 1px solid #e5e7eb; border-radius: 6px; }
.stmt-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
}
.stmt-table thead th {
  background: #f9fafb; color: #374151; font-weight: 600; font-size: 12px;
  text-align: right; padding: 10px 12px; border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 2;
  font-family: 'Inter', sans-serif;
}
.stmt-table thead th.sticky { text-align: left; z-index: 3; }
.stmt-table th.sticky, .stmt-table td.sticky {
  position: sticky; left: 0; background: #fff; z-index: 1;
  text-align: left; min-width: 280px; max-width: 360px;
}
.stmt-table tbody td { padding: 6px 12px; text-align: right; border-bottom: 1px solid #f3f4f6; }
.stmt-table tbody th { padding: 6px 12px; text-align: left; font-weight: 500; border-bottom: 1px solid #f3f4f6; }
.stmt-table .line-row .line-label { color: #111827; }
.stmt-table .line-label .small { margin-left: 6px; opacity: .55; }
.stmt-table .section-row th, .stmt-table .section-row td {
  background: #f9fafb; font-family: 'Inter', sans-serif; font-weight: 700;
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em;
  color: #6b7280; padding: 8px 12px; border-bottom: 1px solid #e5e7eb;
}
.stmt-table .subtotal-row th, .stmt-table .subtotal-row td {
  background: #fafbfc; font-weight: 700; color: #111827;
  border-top: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb;
}
.stmt-table .grand-row th, .stmt-table .grand-row td {
  background: #111827; color: #fff; font-weight: 700;
  border-top: 2px solid #111827;
}
.stmt-table .grand-row th.sticky, .stmt-table .grand-row td.sticky { background: #111827; color: #fff; }
.stmt-table .td-total { font-weight: 700; background: #fffbe6; }
.stmt-table .grand-row .td-total { background: var(--accent); color: #111; }
.stmt-table .th-total { background: #fffbe6 !important; color: #111; }
.stmt-table .neg { color: #b91c1c; }
.stmt-table.compact tbody td, .stmt-table.compact tbody th { padding: 4px 10px; font-size: 12px; }

/* Mapping page controls */
.map-controls { display: flex; gap: 10px; margin-bottom: 12px; }
.search-input, .map-controls select {
  padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 13px; font-family: inherit; background: #fff;
}
.search-input { flex: 1; }
.badge {
  display: inline-block; background: #eef2ff; color: #3730a3;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  padding: 2px 6px; border-radius: 4px; font-weight: 600;
}

/* link-style nav button on output */
.link-btn { color: #111; text-decoration: underline; font-weight: 500; font-size: 14px; }
.link-btn:hover { color: var(--accent-dark, #b8a800); }

.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card.error { background: #fef2f2; border-color: #fecaca; }
.card.error h3 { color: #991b1b; }

/* ============================ Output v2 ============================ */
.page-head-right { display: flex; align-items: center; gap: 12px; }
.seg-toggle { display: inline-flex; background: #111827; border-radius: 6px; padding: 3px; gap: 2px; }
.seg-btn {
  background: transparent; color: #9ca3af; border: 0; padding: 7px 14px;
  border-radius: 4px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
}
.seg-btn.active { background: #fff; color: #111827; }

.toolbar { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; margin-bottom: 12px; }
.toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.toolbar-label { font-size: 11px; font-weight: 700; color: #6b7280; letter-spacing: 0.06em; }
.level-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.level-btn {
  background: #fff; border: 1px solid #e5e7eb; padding: 7px 14px; border-radius: 6px;
  font-weight: 600; font-size: 13px; color: #374151; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.level-btn:hover { border-color: #9ca3af; }
.level-btn.active { background: #111827; color: #fff; border-color: #111827; }
.level-btn .lvl-count {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #6b7280;
  background: #f3f4f6; padding: 1px 6px; border-radius: 3px;
}
.level-btn.active .lvl-count { background: rgba(255,255,255,.18); color: #fff; }
.mini-plus {
  display: inline-block; width: 14px; height: 14px; border: 1px solid #93c5fd;
  border-radius: 3px; text-align: center; line-height: 12px; font-weight: 700;
  font-size: 11px; color: #2563eb; background: #eff6ff; vertical-align: middle;
}

/* Pivot table */
.pivot-card { padding: 0; }
.pivot-card .table-scroll { max-height: 70vh; overflow: auto; border-radius: 8px 8px 0 0; }
.pivot-table { width: 100%; border-collapse: separate; border-spacing: 0; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.pivot-table th, .pivot-table td { padding: 10px 16px; vertical-align: middle; white-space: nowrap; }
.pivot-table thead th {
  background: #fff; color: #6b7280; font-weight: 600;
  border-bottom: 1px solid #e5e7eb; padding: 12px 16px;
  position: sticky; top: 0; z-index: 5;
  font-family: 'Inter', sans-serif; text-align: right;
}
.pivot-table thead .acct-col { text-align: left; z-index: 7; left: 0; min-width: 260px; }
.pivot-table thead .cons-col { text-align: right; z-index: 6; left: 260px; background: #fffbe6; min-width: 200px; }
.pivot-table thead .dim-col { min-width: 160px; }
.pivot-table thead .col-meta { font-size: 10px; font-weight: 700; color: #9ca3af; letter-spacing: 0.04em; }
.pivot-table thead .col-name {
  font-size: 14px; font-weight: 700; color: #111827;
  display: inline-flex; align-items: center; gap: 6px;
}
.pivot-table thead .col-sub { font-size: 10px; font-weight: 600; color: #9ca3af; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.04em; }
.col-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: 1px solid #93c5fd; border-radius: 3px;
  background: #eff6ff; color: #2563eb; font-weight: 700; font-size: 13px;
  cursor: pointer; line-height: 1; padding: 0;
}
.col-toggle:hover { background: #dbeafe; }

/* Sticky first column (account) and consolidated */
.pivot-table tbody .acct-col {
  position: sticky; left: 0; background: #fff; z-index: 2;
  text-align: left; min-width: 260px; max-width: 380px;
  font-family: 'Inter', sans-serif; font-weight: 500;
}
.pivot-table tbody .cons-col {
  position: sticky; left: 260px; z-index: 1;
  background: #fffbe6; text-align: right; font-weight: 700;
  border-right: 1px solid #f1d54a;
  min-width: 200px;
}
.pivot-table tbody .dim-col { text-align: right; color: #1f2937; min-width: 160px; }

/* Section row */
.pivot-table .section-row { cursor: pointer; }
.pivot-table .section-row .acct-col {
  background: #f3f4f6; text-transform: uppercase; font-weight: 700;
  font-size: 12px; letter-spacing: 0.04em; color: #374151;
}
.pivot-table .section-row .cons-col,
.pivot-table .section-row .dim-col {
  background: #f3f4f6; font-weight: 700; color: #374151;
}
.pivot-table .section-row:hover .acct-col,
.pivot-table .section-row:hover .cons-col,
.pivot-table .section-row:hover .dim-col { background: #e5e7eb; }

/* Caret */
.caret { display: inline-block; transition: transform .15s ease; color: #6b7280; margin-right: 6px; font-size: 10px; }
.caret.open { transform: rotate(90deg); }
.caret-spacer { display: inline-block; width: 12px; }

/* Line row (FSLI group) */
.pivot-table .line-row.expandable { cursor: pointer; }
.pivot-table .line-row .acct-col { padding-left: 28px; font-weight: 600; }
.pivot-table .line-row.expandable:hover .acct-col,
.pivot-table .line-row.expandable:hover .cons-col,
.pivot-table .line-row.expandable:hover .dim-col { background: #fafbfc; }

/* Account drill-down row */
.pivot-table .acct-row .acct-col {
  padding-left: 50px; color: #4b5563; font-weight: 400;
  background: #fcfdfd;
}
.pivot-table .acct-row .cons-col { background: #fefae0; font-weight: 500; }
.pivot-table .acct-row .dim-col { background: #fcfdfd; color: #4b5563; }
.pivot-table .acct-row .acct-id { margin-left: 8px; opacity: .6; }
.indent-1 { padding-left: 28px !important; }
.indent-2 { padding-left: 50px !important; }

/* Subtotal row */
.pivot-table .subtotal-row .acct-col,
.pivot-table .subtotal-row .cons-col,
.pivot-table .subtotal-row .dim-col {
  background: #fffbe6; font-weight: 700; color: #111;
  border-top: 1px solid #f1d54a; border-bottom: 1px solid #f1d54a;
}
.pivot-table .subtotal-row .acct-col em { font-style: italic; font-weight: 600; }

/* Grand total */
.pivot-table .grand-row th, .pivot-table .grand-row td {
  background: #111827 !important; color: #fff;
  font-weight: 700; font-size: 14px; padding: 12px;
}
.pivot-table .grand-row .cons-col.grand { background: #ffe600 !important; color: #111; }

/* Negative numbers */
.pivot-table .neg { color: #b91c1c; }

/* Footer */
.pivot-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; background: #fafbfc;
  border-top: 1px solid #e5e7eb; border-radius: 0 0 8px 8px;
}
.legend { display: flex; gap: 18px; font-size: 12px; color: #6b7280; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
#footer-counts { white-space: nowrap; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid #d1d5db; }
.swatch.consolidated { background: #fffbe6; border-color: #f1d54a; }
.swatch.section { background: #f3f4f6; }
.swatch.fsli { background: #fff; }
.swatch.subtotal { background: #ffe600; border-color: #ddc500; }

/* Search input */
#account-search { min-width: 240px; }

/* Hide old tabs/kpi/stmt-table styles when not used */

/* =========================================================================
   AI structure-assistant chatbox (confirm page)
   ========================================================================= */
.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  z-index: 50;
  font-family: 'Inter', sans-serif;
}
.chat-panel.collapsed .chat-body { display: none; }
.chat-panel:not(.collapsed) .chat-toggle { display: none; }

.chat-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border: 1px solid #111827;
  background: #111827; color: #ffe600;
  font-weight: 700; font-size: 13px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  cursor: pointer;
  font-family: inherit;
}
.chat-toggle:hover { background: #1f2937; }
.chat-toggle-icon { font-size: 14px; color: #ffe600; }

.chat-body {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  max-height: min(620px, calc(100vh - 48px));
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: #111827; color: #fff;
}
.chat-title { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.chat-icon { color: #ffe600; }
.chat-close {
  background: transparent; border: 0; color: #9ca3af;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.chat-close:hover { color: #fff; }
.chat-intro {
  margin: 0; padding: 10px 14px;
  background: #fafbfc; border-bottom: 1px solid #f1f5f9;
}
.chat-intro em {
  font-style: normal; background: #fff7d6; color: #1a1a1a;
  padding: 1px 5px; border-radius: 3px; margin: 0 2px;
}
.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  background: #fff;
}
.chat-log:empty::before {
  content: "Start by describing a change.";
  color: #9ca3af; font-size: 12px; font-style: italic;
}
.chat-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-user {
  align-self: flex-end;
  background: #111827; color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-assistant {
  align-self: flex-start;
  background: #f3f4f6; color: #111827;
  border-bottom-left-radius: 3px;
}
.chat-assistant.pending { color: #6b7280; font-style: italic; }
.chat-status {
  align-self: stretch;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.chat-status-applied {
  background: #fffbe6; border: 1px solid #f1d54a; color: #5b4400;
}
.chat-status-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
}
.chat-status-title { font-weight: 700; margin-bottom: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.chat-status ul { margin: 0; padding-left: 18px; }
.chat-status li { margin: 2px 0; }
.chat-form {
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fafbfc;
}
.chat-input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid #d1d5db; border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit; font-size: 13px;
  outline: none;
}
.chat-input:focus { border-color: #111827; box-shadow: 0 0 0 2px rgba(17,24,39,0.08); }
.chat-send { padding: 8px 14px; border-radius: 8px; font-size: 13px; }
.chat-send:disabled { opacity: 0.6; cursor: wait; }

@media (max-width: 700px) {
  .chat-panel { right: 12px; bottom: 12px; left: 12px; width: auto; }
}

/* 10-K parse status banner shown on the upload success card */
.tenk-banner {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}
.tenk-banner.ok   { background: #fffbe6; border: 1px solid #f1d54a; color: #5b4400; }
.tenk-banner.warn { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.tenk-banner code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; }

/* Apply-changes row under the L1/L2/L3 level editors on the Confirm page */
.level-apply-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.level-apply-row .btn-secondary { padding: 6px 14px; font-size: 13px; }
.level-apply-row .level-apply-status { font-size: 12px; }

/* ============================================================
   Auth shell, client/engagement screens, wizard, banner
   ============================================================ */

/* Login -------------------------------------------------------- */
body.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0b0b0b 0%, #1a1a1a 100%); }
.login-shell { width: 100%; max-width: 440px; padding: 24px; }
.login-card {
  background: #fff; border-radius: 12px; padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-brand { display: flex; align-items: center; gap: 4px; font-size: 22px; font-weight: 700; }
.login-brand .brand-ai-dark { color: #111; }
.login-brand .brand-tag { margin-left: 10px; font-size: 10px; letter-spacing: 0.12em; color: #6b7280; font-weight: 600; }
.login-card h1 { font-size: 22px; margin: 16px 0 4px; }
.login-card p.muted { margin: 0 0 20px; font-size: 13px; }
.login-form label { display: block; margin-bottom: 12px; font-size: 12px; font-weight: 500; color: #374151; }
.login-form input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.btn-block { width: 100%; }
.login-foot { margin-top: 14px; text-align: center; }

/* Sidebar collapsed state (rendered nav) ----------------------- */
.sidebar.collapsed nav,
.sidebar.collapsed .brand,
.sidebar.collapsed .brand-sub { display: none; }
.nav-hint { padding: 6px 24px 12px; font-style: italic; }

/* Client / engagement card grid -------------------------------- */
.client-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 8px;
}
.client-card {
  display: block; padding: 18px; background: #fff;
  border: 1px solid var(--border, #e5e7eb); border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.client-card:hover { border-color: var(--yellow); box-shadow: 0 6px 18px rgba(0,0,0,0.06); transform: translateY(-1px); }
.client-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.client-name { font-weight: 600; font-size: 15px; color: #111827; }
.client-meta { margin-top: 6px; }

/* Pills -------------------------------------------------------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.pill-muted { background: #f3f4f6; color: #4b5563; }
.pill-progress { background: #dbeafe; color: #1d4ed8; }
.pill-review { background: #fef3c7; color: #92400e; }
.pill-done { background: #dcfce7; color: #15803d; }

/* Breadcrumbs -------------------------------------------------- */
.crumbs { margin: -8px 0 14px; }
.crumbs a { color: inherit; text-decoration: none; border-bottom: 1px dashed #d1d5db; }
.crumbs a:hover { border-bottom-color: #9ca3af; }

/* Engagement context banner ----------------------------------- */
.eng-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #111827; color: #f3f4f6;
  border-radius: 8px; margin-bottom: 18px; font-size: 13px;
}
.eng-banner-eyebrow { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: #ffe600; font-weight: 700; }
.eng-banner strong { font-weight: 600; }
.eng-banner .muted { color: #9ca3af; }
.eng-banner-switch { margin-left: auto; color: #ffe600 !important; }

/* ============================================================
   EY Client Onboarding Wizard (cwz-*)
   ============================================================ */
.cwz-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: cwz-fade .22s ease-out;
}
.cwz-overlay[hidden] { display: none; }
@keyframes cwz-fade { from { opacity: 0; } to { opacity: 1; } }

.cwz-panel {
  position: relative;
  width: min(1024px, calc(100vw - 32px));
  max-height: 92vh;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 25px 60px -15px rgba(0,0,0,0.35), 0 8px 24px -8px rgba(0,0,0,0.2);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: cwz-pop .28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cwz-pop {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cwz-top-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #FFE600 0%, #FFD700 60%, #FFB800 100%);
  z-index: 1;
}

/* ---- Header ---- */
.cwz-head {
  position: relative;
  padding: 26px 32px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border-bottom: 1px solid #f1f1f3;
}
.cwz-kicker {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: #6b7280;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 6px;
  white-space: nowrap;
}
.cwz-spark { display: inline-flex; align-items: center; }
.cwz-title {
  margin: 0 0 4px;
  font-size: 24px; font-weight: 800; color: #0f172a;
  letter-spacing: -0.015em; line-height: 1.2;
}
.cwz-subtitle {
  margin: 0;
  font-size: 13px; color: #6b7280; line-height: 1.4;
}
.cwz-close {
  position: absolute; top: 20px; right: 20px;
  width: 36px; height: 36px; border-radius: 50%;
  background: transparent; border: 1px solid #e5e7eb; color: #6b7280;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.cwz-close:hover { background: #f3f4f6; color: #111827; border-color: #d1d5db; }
.cwz-close:focus-visible { outline: 2px solid #FFE600; outline-offset: 2px; }

/* ---- Stepper ---- */
.cwz-stepper {
  position: relative;
  list-style: none; margin: 24px 0 4px; padding: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
}
.cwz-track {
  position: absolute;
  left: 7%; right: 7%; top: 13px; height: 2px;
  background: #e5e7eb; border-radius: 999px;
  overflow: hidden;
}
.cwz-fill {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #FFE600 0%, #FFD700 60%, #FFB800 100%);
  box-shadow: 0 0 14px rgba(255,230,0,0.6);
  transition: width .55s cubic-bezier(0.22, 1, 0.36, 1);
}
.cwz-step {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 0 4px;
  position: relative;
}
.cwz-node {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #d1d5db; background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  cursor: not-allowed;
  transition: transform .18s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
  padding: 0; position: relative;
  z-index: 2;
}
.cwz-step.is-reachable .cwz-node { cursor: pointer; }
.cwz-step.is-reachable .cwz-node:hover { transform: scale(1.1); }
.cwz-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #d1d5db;
  transition: background .2s, transform .2s, box-shadow .2s;
}
.cwz-check { display: none; }

.cwz-step.is-active .cwz-node {
  border-color: #FFE600; background: #ffffff;
  box-shadow: 0 0 0 4px rgba(255,230,0,0.18);
}
.cwz-step.is-active .cwz-dot {
  width: 10px; height: 10px;
  background: #FFE600;
  box-shadow: 0 0 10px rgba(255,230,0,0.9);
  animation: cwz-pulse 1.6s ease-in-out infinite;
}
@keyframes cwz-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.25); }
}

.cwz-step.is-done .cwz-node {
  border-color: #0f172a; background: #0f172a;
}
.cwz-step.is-done .cwz-dot { display: none; }
.cwz-step.is-done .cwz-check {
  display: flex; align-items: center; justify-content: center;
  animation: cwz-pop-check .35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cwz-pop-check {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: scale(1); }
}

.cwz-step-label {
  margin-top: 10px;
  font-size: 11.5px; font-weight: 600; color: #6b7280;
  line-height: 1.25;
}
.cwz-step-tone {
  margin-top: 2px;
  font-size: 10px; font-weight: 600; color: #9ca3af;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.cwz-step.is-active .cwz-step-label { color: #0f172a; }
.cwz-step.is-done   .cwz-step-label { color: #374151; }

/* ---- Body ---- */
.cwz-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cwz-body {
  flex: 1; overflow-y: auto;
  padding: 28px 32px 24px;
  background: #ffffff;
}
.cwz-slide-in-r { animation: cwz-slide-r .32s cubic-bezier(0.22, 1, 0.36, 1); }
.cwz-slide-in-l { animation: cwz-slide-l .32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes cwz-slide-r {
  from { opacity: 0; transform: translateX(40px); filter: blur(4px); }
  to   { opacity: 1; transform: translateX(0);    filter: blur(0); }
}
@keyframes cwz-slide-l {
  from { opacity: 0; transform: translateX(-40px); filter: blur(4px); }
  to   { opacity: 1; transform: translateX(0);     filter: blur(0); }
}

.cwz-kicker-step {
  font-size: 11px; font-weight: 700; color: #B58B00;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 4px;
  max-width: 640px; margin-left: auto; margin-right: auto;
}
.cwz-section-title {
  margin: 0 0 18px;
  font-size: 18px; font-weight: 800; color: #0f172a;
  letter-spacing: -0.01em;
  max-width: 640px; margin-left: auto; margin-right: auto;
}

.cwz-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
  max-width: 640px; margin: 0 auto;
}
.cwz-field {
  display: flex; flex-direction: column; gap: 6px;
  opacity: 0; transform: translateY(8px);
  animation: cwz-field-in .32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(50ms + var(--i, 0) * 40ms);
}
@keyframes cwz-field-in {
  to { opacity: 1; transform: translateY(0); }
}
.cwz-label {
  font-size: 13px; font-weight: 600; color: #1f2937;
  display: inline-flex; align-items: center; gap: 4px;
}
.cwz-req { color: #ef4444; font-weight: 700; }
.cwz-field input,
.cwz-field select,
.cwz-field textarea {
  height: 40px;
  padding: 0 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb; border-radius: 6px;
  font: inherit; font-size: 14px; color: #0f172a;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  outline: none; width: 100%;
  font-family: inherit;
}
.cwz-field textarea {
  height: auto; min-height: 88px;
  padding: 10px 12px;
  resize: vertical; line-height: 1.5;
}
.cwz-field input:focus,
.cwz-field select:focus,
.cwz-field textarea:focus {
  border-color: #FFE600;
  box-shadow: 0 0 0 3px rgba(255,230,0,0.25);
}
.cwz-field input:disabled,
.cwz-field select:disabled {
  background: #f8fafc; color: #9ca3af; cursor: not-allowed;
}
.cwz-field input.cwz-invalid,
.cwz-field select.cwz-invalid,
.cwz-field textarea.cwz-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}
.cwz-field input[data-fmt="number"] {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.cwz-hint { font-size: 12px; color: #6b7280; }

/* ---- Maturity table ---- */
.cwz-mat-block { max-width: 100%; margin: 24px auto 0; }
.cwz-mat-title {
  font-size: 14px; font-weight: 700; color: #0f172a;
  margin: 8px 0 10px;
  max-width: 640px; margin-left: auto; margin-right: auto;
}
.cwz-mat-card {
  border: 1px solid #e5e7eb; border-radius: 10px;
  background: #ffffff; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.cwz-mat-head, .cwz-mat-row {
  display: grid; grid-template-columns: 3fr 6fr 3fr;
  gap: 16px; padding: 12px 16px;
}
.cwz-mat-head {
  background: #f8fafc;
  font-size: 11px; font-weight: 700; color: #6b7280;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.cwz-mat-row {
  font-size: 12.5px; line-height: 1.5;
  border-top: 1px solid #f1f1f3;
  position: relative;
  transition: background .2s ease;
}
.cwz-mat-row::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: transparent;
  transition: background .2s ease, box-shadow .2s ease;
}
.cwz-mat-row.is-active { background: rgba(255,230,0,0.10); }
.cwz-mat-row.is-active::before {
  background: #FFE600;
  box-shadow: 0 0 8px rgba(255,230,0,0.7);
}
.cwz-mat-name {
  font-weight: 700; color: #0f172a;
  display: flex; align-items: center; gap: 8px;
}
.cwz-mat-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.cwz-mat-row[data-tone="danger"]  .cwz-mat-dot { background: #ef4444; }
.cwz-mat-row[data-tone="danger"]  .cwz-mat-risk { color: #b91c1c; }
.cwz-mat-row[data-tone="warn"]    .cwz-mat-dot { background: #f97316; }
.cwz-mat-row[data-tone="warn"]    .cwz-mat-risk { color: #c2410c; }
.cwz-mat-row[data-tone="neutral"] .cwz-mat-dot { background: #9ca3af; }
.cwz-mat-row[data-tone="neutral"] .cwz-mat-risk { color: #374151; }
.cwz-mat-row[data-tone="good"]    .cwz-mat-dot { background: #10b981; }
.cwz-mat-row[data-tone="good"]    .cwz-mat-risk { color: #047857; }
.cwz-mat-row[data-tone="great"]   .cwz-mat-dot { background: #FFE600; }
.cwz-mat-row[data-tone="great"]   .cwz-mat-risk { color: #B58B00; }
.cwz-mat-chars { color: #374151; }
.cwz-mat-risk  { font-weight: 600; }

/* ---- Footer ---- */
.cwz-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  border-top: 1px solid #f1f1f3;
  background: #f9fafb;
  gap: 16px;
  flex-shrink: 0;
}
.cwz-trust {
  font-size: 12px; color: #6b7280;
  display: inline-flex; align-items: center; gap: 6px;
}
.cwz-actions { display: flex; gap: 10px; align-items: center; }
.cwz-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 20px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background .18s ease, color .18s ease, border-color .18s ease, opacity .18s ease, box-shadow .18s ease;
  font-family: inherit;
}
.cwz-pill:disabled { opacity: 0.45; cursor: not-allowed; }
.cwz-pill-outline {
  background: #ffffff; color: #1f2937; border-color: #e5e7eb;
}
.cwz-pill-outline:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }
.cwz-pill-primary {
  background: #0f172a; color: #ffffff;
  box-shadow: 0 4px 12px -2px rgba(15,23,42,0.25);
  position: relative; overflow: hidden;
}
.cwz-pill-primary:hover:not(:disabled) { background: #1f2937; }
.cwz-pill-shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,230,0,0.25) 50%, transparent 100%);
  animation: cwz-shimmer 2.4s linear infinite;
}
@keyframes cwz-shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
.cwz-spin { animation: cwz-rotate 1s linear infinite; }
@keyframes cwz-rotate { to { transform: rotate(360deg); } }

/* ---- Celebration overlay ---- */
.cwz-celebrate[hidden] { display: none !important; }
.cwz-celebrate {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 5;
}
.cwz-halo {
  position: absolute;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,230,0,0.4);
  filter: blur(20px);
  animation: cwz-halo 1.2s ease-out forwards;
}
@keyframes cwz-halo {
  0%   { transform: scale(0);   opacity: 1; }
  50%  { transform: scale(2.4); opacity: 0.4; }
  100% { transform: scale(3.4); opacity: 0; }
}
.cwz-medallion {
  position: relative;
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, #FFE600 0%, #FFB800 100%);
  box-shadow: 0 25px 50px -10px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  animation: cwz-medallion .9s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cwz-medallion {
  from { transform: scale(0) rotate(-180deg); }
  to   { transform: scale(1) rotate(0); }
}
.cwz-confetti {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.cwz-confetti span {
  position: absolute;
  width: 6px; height: 6px; border-radius: 50%;
  background: #FFE600;
  box-shadow: 0 0 6px rgba(255,230,0,0.9);
  --x: calc(cos(var(--ang)) * 90px);
  --y: calc(sin(var(--ang)) * 90px);
  animation: cwz-confetti .9s ease-out forwards;
}
@keyframes cwz-confetti {
  from { transform: translate(0,0); opacity: 1; }
  to   { transform: translate(var(--x), var(--y)); opacity: 0; }
}

/* Responsive */
@media (max-width: 720px) {
  .cwz-head { padding: 22px 20px 14px; }
  .cwz-body { padding: 20px; }
  .cwz-foot { padding: 14px 20px; }
  .cwz-step-label, .cwz-step-tone { display: none; }
}

/* ============================================================
   Dashboard (Workspace Overview)
   ============================================================ */
.dash-main { padding: 24px 32px; max-width: 1280px; margin: 0 auto; }
.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.dash-h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.dash-h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.01em; }
.dash-section { margin-top: 24px; }
.btn-pill { border-radius: 999px; padding: 8px 16px; display: inline-flex; align-items: center; gap: 4px; }
.btn-pill .plus { font-size: 16px; line-height: 1; }

/* KPI strip */
.kpi-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
@media (max-width: 1100px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .kpi-strip { grid-template-columns: repeat(2, 1fr); } }
.kpi-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-row { display: flex; justify-content: space-between; align-items: center; }
.kpi-label {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 10.5px;
  color: var(--muted); font-weight: 600;
}
.kpi-icon { color: #9ca3af; display: flex; }
.kpi-value { font-size: 22px; font-weight: 700; color: #0f172a; line-height: 1.1; }
.kpi-pct { font-size: 13px; font-weight: 600; color: var(--muted); }

/* 3-col + 2-col grids */
.dash-grid-3 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; margin-bottom: 8px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 980px) { .dash-grid-3, .dash-grid-2 { grid-template-columns: 1fr; } }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 12px; }
.card-title { font-weight: 600; font-size: 13px; color: #0f172a; }

/* Donut */
.donut-wrap { display: flex; justify-content: center; padding: 8px 0 4px; }
.donut-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 8px; font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: #4b5563; }
.legend-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }
.legend-count { font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: 11px; margin-left: 2px; }

/* Activity */
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.activity-avatar {
  width: 32px; height: 32px; border-radius: 999px; flex: 0 0 32px;
  background: #f3f4f6; color: #4b5563;
  display: flex; align-items: center; justify-content: center;
}
.activity-avatar.ey { background: #FFE600; color: #111; }
.activity-body { font-size: 13px; line-height: 1.45; color: #374151; }
.activity-empty { padding: 8px 0; }

/* Engagement cards grid */
.eng-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 980px) { .eng-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .eng-grid { grid-template-columns: 1fr; } }
.eng-card {
  display: block; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; transition: box-shadow 0.15s, transform 0.15s;
}
.eng-card:hover { box-shadow: 0 8px 20px -10px rgba(0,0,0,0.12); transform: translateY(-1px); border-color: #d1d5db; }
.eng-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.eng-card-title { font-weight: 600; font-size: 14px; color: #0f172a; }
.eng-card-sub { margin-top: 2px; }
.eng-card-name { margin-top: 8px; font-size: 12.5px; color: #4b5563; }
.eng-card-fy { margin-top: 8px; padding-top: 8px; border-top: 1px solid #f3f4f6; color: var(--muted); font-size: 11.5px; letter-spacing: 0.01em; }
.periods-table .btn-sm { padding: 5px 12px; font-size: 12px; font-weight: 600; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; cursor: pointer; }
.periods-table .btn-sm:hover { border-color: #111; background: #fafafa; }
.periods-table tbody tr:hover { background: #fafafa; }
.periods-table th, .periods-table td { padding: 12px 16px; }
.periods-scroll { height: min(60vh, 420px); overflow-y: scroll !important; overflow-x: hidden; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; display: block; }
.periods-scroll::-webkit-scrollbar { width: 10px; }
.periods-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; border: 2px solid #fff; }
.periods-scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.periods-scroll::-webkit-scrollbar-track { background: #f8fafc; }
.periods-scroll .periods-table { margin: 0; border: 0; }
.periods-scroll .periods-table thead th { position: sticky; top: 0; background: #fafafa; z-index: 2; box-shadow: inset 0 -1px 0 #e5e7eb; }

/* Add Fiscal Year modal (scoped to engagement-periods page) */
.fy-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 90; }
.fy-modal-backdrop[hidden] { display: none; }
.fy-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(440px, 92vw); background: #fff; border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25); z-index: 91;
  display: flex; flex-direction: column;
}
.fy-modal[hidden] { display: none; }
.fy-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.fy-modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: #0f172a; }
.fy-modal-close { background: transparent; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: #64748b; padding: 0 4px; }
.fy-modal-close:hover { color: #0f172a; }
.fy-modal-body { padding: 18px 20px 4px; }
.fy-modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; }
.fy-form-label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 6px; letter-spacing: 0.02em; }
.fy-form-input { width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff; color: #0f172a; }
.fy-form-input:focus { outline: 2px solid #ffe600; outline-offset: -1px; border-color: #ffe600; }
.fy-form-error { color: #b91c1c; font-size: 12.5px; margin: 12px 0 0; }
.fy-form-error[hidden] { display: none; }
.eng-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #f3f4f6; }
.ms-label { font-size: 10px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.ms-value { font-size: 16px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }

/* Status pills (shared with engagement detail) */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 999px;
}
.status-draft     { background: #f3f4f6; color: #4b5563; }
.status-processing{ background: #FFF8B8; color: #8a6d00; }
.status-ready     { background: #dcfce7; color: #166534; }
.status-archived  { background: #e5e7eb; color: #4b5563; }

/* Empty engagement state */
.empty-state {
  border: 2px dashed #d1d5db; border-radius: 12px;
  padding: 36px 16px; text-align: center; color: #4b5563;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: #fafafa; grid-column: 1 / -1;
}
.empty-icon { width: 40px; height: 40px; color: #9ca3af; display: flex; align-items: center; justify-content: center; }
.empty-title { font-weight: 600; font-size: 14px; color: #0f172a; }

/* ============================================================
   Engagement detail page
   ============================================================ */
.eng-detail-main { padding: 20px 32px; max-width: 1280px; margin: 0 auto; }
.eng-topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: #0f172a; }
.crumbs strong { color: #0f172a; font-weight: 600; }
.crumb-sep { color: #d1d5db; margin: 0 4px; font-weight: 600; letter-spacing: -1px; }
.eng-crumbs { margin: 0 0 12px; }

/* ===== Materiality gate (hide KPI / rationale / AI-conf until confirmed) ===== */
.materiality-gated.is-gated { display: none !important; }
.materiality-gated.just-revealed {
  animation: matRevealFade 0.55s ease both;
}
@keyframes matRevealFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.confirm-structure-bar[hidden],
.rerun-mat-bar[hidden] { display: none !important; }

/* Section headings inside the scoping output page (e.g. "Materiality Metrics",
   "Scoping Console") — sit between gated blocks once the agent has run. */
.scope-section-head {
  margin: 18px 0 10px;
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: 0.01em;
}
.scope-section-head .muted { font-weight: 500; color: #64748b; margin-left: 6px; }
.scope-section-head .muted.small { font-size: 12px; }
.confirm-structure-bar {
  display: flex; align-items: center; gap: 14px;
  margin: 14px 0 16px; padding: 14px 18px;
  border: 1px solid #f0d000; border-radius: 12px;
  background: linear-gradient(135deg, #fffbe5 0%, #ffffff 70%);
  box-shadow: 0 1px 0 rgba(15,23,42,0.04);
}
.csb-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #ffe600; color: #0f172a; border-radius: 8px;
  font-size: 16px; font-weight: 700;
}
.csb-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.csb-text strong { font-size: 13.5px; color: #0f172a; }
.csb-text .muted { font-size: 12px; line-height: 1.45; }
.csb-btn {
  flex-shrink: 0; background: #0f172a; color: #ffe600;
  border: 0; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.csb-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(15,23,42,0.18); }
.csb-btn:active { transform: translateY(0); }

/* ===== Re-run Materiality banner (post-confirm structural edits) ===== */
.rerun-mat-bar {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0 12px; padding: 10px 14px;
  border: 1px dashed #ffc400; border-radius: 10px;
  background: linear-gradient(135deg, #fffbe5 0%, #fff8d2 100%);
}
.rmb-icon {
  width: 26px; height: 26px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #ffe600; color: #0f172a; border-radius: 6px;
  font-size: 14px; font-weight: 700;
}
.rmb-text { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.rmb-text strong { font-size: 12.5px; color: #0f172a; }
.rmb-text .muted { font-size: 11.5px; line-height: 1.4; }
.rmb-btn {
  flex-shrink: 0; background: #0f172a; color: #ffe600;
  border: 0; padding: 8px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.rmb-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(15,23,42,0.18); }
.rmb-btn:active { transform: translateY(0); }

/* ===== Editable dimension pills ===== */
.scope-dim-pill-wrap {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0 4px 6px 0;
}
.scope-dim-pill-wrap .scope-dim-pill { margin: 0; }
.dim-edit-btn {
  width: 22px; height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: #94a3b8; cursor: pointer;
  font-size: 12px; line-height: 1;
  opacity: 0; transition: opacity 0.12s, border-color 0.12s, color 0.12s, background 0.12s;
}
.scope-dim-pill-wrap:hover .dim-edit-btn,
.scope-dim-pill-wrap.active .dim-edit-btn { opacity: 1; }
.dim-edit-btn:hover { color: #0f172a; border-color: #e5e7eb; background: #fff; }
.scope-dim-pill-wrap .dim-edit-input {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 10px; border: 1.5px solid #ffe600; border-radius: 999px;
  background: #fffbe5; color: #0f172a; min-width: 180px; outline: none;
}
.scope-dim-pill-wrap .dim-edit-apply {
  padding: 6px 12px; border: 0; border-radius: 999px;
  background: #0f172a; color: #ffe600; font-weight: 600; font-size: 12px;
  cursor: pointer;
}
.scope-dim-pill-wrap .dim-edit-apply:hover { filter: brightness(1.1); }
.scope-dim-pill-wrap .dim-edit-cancel {
  width: 24px; height: 24px; padding: 0; border: 1px solid #e5e7eb;
  border-radius: 999px; background: #fff; cursor: pointer; color: #475569;
  font-size: 11px;
}
.scope-dim-pill-wrap .dim-edit-cancel:hover { color: #0f172a; border-color: #0f172a; }

/* ===== Editable entity-column cells ===== */
.sc-cell { position: relative; }
.sc-cell-edit {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 18px; height: 18px; padding: 0; border: 0; background: transparent;
  color: #94a3b8; cursor: pointer; border-radius: 4px; font-size: 11px;
  opacity: 0; transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.sc-cell:hover .sc-cell-edit { opacity: 1; }
.sc-cell-edit:hover { color: #0f172a; background: #f1f5f9; }
.sc-cell-edited { background: #fffbe5 !important; box-shadow: inset 3px 0 0 #ffe600; }
/* When the user-edited value also crosses Tolerable Error, treat it like a
   system selection (blue) but keep the yellow rail to mark it as edited. */
.scope-table td.sc-cell.sys.sc-cell-edited { background: #dbeafe !important; }
.scope-table tbody tr:hover td.sc-cell.sys.sc-cell-edited { background: #cfe1fb !important; }
.scope-table td.sc-cell.usr.sc-cell-edited { background: #93c5fd !important; }
.sc-cell-editing { background: #fffbe5 !important; padding: 4px !important; }
.cell-edit-wrap {
  display: inline-flex; align-items: center; gap: 4px; width: 100%;
}
.cell-edit-input {
  flex: 1; min-width: 0; font: inherit; font-size: 12px;
  text-align: right; padding: 4px 6px;
  border: 1.5px solid #ffe600; border-radius: 4px; background: #fff;
  color: #0f172a; outline: none;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.cell-edit-ok, .cell-edit-no {
  width: 20px; height: 22px; padding: 0; border: 1px solid #e5e7eb;
  border-radius: 4px; background: #fff; cursor: pointer; font-size: 11px;
  line-height: 1; color: #475569;
}
.cell-edit-ok { color: #0f172a; background: #ffe600; border-color: #ffe600; font-weight: 700; }
.cell-edit-ok:hover { filter: brightness(1.05); }
.cell-edit-no:hover { color: #0f172a; border-color: #0f172a; }

/* ===== AI Confidence Score (Scoping Console) ===== */
.ai-conf-card {
  margin: 14px 0 18px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffef5 0%, #ffffff 60%);
  box-shadow: 0 1px 0 rgba(15,23,42,0.04);
  overflow: hidden;
}
.ai-conf-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  background: linear-gradient(90deg, rgba(255,230,0,0.18), rgba(255,230,0,0));
}
.ai-conf-title { display: flex; align-items: baseline; gap: 10px; }
.ai-conf-title > span:nth-child(2) { font-size: 14px; font-weight: 700; color: #0f172a; letter-spacing: -0.01em; }
.ai-conf-spark { color: #0f172a; background: #ffe600; padding: 2px 6px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.ai-conf-tagline { font-size: 12px; }
.ai-conf-head-actions { display: flex; align-items: center; gap: 8px; }
.ai-conf-toggle {
  width: 26px; height: 26px; border: 1px solid #e5e7eb; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 13px; color: #475569; line-height: 1;
}
.ai-conf-toggle:hover { border-color: #0f172a; color: #0f172a; }
.ai-conf-body { padding: 18px; transition: max-height 0.18s ease; }
.ai-conf-body.collapsed { display: none; }
.ai-conf-meter {
  display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center;
  padding-bottom: 16px; border-bottom: 1px dashed #e5e7eb; margin-bottom: 16px;
}
.ai-conf-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ai-conf-ring svg { display: block; }
.ai-conf-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.ai-conf-band-label { font-size: 12.5px; color: #475569; margin-bottom: 8px; }
.ai-conf-band-label strong { color: #0f172a; font-weight: 700; }
/* Continuous gradient progress bar driven by --conf-pct (e.g. 93%). The
   full red→amber→green gradient lives on the track; an overlay masks the
   unfilled portion on the right with the neutral background colour. */
.ai-conf-band-track {
  position: relative; height: 10px; border-radius: 5px; overflow: hidden;
  max-width: 560px;
  background: linear-gradient(90deg,
    #b91c1c 0%, #d97706 28%, #ca8a04 50%, #16a34a 75%, #047857 100%);
}
.ai-conf-band-track::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0;
  width: calc(100% - var(--conf-pct, 0%));
  background: #eef2f7;
  transition: width 0.4s ease;
}
.ai-conf-seg { display: none; }
.ai-conf-marker {
  position: absolute; top: -4px; width: 12px; height: 18px; border-radius: 3px;
  background: #ffe600; border: 2px solid #0f172a; box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: left 0.25s ease;
}
.ai-conf-band-ticks {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 6px;
  max-width: 560px;
  font-size: 10.5px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em;
}
.ai-conf-band-ticks span { text-align: center; }
.ai-conf-signals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.ai-conf-tile {
  position: relative; display: flex; min-height: 92px;
  border: 1px solid #e5e7eb; border-radius: 10px; background: #fff;
  overflow: hidden; transition: border-color 0.12s, transform 0.12s;
}
.ai-conf-tile:hover { border-color: #0f172a; transform: translateY(-1px); }
.ai-conf-tile-stripe { width: 4px; flex-shrink: 0; }
.ai-conf-tile-body { padding: 10px 12px 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ai-conf-tile-top { display: flex; align-items: center; gap: 8px; }
.ai-conf-tile-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; font-size: 12px; }
.ai-conf-tile-count { font-size: 22px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ai-conf-tile-label { font-size: 12px; color: #475569; line-height: 1.35; flex: 1; }
.ai-conf-tile-cta { align-self: flex-start; background: transparent; border: 0; padding: 0; cursor: pointer; font-size: 11.5px; font-weight: 600; color: #0f172a; }
.ai-conf-tile-cta:hover { text-decoration: underline; }
/* Tone-specific stripes + icon backgrounds */
.ai-conf-tone-warn   .ai-conf-tile-stripe { background: #f59e0b; }
.ai-conf-tone-warn   .ai-conf-tile-icon   { background: #fef3c7; color: #92400e; }
.ai-conf-tone-good   .ai-conf-tile-stripe { background: #16a34a; }
.ai-conf-tone-good   .ai-conf-tile-icon   { background: #dcfce7; color: #166534; }
.ai-conf-tone-muted  .ai-conf-tile-stripe { background: #94a3b8; }
.ai-conf-tone-muted  .ai-conf-tile-icon   { background: #f1f5f9; color: #475569; }
.ai-conf-tone-danger .ai-conf-tile-stripe { background: #dc2626; }
.ai-conf-tone-danger .ai-conf-tile-icon   { background: #fee2e2; color: #991b1b; }
.ai-conf-tone-calm   .ai-conf-tile-stripe { background: #0ea5e9; }
.ai-conf-tone-calm   .ai-conf-tile-icon   { background: #e0f2fe; color: #075985; }
.ai-conf-tone-user   .ai-conf-tile-stripe { background: #ffe600; }
.ai-conf-tone-user   .ai-conf-tile-icon   { background: #fffbe5; color: #0f172a; }
@media (max-width: 720px) {
  .ai-conf-meter { grid-template-columns: 1fr; gap: 14px; }
}

.eng-head { margin-bottom: 14px; }
.eng-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.eng-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.dot-sep { color: #d1d5db; }

.eng-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; padding: 4px; background: #fafafa; border-radius: 10px 10px 0 0; }
.eng-tab {
  background: transparent; border: none; padding: 8px 14px; border-radius: 8px;
  font: inherit; font-size: 13px; color: #4b5563; cursor: pointer;
}
.eng-tab.active { background: #fff; color: #0f172a; box-shadow: 0 1px 2px rgba(0,0,0,0.06); font-weight: 600; }
.eng-tab:hover:not(.active) { color: #111; background: #fff; }

/* Engagement KPI grid (4 cols, wraps to 7) */
.eng-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .eng-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .eng-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.eng-kpi {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-height: 88px;
}
.eng-kpi-row { display: flex; justify-content: space-between; align-items: center; }
.eng-kpi-label {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 10.5px;
  color: var(--muted); font-weight: 600;
}
.eng-kpi-icon { color: #9ca3af; }
.eng-kpi-value { font-size: 24px; font-weight: 700; color: #0f172a; line-height: 1.1; font-variant-numeric: tabular-nums; }
.eng-kpi.accent .eng-kpi-value { color: #0f172a; }
.eng-kpi-accent-bar { height: 3px; background: #FFE600; border-radius: 999px; margin-top: 6px; }

/* FSLI bars */
.bar-chart { display: flex; flex-direction: column; gap: 6px; min-height: 200px; }
.fsli-bar-row { display: grid; grid-template-columns: 130px 1fr 60px; gap: 8px; align-items: center; font-size: 12px; }
.fsli-bar-label { color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsli-bar-track { background: #f3f4f6; border-radius: 4px; height: 14px; overflow: hidden; }
.fsli-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; }
.fsli-bar-value { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #0f172a; text-align: right; }
.fsli-empty { padding: 32px 0; text-align: center; }
.bar-legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: #4b5563; }
.bar-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.proc-chart { min-height: 200px; display: flex; align-items: center; justify-content: center; }
.proc-empty, .risk-empty { text-align: center; padding: 32px 0; }
.placeholder-card { padding: 40px; text-align: center; }

/* ============================================================
   Engagements list page
   ============================================================ */
.eng-list-main { padding: 20px 32px; max-width: 1280px; margin: 0 auto; }

.eng-toolbar {
  display: flex; align-items: center; gap: 14px; margin: 6px 0 16px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative; flex: 1 1 320px; max-width: 420px;
}
.search-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: #9ca3af; pointer-events: none;
}
.search-wrap input {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border); border-radius: 999px;
  background: #fff; font: inherit; font-size: 13px; color: #111;
  outline: none;
}
.search-wrap input:focus { border-color: #9ca3af; }

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  border: 1px solid var(--border); background: #fff; color: #4b5563;
  padding: 7px 16px; border-radius: 999px; font: inherit; font-size: 13px;
  cursor: pointer;
}
.filter-pill:hover { border-color: #9ca3af; color: #0f172a; }
.filter-pill.active { background: #0f172a; color: #fff; border-color: #0f172a; }

.eng-table-wrap {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.eng-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13.5px; color: #111;
}
.eng-table thead th {
  background: #fafafa; color: #4b5563; font-weight: 600;
  text-align: left; padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.eng-table thead th.num { text-align: right; }
.eng-table tbody td {
  padding: 14px 18px; border-bottom: 1px solid #f3f4f6; vertical-align: middle;
}
.eng-table tbody td.num {
  text-align: right; font-variant-numeric: tabular-nums; font-weight: 500;
}
.eng-table tbody tr.eng-row { cursor: pointer; transition: background 0.1s; }
.eng-table tbody tr.eng-row:hover td { background: #fafbfc; }
.eng-table tbody tr:last-child td { border-bottom: none; }

.cell-client { display: flex; align-items: center; gap: 8px; }
.client-name { font-weight: 600; color: #0f172a; }
.client-spark { flex: 0 0 14px; }

/* Header action group used on Dashboard + Engagements list */
.head-actions { display: inline-flex; gap: 8px; align-items: center; }
.head-actions .btn-secondary.btn-pill {
  border: 1px solid var(--border); background: #fff; color: #0f172a;
  text-decoration: none; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; display: inline-flex; align-items: center; gap: 4px;
}
.head-actions .btn-secondary.btn-pill:hover { border-color: #9ca3af; background: #fafbfc; }

/* Required-field asterisk in onboarding wizard labels */
.wizard-card .req { color: #ef4444; font-weight: 700; margin-left: 2px; }

/* ===========================================================================
   SCOPING CONSOLE (/scoping)
   =========================================================================== */
.scope-main { padding-bottom: 60px; }

/* B. Primary toggle bar */
.scope-primary-tabs { display: flex; gap: 8px; margin: 12px 0 18px; }
/* Upload page header actions (Refresh + Use sample files) */
.page-head-actions { display: inline-flex; gap: 14px; align-items: center; }
#refresh-uploads { color: #6b7280; }
#refresh-uploads:hover { color: #111; }

/* "Uploaded" badge on restored file pills */
.fp-badge {
  display: inline-block; margin-left: 8px; padding: 1px 7px;
  font: 600 10px/1.4 Inter, sans-serif; text-transform: uppercase;
  letter-spacing: .04em; color: #166534; background: #dcfce7;
  border: 1px solid #bbf7d0; border-radius: 999px; vertical-align: middle;
}

/* ---- FSLI Configure Risk-Ratings & Rationale modal --------------------- */
.fsli-cfg-overlay { z-index: 1200; }
.fsli-cfg-card { width: min(1100px, 95vw); max-height: 90vh; display: flex; flex-direction: column; }
.fsli-cfg-head { align-items: flex-start; gap: 16px; }
.fsli-cfg-head-left { flex: 1 1 auto; min-width: 0; }
.fsli-cfg-head-right { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.fsli-cfg-title { font: 700 18px/1.2 Inter, sans-serif; color: #b91c1c; margin: 4px 0 8px; }
.fsli-cfg-picker-row { display: flex; gap: 8px; align-items: center; }
.fsli-cfg-picker {
  font: 500 13px Inter, sans-serif; padding: 6px 10px; border: 1px solid #d1d5db;
  border-radius: 8px; background: #fff; min-width: 280px; max-width: 100%;
}
.fsli-cfg-save { padding: 8px 18px; }
.fsli-cfg-body { padding: 16px 22px 24px; }
.fsli-cfg-kpis {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px;
}
.fsli-cfg-kpi {
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 14px; background: #fff;
}
.fsli-cfg-kpi-label {
  font: 500 11px/1 Inter, sans-serif; color: #6b7280;
  text-transform: uppercase; letter-spacing: .04em;
}
.fsli-cfg-kpi-value { font: 700 18px/1.2 Inter, sans-serif; color: #111; margin-top: 8px; }
.fsli-cfg-kpi-value.risk-low    { color: #047857; }
.fsli-cfg-kpi-value.risk-medium { color: #b45309; }
.fsli-cfg-kpi-value.risk-high   { color: #b91c1c; }
.fsli-cfg-kpi-value.delta-up    { color: #047857; }
.fsli-cfg-kpi-value.delta-dn    { color: #b91c1c; }
.fsli-cfg-section { margin-bottom: 22px; }
.fsli-cfg-section-head {
  display: flex; align-items: center; gap: 10px;
  font: 600 13px/1 Inter, sans-serif; color: #111;
  background: #f3f4f6; padding: 10px 14px; border-radius: 8px; margin-bottom: 8px;
}
.fsli-cfg-section-count {
  font: 600 11px/1 Inter, sans-serif; color: #374151;
  background: #fff; border: 1px solid #d1d5db; border-radius: 999px; padding: 2px 8px;
}
.fsli-cfg-subhead {
  display: flex; align-items: center; gap: 10px;
  font: 600 12px/1 Inter, sans-serif; color: #374151;
  margin: 14px 0 6px;
}
.fsli-cfg-subhead-hint { font-weight: 500; }
.fsli-cfg-table { width: 100%; border-collapse: separate; border-spacing: 0; font: 500 13px/1.4 Inter, sans-serif; }
.fsli-cfg-table thead th {
  text-align: left; font: 600 11px/1.2 Inter, sans-serif; color: #374151;
  text-transform: uppercase; letter-spacing: .04em; background: #f9fafb;
  padding: 10px 12px; border-bottom: 1px solid #e5e7eb;
}
.fsli-cfg-table tbody td {
  padding: 10px 12px; border-bottom: 1px solid #f1f3f5; vertical-align: middle;
}
.fsli-cfg-table .fsli-cfg-comp { width: 32%; }
.fsli-cfg-table .fsli-cfg-bal  { width: 18%; text-align: right; font-variant-numeric: tabular-nums; }
.fsli-cfg-table .fsli-cfg-tog  { width: 18%; }
.fsli-cfg-table .fsli-cfg-rat  { width: 32%; }
.fsli-cfg-rationale {
  width: 100%; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font: 500 12.5px Inter, sans-serif; color: #111;
}
.fsli-cfg-rationale:focus { outline: 2px solid #ffe600; outline-offset: -1px; border-color: #111; }
.fsli-cfg-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 0; background: transparent; padding: 0; font: 600 12px/1 Inter, sans-serif;
}
.fsli-cfg-toggle-track {
  width: 36px; height: 20px; background: #d1d5db; border-radius: 999px;
  position: relative; transition: background .15s;
}
.fsli-cfg-toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.fsli-cfg-toggle.is-in  .fsli-cfg-toggle-track  { background: #111; }
.fsli-cfg-toggle.is-in  .fsli-cfg-toggle-thumb  { transform: translateX(16px); }
.fsli-cfg-toggle.is-in  .fsli-cfg-toggle-label  { color: #111; }
.fsli-cfg-toggle.is-out .fsli-cfg-toggle-label  { color: #6b7280; }
.fsli-cfg-empty {
  padding: 14px; text-align: center; color: #6b7280;
  background: #f9fafb; border: 1px dashed #e5e7eb; border-radius: 8px;
  font: 500 12.5px Inter, sans-serif;
}
@media (max-width: 900px) {
  .fsli-cfg-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* Page-head layout for Scoping page: title left, view-switch top-right */
.scope-page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.scope-page-head > div { min-width: 0; }
/* View switcher (Scoping ⟷ Consolidated BS / IS) */
.scope-view-switch {
  display: inline-flex; gap: 0; margin: 0;
  background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 999px; padding: 4px;
  flex-shrink: 0;
}
.scope-page-head .scope-view-switch { align-self: center; }
.scope-view-switch .sv-btn {
  border: 0; background: transparent; padding: 7px 18px;
  font: 600 13px Inter, sans-serif; color: #6b7280; border-radius: 999px;
  cursor: pointer; transition: background .15s, color .15s;
}
.scope-view-switch .sv-btn:hover:not(.active) { color: #111; }
.scope-view-switch .sv-btn.active { background: #111; color: #ffe600; }

/* Embedded BS/IS frame */
.scope-bsis-view {
  border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;
  overflow: hidden; height: calc(100vh - 200px); min-height: 520px;
}
.scope-bsis-view iframe {
  width: 100%; height: 100%; border: 0; display: block;
}

/* Embed mode for /output (when loaded inside scoping iframe) */
html.embed-mode .sidebar,
html.embed-mode .eng-banner { display: none !important; }
html.embed-mode .main { margin-left: 0 !important; padding: 12px 20px !important; }

/* Keep the IS / BS / Both toggle visible inside the scoping iframe, but hide
   the page title and Back link so the embed stays compact. */
html.embed-mode .page-head {
  display: flex !important;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
html.embed-mode .page-head > div:first-child { display: none !important; }
html.embed-mode .page-head #back-link { display: none !important; }

.scope-tab {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 999px;
  padding: 9px 22px; font: 600 13px/1 Inter, sans-serif; color: #111;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: all .15s;
}
.scope-tab:hover:not(:disabled) { border-color: #111; }
.scope-tab.active { background: #111; color: #fff; border-color: #111; }
.scope-tab:disabled { color: #9ca3af; cursor: not-allowed; background: #f9fafb; }
.scope-tab-soon { font-size: 10px; font-weight: 500; color: #9ca3af; padding: 2px 6px; background: #f3f4f6; border-radius: 4px; }

/* C. KPI strip */
.scope-kpis {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px;
  padding: 18px 20px; align-items: center;
}
.scope-kpi { padding-right: 16px; border-right: 1px solid #f1f3f5; }
.scope-kpi:nth-child(3) { border-right: none; }
.scope-kpi-label { font: 500 11px/1 Inter, sans-serif; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; }
.scope-kpi-value { font: 700 28px/1.1 Inter, sans-serif; color: #111; margin: 8px 0 4px; letter-spacing: -.01em; }
.scope-kpi-sub { font: 500 12px/1.3 Inter, sans-serif; color: #6b7280; }
.ai-conf-head-actions .ai-conf-configure {
  background: #fff; border: 1px solid #d1d5db; color: #111;
  padding: 5px 10px; border-radius: 6px; font-weight: 600; font-size: 12px;
  line-height: 1; cursor: pointer; height: 26px;
  display: inline-flex; align-items: center;
}
.ai-conf-head-actions .ai-conf-configure:hover { border-color: #111; }

/* D. Rationale */
.scope-rationale {
  margin: 12px 2px 18px; font: 400 12.5px/1.55 Inter, sans-serif; color: #6b7280;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
}
.scope-rationale.clamped .scope-rationale-body {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 900px;
}
.scope-rationale-eyebrow { color: #111; font-weight: 600; }
.scope-rationale-more { background: none; border: none; color: #2563eb; cursor: pointer; font: 600 12px/1 Inter, sans-serif; padding: 0; }

/* F. Dimension toggle — Consolidation Level dropdown card */
.scope-dim-bar { display: flex; gap: 12px; margin: 14px 0 10px; flex-wrap: wrap; align-items: stretch; }
.scope-cl-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px; border: 1px solid #e5e7eb; border-radius: 10px;
  background: #fff;
  flex: 1 1 0; min-width: 240px;
}
.scope-cl-card .scope-cl-select { min-width: 0; width: 100%; }
.scope-cl-eyebrow {
  font: 600 10.5px/1 Inter, sans-serif; color: #6b7280;
  letter-spacing: .08em; text-transform: uppercase;
}
.scope-cl-row { display: flex; align-items: center; gap: 6px; position: relative; }
.scope-cl-select {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #d1d5db; border-radius: 8px;
  padding: 8px 12px; font: 600 13px/1 Inter, sans-serif; color: #0f172a;
  cursor: pointer; min-width: 180px; justify-content: space-between;
}
.scope-cl-select:hover { border-color: #111; }
.scope-cl-label { flex: 1; text-align: left; }
.scope-cl-count { background: #f1f3f5; border-radius: 4px; padding: 2px 7px; font: 600 11px/1.2 Inter, sans-serif; color: #374151; }
.scope-cl-caret { color: #6b7280; }
.scope-cl-pencil {
  background: transparent; border: 0; cursor: pointer; color: #94a3b8;
  font-size: 14px; padding: 4px 6px; border-radius: 4px;
}
.scope-cl-pencil:hover { color: #0f172a; background: #f1f5f9; }
.scope-cl-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px;
  min-width: 280px;
}
/* Make sure [hidden] always wins over any display: */
.scope-cl-menu[hidden] { display: none !important; }
/* When portaled into <body>, the menu uses fixed positioning so it sits on
   top of every stacking context on the page. */
.scope-cl-menu.scope-cl-menu-portal { position: fixed; top: 0; left: 0; z-index: 2001; }
/* Transparent full-viewport overlay used to catch outside clicks. Sits just
   below the portaled menu so that clicks on options reach the option. */
.scope-cl-backdrop {
  position: fixed; inset: 0; background: transparent; z-index: 2000;
}

/* ---- Configure Consolidation Levels modal (iframes /confirm?modal=1) ---- */
.cl-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.cl-modal[hidden] { display: none !important; }
.cl-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.cl-modal-panel {
  position: relative; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  width: min(1200px, 94vw); height: min(820px, 90vh);
  display: flex; flex-direction: column; overflow: hidden;
}
.cl-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 16px 20px; border-bottom: 1px solid #e5e7eb;
}
.cl-modal-head h3 { margin: 0 0 2px; font: 600 16px/1.2 Inter, sans-serif; color: #0f172a; }
.cl-modal-head .muted { margin: 0; }
.cl-modal-close {
  background: transparent; border: 0; cursor: pointer; color: #475569;
  font-size: 22px; line-height: 1; padding: 4px 10px; border-radius: 8px;
}
.cl-modal-close:hover { background: #f1f5f9; color: #0f172a; }
.cl-modal-body { flex: 1; min-height: 0; }
.cl-modal-body iframe { width: 100%; height: 100%; border: 0; display: block; background: #f7f8fa; }
body.cl-modal-open { overflow: hidden; }

/* ---- Configure Account Coverage modal ----------------------------------- */
.cov-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.cov-modal[hidden] { display: none !important; }
.cov-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.cov-modal-panel {
  position: relative; background: #fff; border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; overflow: hidden;
}
.cov-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 12px; border-bottom: 1px solid #eef2f7;
}
.cov-modal-head h3 { margin: 0 0 2px; font: 600 16px/1.2 Inter, sans-serif; color: #0f172a; }
.cov-modal-head .muted { margin: 0; }
.cov-modal-close {
  background: transparent; border: 0; font-size: 22px; line-height: 1;
  color: #64748b; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.cov-modal-close:hover { background: #f1f5f9; color: #0f172a; }
.cov-modal-body { padding: 18px 20px 8px; overflow: auto; }
.cov-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px 16px; border-top: 1px solid #eef2f7; background: #fff;
}
.cov-section-title {
  font: 600 13px/1 Inter, sans-serif; color: #0f172a; margin-bottom: 12px;
}
.cov-radio-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.cov-radio { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.cov-radio input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.cov-radio-mark {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #cbd5e1;
  background: #fff; display: inline-block; position: relative; flex: 0 0 16px;
}
.cov-radio input[type="radio"]:checked + .cov-radio-mark {
  border-color: #0f172a;
}
.cov-radio input[type="radio"]:checked + .cov-radio-mark::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: #0f172a;
}
.cov-radio input[type="radio"]:focus-visible + .cov-radio-mark {
  box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.5);
}
.cov-radio-label { font: 500 13px/1 Inter, sans-serif; color: #0f172a; }
.cov-tiers { display: flex; flex-direction: column; gap: 14px; }
.cov-tiers.is-disabled { opacity: 0.45; pointer-events: none; }
.cov-tier-title { font: 600 12.5px/1 Inter, sans-serif; color: #0f172a; margin-bottom: 8px; }
.cov-tier-row { display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.cov-tier-row-double { gap: 16px; }
.cov-tier-cell { display: flex; flex-direction: column; gap: 6px; }
.cov-tier-help { font: 400 11.5px/1.2 Inter, sans-serif; color: #6b7280; padding-left: 2px; }
.cov-stepper {
  display: inline-flex; align-items: stretch; gap: 6px;
}
.cov-step {
  width: 36px; height: 36px; border: 1px solid #e5e7eb; background: #fff;
  border-radius: 8px; cursor: pointer; font: 600 16px/1 Inter, sans-serif; color: #374151;
  display: inline-flex; align-items: center; justify-content: center;
}
.cov-step:hover { border-color: #0f172a; color: #0f172a; }
.cov-num {
  width: 80px; height: 36px; border: 1px solid #e5e7eb; border-radius: 8px;
  text-align: center; font: 600 14px/1 "JetBrains Mono", ui-monospace, monospace;
  color: #0f172a; background: #fff;
  -moz-appearance: textfield;
}
.cov-num::-webkit-outer-spin-button,
.cov-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cov-num:focus { outline: none; border-color: #0f172a; box-shadow: 0 0 0 2px rgba(255, 230, 0, 0.5); }
.cov-btn {
  border-radius: 8px; padding: 8px 14px; font: 600 13px/1 Inter, sans-serif;
  cursor: pointer; border: 1px solid transparent;
}
.cov-btn-ghost { background: #fff; color: #0f172a; border-color: #e5e7eb; }
.cov-btn-ghost:hover { border-color: #0f172a; }
.cov-btn-primary { background: #FFE600; color: #0f172a; border-color: #E6CF00; }
.cov-btn-primary:hover { filter: brightness(1.05); }

/* ---- /confirm in modal mode: hide chrome so only the editor shows ------- */
html.confirm-modal-mode body > .sidebar,
html.confirm-modal-mode .page-head,
html.confirm-modal-mode .page-actions,
html.confirm-modal-mode #files-list,
html.confirm-modal-mode #warnings-card,
html.confirm-modal-mode .card:has(#files-list),
html.confirm-modal-mode .card:has(> .card-head h3:first-child) ~ .card:not(.hierarchies-card) {
  display: none !important;
}
html.confirm-modal-mode body { background: #f7f8fa; }
html.confirm-modal-mode .main { margin-left: 0 !important; padding: 16px 20px !important; max-width: none !important; }
html.confirm-modal-mode .hierarchies-card { margin: 0; box-shadow: none; border: 1px solid #e5e7eb; }
/* The card itself must outrank later siblings (legend bar, table) when open. */
.scope-cl-card { position: relative; z-index: 5; }
.scope-cl-card.is-open { z-index: 1000; }
/* NOTE: Don't give .scope-dim-bar its own stacking context — that would trap
   the open card's z-index inside the bar, putting the click backdrop on top
   of the menu options. The card's own z-index (5 / 1000) is enough to beat
   the legend (1) and table (0) below. */
.scope-legend-bar { position: relative; z-index: 1; }
.scope-table-wrap { position: relative; z-index: 0; }
.scope-cl-opt {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 8px 10px; border: 0; background: #fff; border-radius: 6px;
  font: 500 13px/1.2 Inter, sans-serif; color: #0f172a; cursor: pointer; text-align: left;
  width: 100%;
}
.scope-cl-opt:hover { background: #f9fafb; }
.scope-cl-opt.active { background: #FFF7C2; font-weight: 600; }
.scope-cl-configure {
  font: 500 11.5px/1 Inter, sans-serif; color: #B8920A;
  text-decoration: none; background: transparent; border: 0; padding: 0;
}
.scope-cl-configure:hover { color: #8C6F00; text-decoration: underline; }
.scope-cl-edit-input {
  flex: 1; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px;
  font: 500 13px/1 Inter, sans-serif; color: #0f172a; min-width: 200px;
}
.scope-cl-edit-apply, .scope-cl-edit-cancel {
  padding: 8px 12px; border-radius: 8px; font: 600 12px/1 Inter, sans-serif; cursor: pointer;
}
.scope-cl-edit-apply { background: #FFE600; border: 1px solid #FFE600; color: #111; }
.scope-cl-edit-apply:hover { filter: brightness(1.05); }
.scope-cl-edit-cancel { background: #fff; border: 1px solid #d1d5db; color: #4b5563; }
.scope-cl-edit-cancel:hover { color: #0f172a; border-color: #0f172a; }
.scope-dim-pill {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 999px;
  padding: 7px 16px; font: 500 12.5px/1 Inter, sans-serif; color: #374151;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.scope-dim-pill:hover { border-color: #111; }
.scope-dim-pill.active { background: #FFE600; color: #111; border-color: #FFE600; font-weight: 600; }
.dim-count { background: rgba(0,0,0,0.08); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 600; }
.scope-dim-pill.active .dim-count { background: rgba(0,0,0,0.15); }

/* G. Legend */
.scope-legend-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0 8px; gap: 12px;
}
.scope-legend { display: flex; align-items: center; gap: 14px; font: 500 12px/1 Inter, sans-serif; color: #4b5563; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -2px; }
.legend-swatch.sys { background: #dbeafe; }
.legend-swatch.usr { background: #93c5fd; }
.scope-legend-bar .btn-secondary { background: #fff; border: 1px solid #d1d5db; padding: 7px 14px; border-radius: 7px; font-weight: 600; font-size: 12px; cursor: pointer; }
.scope-legend-bar .btn-secondary:hover { border-color: #111; }

/* Statement filter (All / Balance Sheet / Income Statement) */
.sc-stmt-filter {
  display: inline-flex; align-items: stretch;
  background: #fff; border: 1px solid #d1d5db; border-radius: 7px;
  overflow: hidden; margin-left: auto;
}
.sc-stmt-btn {
  font: 600 12px/1 'Inter', sans-serif; color: #4b5563;
  background: #fff; border: 0; padding: 7px 12px; cursor: pointer;
  border-right: 1px solid #e5e7eb;
}
.sc-stmt-btn:last-child { border-right: 0; }
.sc-stmt-btn:hover { background: #f9fafb; color: #111; }
.sc-stmt-btn.active { background: #ffe600; color: #111; }
.sc-stmt-btn:focus-visible { outline: 2px solid #ffe600; outline-offset: -2px; }
.sc-stmt-count {
  display: inline-block; margin-left: 6px;
  background: rgba(0,0,0,0.08); border-radius: 4px; padding: 1px 6px;
  font-size: 11px; font-weight: 600;
}
.sc-stmt-btn.active .sc-stmt-count { background: rgba(0,0,0,0.15); }
.scope-toast {
  display: inline-block; margin-left: 10px;
  background: #10b981; color: #fff; padding: 6px 12px; border-radius: 6px;
  font: 600 12px/1 Inter, sans-serif;
}

/* H. Table */
.scope-table-wrap {
  border: 1px solid #e5e7eb; border-radius: 10px; background: #fff;
  overflow: auto; max-height: calc(100vh - 460px); min-height: 400px;
  position: relative;
}
.scope-table {
  border-collapse: separate; border-spacing: 0;
  width: max-content; min-width: 100%;
  table-layout: fixed; /* honor declared column widths so sticky left: offsets stay accurate */
  --w-acct: 220px; --w-cons: 130px; --w-risk: 95px; --w-scope: 105px; --w-cov: 120px;
}
.scope-table th, .scope-table td { box-sizing: border-box; }
.scope-table .sc-col-acct.sc-frozen { overflow: hidden; text-overflow: ellipsis; }
.sc-th-label { display: inline-block; max-width: calc(100% - 18px); overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.scope-table thead th {
  background: #f9fafb; position: sticky; top: 0; z-index: 5;
  font: 600 11px/1.3 Inter, sans-serif; color: #374151; text-transform: uppercase;
  letter-spacing: .03em; padding: 12px 10px; text-align: left;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
.scope-table tbody td {
  padding: 9px 10px; border-bottom: 1px solid #f1f3f5;
  font: 500 13px/1.3 Inter, sans-serif; color: #111; background: #fff;
  vertical-align: middle; white-space: nowrap;
}
.scope-table tbody tr:hover td { background: #fafbfc; }
.scope-table tbody tr:hover td.sys { background: #cfe1fb; }
.scope-table tbody tr:hover td.usr { background: #7eb6f7; }
.sc-frozen { position: sticky; left: 0; z-index: 3; background: #fff; }
.scope-table thead th.sc-frozen { z-index: 6; background: #f9fafb; }
.sc-col-acct  { width: var(--w-acct);  min-width: var(--w-acct);  left: 0; box-shadow: none; }
.sc-col-cons  { width: var(--w-cons);  min-width: var(--w-cons);  left: var(--w-acct); text-align: right; padding-right: 14px; }
.sc-col-risk  { width: var(--w-risk);  min-width: var(--w-risk);  left: calc(var(--w-acct) + var(--w-cons)); }
.sc-col-scope { width: var(--w-scope); min-width: var(--w-scope); left: calc(var(--w-acct) + var(--w-cons) + var(--w-risk)); }
.sc-col-cov   { width: var(--w-cov);   min-width: var(--w-cov);   left: calc(var(--w-acct) + var(--w-cons) + var(--w-risk) + var(--w-scope));
                box-shadow: 4px 0 6px -4px rgba(0,0,0,0.08); }
.sc-resize-handle {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 12; user-select: none;
  background: transparent; transition: background .15s;
}
.sc-col-collapse {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 4px; border: 0; padding: 0;
  background: transparent; color: #9ca3af; cursor: pointer;
  font: 600 13px/1 Inter, sans-serif; display: none;
  z-index: 11; transition: background .15s, color .15s;
}
.scope-table thead th.sc-frozen:hover .sc-col-collapse { display: inline-flex; align-items: center; justify-content: center; }
.sc-col-collapse:hover { background: #fee2e2; color: #b91c1c; }
.scope-table .sc-col-collapsed {
  width: 0 !important; min-width: 0 !important; max-width: 0 !important;
  padding-left: 0 !important; padding-right: 0 !important;
  overflow: hidden !important;
  border-left: 0 !important; border-right: 0 !important;
  box-shadow: none !important;
}
.scope-table .sc-col-collapsed * { display: none !important; }

/* Columns menu in legend bar */
.sc-cols-menu-wrap { position: relative; display: inline-block; }
.sc-cols-count { color: #b45309; font-weight: 700; margin-left: 4px; }
.sc-cols-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 100;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; min-width: 240px;
}
.sc-cols-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; font: 500 13px Inter, sans-serif; color: #111;
}
.sc-cols-menu-item:hover { background: #f9fafb; }
.sc-cols-menu-item input { width: 14px; height: 14px; cursor: pointer; }
.sc-cols-menu-foot { border-top: 1px solid #f1f3f5; margin-top: 4px; padding: 6px 4px 2px; }
.sc-cols-show-all {
  width: 100%; background: #fff; border: 1px solid #d1d5db;
  border-radius: 6px; padding: 6px 10px; font: 600 12px Inter, sans-serif;
  color: #111; cursor: pointer;
}
.sc-cols-show-all:hover { border-color: #111; background: #f9fafb; }
.sc-resize-handle:hover, .sc-resize-handle.dragging { background: #ffe600; }
body.sc-resizing { cursor: col-resize !important; user-select: none; }
body.sc-resizing * { cursor: col-resize !important; }
.scope-table thead th.sc-col-cov { box-shadow: 4px 0 6px -4px rgba(0,0,0,0.12); }
.sc-dim-col { min-width: 120px; max-width: 160px; text-align: right; padding-right: 14px; }
.scope-table thead th.sc-dim-col { text-align: right; padding-right: 14px; }
.sc-mono { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; }
.cell-cur { color: #9ca3af; margin-right: 2px; font-weight: 400; }
.cell-zero { color: #9ca3af; }
.scope-table td.neg { color: #b91c1c; }
.sc-acct-label { font-weight: 600; }
.sc-acct-code { margin-left: 6px; font-size: 11px; }
.sc-high-risk .sc-acct-label { color: #b91c1c; }
.sc-caret, .sc-caret-spacer { display: inline-block; width: 14px; margin-right: 6px; color: #9ca3af; cursor: pointer; transition: transform .15s; user-select: none; }
.sc-caret.open { transform: rotate(90deg); color: #111; }
.sc-gl-row td { background: #fafbfc; }
.sc-gl-indent { padding-left: 36px !important; }
.sc-gl-row .sc-acct-label { font-weight: 500; color: #4b5563; }
.sc-filter { color: #9ca3af; font-size: 9px; margin-left: 4px; cursor: pointer; }

/* Risk pills */
.sc-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font: 600 11px/1.3 Inter, sans-serif; }
.rp-low  { background: #d1fae5; color: #065f46; }
.rp-med  { background: #fef3c7; color: #92400e; }
.rp-high { background: #fee2e2; color: #991b1b; }

/* Risk Rating dropdown — pill that contains a hidden native <select> for the menu */
.sc-risk-select {
  position: relative; cursor: pointer; display: inline-flex;
  align-items: center; gap: 5px; padding: 3px 8px 3px 10px;
  transition: filter .12s, box-shadow .12s;
}
.sc-risk-select:hover { filter: brightness(0.96); box-shadow: 0 0 0 1px rgba(17,17,17,0.08); }
.sc-pill-caret { opacity: 0.7; flex-shrink: 0; }
.sc-risk-dd {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: 0; padding: 0; margin: 0;
  font: inherit; appearance: none; -webkit-appearance: none;
}
.sc-risk-dd:focus { outline: none; }
.sc-risk-select:focus-within { box-shadow: 0 0 0 2px rgba(255,230,0,0.55); outline: none; }
.sc-pill-edited { box-shadow: inset 0 0 0 1px rgba(17,17,17,0.35); }
.sc-scope { font: 600 12px/1 Inter, sans-serif; }
.sp-size { color: #065f46; }
.sp-risk { color: #92400e; }
.sp-out  { color: #9ca3af; }

/* Coverage bar */
.sc-cov { display: flex; align-items: center; gap: 8px; }
.sc-cov-bar { flex: 1; height: 6px; background: #f1f3f5; border-radius: 3px; overflow: hidden; }
.sc-cov-fill { height: 100%; transition: width .2s; }
.sc-cov-val { font: 600 11px/1 "JetBrains Mono", monospace; color: #4b5563; min-width: 30px; text-align: right; }

/* Cell highlights */
.scope-table td.sc-cell { cursor: pointer; transition: background .12s; position: relative; }
.scope-table td.sc-cell.sys { background: #dbeafe; }
.scope-table td.sc-cell.usr { background: #93c5fd; color: #0c1f3d; font-weight: 600; }
.sc-usr-dot { display: inline-block; width: 6px; height: 6px; background: #1d4ed8; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* J. Footer */
.scope-foot {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 14px 4px 0; font: 500 12px/1.4 Inter, sans-serif; color: #4b5563;
  flex-wrap: wrap;
}

/* Tooltip */
.sc-tooltip {
  position: absolute; z-index: 100; background: #111; color: #fff;
  padding: 6px 10px; border-radius: 6px; font: 500 12px/1.3 Inter, sans-serif;
  width: 200px; text-align: center; pointer-events: none;
}

/* E. Slide-out */
.scope-slideout-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 50;
  opacity: 0; transition: opacity .25s;
}
.scope-slideout-backdrop.show { opacity: 1; }
.scope-slideout {
  position: fixed; right: 0; top: 0; bottom: 0; width: 420px;
  background: #fff; z-index: 60; box-shadow: -8px 0 24px rgba(0,0,0,0.12);
  transform: translateX(100%); transition: transform .25s ease-out;
  display: flex; flex-direction: column;
}
.scope-slideout.open { transform: translateX(0); }
.scope-slideout-head {
  padding: 18px 22px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
}
.scope-slideout-head h3 { margin: 0; font: 600 16px/1 Inter, sans-serif; }
.scope-slideout-body { flex: 1; padding: 20px 22px; overflow-y: auto; }
.cfg-field { margin-bottom: 22px; }
.cfg-field label { display: flex; justify-content: space-between; font: 600 12px/1 Inter, sans-serif; color: #111; margin-bottom: 8px; }
.cfg-val { color: #2563eb; font-family: "JetBrains Mono", monospace; }
.cfg-field select {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 7px;
  font: 500 13px/1 Inter, sans-serif; background: #fff;
}
.cfg-field input[type="range"] { width: 100%; accent-color: #FFE600; }
.cfg-range-labels { display: flex; justify-content: space-between; font: 500 11px/1 Inter, sans-serif; color: #9ca3af; margin-top: 4px; }
.cfg-preview {
  margin-top: 26px; padding: 14px 16px; background: #f9fafb;
  border: 1px solid #e5e7eb; border-radius: 10px;
}
.cfg-preview-title { font: 600 11px/1 Inter, sans-serif; text-transform: uppercase; color: #6b7280; letter-spacing: .04em; margin-bottom: 12px; }
.cfg-preview-row { display: flex; justify-content: space-between; padding: 6px 0; font: 500 13px/1 Inter, sans-serif; }
.cfg-preview-row strong { font-family: "JetBrains Mono", monospace; color: #111; }
.scope-slideout-foot {
  padding: 14px 22px; border-top: 1px solid #e5e7eb;
  display: flex; gap: 10px; justify-content: flex-end;
}
.cfg-field-inline {
  margin-top: 22px; margin-bottom: 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.cfg-field-inline label {
  display: inline; margin-bottom: 0;
  font: 600 12px/1.3 Inter, sans-serif; color: #111;
}
.cfg-field-inline input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: #FFE600; cursor: pointer; margin: 0;
}
.cfg-field-link { justify-content: flex-start; }
.cfg-field-link a {
  font: 600 12px/1.3 Inter, sans-serif;
  color: #0f172a;
  text-decoration: none;
  border-bottom: 1px dashed #cbd5e1;
  cursor: pointer;
}
.cfg-field-link a:hover {
  color: #b45309;
  border-bottom-color: #FFE600;
  text-decoration: none;
}

/* ---- Refine Scoping modal ----------------------------------------------- */
.refine-modal { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; }
.refine-modal[hidden] { display: none !important; }
.refine-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); }
.refine-modal-panel {
  position: relative; background: #fff; border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.26);
  width: min(560px, 94vw); max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.refine-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid #e5e7eb;
}
.refine-modal-head h3 { margin: 0 0 2px; font: 600 14px/1.2 Inter, sans-serif; color: #0f172a; }
.refine-modal-head .muted { margin: 0; font-size: 11.5px; line-height: 1.35; }
.refine-modal-close {
  background: transparent; border: 0; cursor: pointer; color: #475569;
  font-size: 18px; line-height: 1; padding: 2px 8px; border-radius: 6px;
}
.refine-modal-close:hover { background: #f1f5f9; color: #0f172a; }
.refine-modal-body { padding: 14px 16px; overflow: auto; }
body.refine-modal-open { overflow: hidden; }

.refine-table { display: flex; flex-direction: column; gap: 6px; }
.refine-row {
  display: grid; grid-template-columns: 64px 1fr 64px;
  gap: 6px; align-items: stretch;
}
.refine-end {
  background: #e5e7eb; color: #475569; font: 600 11px/1 Inter, sans-serif;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 4px; border-radius: 5px; min-height: 38px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.refine-end-right { background: #e5e7eb; color: #475569; }
.refine-row.is-low  .refine-end-left,
.refine-row.is-high .refine-end-right {
  background: #FFE600; color: #0f172a;
  box-shadow: 0 0 0 2px rgba(255, 230, 0, 0.25);
  transform: translateX(0);
}
.refine-row.is-low  .refine-end-left  { transform: translateX(-2px); }
.refine-row.is-high .refine-end-right { transform: translateX(2px); }

/* Slider track row */
.refine-track-wrap {
  position: relative; min-height: 38px;
  background: #f7f8fa; border: 1px solid #e5e7eb; border-radius: 6px;
  display: flex; flex-direction: column; justify-content: center;
  padding: 5px 10px 4px;
}
.refine-track-label {
  font: 500 11px/1.1 Inter, sans-serif; color: #475569;
  margin-bottom: 4px; text-align: center; pointer-events: none;
  letter-spacing: 0.01em;
}
/* Yellow fill that grows from the left as the slider moves right.
   Width is set inline by JS via --pct CSS var. */
.refine-track-fill {
  position: absolute; left: 8px; right: 8px; bottom: 10px;
  height: 4px; border-radius: 999px; background: #e5e7eb;
  pointer-events: none; overflow: hidden;
}
.refine-track-fill::before {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: var(--pct, 50%); background: #FFE600;
  border-radius: 999px;
  transition: width .12s ease-out;
}
.refine-dim-slider {
  -webkit-appearance: none; appearance: none;
  position: absolute; left: 8px; right: 8px; bottom: 4px;
  width: calc(100% - 16px); height: 16px;
  background: transparent; outline: none; cursor: pointer; padding: 0;
  z-index: 2;
}
.refine-dim-slider::-webkit-slider-runnable-track {
  height: 16px; background: transparent; border: 0;
}
.refine-dim-slider::-moz-range-track {
  height: 16px; background: transparent; border: 0;
}
/* Small circular knob — same shape used on every slider in this modal. */
.refine-dim-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: #FFE600;
  border: 1.5px solid #0f172a; cursor: grab;
  margin-top: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  transition: transform .12s ease, box-shadow .12s ease;
}
.refine-dim-slider:hover::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 2px 5px rgba(0,0,0,0.26), 0 0 0 3px rgba(255,230,0,0.22);
}
.refine-dim-slider:active::-webkit-slider-thumb {
  cursor: grabbing; transform: scale(1.25);
  box-shadow: 0 2px 6px rgba(0,0,0,0.30), 0 0 0 4px rgba(255,230,0,0.32);
}
.refine-dim-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #FFE600; border: 1.5px solid #0f172a; cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}
.refine-dim-slider:active::-moz-range-thumb { cursor: grabbing; }

/* Live value bubble that floats above the thumb while interacting. */
.refine-track-bubble {
  position: absolute; left: calc(8px + (100% - 16px) * var(--pct-num, 0.5));
  bottom: calc(100% - 6px);
  transform: translate(-50%, 0) scale(0.85);
  background: #0f172a; color: #FFE600;
  font: 700 11px/1 "JetBrains Mono", ui-monospace, monospace;
  padding: 4px 7px; border-radius: 5px; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity .12s ease, transform .12s ease, left .08s linear;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  z-index: 3;
}
.refine-track-bubble::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  width: 0; height: 0; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: #0f172a;
}
.refine-track-wrap:hover .refine-track-bubble,
.refine-track-wrap.is-dragging .refine-track-bubble,
.refine-dim-slider:focus + .refine-track-fill ~ .refine-track-bubble,
.refine-dim-slider:focus-visible ~ .refine-track-bubble {
  opacity: 1; transform: translate(-50%, 0) scale(1);
}

/* Aggregated position bar (read-only readout of the average) */
.refine-rangebar {
  margin-top: 12px;
  background: #FFE600;
  display: grid; grid-template-columns: 64px 1fr 64px;
  gap: 6px; align-items: center;
  padding: 7px 0; border-radius: 5px;
}
.refine-rangebar-end {
  font: 700 11px/1 Inter, sans-serif; color: #0f172a;
  padding: 0 8px;
}
.refine-rangebar-end:last-child { text-align: right; }
.refine-rangebar-mid {
  font: 700 11px/1 Inter, sans-serif; color: #0f172a;
  text-align: center; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px;
}
.refine-agg-pct {
  display: inline-block; min-width: 38px;
  background: rgba(15,23,42,0.85); color: #FFE600;
  padding: 2px 7px; border-radius: 999px;
  font: 700 11px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.02em;
}

.refine-agg-track {
  position: relative; height: 24px; margin: 6px 64px 2px;
}
.refine-agg-fill {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 6px; background: #e5e7eb; border-radius: 999px; overflow: hidden;
}
.refine-agg-fill::before {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: var(--agg, 50%); background: linear-gradient(90deg, #ffd400, #FFE600);
  border-radius: 999px; transition: width .18s ease-out;
}
/* Aggregate position marker — small circle, same family as the dim knobs. */
.refine-agg-marker {
  position: absolute; top: 50%; left: var(--agg, 50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: #FFE600; border: 1.5px solid #0f172a;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  transition: left .18s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
  animation: refineMarkerPulse 2.4s ease-in-out infinite;
}
@keyframes refineMarkerPulse {
  0%, 100% { box-shadow: 0 1px 3px rgba(0,0,0,0.22); }
  50%      { box-shadow: 0 1px 3px rgba(0,0,0,0.22), 0 0 0 4px rgba(255,230,0,0.28); }
}
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.refine-values {
  margin-top: 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.refine-values-col {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px;
  background: #fafafa; transition: background .15s, border-color .15s;
}
.refine-values-col.is-active {
  background: #fffceb; border-color: #FFE600;
  box-shadow: 0 0 0 2px rgba(255,230,0,0.25);
}
.refine-values-title {
  font: 700 10px/1 Inter, sans-serif; color: #475569;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.refine-values-list { display: flex; flex-direction: column; gap: 5px; }
.refine-values-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font: 500 11.5px/1.3 Inter, sans-serif; color: #0f172a;
}
.refine-values-row strong {
  font: 700 11.5px/1 "JetBrains Mono", ui-monospace, monospace; color: #0f172a;
}
.refine-values-empty { padding: 4px 0; }

/* Income-Statement profit subtotal rows (Gross Profit, EBIT, PTI, Net Profit) */
.pivot-table .subtotal-row.is-profit-row .acct-col,
.pivot-table .subtotal-row.is-profit-row .cons-col,
.pivot-table .subtotal-row.is-profit-row .dim-col {
  background: #fffbe5;
  border-top: 1px solid #f1d600;
  border-bottom: 1px solid #f1d600;
  color: #0f172a;
}
.pivot-table .subtotal-row.is-profit-row strong { font-weight: 700; }

/* "Both" view: banner separating Income Statement and Balance Sheet tables */
.pivot-card #pivot-tables > .pivot-stmt-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0f172a;
  margin: 18px 0 8px;
  padding: 8px 12px;
  background: #f7f8fa;
  border-left: 3px solid #ffe600;
  border-radius: 4px;
}
.pivot-card #pivot-tables > .pivot-stmt-title:first-child { margin-top: 0; }
.pivot-card #pivot-tables > .pivot-table + .pivot-stmt-title { margin-top: 28px; }
