/* PlatformCo Insurance Platform — Component library (static-mockup equivalent of @imagine/global-design-library) */

/* ================= Buttons ================= */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); font-weight: var(--font-semibold);
  padding: var(--space-2-5) var(--space-4); border: none; cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard);
  white-space: nowrap;
}
.btn-primary { background: var(--color-accent-primary); color: var(--color-text-on-accent); border-radius: var(--radius-button-primary); box-shadow: var(--shadow-elevation-1); }
.btn-primary:hover { background: var(--color-accent-primary-hover); }
.btn-primary:active { background: var(--color-accent-primary-active); transform: scale(.98); }
.btn-primary:disabled { background: var(--color-surface-3); color: var(--color-text-disabled); cursor: not-allowed; }
.btn-secondary { background: var(--color-surface-0); color: var(--color-text-secondary); border: 1px solid var(--color-surface-border); border-radius: var(--radius-button-secondary); }
.btn-secondary:hover { background: var(--color-surface-2); border-color: var(--color-surface-border-strong); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); border-radius: var(--radius-button-secondary); }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.btn-danger { background: var(--color-feedback-error); color: var(--color-text-on-accent); border-radius: var(--radius-button-primary); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: var(--space-1-5) var(--space-3); font-size: var(--text-xs); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-md); border: 1px solid var(--color-surface-border); background: var(--color-surface-0); color: var(--color-text-secondary); }
.btn-icon:hover { background: var(--color-surface-2); color: var(--color-text-primary); }

/* ================= Card ================= */
.card { background: var(--color-surface-0); border: 1px solid var(--color-surface-border); border-radius: var(--radius-card); box-shadow: var(--shadow-elevation-1); padding: var(--space-6); }
.card-flush { padding: 0; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--space-4); gap: var(--space-4); }
.card-title { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: var(--font-semibold); color: var(--color-text-primary); }
.card-subtitle { font-size: var(--text-sm); color: var(--color-text-tertiary); margin-top: 2px; }
.card-ai { border-radius: var(--radius-ai-card); box-shadow: var(--shadow-elevation-2), var(--shadow-glow-ai); border-color: var(--color-accent-primary-soft); }
.card-hover:hover { box-shadow: var(--shadow-elevation-2); border-color: var(--color-surface-border-strong); }

/* ================= Page header ================= */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-6); gap: var(--space-4); flex-wrap: wrap; }
.page-title { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: var(--font-bold); color: var(--color-text-primary); }
.page-subtitle { font-size: var(--text-base); color: var(--color-text-tertiary); margin-top: var(--space-1); }
.breadcrumbs { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--color-text-tertiary); margin-bottom: var(--space-2); }
.breadcrumbs a:hover { color: var(--color-accent-primary); }

/* ================= Badges / chips / status ================= */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); font-weight: var(--font-semibold); padding: 3px var(--space-2-5); border-radius: var(--radius-badge); border: 1px solid transparent; line-height: 1.4; }
.badge-neutral { background: var(--color-surface-2); color: var(--color-text-secondary); border-color: var(--color-surface-border); }
.badge-success { background: var(--color-feedback-success-soft); color: var(--color-feedback-success); border-color: var(--color-feedback-success-soft); }
.badge-warning { background: var(--color-feedback-warning-soft); color: var(--color-feedback-warning); border-color: var(--color-feedback-warning-soft); }
.badge-error { background: var(--color-feedback-error-soft); color: var(--color-feedback-error); border-color: var(--color-feedback-error-soft); }
.badge-info { background: var(--color-feedback-info-soft); color: var(--color-feedback-info); border-color: var(--color-feedback-info-soft); }
.badge-accent { background: var(--color-accent-primary-soft); color: var(--color-accent-primary); border-color: var(--color-accent-primary-soft); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--font-medium); padding: 3px var(--space-2-5); border-radius: var(--radius-full); background: var(--color-surface-2); color: var(--color-text-secondary); border: 1px solid var(--color-surface-border); }
.agent-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: var(--font-bold); letter-spacing: .04em; padding: 2px 7px; border-radius: var(--radius-full); background: var(--color-accent-primary-soft); color: var(--color-accent-primary); }
.agent-chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot-success { background: var(--color-feedback-success); }
.status-dot-warning { background: var(--color-feedback-warning); }
.status-dot-error { background: var(--color-feedback-error); }
.status-dot-neutral { background: var(--color-text-disabled); }
.status-dot-info { background: var(--color-feedback-info); }
.status-row { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }

