/* AI Business Strategy UI — tokens from the validated reference palette (dataviz skill).
   Light/dark selected via prefers-color-scheme; charts read roles, not hex. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;          /* single-measure bars */
  --critical: #d03b3b;
  --good-text: #006300;
  /* ordinal blue ramp, low → high (steps 250/350/450/550/700; validated) */
  --seq-1: #86b6ef; --seq-2: #5598e7; --seq-3: #2a78d6;
  --seq-4: #1c5cab; --seq-5: #0d366b;
  --no-data: #efeeea;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --critical: #e66767;
    --good-text: #0ca30c;
    /* on the dark surface, higher value = lighter = more contrast */
    --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5;
    --seq-4: #86b6ef; --seq-5: #cde2fb;
    --no-data: #242422;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 10px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--ink-2); margin-top: 18px; }
.muted { color: var(--muted); }
.error { color: var(--critical); margin: 8px 0; font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 560px; }

/* Settings: masonry-style card grid so it uses horizontal space instead of
   one long narrow column. Cards flow into 1–3 columns by viewport width. */
.settings-grid { columns: 3 380px; column-gap: 18px; }
.settings-grid > .card { break-inside: avoid; margin: 0 0 18px; }
.settings-grid h2 { margin-top: 0; }
.settings-full { column-span: all; }
/* Admin-only cards are hidden until an admin opens Settings. */
#tab-settings:not(.show-admin) .admin-only { display: none; }

/* ---------- Login ---------- */
#login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
/* Landscape split: brand image on the left, login card on the right.
   Both panels stretch to the same height so it reads as one wide unit. */
.login-split {
  display: flex; align-items: stretch; justify-content: center;
  width: 100%; max-width: 880px;
}
.login-image-panel {
  flex: 1 1 0; min-width: 0; max-width: 500px;
  overflow: hidden;
  border-radius: 10px 0 0 10px;
}
.login-image-panel img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* When the image panel is present, square the card's adjoining corners. */
.login-split.has-image .login-card { border-radius: 0 10px 10px 0; }
.login-card { width: 360px; flex: 0 0 360px; padding: 28px; margin-bottom: 0; }
@media (max-width: 720px) {
  .login-image-panel { display: none; }
  .login-split.has-image .login-card { border-radius: 10px; }
}
.login-sub { color: var(--ink-2); font-size: 12px; margin-top: -4px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 10px; }
.login-card label { font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.hipaa-note { font-size: 11px; color: var(--muted); margin-top: 16px; }

input, select {
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--baseline);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--series); outline-offset: 0; }

.btn {
  border: 1px solid var(--baseline);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}
.btn.primary { background: var(--series); border-color: var(--series); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--grid); }
.btn.sso { width: 100%; margin-top: 8px; }
.btn.small { padding: 3px 8px; font-size: 12px; }

