@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/Manrope-Regular.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/Manrope-Medium.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/Manrope-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 700 900; font-display: swap; src: url("/static/fonts/Manrope-Bold.ttf") format("truetype"); }

:root {
  --canvas: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f1efeb;
  --ink: #17191e;
  --ink-2: #3b404a;
  --muted: #6b707a;
  --faint: #70747d;
  --line: #e6e3dd;
  --line-strong: #d5d1c9;
  --nav: #15171c;
  --nav-ink: #ecebe7;
  --nav-muted: #8d919a;
  --nav-active: #24272f;
  --nav-line: rgba(255, 255, 255, .07);
  --nav-line-strong: rgba(255, 255, 255, .16);
  --nav-ink-strong: #ffffff;
  --nav-accent: #9aa7f5;
  --nav-accent-soft: rgba(124, 140, 240, .15);
  --accent: #3446b4;
  --accent-hover: #2a3a9c;
  --accent-ink: #ffffff;
  --accent-soft: #eceefa;
  --accent-line: #c9cff0;
  --positive: #1b7553;
  --positive-soft: #e7f3ec;
  --warning: #9c5d0b;
  --warning-soft: #faf0de;
  --danger: #b3364a;
  --danger-soft: #fbeced;
  --purple: #6b52c4;
  --purple-soft: #f1eefb;
  --scrim: rgba(21, 23, 28, .48);
  --veil: rgba(246, 245, 242, .72);
  --positive-ring: rgba(27, 117, 83, .18);
  --focus-ring: 0 0 0 3px rgba(52, 70, 180, .22);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(23, 25, 30, .05);
  --shadow: 0 12px 32px rgba(23, 25, 30, .12);
  --font: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --bg: var(--canvas);
  --primary: var(--accent);
  --primary-soft: var(--accent-soft);
  --nav-2: var(--nav-active);
  --border: var(--line);
  --border-color: var(--line);
  --text: var(--ink);
}

