/* ==========================================================================
   Pulse — Social Media Monitoring & Engagement Intelligence
   Design system + layout. Tokens follow the validated dataviz palette.
   ========================================================================== */

/* ---------------------------------------------------------------------
   Tokens — light default, dark via prefers-color-scheme + [data-theme]
   --------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* surfaces */
  --page:            #f9f9f7;
  --surface-1:       #fcfcfb;
  --surface-2:       #ffffff;
  --surface-raised:  #ffffff;
  --overlay:         rgba(11, 11, 11, 0.46);

  /* ink */
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --text-muted:      #898781;
  --text-on-accent:  #ffffff;

  /* structure */
  --border:          rgba(11, 11, 11, 0.10);
  --border-strong:   rgba(11, 11, 11, 0.16);
  --gridline:        #e1e0d9;
  --baseline:        #c3c2b7;

  /* categorical — fixed platform identity order (palette.md slots 1-6) */
  --series-1: #2a78d6; /* twitter/X */
  --series-2: #eb6834; /* reddit */
  --series-3: #1baf7a; /* youtube */
  --series-4: #eda100; /* instagram */
  --series-5: #e87ba4; /* facebook */
  --series-6: #4a3aa7; /* linkedin */
  --series-accent: #2a78d6;
  --brand: var(--series-6); /* distinct UI-chrome accent, reuses the validated violet slot */

  /* sequential (blue) */
  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5;
  --seq-450: #2a78d6; --seq-500: #256abf; --seq-600: #184f95;

  /* status */
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  /* sentiment (domain convention, distinct usage from run-status) */
  --sentiment-pos: #0ca30c;
  --sentiment-neu: #898781;
  --sentiment-neg: #d03b3b;

  --success-text: #006300;
  --warning-text: #8a5a00;

  --shadow-sm: 0 1px 2px rgba(11,11,11,0.05), 0 1px 1px rgba(11,11,11,0.04);
  --shadow-md: 0 4px 14px rgba(11,11,11,0.07), 0 1px 3px rgba(11,11,11,0.05);
  --shadow-lg: 0 16px 40px rgba(11,11,11,0.12), 0 2px 8px rgba(11,11,11,0.06);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --sidebar-w: 272px;
  --topbar-h: 64px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:            #0d0d0d;
    --surface-1:       #1a1a19;
    --surface-2:       #201f1d;
    --surface-raised:  #232220;
    --overlay:         rgba(0, 0, 0, 0.6);

    --text-primary:    #ffffff;
    --text-secondary:  #c3c2b7;
    --text-muted:      #898781;

    --border:          rgba(255, 255, 255, 0.10);
    --border-strong:   rgba(255, 255, 255, 0.16);
    --gridline:        #2c2c2a;
    --baseline:        #383835;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #9085e9;
    --series-accent: #3987e5;

    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #e66767;

    --sentiment-pos: #0ca30c;
    --sentiment-neu: #898781;
    --sentiment-neg: #e66767;

    --success-text: #0ca30c;
    --warning-text: #f2b544;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
    --shadow-lg: 0 20px 48px rgba(0,0,0,0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:            #0d0d0d;
  --surface-1:       #1a1a19;
  --surface-2:       #201f1d;
  --surface-raised:  #232220;
  --overlay:         rgba(0, 0, 0, 0.6);

  --text-primary:    #ffffff;
  --text-secondary:  #c3c2b7;
  --text-muted:      #898781;

  --border:          rgba(255, 255, 255, 0.10);
  --border-strong:   rgba(255, 255, 255, 0.16);
  --gridline:        #2c2c2a;
  --baseline:        #383835;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #9085e9;
  --series-accent: #3987e5;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #e66767;

  --sentiment-pos: #0ca30c;
  --sentiment-neu: #898781;
  --sentiment-neg: #e66767;

  --success-text: #0ca30c;
  --warning-text: #f2b544;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.5);
}