/* ---------- Shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: 0.4px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.tab {
  border: none; background: none; color: var(--ink-2);
  padding: 8px 12px; border-radius: 6px; font: inherit; cursor: pointer;
}
.tab.active { background: var(--grid); color: var(--ink); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.role-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--baseline); color: var(--ink-2);
}
main { max-width: 1180px; margin: 20px auto; padding: 0 20px; }

/* ---------- Sliders ---------- */
.controls-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.weight-total { font-weight: 700; }
.weight-total.bad { color: var(--critical); }
.sliders {
  display: grid;
  /* Wider min so the range input never gets squeezed below its intrinsic width
     (that squeeze is what made rows overlap). Caps at ~3 columns → 3 rows. */
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px 24px; margin-top: 8px;
}
.slider-row { display: grid; grid-template-columns: 118px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.slider-row > span:first-child { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.slider-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
input[type="range"] { accent-color: var(--series); padding: 0; min-width: 0; width: 100%; }

/* ---------- Panel layout ---------- */
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Tile map ---------- */
.tile-map {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  max-width: 640px;
}
.tile {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: var(--no-data);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: default;
}
.tile.has-data { color: #fff; border-color: transparent; }
.tile.light-fill { color: var(--ink); }   /* readable ink on the lightest steps */
.map-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 12px; font-size: 11px; color: var(--ink-2);
}
.map-legend .swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px; margin-right: 4px; vertical-align: -2px;
  border: 1px solid var(--border);
}

/* ---------- Ranking bars ---------- */
.ranking { display: flex; flex-direction: column; gap: 7px; }
.bar-row {
  display: grid; grid-template-columns: 34px 1fr 46px;
  gap: 8px; align-items: center; font-size: 12px;
}
.bar-track { background: none; border-left: 2px solid var(--baseline); height: 14px; }
.bar-fill {
  height: 12px; margin-top: 1px;
  background: var(--series);
  border-radius: 0 4px 4px 0;   /* rounded data-end, flat at baseline */
  min-width: 2px;
  transition: width .25s;
}
.bar-row .val { font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-2); }
.bar-row .code { font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.top-row td { font-weight: 600; }
td .ok { color: var(--good-text); }
td .fail { color: var(--critical); }

/* ---------- Forms / admin ---------- */
.user-form { display: flex; flex-wrap: wrap; gap: 8px; }
.user-form input, .user-form select { flex: 1 1 160px; }
#import-form { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Dialog / data load ---------- */
.ok-msg { color: var(--good-text); margin: 8px 0; font-size: 13px; }
dialog {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 22px; width: 340px;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog label { font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
#dataload-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
#dl-table { flex: 1 1 100%; }
#dl-columns table { font-size: 12px; }
#dl-columns .req { color: var(--critical); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.tooltip .tt-title { font-weight: 700; }
.tooltip .tt-sub { color: var(--ink-2); }

/* ============ Extended components (i18n UI, charts, AI, news) ============ */

/* Categorical palette (dataviz reference) for the 7 dimensions */
:root {
  --cat-1: #2a78d6; --cat-2: #008300; --cat-3: #e87ba4; --cat-4: #eda100;
  --cat-5: #1baf7a; --cat-6: #eb6834; --cat-7: #4a3aa7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cat-1: #3987e5; --cat-2: #008300; --cat-3: #d55181; --cat-4: #c98500;
    --cat-5: #199e70; --cat-6: #d95926; --cat-7: #9085e9;
  }
}

.linkbtn {
  background: none; border: none; color: var(--series);
  cursor: pointer; font: inherit; padding: 0;
}
.lang-switch { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }
.row-gap { display: flex; gap: 8px; align-items: center; }
.small { font-size: 12px; }
.notice {
  background: var(--grid); border-radius: 8px; padding: 12px;
  color: var(--ink-2); font-size: 13px; margin: 8px 0;
}
hr { border: none; border-top: 1px solid var(--grid); margin: 16px 0; }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; }

/* KPI tiles */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
}
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Segmented toggle */
.seg { display: inline-flex; border: 1px solid var(--baseline); border-radius: 7px; overflow: hidden; }
.seg-btn {
  border: none; background: var(--surface); color: var(--ink-2);
  padding: 5px 12px; font: inherit; font-size: 12px; cursor: pointer;
}
.seg-btn.active { background: var(--series); color: #fff; }

/* Geographic map */
#geo-map-wrap { width: 100%; }
#geo-map { width: 100%; height: auto; display: block; }
.geo-state {
  stroke: var(--surface); stroke-width: 0.8; transition: opacity .12s;
}
.geo-state:hover { opacity: 0.82; }
.geo-state.light-fill { stroke: var(--baseline); }

/* Contribution stacked bars */
.contrib { display: flex; flex-direction: column; gap: 7px; }
.contrib-row { display: grid; grid-template-columns: 34px 1fr 46px; gap: 8px; align-items: center; font-size: 12px; }
.contrib-track {
  display: flex; height: 16px; background: var(--grid);
  border-radius: 4px; overflow: hidden;
}
.contrib-seg { height: 100%; border-right: 2px solid var(--surface); }
.contrib-row .code { font-weight: 600; }
.contrib-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.cat-legend, .map-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 11px; color: var(--ink-2); }
.cat-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }

/* Scatter */
#scatter-wrap { width: 100%; }
#scatter { width: 100%; height: auto; }
.axis-line { stroke: var(--baseline); stroke-width: 1.5; }
.axis-tick { fill: var(--muted); font-size: 11px; }
.axis-tick.mid { text-anchor: middle; }
.axis-tick.end { text-anchor: end; }
.axis-title { fill: var(--ink-2); font-size: 12px; }
.axis-title.mid { text-anchor: middle; }
.dot { fill: var(--series); stroke: var(--surface); stroke-width: 1.5; }
.dot:hover { fill: var(--seq-4); }
.dot-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }

