/* =================================================================
   Life Interiors · NPS Dashboard
   Aesthetic: warm minimal — cream surfaces, deep slate ink,
   single muted terracotta accent. Bootstrap is our skeleton; we
   reskin it lightly.
   ================================================================= */

:root {
  /* warm neutrals */
  --bg:        #f6f3ee;
  --surface:   #ffffff;
  --surface-2: #fbf9f5;
  --line:      #e8e3da;
  --line-2:    #efeae0;
  --ink:       #1f1d1a;
  --ink-2:     #4a4642;
  --muted:     #8a847b;
  --muted-2:   #b5afa3;

  /* nps semantic colors */
  --prom:      #2f8a5f;
  --prom-bg:   #def0e5;
  --pass:      #b5872c;
  --pass-bg:   #f4e9cf;
  --detr:      #b8503a;
  --detr-bg:   #f3d8cd;

  /* accent */
  --accent:    #c47a5c;
  --accent-2:  #a55f44;

  /* sizing */
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 0 rgba(31,29,26,0.04), 0 8px 24px -16px rgba(31,29,26,0.10);
}

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--ink); }
body {
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  min-height: 100vh;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.dot { color: var(--muted-2); margin: 0 .35rem; }

/* tabular numerals everywhere numbers matter */
.score-value, .stat .val, .th-pct, .th-nps, .nps-num,
#tvScore, #tvClock, .score-pill,
.theme-row .pct, .theme-row .nps {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ============= TOPBAR ============= */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; letter-spacing: 0.05em;
}
.brand-title { font-weight: 600; line-height: 1; }
.brand-sub   { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 4px; }

.view-switch {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.vs-btn {
  border: 0; background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.vs-btn:hover { color: var(--ink); }
.vs-btn.active { background: var(--ink); color: var(--bg); }
.vs-btn i { font-size: 14px; }

.topbar-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}
.daterange {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 6px 4px 10px;
}
.daterange label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  margin: 0;
}
.daterange input[type="date"] {
  border: 0; background: transparent;
  font-size: 13px; color: var(--ink);
  padding: 4px 2px; min-width: 120px;
  height: 28px;
}
.daterange input:focus { outline: none; box-shadow: none; }
.daterange .btn { font-size: 12px; padding: 4px 10px; }
.topbar-meta {
  padding: 0 24px 10px;
  color: var(--muted);
  font-size: 12px;
}

/* ============= GRID ============= */
main.view { padding: 20px 24px 60px; }
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .col-side { order: 2; }
}