/* ---------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  background-image: radial-gradient(1100px 600px at 14% -8%, color-mix(in srgb, var(--series-1) 5%, transparent), transparent 60%),
                     radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--series-6) 4%, transparent), transparent 55%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; }
.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
::selection { background: var(--series-accent); color: #fff; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------------
   Accessibility — focus, motion, skip link
   --------------------------------------------------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--series-accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: fixed; top: -48px; left: 12px; z-index: 300;
  background: var(--series-accent); color: #fff; font-weight: 700; font-size: 13px;
  padding: 10px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  transition: top .15s var(--ease);
}
.skip-link:focus-visible { top: 12px; outline-color: #fff; outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--series-1), var(--series-6) 130%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--series-1) 25%, transparent);
  flex-shrink: 0;
}
.brand-mark .icon { stroke: #fff; width: 17px; height: 17px; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-section {
  padding: 16px 14px 6px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.new-query-btn {
  margin: 4px 14px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  background: linear-gradient(135deg, var(--series-1), color-mix(in srgb, var(--series-1) 55%, var(--series-6)) 130%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), filter .15s var(--ease);
  box-shadow: var(--shadow-sm);
}
.new-query-btn:hover { filter: brightness(1.08); box-shadow: var(--shadow-md); }
.new-query-btn:active { transform: scale(0.98); }
.new-query-btn .icon { stroke: #fff; }

.cmdk-trigger {
  margin: 12px 14px 2px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted); font-size: 12.5px; font-weight: 550;
  cursor: pointer; transition: border-color .12s var(--ease), background .12s var(--ease);
}
.cmdk-trigger:hover { border-color: var(--border-strong); background: var(--surface-raised); color: var(--text-secondary); }
.cmdk-trigger .icon { stroke: var(--text-muted); }
.cmdk-trigger span.grow { flex: 1; text-align: left; }
.kbd {
  font-size: 10px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-family: ui-monospace, "SF Mono", Consolas, monospace; background: var(--surface-1);
  flex-shrink: 0;
}
.kbd-combo { display: inline-flex; gap: 2px; }

.query-list { list-style: none; margin: 0; padding: 0 10px; display: flex; flex-direction: column; gap: 3px; }
.query-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s var(--ease);
  position: relative;
}
.query-item:hover { background: var(--surface-2); }
.query-item.active { background: var(--surface-2); border-color: var(--border); box-shadow: var(--shadow-sm); }
.query-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  background: var(--series-accent); border-radius: 3px;
}
.query-item-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-raised); border: 1px solid var(--border);
  color: var(--text-secondary);
}
.query-item.active .query-item-icon { color: var(--series-accent); border-color: color-mix(in srgb, var(--series-accent) 40%, var(--border)); }
.query-item-body { min-width: 0; flex: 1; }
.query-item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.query-item-meta { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-good); box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--status-good) 22%, transparent); flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.spend-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  background: var(--surface-2);
}
.spend-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.spend-card-title { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }
.spend-card-value { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.meter-track { height: 6px; border-radius: 4px; background: color-mix(in srgb, var(--series-accent) 16%, var(--surface-1)); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--series-accent); transition: width .5s var(--ease); }
.meter-fill.warn { background: var(--status-warning); }
.meter-fill.danger { background: var(--status-critical); }

.user-row { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: var(--radius-md); cursor: pointer; }
.user-row:hover { background: var(--surface-2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--series-6), var(--series-1)); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-row-name { font-size: 12.5px; font-weight: 600; }
.user-row-role { font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Main column
   --------------------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page) 72%, transparent);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
}
.topbar-title-wrap { min-width: 0; }
.topbar-eyebrow { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.topbar-title { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.type-chip {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--series-accent) 14%, transparent);
  color: var(--series-accent);
  border: 1px solid color-mix(in srgb, var(--series-accent) 30%, transparent);
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.icon-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1);
  cursor: pointer; color: var(--text-secondary);
  transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-strong); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 8px 13px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font-weight: 600; font-size: 12.5px;
  cursor: pointer; transition: background .12s var(--ease), border-color .12s var(--ease), transform .1s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }
.btn .icon { stroke: var(--text-secondary); }
.btn-primary { background: var(--series-accent); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--series-accent); }
.btn-primary .icon { stroke: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-danger-text { color: var(--status-critical); }
.btn.is-loading { pointer-events: none; opacity: .85; }
.spinner { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; animation: spin .6s linear infinite; border: 2px solid var(--border-strong); border-top-color: var(--text-secondary); }
.btn-primary .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.freshness-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); font-weight: 550; white-space: nowrap; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-good); position: relative; flex-shrink: 0; }
.pulse-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--status-good);
  opacity: .35; animation: pulse-ring 2s var(--ease) infinite;
}
.pulse-dot.stale { background: var(--status-warning); }
.pulse-dot.stale::after { background: var(--status-warning); }
@keyframes pulse-ring { 0% { transform: scale(.6); opacity: .5; } 100% { transform: scale(2.2); opacity: 0; } }

.menu-pop {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 190px;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  animation: pop-in .14s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 7px; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .icon { stroke: var(--text-secondary); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.rel { position: relative; }

/* ---------------------------------------------------------------------
   Content area / tabs / filter row
   --------------------------------------------------------------------- */