/* AI chat */
.ai-chat {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 40px;               /* grows downward with content; page scrolls */
  padding: 4px 2px; margin: 8px 0;
}
.ai-msg {
  max-width: 82%; padding: 10px 13px; border-radius: 12px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap;
}
.ai-user { align-self: flex-end; background: var(--series); color: #fff; border-bottom-right-radius: 3px; }
.ai-assistant { align-self: flex-start; background: var(--grid); color: var(--ink); border-bottom-left-radius: 3px; }
.ai-msg.pending { opacity: 0.6; font-style: italic; }
.ai-msg.ai-error { background: transparent; color: var(--critical); border: 1px solid var(--critical); }
.ai-form { display: flex; gap: 8px; align-items: flex-end; }
.ai-form textarea {
  flex: 1; resize: vertical; min-height: 42px; background: var(--page);
  color: var(--ink); border: 1px solid var(--baseline); border-radius: 6px;
  padding: 8px 10px; font: inherit;
}
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--baseline); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.chip:hover { background: var(--grid); }

/* News */
.news-list { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.news-pager { display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-top: 16px; }
.news-pager .btn[disabled] { opacity: 0.45; cursor: default; }
.news-item { border-bottom: 1px solid var(--grid); padding-bottom: 12px; }
.news-item h3 { margin: 0 0 3px; font-size: 15px; }
.news-item h3 a { color: var(--series); text-decoration: none; }
.news-item h3 a:hover { text-decoration: underline; }
.news-meta { font-size: 12px; color: var(--muted); }
.news-tags { color: var(--series); font-weight: 600; }
.news-summary { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }

/* Suggested feeds + relevance stats */
.suggestions {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px; margin: 10px 0 18px;
}
.sugg-card {
  border: 1px solid var(--border); border-radius: 9px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px; background: var(--page);
}
.sugg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sugg-name { font-weight: 600; font-size: 13px; }
.sugg-cat {
  font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-2); border: 1px solid var(--baseline); border-radius: 999px;
  padding: 1px 7px; white-space: nowrap;
}
.sugg-desc { font-size: 12px; color: var(--ink-2); margin: 0; flex: 1; }
.sugg-card .btn { align-self: flex-start; }
.btn.small.primary { background: var(--series); border-color: var(--series); color: #fff; }

.rel-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.rel-bar {
  width: 70px; height: 8px; background: var(--grid);
  border-radius: 4px; overflow: hidden;
}
.rel-fill { height: 100%; background: var(--series); border-radius: 4px; }

/* Panel actions, trends, movers, feed flags */
.panel-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }

#trend-wrap { width: 100%; }
#trend-chart { width: 100%; height: auto; }
.trend-line { fill: none; stroke-width: 2; }
.trend-dot { stroke: var(--surface); stroke-width: 1; }

.movers { display: flex; flex-direction: column; gap: 6px; }
.mover-row {
  display: grid; grid-template-columns: 34px 60px 1fr; gap: 8px;
  align-items: center; font-size: 12px;
}
.mover-row .code { font-weight: 600; }
.mover-row .val { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mover-delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.mover-delta.up { color: var(--good-text); }
.mover-delta.down { color: var(--critical); }
.mover-delta.flat { color: var(--muted); }

.flag {
  font-size: 10px; padding: 1px 7px; border-radius: 999px;
  vertical-align: 1px; white-space: nowrap;
}
.flag-low { background: rgba(208,59,59,.14); color: var(--critical); }
.flag-new { background: var(--grid); color: var(--muted); }

/* Alerts bell, watchlist stars, wide dialogs, compare, state detail */
.bell { position: relative; font-size: 15px; padding: 4px 8px; }
.badge {
  position: absolute; top: -2px; right: -2px; background: var(--critical);
  color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 3px;
}
.star {
  background: none; border: none; cursor: pointer; font-size: 15px;
  color: var(--muted); padding: 0 2px; line-height: 1;
}
.star.on { color: var(--cat-4); }
.state-link { font-size: 13px; text-align: left; }
.fail-text { color: var(--critical); }

.wide-dialog { width: min(760px, 94vw); max-height: 88vh; overflow-y: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.dialog-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 12px; }
.dtab {
  border: none; background: none; color: var(--ink-2); cursor: pointer;
  padding: 7px 12px; font: inherit; border-bottom: 2px solid transparent;
}
.dtab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--series); }
.dtab-body { min-height: 60px; }
#state-overview .kv { margin-top: 12px; }