/* ============= CARDS ============= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card-eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 500;
}
.card-title {
  font-size: 18px; font-weight: 600;
  margin: 4px 0 0;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.card-head.sticky { margin-bottom: 8px; }
.card-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ============= HERO ============= */
.hero-card { padding-bottom: 12px; }
.hero-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: end;
  margin-top: 6px;
}
.hero-score .score-display {
  display: flex; align-items: baseline; gap: 16px;
}
.score-value {
  font-family: "Instrument Serif", "DM Sans", serif;
  font-size: 92px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.score-delta {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600; font-size: 13px;
}
.score-delta.up   { color: var(--prom); background: var(--prom-bg); }
.score-delta.down { color: var(--detr); background: var(--detr-bg); }
.score-delta.flat { color: var(--muted); background: var(--line-2); }
.score-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.score-meta strong { color: var(--ink-2); font-weight: 600; }

.hero-mix { display: flex; flex-direction: column; gap: 10px; }
.mixbar {
  display: flex; width: 100%;
  height: 14px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.mixbar .seg { display: block; height: 100%; transition: width .35s ease; }
.seg-prom { background: var(--prom); }
.seg-pass { background: var(--pass); }
.seg-detr { background: var(--detr); }

.mix-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.mix-legend strong { color: var(--ink); margin-left: 4px; font-weight: 600; }

.dot-prom, .dot-pass, .dot-detr {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.dot-prom { background: var(--prom); }
.dot-pass { background: var(--pass); }
.dot-detr { background: var(--detr); }

/* ============= CHART ============= */
.chart-wrap {
  margin-top: 22px;
  border-top: 1px solid var(--line-2);
  padding-top: 16px;
}
.chart-canvas {
  position: relative;
  height: 240px;
  width: 100%;
}
.chart-canvas canvas { display: block; }
.chart-tools {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.chart-tools-right { color: var(--muted); }
.seg-control {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px; padding: 2px;
}
.seg-control.sm { font-size: 12px; }
.seg-control button {
  border: 0; background: transparent;
  padding: 4px 10px; font-size: 12px;
  border-radius: 6px; cursor: pointer;
  color: var(--muted);
}
.seg-control button.active { background: var(--ink); color: var(--bg); }
.seg-control button:hover:not(.active) { color: var(--ink); }

/* ============= STATS ROW ============= */
.stat-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
}
.stat .lab {
  color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; align-items: center;
}
.stat .val {
  font-size: 22px; font-weight: 600;
  margin-top: 4px; line-height: 1.1;
}
@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .hero-row { grid-template-columns: 1fr; gap: 16px; }
  .score-value { font-size: 72px; }
}

/* ============= THEMES TABLE ============= */
.themes-table-wrap { overflow-x: auto; }
.themes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.themes-table thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.themes-table .th-pct, .themes-table .th-nps { text-align: right; width: 110px; }
.themes-table .th-cmp { width: 240px; }
.themes-table .th-trend { width: 110px; }
.themes-table tbody tr {
  border-bottom: 1px solid var(--line-2);
  transition: background .15s;
}
.themes-table tbody tr:hover { background: var(--surface-2); }
.themes-table tbody td { padding: 14px 12px; vertical-align: middle; }
.theme-row .name {
  font-weight: 500;
}
.theme-row .name small {
  display: block; color: var(--muted);
  font-size: 11px; font-weight: 400; margin-top: 2px;
}
.theme-row .pct, .theme-row .nps { text-align: right; font-weight: 600; }
.theme-row .nps .delta {
  display: inline-block; margin-left: 4px;
  font-size: 11px; color: var(--muted);
}
.theme-row .delta.up   { color: var(--prom); }
.theme-row .delta.down { color: var(--detr); }

.cmp-bar {
  position: relative;
  height: 8px; background: var(--line-2);
  border-radius: 4px;
}
.cmp-bar .center {
  position: absolute; top: -3px; bottom: -3px;
  width: 1px; background: var(--muted-2);
}
.cmp-bar .center::after {
  content: attr(data-label);
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--muted);
  white-space: nowrap;
}
.cmp-bar .fill {
  position: absolute; top: 0; bottom: 0;
  border-radius: 4px;
}
.cmp-bar .fill.pos { background: rgba(47,138,95,0.5); }
.cmp-bar .fill.neg { background: rgba(184,80,58,0.5); }

.trend-mini {
  height: 24px; width: 100%;
  display: block;
}

.row-actions { text-align: right; }
.row-actions .btn-icon {
  background: transparent; border: 0;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.row-actions .btn-icon:hover { background: var(--line-2); color: var(--ink); }

.themes-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px;
}
.themes-foot .btn-link { color: var(--accent-2); text-decoration: none; font-weight: 500; }
.themes-foot .btn-link:hover { color: var(--accent); }
.themes-foot-note { color: var(--muted); font-size: 12px; }

/* ============= RESPONSE FEED ============= */
.responses-card { padding: 16px; position: sticky; top: 96px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.responses-card .card-head { padding: 6px 8px 8px; margin-bottom: 6px; }
.response-search {
  position: relative; margin: 0 4px 8px;
}
.response-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
}
.response-search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  color: var(--ink);
}
.response-search input:focus { outline: none; border-color: var(--ink-2); }