[hidden] { display: none !important; }
.hidden { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }
button { cursor: pointer; }
a { color: var(--accent); }
table, .metric-value, .mini-stat strong, .nav-count { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

h1 { margin: 4px 0; font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
h2 { margin: 3px 0 0; font-size: 16px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
h3 { font-weight: 700; }
.eyebrow, .panel-kicker { color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.muted { color: var(--muted); font-size: 12px; }
.muted-copy { color: var(--faint); }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.section-help { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 8px 0 0; }

.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--radius-sm); padding: 0 14px; border: 1px solid transparent; font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; transition: background-color .12s ease, border-color .12s ease; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }
.button.danger-safe { background: var(--ink); color: var(--surface); }
.button.danger-safe:hover:not(:disabled) { background: var(--ink-2); }
.button.small { min-height: 30px; padding: 0 11px; font-size: 12px; }
.button.tiny { min-height: 26px; padding: 0 9px; font-size: 11px; }
.link-button:focus-visible, .button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.control-field { display: grid; gap: 5px; min-width: 0; }
.control-field span, .modal-field span, .settings-fields label span { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.control-field input, .control-field select, .modal-field input, .modal-field select, .settings-fields input, .settings-fields textarea { min-height: 36px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 0 10px; color: var(--ink); outline: none; transition: border-color .12s ease, box-shadow .12s ease; }
.settings-fields textarea { padding: 9px 10px; min-height: 78px; resize: vertical; }
.control-field select, .modal-field select { text-overflow: ellipsis; }
.control-field input:focus, .control-field select:focus, .modal-field input:focus, .modal-field select:focus, .settings-fields input:focus, .settings-fields textarea:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: var(--nav-ink); padding: 20px 12px 14px; display: flex; flex-direction: column; gap: 22px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--nav-active) transparent; }
.brand { position: relative; flex: 0 0 auto; display: flex; gap: 11px; align-items: center; min-height: 32px; padding: 0 44px 0 8px; }
.brand-mark { width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: 0 0 auto; font-weight: 700; font-size: 15px; background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--nav-line-strong); }
.brand-text { min-width: 0; white-space: nowrap; line-height: 1.25; }
.brand-title { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.brand-subtitle { color: var(--nav-muted); font-size: 11px; margin-top: 1px; }
.nav { display: grid; gap: 18px; }
.nav-group { display: grid; gap: 1px; }
.nav-group-label { position: relative; padding: 0 10px 6px; white-space: nowrap; overflow: hidden; color: var(--nav-muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.nav-group-label::after { content: ""; position: absolute; left: 12px; right: 12px; top: 7px; height: 1px; background: var(--nav-line-strong); opacity: 0; pointer-events: none; }
.nav-item { position: relative; border: 0; background: transparent; color: var(--nav-muted); min-height: 36px; padding: 0 10px; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 11px; align-items: center; text-align: left; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; transition: background-color .12s ease, color .12s ease; }
.nav-item:hover { background: var(--nav-line); color: var(--nav-ink); }
.nav-item:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--nav-accent); }
.nav-item.active { background: var(--nav-accent-soft); color: var(--nav-ink-strong); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-accent); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-item.active .nav-icon { color: var(--nav-accent); }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { min-width: 20px; height: 18px; display: grid; place-items: center; padding: 0 6px; border-radius: 999px; background: var(--nav-active); color: var(--nav-ink); font-size: 10px; font-weight: 700; }
.nav-item.active .nav-count { background: var(--nav-accent); color: var(--nav); }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.safety-card { background: var(--nav-line); border: 1px solid var(--nav-line); padding: 11px 12px; border-radius: var(--radius); overflow: hidden; }
/* Fixed min-width stops the copy re-wrapping taller while the rail narrows. */
.safety-card p { min-width: 198px; max-height: 60px; overflow: hidden; color: var(--nav-muted); font-size: 11px; line-height: 1.5; margin: 6px 0 0; }
.safety-row { display: flex; gap: 8px; align-items: center; font-size: 12px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 3px var(--positive-ring); display: inline-block; flex: 0 0 auto; }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px 0 8px; border-top: 1px solid var(--nav-line); }
.sidebar-user-text { max-width: 120px; overflow: hidden; white-space: nowrap; color: var(--nav-muted); font-size: 12px; font-weight: 500; }
.sidebar-user .button.secondary { min-height: 30px; padding: 0 11px; font-size: 12px; background: transparent; color: var(--nav-ink); border-color: var(--nav-line-strong); }
.sidebar-user .button.secondary:hover:not(:disabled) { background: var(--nav-line); border-color: var(--nav-muted); }
.version { max-height: 16px; overflow: hidden; white-space: nowrap; color: var(--nav-muted); font-size: 10px; padding: 0 4px 0 8px; }
.sidebar-backdrop { display: none; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 28px; display: grid; }
.topbar-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { min-height: 54px; }
.topbar-page { flex: 1; min-width: 0; font-size: 17px; font-weight: 700; letter-spacing: -.015em; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-filters { padding: 2px 0 12px; }
.topbar-controls { display: flex; flex-wrap: nowrap; align-items: end; gap: 10px; flex: 1; min-width: 0; }
.topbar-controls .control-field select { width: 100%; max-width: 100%; overflow: hidden; white-space: nowrap; }
.topbar-controls > .control-field { flex: 0 0 auto; }
.topbar-controls .client-field { flex: 0 1 235px; min-width: 120px; }
.topbar-controls .channel-field { flex: 0 1 165px; min-width: 112px; }
.topbar-controls .account-field { flex: 0 1 290px; min-width: 130px; }
.platform-field select { width: 145px; }
.control-field.hidden, #platformSelect.hidden { display: none !important; }
.topbar-controls #analyzeButton { margin-left: auto; }
.mode-pill { border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 999px; padding: 6px 11px; display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; max-width: 100%; }
.mobile-brand { display: none; }
.sidebar-open { display: none; flex: 0 0 auto; width: 36px; height: 36px; margin-left: -8px; place-items: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); transition: background-color .12s ease, color .12s ease; }
.sidebar-open:hover { background: var(--surface-3); color: var(--ink); }
.sidebar-open:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sidebar-toggle { position: absolute; top: 0; right: 0; width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--nav-muted); transition: background-color .12s ease, color .12s ease; }
.sidebar-toggle:hover { background: var(--nav-line); color: var(--nav-ink); }
.sidebar-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--nav-accent); }
.sidebar-toggle-icon { overflow: visible; }
/* All three bars share one path at y=12; transforms fan them into a hamburger or fold them into a left arrow. */
.sidebar-toggle-icon .bar { transform-box: view-box; transform-origin: 4px 12px; }
.sidebar-toggle-icon .bar-top { transform: translateY(0) rotate(-45deg) scaleX(.53); }
.sidebar-toggle-icon .bar-bottom { transform: translateY(0) rotate(45deg) scaleX(.53); }
.analysis-mode-field { min-width: 151px; }
.analysis-mode-toggle { min-height: 36px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-3); padding: 3px; }
.analysis-mode-toggle button { border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; padding: 0 10px; }
.analysis-mode-toggle button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.analysis-mode-toggle button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.comparison-bar { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 10px 28px; }
.comparison-bar.hidden, .comparison-field.hidden, .comparison-badge.hidden { display: none !important; }
.comparison-bar-inner { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; min-width: 0; }
.comparison-bar-title { display: grid; gap: 3px; min-width: 0; flex: 0 1 205px; padding-bottom: 2px; }
.comparison-bar-title span, .comparison-field > span { font-size: 11px; font-weight: 600; color: var(--muted); }
.comparison-bar-title strong { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comparison-field { display: grid; gap: 5px; min-width: 0; }
.comparison-field select, .comparison-field input { min-height: 34px; max-width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); padding: 0 9px; color: var(--ink); outline: none; text-overflow: ellipsis; }
.comparison-field select:focus, .comparison-field input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.comparison-type-field select { width: 200px; }
#comparisonAccountField select { width: 300px; }
.comparison-context-note { margin-left: auto; align-self: center; color: var(--muted); font-size: 11px; line-height: 1.35; text-align: right; max-width: 340px; }
.content { padding: 28px 30px 56px; max-width: 1550px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: view-in .16s ease; }
@keyframes view-in { from { opacity: .4; } to { opacity: 1; } }
.meta-only.hidden, .google-only.hidden { display: none !important; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page-heading p { color: var(--muted); margin: 0; font-size: 13px; max-width: 72ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.table-panel { padding: 0; overflow: hidden; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; min-height: 112px; box-shadow: var(--shadow-sm); min-width: 0; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: 10px 0 8px; overflow-wrap: anywhere; }
.metric-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.delta { padding: 2px 6px; border-radius: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--positive); background: var(--positive-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.neutral { color: var(--ink-2); background: var(--surface-3); }

.priority-pill, .decision-pill, .risk-pill { display: inline-flex; align-items: center; justify-content: center; width: max-content; border-radius: 4px; padding: 4px 7px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.priority-critical { color: var(--danger); background: var(--danger-soft); }
.priority-high { color: var(--warning); background: var(--warning-soft); }
.priority-medium { color: var(--ink-2); background: var(--surface-3); }
.priority-low { color: var(--positive); background: var(--positive-soft); }
.decision-deferred { color: var(--purple); background: var(--purple-soft); }
.decision-actionable_review, .decision-ready_for_approval { color: var(--positive); background: var(--positive-soft); }
.decision-review_recommended, .decision-review_only { color: var(--accent); background: var(--accent-soft); }
.platform-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.platform-badge.meta { background: var(--positive-soft); color: var(--positive); }
.platform-badge.google { background: var(--accent-soft); color: var(--accent); }
.client-group-badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; white-space: nowrap; }

.action-tabs { display: flex; gap: 2px; margin: 16px 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.action-tab { border: 0; background: transparent; padding: 9px 12px 10px; color: var(--muted); font-size: 13px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.action-tab:hover { color: var(--ink); }
.action-tab span { margin-left: 5px; min-width: 20px; display: inline-grid; place-items: center; border-radius: 999px; padding: 1px 6px; background: var(--surface-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.action-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.action-tab.active span { background: var(--accent-soft); }

.table-wrap, .performance-table-wrap { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { background: var(--surface-2); color: var(--muted); text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; margin-bottom: 2px; font-weight: 600; }
td small { color: var(--muted); }

.info-banner { display: flex; align-items: flex-start; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; color: var(--ink-2); }
.info-banner strong { flex: 0 0 auto; color: var(--ink); font-size: 12px; }
.info-banner span { font-size: 12px; line-height: 1.55; }
.safety-banner { display: flex; gap: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink); padding: 13px 15px; border-radius: var(--radius); margin-bottom: 16px; }
.safety-banner p { margin: 3px 0 0; font-size: 12px; color: var(--ink-2); }
.shield { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; background: var(--surface); color: var(--accent); display: grid; place-items: center; font-weight: 700; }

.empty-state { min-height: 120px; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.empty-state.compact { min-height: 70px; }
.skeleton-card { background: linear-gradient(100deg, var(--surface) 20%, var(--surface-3) 38%, var(--surface) 56%); background-size: 200% 100%; animation: shine 1.35s infinite; }
@keyframes shine { to { background-position-x: -200%; } }
.loading-overlay { position: fixed; inset: 0; background: var(--veil); z-index: 80; display: grid; place-items: center; }
.loading-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 22px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: var(--scrim); display: grid; place-items: center; padding: 20px; }
.modal-backdrop.hidden { display: none; }
.modal { width: min(540px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); position: relative; }
.modal-wide { width: min(760px, 100%); }
.modal h2 { font-size: 20px; margin: 6px 0 5px; }
.modal-close { position: absolute; top: 13px; right: 14px; width: 32px; height: 32px; border: 0; background: var(--surface-3); border-radius: 50%; color: var(--ink-2); font-size: 19px; }
.modal-close:hover { background: var(--line); }
.modal-copy { color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.modal-field { display: grid; gap: 6px; margin-top: 13px; }
.confirmation-code { border: 1px dashed var(--line-strong); background: var(--surface-2); color: var(--ink); border-radius: var(--radius-sm); padding: 11px 12px; font-family: var(--font-mono); font-size: 12px; margin: 13px 0; user-select: all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.preview-section { margin: 16px 0; }
.preview-section h3 { font-size: 13px; margin: 0 0 8px; }
.check-list { display: grid; gap: 7px; padding: 0; list-style: none; }
.check-list li { font-size: 12px; color: var(--ink-2); padding-left: 20px; position: relative; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--positive); font-weight: 700; }
.live-warning { margin-top: 13px; border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 11px; display: grid; gap: 3px; font-size: 12px; }
.live-warning.hidden { display: none; }
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 9px; width: min(360px, calc(100vw - 40px)); }
.toast { background: var(--nav); color: var(--nav-ink); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); font-size: 12px; line-height: 1.45; animation: toastin .18s ease; }
.toast.success { background: var(--positive); color: var(--accent-ink); }
.toast.error { background: var(--danger); color: var(--accent-ink); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

.login-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; background: linear-gradient(to bottom, var(--nav) 0, var(--nav) 42%, var(--canvas) 42%); }
.login-card { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 28px; width: min(380px, 100%); margin: auto; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0 0 4px; }
.login-card > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-card .button.primary { margin-top: 6px; min-height: 40px; }
.login-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.login-brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.login-card label { font-size: 13px; font-weight: 600; }
.login-card input { min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
.login-card input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.login-error { color: var(--danger); min-height: 1.2em; font-size: 13px; }
.login-help-toggle { align-self: flex-start; background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.login-help { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.login-help p { margin: 0 0 6px; }
.login-help p:last-child { margin-bottom: 0; }
.login-help a { color: var(--accent); }
.sign-in-block { display: flex; flex-direction: column; gap: 6px; }
.email-field { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.email-field:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.login-card .email-field input { border: 0; border-radius: 0; flex: 1; min-width: 0; box-shadow: none; }
.email-suffix { background: var(--surface-2); color: var(--muted); padding: 0 10px; display: flex; align-items: center; font-size: 13px; border-left: 1px solid var(--line-strong); white-space: nowrap; }

body[data-access-level="view"] [data-needs="operate"],
body[data-access-level="view"] [data-needs="launch"],
body[data-access-level="operate"] [data-needs="launch"],
body:not([data-role="admin"]) [data-needs="admin"] { display: none !important; }

@media (max-width: 1250px) {
  .analysis-mode-field { min-width: 138px; }
  .comparison-context-note { display: none; }
  .topbar-controls { flex-wrap: wrap; }
  .topbar-controls .client-field, .topbar-controls .channel-field, .topbar-controls .account-field { flex-grow: 1; }
}
@media (max-width: 1150px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 701px) {
  .app-shell.sidebar-collapsed, .sidebar-pre-collapsed .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) :is(.brand-text, .nav-label, .safety-row strong, .sidebar-user-text, .version) { opacity: 0; transform: translateX(-6px); pointer-events: none; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .nav-group-label { color: transparent; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .nav-group-label::after { opacity: 1; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .nav-group:first-child .nav-group-label::after { display: none; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .nav-item { padding-left: 15px; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .nav-count { position: absolute; top: 4px; left: 27px; min-width: 16px; height: 14px; padding: 0 4px; font-size: 9px; box-shadow: 0 0 0 2px var(--nav); }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .safety-card { padding-left: 19px; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .safety-card p { max-height: 0; margin-top: 0; opacity: 0; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .sidebar-user { gap: 0; padding-left: 0; padding-right: 0; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .sidebar-user-text { max-width: 0; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .sidebar-user .button.secondary { flex: 1; padding: 0 4px; font-size: 11px; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .version { max-height: 0; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .brand { padding: 44px 8px 0; }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .sidebar-toggle { transform: translateX(-8px); }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .sidebar-toggle-icon .bar-top { transform: translateY(-6px) rotate(0) scaleX(1); }
  :is(.sidebar-collapsed, .sidebar-pre-collapsed) .sidebar-toggle-icon .bar-bottom { transform: translateY(6px) rotate(0) scaleX(1); }

  /* sidebar-motion is added after first paint so the restored state never animates in. */
  .app-shell.sidebar-motion { transition: grid-template-columns .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar-motion :is(.brand-text, .nav-label, .safety-row strong, .sidebar-user-text, .version) { transition: opacity .12s ease, transform .22s ease, max-width .22s ease, max-height .22s ease; }
  .sidebar-motion:not(.sidebar-collapsed) :is(.brand-text, .nav-label, .safety-row strong, .sidebar-user-text, .version) { transition-delay: 70ms, 0s, 0s, 0s; transition-duration: .15s, .22s, .22s, .22s; }
  .sidebar-motion .nav-group-label, .sidebar-motion .nav-group-label::after { transition: color .15s ease, opacity .15s ease; }
  .sidebar-motion .nav-item { transition: background-color .12s ease, color .12s ease, padding .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar-motion :is(.safety-card, .sidebar-user) { transition: padding .22s cubic-bezier(.2, .7, .2, 1), gap .22s ease; }
  .sidebar-motion .brand { transition: padding .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar-motion .sidebar-toggle { transition: background-color .12s ease, color .12s ease, transform .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar-motion .sidebar-toggle-icon .bar { transition: transform .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar-motion .safety-card p { transition: max-height .22s ease, margin .22s ease, opacity .12s ease; }
}
@media (max-width: 850px) {
  .topbar { padding: 0 16px; }
  .comparison-bar { padding: 9px 16px; }
  .content { padding: 22px 16px 40px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 90; width: min(280px, calc(100vw - 48px)); height: 100vh; height: 100dvh; transform: translateX(-100%); visibility: hidden; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 85; background: var(--scrim); opacity: 0; visibility: hidden; }
  .sidebar-drawer-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .sidebar-drawer-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  /* visibility flips at the end of the close so the drawer stays painted while it slides out. */
  .sidebar-motion .sidebar { transition: transform .22s cubic-bezier(.2, .7, .2, 1), box-shadow .22s ease, visibility 0s linear .22s; }
  .sidebar-motion .sidebar-backdrop { transition: opacity .22s ease, visibility 0s linear .22s; }
  .sidebar-motion.sidebar-drawer-open :is(.sidebar, .sidebar-backdrop) { transition-delay: 0s; }
  body.sidebar-scroll-locked { overflow: hidden; }
  .sidebar-open { display: grid; }
  .topbar-controls .control-field, .topbar-controls .analysis-mode-field { flex: 1 1 140px; min-width: 0; }
  .topbar-controls #analyzeButton { flex: 1 1 100%; margin-left: 0; }
  .comparison-type-field select, #comparisonAccountField select { width: 100%; }
  .comparison-bar-title, .comparison-field { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-motion, .sidebar-motion * { transition: none !important; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .page-heading { display: grid; }
}