.compare-picker { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 14px; }
.compare-picker label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }

.alerts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.alert-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.alert-row .code { font-weight: 600; min-width: 44px; }
.alert-row .code.watched { color: var(--cat-4); }

/* AI bot persona + news relevance tiers */
.ai-bot-header { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.ai-bot-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border); background: var(--grid); }
.ai-bot-emoji { font-size: 64px; line-height: 1; }
.ai-bot-name { font-weight: 700; font-size: 17px; }
.ai-bot-header p { margin: 2px 0 0; }

.ai-turn { display: flex; align-items: flex-start; gap: 10px; align-self: flex-start; max-width: 92%; }
.ai-turn .ai-msg { max-width: none; }
.ai-turn-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; margin-top: 2px; border: 1px solid var(--border); }
.ai-turn-avatar.emoji { font-size: 34px; border: none; width: auto; text-align: center; }

.tier { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  vertical-align: 1px; text-transform: uppercase; letter-spacing: .3px; }
.tier-must_read { background: rgba(208,59,59,.15); color: var(--critical); }
.tier-important_future { background: rgba(237,161,0,.18); color: #a86f00; }
.tier-relevant { background: var(--grid); color: var(--ink-2); }
@media (prefers-color-scheme: dark) { .tier-important_future { color: #eda100; } }

.avatar-row { display: flex; align-items: center; gap: 14px; margin: 10px 0; flex-wrap: wrap; }
.avatar-preview { width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border); }
/* Branding previews in Settings */
.logo-preview { height: 48px; max-width: 220px; object-fit: contain;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; background: var(--page); }
.loginimg-preview { width: 180px; height: 100px; object-fit: cover;
  border: 1px solid var(--border); border-radius: 8px; }
h3.sub { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 14px 0 2px; }
/* App logo in the header (replaces the text brand when set) */
.app-logo { height: 30px; max-width: 200px; object-fit: contain; }
/* Login screen branding — the hero image now fills the left split panel
   (see .login-image-panel above); the logo sits atop the login card. */
.login-logo { display: block; max-width: 100%; max-height: 88px; object-fit: contain;
  margin: 0 auto 20px; }
#set-company-context, #set-relevance-prompt { font: inherit; width: 100%;
  background: var(--page); color: var(--ink); border: 1px solid var(--baseline);
  border-radius: 6px; padding: 8px 10px; resize: vertical; }

/* AI conversations layout + markdown formatting */
.ai-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .ai-layout { grid-template-columns: 1fr; } }
.ai-sidebar h3 { margin: 14px 0 6px; }
#ai-new-chat { width: 100%; }
.ai-convos { display: flex; flex-direction: column; gap: 4px; max-height: 460px; overflow-y: auto; }
.convo-row { display: flex; align-items: center; gap: 4px; border-radius: 6px; }
.convo-row.active { background: var(--grid); }
.convo-title {
  flex: 1; text-align: left; background: none; border: none; color: var(--ink);
  font: inherit; font-size: 13px; padding: 7px 8px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.convo-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px 8px; font-size: 12px; border-radius: 6px;
}
.convo-del:hover { color: var(--critical); }

/* Markdown inside assistant bubbles */
.ai-assistant h4 { margin: 8px 0 4px; font-size: 14px; color: var(--ink); }
.ai-assistant p { margin: 6px 0; }
.ai-assistant ul, .ai-assistant ol { margin: 6px 0; padding-left: 20px; }
.ai-assistant li { margin: 2px 0; }
.ai-assistant code {
  background: var(--page); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 4px; font-family: ui-monospace, monospace; font-size: 12px;
}
.ai-assistant > *:first-child { margin-top: 0; }
.ai-assistant > *:last-child { margin-bottom: 0; }