.response-list {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 0 4px;
}
.response-list::-webkit-scrollbar { width: 8px; }
.response-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.response-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line-2);
}
.response-item:last-child { border-bottom: 0; }
.score-pill {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: 15px;
  border: 1.5px solid;
}
.score-pill.prom { background: var(--prom-bg); color: var(--prom); border-color: rgba(47,138,95,0.35); }
.score-pill.pass { background: var(--pass-bg); color: var(--pass); border-color: rgba(181,135,44,0.35); }
.score-pill.detr { background: var(--detr-bg); color: var(--detr); border-color: rgba(184,80,58,0.35); }

.response-body .text {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.45;
}
.response-body .text.no-comment { color: var(--muted); font-style: italic; }
.response-body .text mark {
  background: rgba(196,122,92,0.18);
  color: inherit; padding: 0 2px;
}
.response-body .meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px;
  gap: 8px;
}
.response-body .who {
  color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.response-body .when {
  color: var(--muted-2); font-size: 11px; white-space: nowrap;
}
.theme-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.theme-tag {
  display: inline-block;
  font-size: 10px; padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ============= FULL RESPONSES VIEW ============= */
.full-response-table-wrap {
  border-top: 1px solid var(--line-2);
  margin-top: 8px;
}
.full-response-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.full-response-table thead th {
  text-align: left; color: var(--muted);
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.full-response-table tbody td {
  padding: 12px; border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}
.full-response-table .col-score { width: 60px; }
.full-response-table .col-cust  { width: 220px; }
.full-response-table .col-theme { width: 200px; }
.full-response-table .col-when  { width: 140px; white-space: nowrap; color: var(--muted); }
.full-response-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px;
}

/* ============= THEME EDITOR ============= */
.theme-editor-list { display: flex; flex-direction: column; gap: 12px; }
.theme-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: var(--surface-2);
}
.theme-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.theme-editor-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.theme-editor-head .stats {
  color: var(--muted); font-size: 12px;
  display: flex; gap: 14px;
}
.theme-editor-head .stats b { color: var(--ink); }
.kw-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kw {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 4px 4px 10px;
  font-size: 12px; color: var(--ink-2);
}
.kw button {
  background: transparent; border: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.kw button:hover { background: var(--line-2); color: var(--detr); }
.kw-add {
  display: inline-flex; gap: 6px;
}
.kw-add input {
  border: 1px dashed var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  min-width: 140px;
}
.kw-add input:focus { outline: none; border-style: solid; border-color: var(--ink-2); }
.editor-actions {
  display: flex; gap: 6px;
}

/* ============= TV VIEW ============= */
body[data-view="tv"] { background: #0b0d10; }
body[data-view="tv"] .topbar { display: none; }
.view-tv { padding: 0 !important; }
.tv-stage {
  --tv-ink: #f3f0ea;
  --tv-muted: #6f7782;
  --tv-line: #1c2026;
  --tv-surface: #11141a;
  --tv-surface-2: #161a21;
  background: #0b0d10;
  color: var(--tv-ink);
  min-height: 100vh;
  padding: 32px 40px;
  font-family: "DM Sans", -apple-system, sans-serif;
}
.tv-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.tv-brand { display: flex; align-items: center; gap: 16px; }
.tv-brand .brand-mark { background: var(--tv-ink); color: #0b0d10; width: 44px; height: 44px; font-size: 16px; }
.tv-brand-title { font-size: 18px; font-weight: 600; letter-spacing: 0.02em; }
.tv-brand-sub { color: var(--tv-muted); font-size: 13px; margin-top: 2px; }
.tv-clock {
  font-size: 24px; font-weight: 500;
  color: var(--tv-ink);
  font-variant-numeric: tabular-nums;
}

.tv-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 28px;
  height: calc(100vh - 120px);
}
.tv-hero, .tv-feed {
  background: var(--tv-surface);
  border: 1px solid var(--tv-line);
  border-radius: 16px;
  padding: 28px 32px;
  display: flex; flex-direction: column;
  min-height: 0;
}
.tv-eyebrow {
  color: var(--tv-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 500;
}
.tv-score {
  display: flex; align-items: baseline; gap: 20px;
  margin-top: 10px;
}
#tvScore {
  font-family: "Instrument Serif", "DM Sans", serif;
  font-size: clamp(120px, 16vw, 220px);
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--tv-ink);
}
.tv-delta {
  font-size: 22px; font-weight: 500;
  padding: 6px 14px; border-radius: 999px;
}
.tv-delta.up { color: #6dd4a3; background: rgba(109,212,163,0.12); }
.tv-delta.down { color: #ff8a6e; background: rgba(255,138,110,0.12); }
.tv-delta.flat { color: var(--tv-muted); background: rgba(255,255,255,0.05); }

.tv-mix { margin-top: 16px; }
.tv-mixbar {
  display: flex; height: 18px; border-radius: 999px;
  background: var(--tv-line); overflow: hidden;
}
.tv-mix-legend {
  display: flex; gap: 28px; margin-top: 14px;
  color: var(--tv-muted); font-size: 15px;
}
.tv-mix-legend b { color: var(--tv-ink); font-weight: 600; margin-left: 6px; }

.tv-trend-wrap {
  flex: 1; min-height: 0;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--tv-line);
  position: relative;
  display: flex;
}
.tv-trend-canvas {
  position: relative;
  flex: 1;
  min-height: 180px;
  max-height: 240px;
  width: 100%;
}
.tv-trend-canvas canvas { display: block; }
.tv-trend-wrap canvas { max-height: 240px; }

.tv-themes {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--tv-line);
}
.tv-theme {
  background: var(--tv-surface-2);
  border-radius: 10px;
  padding: 14px;
}
.tv-theme .name { font-size: 12px; color: var(--tv-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tv-theme .nps  { font-size: 28px; font-weight: 600; margin-top: 6px; font-family: "Instrument Serif", serif; }
.tv-theme .nps.up { color: #6dd4a3; }
.tv-theme .nps.down { color: #ff8a6e; }
.tv-theme .pct { color: var(--tv-muted); font-size: 12px; margin-top: 2px; }

.tv-feed-head { display: flex; justify-content: space-between; }
.tv-feed-head .muted { color: var(--tv-muted); font-size: 12px; }
.tv-feed-list {
  flex: 1; overflow: hidden;
  margin-top: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.tv-feed-item {
  display: grid; grid-template-columns: 48px 1fr; gap: 14px;
  padding: 16px; background: var(--tv-surface-2);
  border-radius: 12px;
  animation: tvIn .45s cubic-bezier(.22,.61,.36,1) both;
}
.tv-feed-item .pill {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: 18px;
  border: 1.5px solid;
}
.tv-feed-item .pill.prom { background: rgba(109,212,163,0.1); border-color: rgba(109,212,163,0.5); color: #6dd4a3; }
.tv-feed-item .pill.pass { background: rgba(229,194,108,0.1); border-color: rgba(229,194,108,0.5); color: #e5c26c; }
.tv-feed-item .pill.detr { background: rgba(255,138,110,0.1); border-color: rgba(255,138,110,0.5); color: #ff8a6e; }
.tv-feed-item .text { font-size: 16px; line-height: 1.4; color: var(--tv-ink); }
.tv-feed-item .text.no-comment { color: var(--tv-muted); font-style: italic; }
.tv-feed-item .meta {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: 12px; color: var(--tv-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
@keyframes tvIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============= TOASTS ============= */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 1080;
  display: flex; flex-direction: column; gap: 10px;
}
.toast-msg {
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 32px -12px rgba(0,0,0,0.4);
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bootstrap overrides */
.btn-dark { background: var(--ink); border-color: var(--ink); }
.btn-dark:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-outline-secondary { color: var(--ink-2); border-color: var(--line); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.form-control:focus { border-color: var(--ink-2); box-shadow: none; }
.modal-content { border-radius: var(--radius); border: 1px solid var(--line); }
.dropdown-menu { border-radius: 10px; border-color: var(--line); font-size: 13px; }
.dropdown-item.active, .dropdown-item:active { background: var(--ink); color: var(--bg); }
.dropdown-item .check {
  display: inline-block; width: 14px; color: var(--accent-2);
}

/* =====================================================================
   DARK MODE
   Light-mode colour decisions stand — dark mode is a desaturated, warm-
   leaning translation, with brighter semantic colours so the NPS pills
   still pop against the deeper surfaces.
   ===================================================================== */
body[data-mode="dark"] {
  --bg:        #14161a;
  --surface:   #1c1f25;
  --surface-2: #22262d;
  --line:      #2e333b;
  --line-2:    #262a31;
  --ink:       #f1ede5;
  --ink-2:     #c9c3b6;
  --muted:     #8a847b;
  --muted-2:   #5a554d;

  --prom:      #6dd4a3;
  --prom-bg:   rgba(109,212,163,0.13);
  --pass:      #e5c26c;
  --pass-bg:   rgba(229,194,108,0.13);
  --detr:      #ff8a6e;
  --detr-bg:   rgba(255,138,110,0.13);

  --accent:    #d89878;
  --accent-2: #c47a5c;

  --shadow:    0 1px 0 rgba(0,0,0,0.3), 0 8px 24px -16px rgba(0,0,0,0.5);
}
body[data-mode="dark"] .topbar { background: var(--surface); border-bottom-color: var(--line); }
body[data-mode="dark"] .brand-mark { background: var(--ink); color: var(--surface); }
body[data-mode="dark"] .vs-btn.active { background: var(--ink); color: var(--surface); }
body[data-mode="dark"] .form-control,
body[data-mode="dark"] .daterange input[type="date"] {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  color-scheme: dark;
}
body[data-mode="dark"] .daterange { background: var(--surface-2); border-color: var(--line); }
body[data-mode="dark"] .seg-control { background: var(--surface-2); border-color: var(--line); }
body[data-mode="dark"] .seg-control button { color: var(--muted); }
body[data-mode="dark"] .seg-control button.active { background: var(--ink); color: var(--surface); }
body[data-mode="dark"] .seg-control button:hover:not(.active) { color: var(--ink); }
body[data-mode="dark"] .btn-dark { background: var(--ink); border-color: var(--ink); color: var(--surface); }
body[data-mode="dark"] .btn-dark:hover { background: var(--ink-2); border-color: var(--ink-2); color: var(--surface); }
body[data-mode="dark"] .btn-outline-secondary {
  background: var(--surface); color: var(--ink-2); border-color: var(--line);
}
body[data-mode="dark"] .btn-outline-secondary:hover {
  background: var(--surface-2); color: var(--ink); border-color: var(--line);
}
body[data-mode="dark"] .score-delta.flat { background: var(--line-2); color: var(--muted); }

/* mix bar + cmp bar adapt via vars; ensure base track stays distinguishable */
body[data-mode="dark"] .mixbar,
body[data-mode="dark"] .tv-mixbar { background: var(--line); }
body[data-mode="dark"] .cmp-bar { background: var(--line); }
body[data-mode="dark"] .cmp-bar .fill.pos { background: rgba(109,212,163,0.45); }
body[data-mode="dark"] .cmp-bar .fill.neg { background: rgba(255,138,110,0.45); }

/* themes table hover & active */
body[data-mode="dark"] .themes-table tbody tr:hover { background: var(--surface-2); }
body[data-mode="dark"] .themes-table tbody tr.theme-row.active {
  background: linear-gradient(90deg, rgba(216,152,120,0.12), rgba(216,152,120,0.02));
}
body[data-mode="dark"] .themes-table tbody tr.theme-row.active .name { color: var(--accent); }

/* response sidebar */
body[data-mode="dark"] .response-search input { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
body[data-mode="dark"] .response-list::-webkit-scrollbar-thumb { background: var(--line); }
body[data-mode="dark"] .response-body .text mark { background: rgba(216,152,120,0.22); color: var(--ink); }

/* score pills (need explicit override since they use bg vars) */
body[data-mode="dark"] .score-pill.prom { border-color: rgba(109,212,163,0.45); }
body[data-mode="dark"] .score-pill.pass { border-color: rgba(229,194,108,0.45); }
body[data-mode="dark"] .score-pill.detr { border-color: rgba(255,138,110,0.45); }

/* active theme chip uses accent colours; recolour for darker surface */
body[data-mode="dark"] .active-theme-chip {
  background: rgba(216,152,120,0.12);
  border-color: rgba(216,152,120,0.35);
  color: var(--accent);
}
body[data-mode="dark"] .active-theme-chip button { color: var(--accent); }
body[data-mode="dark"] .active-theme-chip button:hover { background: rgba(216,152,120,0.18); }

/* theme editor / keyword chips */
body[data-mode="dark"] .theme-editor { background: var(--surface-2); border-color: var(--line); }
body[data-mode="dark"] .kw { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
body[data-mode="dark"] .kw-add input { border-color: var(--line); color: var(--ink); }

/* summary card */
body[data-mode="dark"] .summary-empty { background: var(--surface-2); border-color: var(--line); }
body[data-mode="dark"] .summary-section li { background: var(--surface-2); border-color: var(--line-2); }
body[data-mode="dark"] .summary-narrative {
  background: linear-gradient(180deg, rgba(216,152,120,0.10), rgba(216,152,120,0.02));
  border-color: rgba(216,152,120,0.25);
  color: var(--ink-2);
}
body[data-mode="dark"] .summary-loading { background: var(--surface-2); border-color: var(--line); }
body[data-mode="dark"] .summary-loading .spinner { border-color: var(--line); border-top-color: var(--accent); }

/* modal */
body[data-mode="dark"] .modal-content { background: var(--surface); color: var(--ink); border-color: var(--line); }
body[data-mode="dark"] .modal-header,
body[data-mode="dark"] .modal-footer { border-color: var(--line); }
body[data-mode="dark"] .btn-close { filter: invert(0.92); }
body[data-mode="dark"] .form-label { color: var(--ink-2); }

/* dropdowns */
body[data-mode="dark"] .dropdown-menu {
  background: var(--surface); border-color: var(--line); color: var(--ink-2);
}
body[data-mode="dark"] .dropdown-item { color: var(--ink-2); }
body[data-mode="dark"] .dropdown-item:hover { background: var(--surface-2); color: var(--ink); }
body[data-mode="dark"] .dropdown-item.active, body[data-mode="dark"] .dropdown-item:active {
  background: var(--accent); color: var(--surface);
}
body[data-mode="dark"] hr.dropdown-divider { border-color: var(--line); }

/* full responses table */
body[data-mode="dark"] .full-response-table tbody td,
body[data-mode="dark"] .full-response-table thead th { border-color: var(--line-2); }

/* TV view is already dark — don't double-apply, just neutralise the topbar
   chrome leak when entering tv mode while dark mode is on */
body[data-mode="dark"][data-view="tv"] { background: #0b0d10; }

/* toast */
body[data-mode="dark"] .toast-msg { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

/* Bootstrap .text-muted defaults to a dark colour — override for dark mode */
body[data-mode="dark"] .text-muted { color: var(--muted) !important; }
body[data-mode="dark"] .muted { color: var(--muted); }

/* keyword & chart canvas backgrounds — Chart.js handles its own colours
   from JS; the renderTrendChart code reads CSS vars at draw time. */

/* Theme rows are selectable */
.themes-table tbody tr.theme-row { cursor: pointer; }
.themes-table tbody tr.theme-row.active {
  background: linear-gradient(90deg, rgba(196,122,92,0.08), rgba(196,122,92,0.02));
}
.themes-table tbody tr.theme-row.active td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.themes-table tbody tr.theme-row.active .name {
  color: var(--accent-2);
}

/* Active-theme chip in responses sidebar */
.active-theme-chip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin: 0 4px 8px;
  padding: 8px 10px 8px 12px;
  background: rgba(196,122,92,0.12);
  border: 1px solid rgba(196,122,92,0.3);
  border-radius: 10px;
  font-size: 12px;
  color: var(--accent-2);
}
.active-theme-chip strong { color: var(--ink); font-weight: 600; margin-left: 4px; }
.active-theme-chip button {
  background: transparent; border: 0;
  width: 22px; height: 22px; border-radius: 50%;
  color: var(--accent-2); cursor: pointer;
  display: grid; place-items: center;
}
.active-theme-chip button:hover { background: rgba(196,122,92,0.2); }

/* ============= SUMMARY CARD ============= */
.summary-card .card-head-actions { gap: 12px; }
.summary-card .card-head-actions .btn-dark i { font-size: 13px; margin-right: 2px; }
.summary-body { margin-top: 4px; }
.summary-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 28px 24px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.summary-empty i {
  font-size: 28px; color: var(--accent);
  margin-bottom: 8px; opacity: 0.6;
}
.summary-empty p { margin: 4px 0; max-width: 480px; font-size: 13px; }
.summary-empty strong { color: var(--ink); }

.summary-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 6px;
}
@media (max-width: 900px) { .summary-content { grid-template-columns: 1fr; } }
.summary-section h4 {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.summary-section h4 i { font-size: 12px; }
.summary-section h4.wins   { color: var(--prom); }
.summary-section h4.risks  { color: var(--detr); }
.summary-section h4.themes { color: var(--accent-2); }
.summary-section h4.actions { color: var(--ink-2); }
.summary-section ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.summary-section li {
  position: relative;
  padding: 10px 12px 10px 28px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}
.summary-section li::before {
  content: "";
  position: absolute; left: 12px; top: 16px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
}
.summary-section.wins   li::before { background: var(--prom); }
.summary-section.risks  li::before { background: var(--detr); }
.summary-section.themes li::before { background: var(--accent); }
.summary-section.actions li::before { background: var(--ink-2); }
.summary-section li em {
  display: block; margin-top: 4px;
  font-size: 11px; color: var(--muted);
  font-style: normal;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.summary-narrative {
  grid-column: 1 / -1;
  font-size: 14px; line-height: 1.55;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(196,122,92,0.06), rgba(196,122,92,0.02));
  border: 1px solid rgba(196,122,92,0.2);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
}
.summary-narrative strong { color: var(--ink); }
.summary-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 36px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.summary-loading .spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.summary-error {
  padding: 14px 16px;
  background: rgba(184,80,58,0.08);
  border: 1px solid rgba(184,80,58,0.3);
  border-radius: var(--radius-sm);
  color: var(--detr);
  font-size: 13px;
}

/* TV feed: scrollable, multiple items */
.tv-feed { overflow: hidden; }
.tv-feed-list {
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.tv-feed-list::-webkit-scrollbar { width: 6px; }
.tv-feed-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.tv-feed-list::-webkit-scrollbar-track { background: transparent; }
.tv-refresh-indicator {
  color: var(--tv-muted, #6f7782);
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.tv-back {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  width: 40px; height: 40px;
  border-radius: 10px;
  color: var(--tv-ink, #f3f0ea);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 18px;
  transition: background .15s;
}
.tv-back:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.2); }
.tv-head-actions {
  display: flex; align-items: center; gap: 14px;
}
.tv-range-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--tv-ink, #f3f0ea);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.tv-range-btn:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.2); }
.tv-range-btn::after {
  margin-left: 4px;
  border-top-color: rgba(255,255,255,0.5) !important;
}
.tv-range-menu {
  background: #161a21;
  border: 1px solid #1c2026;
  color: var(--tv-ink, #f3f0ea);
}
.tv-range-menu .dropdown-item {
  color: rgba(243,240,234,0.8);
  font-size: 13px;
  padding: 8px 14px;
}
.tv-range-menu .dropdown-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.tv-range-menu .dropdown-item.active { background: var(--accent); color: #fff; }
.tv-range-menu hr { border-color: #1c2026; }