.content { padding: 20px 22px 60px; max-width: 1520px; }

.tabs {
  display: flex; align-items: center; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 4px; margin-right: 22px;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 13.5px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: color .12s var(--ease);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--series-accent); }
.tab-count {
  font-size: 10.5px; font-weight: 700; background: var(--surface-2); color: var(--text-muted);
  padding: 1px 6px; border-radius: var(--radius-pill); border: 1px solid var(--border);
}
.tab-btn.active .tab-count { color: var(--series-accent); border-color: color-mix(in srgb, var(--series-accent) 35%, transparent); }

.filter-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.select-field, .field-btn {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; white-space: nowrap;
  padding: 7px 10px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-1); font-size: 12.5px; font-weight: 550; color: var(--text-secondary);
  cursor: pointer;
}
.field-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.field-btn .icon { stroke: var(--text-muted); }
.field-btn.is-active { color: var(--series-accent); border-color: color-mix(in srgb, var(--series-accent) 40%, var(--border)); background: color-mix(in srgb, var(--series-accent) 8%, var(--surface-1)); }
select.select-field { appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23898781' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.filter-spacer { flex: 1; }
.search-field { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-1); min-width: 220px; transition: border-color .12s var(--ease); }
.search-field:focus-within { border-color: var(--series-accent); }
.search-field input { border: none; background: none; outline: none; font-size: 12.5px; color: var(--text-primary); width: 100%; }
.search-field .icon { stroke: var(--text-muted); flex-shrink: 0; }
.search-field.has-text .kbd, .search-field:focus-within .kbd { display: none; }
.search-clear { display: none; width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 50%; color: var(--text-muted); cursor: pointer; flex-shrink: 0; }
.search-clear:hover { background: var(--surface-2); color: var(--text-primary); }
.search-field.has-text .search-clear { display: flex; }
.platform-toggle-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.platform-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-1);
  font-size: 12px; font-weight: 600; color: var(--text-secondary); cursor: pointer;
  transition: opacity .12s var(--ease), border-color .12s var(--ease);
}
.platform-chip[data-on="false"] { opacity: 0.42; }
.platform-chip .badge-dot { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: #fff; }

/* ---------------------------------------------------------------------
   View / section scaffolding
   --------------------------------------------------------------------- */
.view { display: none; animation: fade-in .18s var(--ease); }
.view.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-head:first-child { margin-top: 0; }
.section-title { font-size: 14.5px; font-weight: 650; }
.section-hint { font-size: 12px; color: var(--text-muted); }
.link-more { font-size: 12px; font-weight: 600; color: var(--series-accent); cursor: pointer; display: flex; align-items: center; gap: 4px; }

/* ---------------------------------------------------------------------
   Stat tiles
   --------------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat-tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 15px 16px 14px; position: relative; overflow: hidden;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.stat-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 550; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stat-label .icon { stroke: var(--text-muted); width: 14px; height: 14px; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: proportional-nums; }
.stat-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.stat-delta { font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.stat-delta.up { color: var(--success-text); }
.stat-delta.down { color: var(--status-critical); }
.stat-delta .icon { width: 12px; height: 12px; }
.stat-period { font-size: 11px; color: var(--text-muted); }
.stat-spark { width: 68px; height: 26px; }

.kpi-band-label {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 22px 0 10px;
}
.kpi-band-label::after { content: ""; flex: 1; height: 1px; background: var(--gridline); }

/* ---------------------------------------------------------------------
   Cards / chart panels
   --------------------------------------------------------------------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 7px; }
.card-title .icon { stroke: var(--text-muted); }
.card-subtitle { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.card-controls { display: flex; align-items: center; gap: 6px; }
.seg-control { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 2px; background: var(--surface-2); }
.seg-btn { padding: 5px 10px; border-radius: 7px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; border: none; background: none; }
.seg-btn.active { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; align-items: stretch; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-main-side { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }

.chart-wrap { position: relative; width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-secondary); font-weight: 550; cursor: pointer; user-select: none; }
.legend-item[data-off="true"] { opacity: 0.4; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-swatch.line { width: 12px; height: 2px; border-radius: 2px; }

.empty-note { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--text-muted); font-size: 12px; margin-top: 10px; }

.chart-empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; color: var(--text-muted); font-size: 12px; padding: 20px; pointer-events: none;
}
.chart-empty-state .icon-lg { stroke: var(--border-strong); }

/* ---------------------------------------------------------------------
   Donut center label (sentiment)
   --------------------------------------------------------------------- */
.donut-wrap { position: relative; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center .val { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.donut-center .lbl { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.sentiment-legend { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.sentiment-row { display: flex; align-items: center; gap: 9px; }
.sentiment-row .sw { width: 10px; height: 10px; border-radius: 3px; }
.sentiment-row .name { font-size: 12px; color: var(--text-secondary); font-weight: 600; flex: 1; }
.sentiment-row .pct { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------
   Platform breakdown bars
   --------------------------------------------------------------------- */
.pbar-row { display: grid; grid-template-columns: 96px 1fr 52px; align-items: center; gap: 10px; padding: 7px 0; }
.pbar-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.pbar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pbar-fill { display: block; height: 100%; border-radius: 4px; transition: width .6s var(--ease); }
.pbar-val { font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ---------------------------------------------------------------------
   Badges — platform, sentiment, status, impact
   --------------------------------------------------------------------- */
.badge-dot { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: #fff; flex-shrink: 0; }
.badge-dot.sm { width: 16px; height: 16px; font-size: 7.5px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; border: 1px solid transparent; }
.chip-sentiment-positive { background: color-mix(in srgb, var(--sentiment-pos) 14%, transparent); color: var(--success-text); }
.chip-sentiment-neutral { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.chip-sentiment-negative { background: color-mix(in srgb, var(--sentiment-neg) 14%, transparent); color: var(--status-critical); }

.chip-status-success { background: color-mix(in srgb, var(--status-good) 14%, transparent); color: var(--success-text); }
.chip-status-partial { background: color-mix(in srgb, var(--status-warning) 20%, transparent); color: var(--warning-text); }
.chip-status-failed { background: color-mix(in srgb, var(--status-critical) 14%, transparent); color: var(--status-critical); }
.chip-status-queued { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

.chip-side-owned { background: color-mix(in srgb, var(--series-1) 14%, transparent); color: var(--series-1); }
.chip-side-mention { background: var(--surface-2); color: var(--text-secondary); border-color: var(--border); }

.velocity-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: var(--status-serious); }
.velocity-flag.viral { color: var(--status-critical); }
.velocity-flag .icon { width: 12px; height: 12px; }

.impact-pill { display: inline-flex; align-items: center; gap: 6px; }
.impact-track { width: 46px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.impact-fill { display: block; height: 100%; border-radius: 3px; }
.impact-num { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; width: 22px; text-align: right; }

.verified-tick { color: var(--series-accent); display: inline-flex; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th {
  text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 0 12px 9px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--text-secondary); }
.th-sort-inner { display: inline-flex; align-items: center; gap: 4px; }
.num-cell .th-sort-inner { justify-content: flex-end; }
.sort-arrow { width: 10px; height: 10px; opacity: .35; transition: opacity .12s var(--ease), transform .12s var(--ease); }
.data-table thead th.sort-active { color: var(--series-accent); }
.data-table thead th.sort-active .sort-arrow { opacity: 1; }
.data-table thead th.sort-asc .sort-arrow { transform: rotate(180deg); }
.data-table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s var(--ease); }
.data-table tbody tr:hover { background: var(--surface-2); }
.num-cell { font-variant-numeric: tabular-nums; text-align: right; }
th.num-cell { text-align: right; }
.post-cell { display: flex; align-items: flex-start; gap: 10px; max-width: 420px; }
.post-cell-text { font-size: 12.5px; color: var(--text-primary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.author-cell { display: flex; align-items: center; gap: 9px; }
.author-meta { min-width: 0; }
.author-name { font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; display: flex; align-items: center; gap: 4px; }
.author-handle { font-size: 11px; color: var(--text-muted); }
.cell-muted { color: var(--text-muted); }
.row-icon-btn { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--text-muted); cursor: pointer; }
.row-icon-btn:hover { background: var(--surface-raised); color: var(--text-primary); }

/* ---------------------------------------------------------------------
   Keyword cloud
   --------------------------------------------------------------------- */
.keyword-cloud { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.keyword-tag {
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-2);
  color: var(--text-secondary); font-weight: 650; white-space: nowrap; cursor: default;
  transition: border-color .12s var(--ease), color .12s var(--ease);
}
.keyword-tag:hover { border-color: var(--series-accent); color: var(--text-primary); }

/* ---------------------------------------------------------------------
   Trending / viral panel cards
   --------------------------------------------------------------------- */
.trend-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.trend-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 13px 14px; background: var(--surface-1); cursor: pointer; transition: border-color .12s var(--ease), box-shadow .12s var(--ease); }
.trend-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.trend-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.trend-card-text { font-size: 12px; color: var(--text-secondary); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 10px; min-height: 34px; }
.trend-spark { width: 100%; height: 34px; }
.trend-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* ---------------------------------------------------------------------
   Owned vs Mentions split
   --------------------------------------------------------------------- */
.split-band { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.split-card { border-radius: var(--radius-lg); padding: 16px 18px; border: 1px solid var(--border); position: relative; overflow: hidden; }
.split-card.owned { background: linear-gradient(160deg, color-mix(in srgb, var(--series-1) 9%, var(--surface-1)), var(--surface-1)); }
.split-card.mentions { background: linear-gradient(160deg, color-mix(in srgb, var(--series-6) 8%, var(--surface-1)), var(--surface-1)); }
.split-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; margin-bottom: 12px; }
.split-head .icon-chip { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; }
.split-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.split-metric-value { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.split-metric-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.split-note { margin-top: 12px; font-size: 11.5px; color: var(--text-secondary); display: flex; gap: 6px; align-items: flex-start; }
.split-note .icon { flex-shrink: 0; margin-top: 1px; stroke: var(--text-muted); }

/* ---------------------------------------------------------------------
   Sources list
   --------------------------------------------------------------------- */
.source-group { margin-bottom: 6px; }
.source-row {
  display: grid; grid-template-columns: 28px 1fr auto auto auto; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-md);
}
.source-row:hover { background: var(--surface-2); }
.source-type { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 7px; border-radius: var(--radius-pill); }
.source-value { font-size: 12.5px; font-weight: 600; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.confidence-pill { display: flex; align-items: center; gap: 6px; }
.confidence-track { width: 50px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.confidence-fill { display: block; height: 100%; border-radius: 3px; background: var(--series-accent); }
.confirm-toggle { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; color: transparent; cursor: pointer; }
.confirm-toggle.checked { background: var(--status-good); border-color: var(--status-good); color: #fff; }

/* ---------------------------------------------------------------------
   Runs table & budget guard
   --------------------------------------------------------------------- */
.guard-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--status-good) 30%, var(--border)); background: color-mix(in srgb, var(--status-good) 8%, var(--surface-1));
  margin-bottom: 16px;
}
.guard-banner .icon-wrap { width: 34px; height: 34px; border-radius: 9px; background: color-mix(in srgb, var(--status-good) 20%, transparent); color: var(--status-good); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.guard-banner-title { font-size: 12.5px; font-weight: 700; }
.guard-banner-sub { font-size: 11.5px; color: var(--text-secondary); }
.guard-banner-spacer { flex: 1; }

/* ---------------------------------------------------------------------
   Modal — Create Query wizard
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .18s var(--ease);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); transform: translateY(10px) scale(0.98); transition: transform .18s var(--ease);
}
.modal-overlay.open .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-raised); z-index: 2; }
.modal-title { font-size: 14.5px; font-weight: 700; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface-raised); }

.wizard-steps { display: flex; align-items: center; gap: 6px; padding: 0 20px; margin-top: 4px; }
.wizard-step { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.wizard-step .num { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 10px; }
.wizard-step.active { color: var(--series-accent); }
.wizard-step.active .num { border-color: var(--series-accent); background: var(--series-accent); color: #fff; }
.wizard-step.done .num { border-color: var(--status-good); background: var(--status-good); color: #fff; }
.wizard-line { width: 20px; height: 1px; background: var(--border-strong); }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 650; color: var(--text-primary); }
.field-optional { color: var(--text-muted); font-weight: 500; }
.text-input, textarea.text-input {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .12s var(--ease);
}
.text-input:focus { border-color: var(--series-accent); }
.field-help { font-size: 11px; color: var(--text-muted); }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-option { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; text-align: center; }
.type-option .icon { stroke: var(--text-secondary); }
.type-option span { font-size: 11.5px; font-weight: 650; }
.type-option.selected { border-color: var(--series-accent); background: color-mix(in srgb, var(--series-accent) 8%, var(--surface-1)); }
.type-option.selected .icon { stroke: var(--series-accent); }

.pill-select-row { display: flex; flex-wrap: wrap; gap: 7px; }
.pill-select { padding: 7px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-secondary); }
.pill-select.selected { background: var(--series-accent); color: #fff; border-color: transparent; }

.resolved-source-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 6px; }
.resolved-source-row:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Command palette
   --------------------------------------------------------------------- */
.cmdk-overlay {
  position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 110; padding: 12vh 24px 24px;
  opacity: 0; pointer-events: none; transition: opacity .15s var(--ease);
}
.cmdk-overlay.open { opacity: 1; pointer-events: auto; }
.cmdk-panel {
  width: 100%; max-width: 580px; max-height: 60vh; display: flex; flex-direction: column;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); transform: translateY(-8px) scale(.98); transition: transform .15s var(--ease);
  overflow: hidden;
}
.cmdk-overlay.open .cmdk-panel { transform: none; }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.cmdk-input-row .icon { stroke: var(--text-muted); flex-shrink: 0; }
.cmdk-input-row input { flex: 1; border: none; background: none; outline: none; font-size: 14.5px; color: var(--text-primary); }
.cmdk-list { overflow-y: auto; padding: 8px; }
.cmdk-group-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 10px 10px 4px; }
.cmdk-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-md);
  cursor: pointer; font-size: 13px; font-weight: 550; color: var(--text-primary);
}
.cmdk-item .cmdk-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-secondary); }
.cmdk-item .cmdk-icon .icon { stroke: currentColor; }
.cmdk-item-meta { flex: 1; min-width: 0; }
.cmdk-item-sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.cmdk-item .kbd { margin-left: auto; }
.cmdk-item.active { background: color-mix(in srgb, var(--brand) 10%, var(--surface-2)); }
.cmdk-item.active .cmdk-icon { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); color: var(--brand); }
.cmdk-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.cmdk-footer { display: flex; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.cmdk-footer-hint { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Post detail drawer
   --------------------------------------------------------------------- */
.drawer-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 105;
  opacity: 0; pointer-events: none; transition: opacity .18s var(--ease);
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw;
  background: var(--surface-raised); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s var(--ease);
}
.drawer-overlay.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-head-title { font-size: 12.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.drawer-post-header { display: flex; gap: 11px; }
.drawer-post-header .badge-dot { width: 40px; height: 40px; font-size: 14px; border-radius: 12px; }
.drawer-author-name { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.drawer-author-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.drawer-post-text { font-size: 13.5px; line-height: 1.6; color: var(--text-primary); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 13px 14px; }
.drawer-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.drawer-metric { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; background: var(--surface-1); }
.drawer-metric-value { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.drawer-metric-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.drawer-section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.drawer-snapshot-chart { height: 130px; position: relative; }
.drawer-snapshot-labels { display: flex; justify-content: space-between; margin-top: 4px; }
.drawer-snapshot-labels span { font-size: 10.5px; color: var(--text-muted); }
.drawer-term-tag { border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px 10px; font-size: 11px; font-weight: 650; color: var(--text-secondary); background: var(--surface-2); }
.drawer-confidence-row { display: flex; align-items: center; gap: 9px; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ---------------------------------------------------------------------
   Sticky first columns (posts table, small-screen scroll aid)
   --------------------------------------------------------------------- */
#table-posts td:nth-child(2), #table-posts th:nth-child(2) {
  position: sticky; left: 0; z-index: 2; background: var(--surface-1);
  box-shadow: 1px 0 0 var(--border);
}
#table-posts tbody tr:hover td:nth-child(2) { background: var(--surface-2); }
#table-posts thead th:nth-child(2) { z-index: 3; }
#table-posts tbody tr { cursor: pointer; }
#table-posts tbody tr:focus-visible { outline-offset: -2px; }

/* ---------------------------------------------------------------------
   Share-of-voice comparison bars
   --------------------------------------------------------------------- */
.sov-compare { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 7px; }
.sov-compare-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 2px; }
.sov-row { display: grid; grid-template-columns: 108px 1fr 34px; align-items: center; gap: 8px; }
.sov-row-name { font-size: 11px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sov-row.subject .sov-row-name { color: var(--text-primary); font-weight: 700; }
.sov-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.sov-fill { display: block; height: 100%; border-radius: 3px; background: var(--border-strong); }
.sov-row.subject .sov-fill { background: var(--brand); }
.sov-row-val { font-size: 11px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ---------------------------------------------------------------------
   API access panel
   --------------------------------------------------------------------- */
.api-key-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.api-key-value { flex: 1; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; color: var(--text-secondary); letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-endpoint-row { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 8px 4px; align-items: center; border-bottom: 1px solid var(--border); }
.api-endpoint-row:last-child { border-bottom: none; }
.api-method { font-size: 10.5px; font-weight: 800; font-family: ui-monospace, "SF Mono", Consolas, monospace; padding: 2px 6px; border-radius: 5px; text-align: center; }
.api-method.get { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--series-1); }
.api-method.post { background: color-mix(in srgb, var(--status-good) 16%, transparent); color: var(--success-text); }
.api-path { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; color: var(--text-primary); }
.api-path-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ---------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 15px; border-radius: var(--radius-md);
  background: var(--surface-raised); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 12.5px; font-weight: 600; animation: toast-in .2s var(--ease); max-width: 340px;
}
.toast .icon { color: var(--status-good); stroke: var(--status-good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.leaving { animation: toast-out .18s var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------------
   Chart.js tooltip theming (external DOM tooltip)
   --------------------------------------------------------------------- */
.cjs-tooltip {
  position: absolute; pointer-events: none; z-index: 20; transform: translate(-50%, -110%);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow-lg); padding: 9px 11px; font-size: 11.5px; opacity: 0; transition: opacity .1s var(--ease);
  min-width: 150px;
}
.cjs-tooltip.show { opacity: 1; }
.cjs-tooltip-title { font-size: 10.5px; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.cjs-tooltip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.cjs-tooltip-key { width: 10px; height: 2px; border-radius: 2px; flex-shrink: 0; }
.cjs-tooltip-key.dot { width: 7px; height: 7px; border-radius: 50%; }
.cjs-tooltip-label { color: var(--text-secondary); font-weight: 550; flex: 1; }
.cjs-tooltip-val { color: var(--text-primary); font-weight: 750; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------
   Mobile nav trigger (hidden on desktop)
   --------------------------------------------------------------------- */
.mobile-nav-trigger { display: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 70; }
.sidebar-backdrop.show { display: block; }

/* ---------------------------------------------------------------------
   Limitations footer note
   --------------------------------------------------------------------- */
.limits-note {
  display: flex; gap: 10px; align-items: flex-start; padding: 13px 15px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface-1); margin-top: 24px; font-size: 11.5px; color: var(--text-secondary);
}
.limits-note .icon { stroke: var(--text-muted); margin-top: 1px; }
.limits-note b { color: var(--text-primary); }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-main-side { grid-template-columns: 1fr; }
  .split-band { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 82vw; max-width: 300px; transform: translateX(-100%);
    transition: transform .22s var(--ease); box-shadow: var(--shadow-lg); z-index: 80;
  }
  .sidebar.open { transform: none; }
  .mobile-nav-trigger { display: flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title-wrap { min-width: 0; overflow: hidden; }
  .topbar-title { max-width: 34vw; }
  .topbar-actions { gap: 6px; }
  .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 60px; }
}
@media (max-width: 640px) {
  .topbar-actions .lbl { display: none; }
  .topbar-actions .field-btn, .topbar-actions .btn { padding: 8px 9px; }
  .topbar-eyebrow { display: none; }
  .freshness-pill { display: none; }
}
@media (max-width: 620px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .split-metrics { grid-template-columns: 1fr; }
  .drawer-metric-grid { grid-template-columns: repeat(2, 1fr); }
  .sov-row { grid-template-columns: 84px 1fr 30px; }
  .cmdk-overlay { padding: 6vh 12px 12px; }
  .cmdk-panel { max-height: 74vh; }
}
@media (max-width: 520px) {
  .drawer { width: 100vw; max-width: 100vw; }
}

@media print {
  .sidebar, .topbar, .tabs, .filter-row, .mobile-nav-trigger { display: none !important; }
}