/* ================= KPI / Stat tile ================= */
.stat-tile { background: var(--color-surface-0); border: 1px solid var(--color-surface-border); border-radius: var(--radius-card); padding: var(--space-5); box-shadow: var(--shadow-elevation-1); }
.stat-tile-label { font-size: var(--text-xs); font-weight: var(--font-semibold); color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.stat-tile-value { font-family: var(--font-heading); font-weight: var(--font-extrabold); font-size: var(--text-3xl); color: var(--color-text-primary); line-height: var(--leading-tight); }
.stat-tile-trend { font-size: var(--text-xs); font-weight: var(--font-medium); margin-top: var(--space-2); display: flex; align-items: center; gap: 4px; }
.trend-up { color: var(--color-feedback-success); }
.trend-down { color: var(--color-feedback-error); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* ================= Forms ================= */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-secondary); }
.field-hint { font-size: var(--text-xs); color: var(--color-text-tertiary); }
.field-error { font-size: var(--text-xs); color: var(--color-feedback-error); }
.input, .select, .textarea {
  width: 100%; padding: var(--space-2-5) var(--space-3); font-size: var(--text-sm);
  background: var(--color-surface-0); border: 1px solid var(--color-surface-border);
  border-radius: var(--radius-input); color: var(--color-text-primary);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-disabled); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-accent-primary); box-shadow: 0 0 0 3px var(--color-accent-primary-soft); }
.textarea { resize: vertical; min-height: 88px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.checkbox-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-secondary); }

/* ================= Tables ================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-surface-border); border-radius: var(--radius-card); }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: var(--color-surface-0); }
.data-table th { text-align: left; padding: var(--space-3) var(--space-4); font-size: var(--text-xs); font-weight: var(--font-semibold); color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: .04em; background: var(--color-surface-1); border-bottom: 1px solid var(--color-surface-border); white-space: nowrap; }
.data-table td { padding: var(--space-3-5) var(--space-4); color: var(--color-text-secondary); border-bottom: 1px solid var(--color-surface-border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.row-link { cursor: pointer; }
.data-table tbody tr.row-link:hover { background: var(--color-surface-1); }
.data-table td.cell-strong { color: var(--color-text-primary); font-weight: var(--font-medium); }
.data-table td.cell-mono { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-tertiary); }

/* ================= Tabs ================= */
.tabs { display: flex; align-items: center; gap: var(--space-1); border-bottom: 1px solid var(--color-surface-border); margin-bottom: var(--space-6); }
.tab { padding: var(--space-2-5) var(--space-4); font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-tertiary); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab:hover { color: var(--color-text-primary); }
.tab.active { color: var(--color-accent-primary); border-color: var(--color-accent-primary); font-weight: var(--font-semibold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .2s ease-out; }

.subnav { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); flex-wrap: wrap; }
.subnav a { padding: var(--space-2) var(--space-3-5); font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-secondary); background: var(--color-surface-0); border: 1px solid var(--color-surface-border); border-radius: var(--radius-full); }
.subnav a:hover { border-color: var(--color-surface-border-strong); }
.subnav a.active { background: var(--color-accent-primary); border-color: var(--color-accent-primary); color: var(--color-text-on-accent); }

/* ================= Stepper ================= */
.stepper { display: flex; align-items: center; margin-bottom: var(--space-8); }
.stepper-step { display: flex; align-items: center; gap: var(--space-2-5); }
.stepper-circle { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: var(--font-bold); border: 2px solid var(--color-surface-border-strong); color: var(--color-text-tertiary); background: var(--color-surface-0); flex-shrink: 0; }
.stepper-step.done .stepper-circle { background: var(--color-accent-primary); border-color: var(--color-accent-primary); color: var(--color-text-on-accent); }
.stepper-step.current .stepper-circle { border-color: var(--color-accent-primary); color: var(--color-accent-primary); box-shadow: 0 0 0 4px var(--color-accent-primary-soft); }
.stepper-label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-tertiary); }
.stepper-step.current .stepper-label, .stepper-step.done .stepper-label { color: var(--color-text-primary); }
.stepper-line { flex: 1; height: 2px; background: var(--color-surface-border-strong); margin: 0 var(--space-3); }
.stepper-step.done + .stepper-line { background: var(--color-accent-primary); }