/* Info (ⓘ) affordance + explanatory tooltip */
.info-i {
  cursor: help; color: var(--muted); font-size: 0.85em; vertical-align: 1px;
  opacity: 0.7; user-select: none;
}
.info-i:hover, .info-i:focus { color: var(--series); opacity: 1; outline: none; }
th .info-i { text-transform: none; }
.tooltip { max-width: 320px; }
/* Info (ⓘ) tooltips carry richer business explanations — give them more room. */
.tooltip:has(.tt-explain) { max-width: 400px; }
.tt-explain { color: var(--ink-2); font-size: 12px; line-height: 1.5; margin-top: 4px; }
.tt-explain b { color: var(--ink); font-weight: 600; }
.tt-explain p { margin: 5px 0 0; }
.tt-explain b { color: var(--ink); font-weight: 600; }

/* News read tracking */
.nav-badge { position: static; display: inline-block; margin-left: 2px; }
.unread-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--series); margin-right: 6px; vertical-align: 1px;
}
.news-item.read h3 a, .news-item.read h3 span { color: var(--ink-2); font-weight: 400; }
.news-item.unread h3 { font-weight: 700; }
#news-summary-body { max-width: none; }

/* Outreach tab */
.outreach-controls { margin: 10px 0 14px; }
#outreach-segment { min-width: 220px; }
#outreach-output .ai-msg { max-width: none; align-self: stretch; }

/* Export-PDF buttons on AI documents */
.pdf-btn { margin-top: 10px; }

/* Digest preview + ROI/digest forms */
#roi-form, #digest-form { display: flex; flex-direction: column; gap: 10px; }
#roi-form label, #digest-form label { font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.digest-preview {
  white-space: pre-wrap; background: var(--page); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px; font-size: 12px; max-height: 300px; overflow-y: auto;
}

/* Chart help lines + Methodology tab */
.chart-help { font-size: 12px; margin: -2px 0 10px; }
.methodology h3 { margin: 20px 0 6px; font-size: 15px; color: var(--ink); }
.methodology h3:first-child { margin-top: 4px; }
.method-kv { grid-template-columns: 210px 1fr; gap: 6px 16px; margin: 6px 0 4px; }
.method-kv dt { color: var(--ink); font-weight: 600; }
.method-kv dd { color: var(--ink-2); }
.methodology sub { font-size: 0.75em; }
@media (max-width: 640px) { .method-kv { grid-template-columns: 1fr; } .method-kv dd { margin-bottom: 8px; } }

/* Untapped opportunity chart */
.untapped-row { grid-template-columns: 34px 1fr 210px; }
.untapped-fill { height: 16px; background: var(--seq-3); border-radius: 0 4px 4px 0; min-width: 2px; }
.untapped-fill.untapped-white { background: var(--cat-6); }   /* white space = attention color */

/* Lead-demand funnel (pool → captured → white-space) */
.lead-summary { margin-bottom: 14px; }
.lead-stack { display: flex; height: 18px; background: var(--grid);
  border-radius: 4px; overflow: hidden; }
.lead-seg { height: 100%; }
.lead-seg + .lead-seg { border-left: 1px solid var(--surface); }
.seg-comp { background: var(--cat-6); }    /* captured by competitors */
.seg-own  { background: var(--cat-1); }    /* our real leads */
.seg-white { background: var(--cat-2); }   /* winnable white-space */
.lead-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--ink-2); }
.lead-legend-item { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.lead-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lead-dot.seg-pool { background: var(--ink-2); }
.lead-note { margin-top: 8px; }
.lead-est-mark { color: var(--cat-6); font-weight: 700; margin-left: 1px; }
.untapped-val { text-align: right; white-space: nowrap; }
.tt-line { font-size: 12px; }

/* News relevance "why" caption */
.news-why { font-size: 12px; color: var(--ink-2); font-style: italic; margin: 4px 0 0; }

/* News share action */
.news-actions { margin-top: 8px; }

/* Data-freshness status pill */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--baseline); border-radius: 999px;
  color: var(--ink-2); font: inherit; font-size: 12px; padding: 3px 10px; cursor: pointer;
}
.status-pill:hover { background: var(--grid); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--good-text); }
.status-dot.warn { background: var(--cat-4); }
.status-dot.none { background: var(--muted); }
@media (max-width: 720px) { #status-label { display: none; } }