/* ================= Timeline ================= */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--color-surface-border); }
.timeline-item { position: relative; padding-bottom: var(--space-6); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -28px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--color-surface-0); border: 2px solid var(--color-accent-primary); display: flex; align-items: center; justify-content: center; }
.timeline-dot.ai { border-color: var(--color-accent-secondary); }
.timeline-time { font-size: var(--text-xs); color: var(--color-text-tertiary); }
.timeline-text { font-size: var(--text-sm); color: var(--color-text-secondary); margin-top: 2px; }

/* ================= Avatar ================= */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--color-accent-primary); color: var(--color-text-on-accent); font-weight: var(--font-semibold); flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-md { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }

/* ================= Tooltip (hover) ================= */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip-wrap .tooltip-bubble {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--color-text-primary); color: var(--color-surface-0); font-size: var(--text-xs);
  padding: 6px 10px; border-radius: var(--radius-tooltip); white-space: nowrap; box-shadow: var(--shadow-elevation-2);
  opacity: 0; pointer-events: none; transition: opacity var(--duration-fast);
}
.tooltip-wrap:hover .tooltip-bubble { opacity: 1; }

/* ================= Empty state / Skeleton ================= */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-16) var(--space-6); color: var(--color-text-tertiary); }
.empty-state svg { color: var(--color-text-disabled); margin-bottom: var(--space-4); }
.empty-state-title { font-family: var(--font-heading); font-weight: var(--font-semibold); color: var(--color-text-secondary); margin-bottom: var(--space-1); }
.skeleton { background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-surface-3) 37%, var(--color-surface-2) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ================= Accordion ================= */
.accordion-item { border: 1px solid var(--color-surface-border); border-radius: var(--radius-lg); margin-bottom: var(--space-2); overflow: hidden; }
.accordion-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3-5) var(--space-4); cursor: pointer; background: var(--color-surface-0); font-size: var(--text-sm); font-weight: var(--font-medium); }
.accordion-header:hover { background: var(--color-surface-1); }
.accordion-header svg { transition: transform var(--duration-fast); }
.accordion-item.open .accordion-header svg { transform: rotate(180deg); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height var(--duration-standard) var(--ease-standard); background: var(--color-surface-1); }
.accordion-item.open .accordion-body { max-height: 600px; }
.accordion-body-inner { padding: var(--space-4); font-size: var(--text-sm); color: var(--color-text-secondary); }

/* ================= Modal / Drawer ================= */
.overlay-scrim { position: fixed; inset: 0; background: rgba(13,13,40,.5); backdrop-filter: blur(2px); z-index: 40; opacity: 0; pointer-events: none; transition: opacity var(--duration-standard); }
.overlay-scrim.open { opacity: 1; pointer-events: auto; }
/* `visibility: hidden` on the closed state, not just opacity (#821). opacity and
   pointer-events hide a dialog from a sighted mouse user and from nobody else:
   its controls stay in the TAB ORDER and its content stays in the ACCESSIBILITY
   TREE, so a keyboard user tabs into 270 invisible controls across these pages.
   #614 spotted the cause -- its own comment says these "stay in the accessibility
   tree while closed" -- and fixed only the symptom, clearing role/aria-modal.
   `visibility` is the right tool because, unlike `display: none`, it is
   transitionable: delaying it by the fade duration on the closed rule lets the
   fade-out finish before the subtree leaves the tree, and `0s` on .open makes it
   appear immediately. It is in CSS rather than JS so it cannot drift out of step
   with the three separate close paths. */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-48%); width: 520px; max-width: 92vw; max-height: 85vh; overflow-y: auto; background: var(--color-surface-0); border-radius: var(--radius-dialog); box-shadow: var(--shadow-elevation-4); z-index: 41; opacity: 0; pointer-events: none; visibility: hidden; transition: opacity var(--duration-standard), transform var(--duration-standard), visibility 0s linear var(--duration-standard); }
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%,-50%); visibility: visible; transition: opacity var(--duration-standard), transform var(--duration-standard), visibility 0s; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--color-surface-border); }
.modal-body { padding: var(--space-6); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-5) var(--space-6); border-top: 1px solid var(--color-surface-border); }
/* Same fix as `.modal` above (#821), and the drawer's closed state was the worse
   of the two: `translateX(100%)` only moves it off-screen, so it was focusable,
   readable AND still hit-testable. Tabbing into it made the browser scroll toward
   an element parked past the right edge of the viewport. */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw; background: var(--color-surface-0); box-shadow: var(--shadow-elevation-4); z-index: 41; transform: translateX(100%); visibility: hidden; transition: transform var(--duration-standard) var(--ease-standard), visibility 0s linear var(--duration-standard); display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); visibility: visible; transition: transform var(--duration-standard) var(--ease-standard), visibility 0s; }

/* ================= AI-Native Components ================= */

/* AgentStatus */
.agent-status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: var(--font-medium); padding: 5px var(--space-3); border-radius: var(--radius-full); background: var(--color-accent-primary-soft); color: var(--color-accent-primary); }
.agent-status .pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(1.3); } }

/* ConfidenceIndicator */
.confidence-indicator { display: inline-flex; align-items: center; gap: var(--space-2); padding: 4px var(--space-2-5) 4px 4px; border-radius: var(--radius-full); border: 1px solid; font-size: var(--text-xs); font-weight: var(--font-semibold); }
.confidence-indicator .conf-arc { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
.confidence-high { background: var(--color-confidence-high-bg); border-color: var(--color-confidence-high-border); color: var(--color-confidence-high-text); }
.confidence-high .conf-arc { background: conic-gradient(var(--color-confidence-high) 0 100%, var(--color-surface-3) 0); }
.confidence-medium { background: var(--color-confidence-medium-bg); border-color: var(--color-confidence-medium-border); color: var(--color-confidence-medium-text); }
.confidence-medium .conf-arc { background: conic-gradient(var(--color-confidence-medium) 0 65%, var(--color-surface-3) 0); }
.confidence-low { background: var(--color-confidence-low-bg); border-color: var(--color-confidence-low-border); color: var(--color-confidence-low-text); }
.confidence-low .conf-arc { background: conic-gradient(var(--color-confidence-low) 0 35%, var(--color-surface-3) 0); }

/* Autonomy badge */
.autonomy-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--font-semibold); padding: 5px var(--space-3); border-radius: var(--radius-full); border: 1px solid; }
.autonomy-supervised { background: var(--color-autonomy-supervised-bg); border-color: var(--color-autonomy-supervised-border); color: var(--color-autonomy-supervised-text); }
.autonomy-autonomous { background: var(--color-autonomy-autonomous-bg); border-color: var(--color-autonomy-autonomous-border); color: var(--color-autonomy-autonomous-text); }
.autonomy-human-required { background: var(--color-autonomy-human-required-bg); border-color: var(--color-autonomy-human-required-border); color: var(--color-autonomy-human-required-text); }

/* StreamingText */
.streaming-text { font-size: var(--text-sm); line-height: var(--leading-relaxed); color: var(--color-text-primary); }
.streaming-cursor { display: inline-block; width: 2px; height: 1em; background: var(--color-accent-primary); vertical-align: text-bottom; animation: blink 1s step-start infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* IntentSummary (bulk/irreversible action preview before executing) */
.intent-summary { border: 1px solid var(--color-accent-primary-soft); background: var(--color-accent-primary-soft); border-radius: var(--radius-xl); padding: var(--space-5); }
.intent-summary-header { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--font-semibold); color: var(--color-accent-primary); margin-bottom: var(--space-3); font-size: var(--text-sm); }
.intent-summary ul { display: flex; flex-direction: column; gap: var(--space-1-5); margin-bottom: var(--space-4); }
.intent-summary li { font-size: var(--text-sm); color: var(--color-text-secondary); display: flex; gap: var(--space-2); }
.intent-summary li::before { content: '\2022'; color: var(--color-accent-primary); }

/* HumanOverrideControl (mandatory on autonomous-mode screens) */
.human-override { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); border: 1px solid var(--color-autonomy-human-required-border); background: var(--color-autonomy-human-required-bg); border-radius: var(--radius-xl); padding: var(--space-4) var(--space-5); }
.human-override-label { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--color-autonomy-human-required-text); font-weight: var(--font-medium); }

/* ProgressiveDisclosure — reuses accordion pattern semantically */
.progressive-disclosure .accordion-header { color: var(--color-text-secondary); }

/* AnomalyHighlight */
.anomaly-highlight { border: 1px dashed var(--color-confidence-low-border); background: var(--color-confidence-low-bg); border-radius: var(--radius-md); padding: var(--space-1) var(--space-2); color: var(--color-confidence-low-text); font-weight: var(--font-medium); }

/* Alert */
.alert { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-lg); border: 1px solid; font-size: var(--text-sm); }
.alert-info { background: var(--color-feedback-info-soft); border-color: var(--color-feedback-info-soft); color: var(--color-feedback-info); }
.alert-success { background: var(--color-feedback-success-soft); border-color: var(--color-feedback-success-soft); color: var(--color-feedback-success); }
.alert-warning { background: var(--color-feedback-warning-soft); border-color: var(--color-feedback-warning-soft); color: var(--color-feedback-warning); }
.alert-error { background: var(--color-feedback-error-soft); border-color: var(--color-feedback-error-soft); color: var(--color-feedback-error); }

/* ================= App Shell: Sidebar + Topbar ================= */
.sidebar { width: 264px; flex-shrink: 0; background: var(--color-chrome-bg); display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-5) var(--space-4); }
.sidebar-brand-mark { width: 32px; height: 32px; border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary)); display: flex; align-items: center; justify-content: center; color: var(--color-text-on-accent); font-weight: var(--font-bold); font-size: var(--text-sm); flex-shrink: 0; }
.sidebar-brand-name { color: var(--color-chrome-text); font-weight: var(--font-semibold); font-size: var(--text-sm); }
.sidebar-nav { flex: 1; padding: 0 var(--space-3) var(--space-4); }
.sidebar-group { margin-bottom: var(--space-5); }
.sidebar-group-label { padding: 0 var(--space-3); margin-bottom: 6px; font-size: 10px; font-weight: var(--font-semibold); text-transform: uppercase; letter-spacing: .06em; color: var(--color-chrome-text-muted); }
.sidebar-item { display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-chrome-text-muted); margin-bottom: 2px; }
.sidebar-item svg { flex-shrink: 0; }
.sidebar-item:hover { background: rgba(255,255,255,.06); color: var(--color-chrome-text); }
.sidebar-item.active { background: var(--color-accent-primary); color: var(--color-text-on-accent); box-shadow: var(--shadow-elevation-1); }
.sidebar-footer { padding: var(--space-4); border-top: 1px solid var(--color-chrome-border); display: flex; align-items: center; gap: var(--space-2-5); }
.sidebar-footer-name { font-size: var(--text-xs); font-weight: var(--font-medium); color: var(--color-chrome-text); }
.sidebar-footer-role { font-size: 11px; color: var(--color-chrome-text-muted); }

.topbar { height: 60px; flex-shrink: 0; background: var(--color-surface-0); border-bottom: 1px solid var(--color-surface-border); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-6); }
.topbar-search { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-disabled); background: var(--color-surface-1); border: 1px solid var(--color-surface-border); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); width: 320px; }
.topbar-search-input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; color: var(--color-text-primary); font-size: var(--text-sm); }
.topbar-search-input::placeholder { color: var(--color-text-disabled); }
.topbar-actions { display: flex; align-items: center; gap: var(--space-4); }

/* Dropdown menus (notifications, org switcher) */
.dropdown { position: relative; }
[data-dropdown-menu] { position: absolute; top: calc(100% + 8px); right: 0; min-width: 240px; background: var(--color-surface-0); border: 1px solid var(--color-surface-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-elevation-3); padding: var(--space-1); z-index: 60; opacity: 0; pointer-events: none; transform: translateY(-4px); transition: opacity var(--duration-fast), transform var(--duration-fast); }
[data-dropdown-menu].open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.dropdown-item { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-sm); color: var(--color-text-secondary); cursor: pointer; width: 100%; text-align: left; background: none; border: none; }
.dropdown-item:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.dropdown-header { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: var(--font-semibold); color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: .04em; }

/* Config toggle switches — interactive.
   The whole switch lives here, not in a page's <style>: app.js's handler fires on ANY
   .toggle click (flipping `off` and toasting "<label> enabled./disabled."), so a page that
   used the class without also copy-pasting the visuals got a control that responded to
   clicks and looked like nothing. It was duplicated byte-for-byte in admin-console.html
   and eligibility-rules.html before #403. */
.toggle { width: 38px; height: 22px; border-radius: var(--radius-full); background: var(--color-accent-primary); position: relative; flex-shrink: 0; cursor: pointer; }
.toggle::after { content: ''; position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--color-surface-0); }
.toggle.off { background: var(--color-surface-border-strong); }
.toggle.off::after { right: auto; left: 2px; }
.icon-btn { position: relative; color: var(--color-text-tertiary); background: none; border: none; display: flex; }
.icon-btn:hover { color: var(--color-text-primary); }
.notif-dot { position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; border-radius: 50%; background: var(--color-feedback-error); color: var(--color-text-on-accent); font-size: 9px; display: flex; align-items: center; justify-content: center; font-weight: var(--font-bold); }
.theme-toggle { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-md); border: 1px solid var(--color-surface-border); background: var(--color-surface-0); color: var(--color-text-secondary); }
.theme-toggle:hover { background: var(--color-surface-2); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
/* app.js only sets data-theme once a user has toggled (persisted to
   localStorage) -- before that, tokens.css's own OS-preference block governs
   the actual colors shown, so this icon must follow the same query or it
   shows "sun" on a page that is already rendering dark (#188). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .25s var(--ease-standard); }

/* ================= Toasts ================= */
.toast-container { position: fixed; bottom: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column-reverse; gap: var(--space-2); width: 360px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: flex-start; gap: var(--space-2-5); padding: var(--space-3) var(--space-3-5); border-radius: var(--radius-lg); background: var(--color-surface-0); border: 1px solid var(--color-surface-border); border-left-width: 3px; box-shadow: var(--shadow-elevation-3); font-size: var(--text-sm); color: var(--color-text-primary); transform: translateX(120%); opacity: 0; transition: transform var(--duration-standard) var(--ease-standard), opacity var(--duration-standard); }
.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(120%); opacity: 0; }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: var(--font-semibold); margin-bottom: 1px; }
.toast-msg { color: var(--color-text-secondary); font-size: var(--text-xs); }
.toast-close { background: none; border: none; color: var(--color-text-tertiary); cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0; }
.toast-close:hover { color: var(--color-text-primary); }
.toast-success { border-left-color: var(--color-feedback-success); } .toast-success .toast-icon { color: var(--color-feedback-success); }
.toast-error   { border-left-color: var(--color-feedback-error); }   .toast-error .toast-icon { color: var(--color-feedback-error); }
.toast-warning { border-left-color: var(--color-feedback-warning); } .toast-warning .toast-icon { color: var(--color-feedback-warning); }
.toast-info    { border-left-color: var(--color-feedback-info); }    .toast-info .toast-icon { color: var(--color-feedback-info); }

/* ================= Wizard ================= */
[data-wizard-panel] { display: none; }
[data-wizard-panel].active { display: block; animation: fadeIn .25s var(--ease-standard); }
[data-wizard-prev][disabled] { opacity: .5; cursor: not-allowed; }

/* ================= Off-canvas nav (mobile/tablet) ================= */
.topbar-burger { display: none; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-md); border: 1px solid var(--color-surface-border); background: var(--color-surface-0); color: var(--color-text-secondary); margin-right: var(--space-2); }
.topbar-burger:hover { background: var(--color-surface-2); }
.topbar-left { display: flex; align-items: center; flex: 1; min-width: 0; }
.nav-scrim { position: fixed; inset: 0; background: rgba(13,13,40,.5); z-index: 45; opacity: 0; pointer-events: none; transition: opacity var(--duration-standard); }

@media (max-width: 1024px) {
  .topbar-burger { display: inline-flex; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 50; transform: translateX(-100%); transition: transform var(--duration-standard) var(--ease-standard); box-shadow: var(--shadow-elevation-4); }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .app-shell.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .app-shell { flex-direction: row; height: 100vh; }
}

/* ================= Responsive grid reflow ================= */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .topbar-search { display: none; }
  .app-content { padding: var(--space-5) var(--space-4); }
  .grid-cols-3, .grid-cols-4, .grid-cols-5 { grid-template-columns: repeat(2, 1fr); }
  .stepper { overflow-x: auto; }
  .stepper-label { font-size: var(--text-xs); }
}
@media (max-width: 640px) {
  .kpi-grid, .grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-5 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3, .col-span-4, .col-span-5, .col-span-6, .col-span-7, .col-span-8, .col-span-9 { grid-column: auto; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .modal { width: 94vw; }
  .toast-container { width: auto; left: 12px; right: 12px; bottom: 12px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; }
  .subnav { overflow-x: auto; flex-wrap: nowrap; }
}
