:root {
  --bg: #0d0f14;
  --bg-elev: #141821;
  --bg-card: #171c27;
  --bg-hover: #1e2430;
  --border: #262c3a;
  --text: #e8eaf0;
  --text-dim: #8b93a7;
  --text-faint: #5a6274;
  --accent: #6d7dfc;
  --accent-soft: rgba(109, 125, 252, 0.15);
  --green: #3ecf8e;
  --red: #f0616d;
  --amber: #f5b942;
  --radius: 10px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
  width: 100%;
}

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  padding: 0 10px 20px;
  color: var(--text);
  line-height: 1.3;
}
.brand span { color: var(--text-dim); font-weight: 400; font-size: 12px; display: block; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 18px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}
.logout-btn {
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
}
.logout-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Main ---------- */
.main { flex: 1; padding: 24px 32px; max-width: 1400px; min-width: 0; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-title .sub { color: var(--text-dim); font-weight: 400; font-size: 13px; margin-top: 2px; }

/* Segmented period control */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: none;
  background: none;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}
.segmented button.active { background: var(--accent); color: #fff; }

.checkbox-inline { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12.5px; cursor: pointer; }

/* ---------- Cards / KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label { color: var(--text-dim); font-size: 12px; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }
.kpi-hint { color: var(--text-faint); font-size: 11px; margin-top: 4px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  min-width: 0; /* let grid/flex parents shrink this below its content's intrinsic width */
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.card-hint { font-size: 12px; color: var(--text-dim); margin: -8px 0 14px; line-height: 1.5; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-width: 0; }
.chart-grid.single { grid-template-columns: 1fr; }
.chart-grid > * { min-width: 0; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.short { height: 220px; }

/* ---------- Tables ---------- */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table-scroll { overflow-x: auto; min-width: 0; }
table.data-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table tr:hover td { background: var(--bg-hover); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr.row-success td { background: rgba(62, 207, 142, 0.08); }
table.data-table tr.row-success:hover td { background: rgba(62, 207, 142, 0.16); }
table.data-table tr.row-canceled td { background: rgba(240, 97, 109, 0.06); }
table.data-table tr.row-canceled:hover td { background: rgba(240, 97, 109, 0.12); }

table.cohort-table td, table.cohort-table th { text-align: right; }
table.cohort-table td:first-child, table.cohort-table th:first-child { text-align: left; }
table.cohort-table td:first-child, table.cohort-table th:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 1;
}
table.cohort-table .cohort-total, table.cohort-table th:last-child { font-weight: 600; }
table.cohort-table tr.cohort-totals-row td {
  font-weight: 600;
  border-top: 2px solid var(--border);
  background: var(--bg-card);
}
table.cohort-table tr.cohort-totals-row td:first-child { background: var(--bg-card); }

/* ---------- Login ---------- */
.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: 320px;
}
.login-card h1 { font-size: 17px; margin: 0 0 4px; }
.login-card p { color: var(--text-dim); font-size: 12.5px; margin: 0 0 22px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 13.5px;
}
.login-card button:hover { opacity: 0.9; }
.login-error { color: var(--red); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------- Misc ---------- */
.empty-state { color: var(--text-dim); padding: 30px; text-align: center; font-size: 13px; }
.loading { color: var(--text-dim); padding: 30px; text-align: center; font-size: 13px; }
.search-row { display: flex; gap: 10px; margin-bottom: 18px; }
.search-row input {
  flex: 1;
  max-width: 360px;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
}
.search-row input:focus { outline: none; border-color: var(--accent); }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  margin: 4px 6px 4px 0;
  font-size: 12.5px;
}
.user-pill:hover { border-color: var(--accent); }
.tabs-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs-inline button {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
}
.tabs-inline button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---------- User card ---------- */
.user-header-row { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.user-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.user-avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-faint);
}
.user-title { font-size: 15px; font-weight: 700; }
.user-subtitle { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge.ok { background: rgba(62, 207, 142, 0.15); color: var(--green); }
.badge.bad { background: rgba(240, 97, 109, 0.15); color: var(--red); }
.badge.warn { background: rgba(245, 185, 66, 0.15); color: var(--amber); }
.badge.neutral { background: var(--bg-hover); color: var(--text-dim); }

.kpi-value.amber { color: var(--amber); }

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-dim);
  font-size: 10px;
  font-style: normal;
  line-height: 1;
  cursor: help;
  margin-left: 5px;
  position: relative;
  flex-shrink: 0;
  vertical-align: middle;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  max-width: 60vw;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
  z-index: 30;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  text-align: left;
}
.info-tip:hover::after, .info-tip:focus::after { opacity: 1; visibility: visible; }

.ue-basis-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.ue-basis-row select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12.5px;
}
.ue-basis-row button {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
}
.ue-basis-row button:hover { color: var(--text); border-color: var(--text-faint); }

.btn-analyze {
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 16px;
  cursor: pointer;
}
.btn-analyze:hover { background: var(--accent-soft); color: var(--accent); }
.btn-analyze:disabled { opacity: 0.6; cursor: not-allowed; }
#gptbot-analysis-result ul { margin: 0 0 10px 20px; }
#gptbot-analysis-result p { margin: 0 0 10px; }
#gptbot-analysis-result li { margin-bottom: 4px; line-height: 1.5; }
.prompt-quote {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-style: italic;
}

/* ---------- Cross-links ---------- */
.link-id {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.link-id:hover { color: #fff; }

/* ---------- Photo gallery ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.photo-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.photo-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
}
.photo-pair img,
.photo-pair .photo-empty {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.photo-pair img { cursor: zoom-in; }
.photo-pair .photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 10px;
  text-align: center;
  padding: 4px;
}
.photo-meta {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---------- Song cards ---------- */
.song-card img,
.song-card > .photo-empty {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.song-card audio { height: 32px; }
.song-card audio::-webkit-media-controls-panel { background: var(--bg-elev); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 40px;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- Generic text/dialog modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-body .chat-messages { max-height: none; padding: 0; }

.gptbot-user-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.gptbot-user-link:hover { color: #fff; }

/* ---------- Broadcast composer ---------- */
.bc-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .bc-grid { grid-template-columns: 1fr; } }
.bc-field { margin-bottom: 14px; }
.bc-field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.bc-input, .bc-select, .bc-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.bc-input:focus, .bc-select:focus, .bc-textarea:focus { outline: none; border-color: var(--accent); }
.bc-textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.bc-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bc-row > * { flex: 1; min-width: 140px; }
.bc-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.bc-toolbar button {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.bc-toolbar button:hover { color: var(--text); border-color: var(--text-faint); }
.bc-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  cursor: pointer;
}
.bc-btn:hover { background: var(--accent-soft); color: var(--accent); }
.bc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bc-btn.secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.bc-btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.bc-btn.danger { background: var(--red); }
.bc-button-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; flex-wrap: wrap; }
.bc-button-row .bc-input { flex: 1; min-width: 100px; }
.bc-button-row select.bc-select { flex: 0 0 110px; }
.bc-remove-btn {
  background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 15px; padding: 4px 8px;
}
.bc-remove-btn:hover { color: var(--red); }
.bc-add-btn {
  background: none; border: 1px dashed var(--border); border-radius: 8px; color: var(--text-dim);
  padding: 7px 12px; font-size: 12px; cursor: pointer; width: 100%; margin-bottom: 6px;
}
.bc-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.bc-preview {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  position: sticky;
  top: 16px;
}
.bc-preview-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.bc-bubble {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.bc-bubble img { border-radius: 8px; margin-bottom: 8px; display: block; }
.bc-bubble audio { width: 100%; margin-bottom: 8px; }
.bc-bubble-buttons { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.bc-bubble-buttons .bc-brow { display: flex; gap: 6px; }
.bc-bubble-buttons button {
  flex: 1;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: default;
}
.bc-segment-count {
  display: flex; align-items: baseline; gap: 8px; margin: 10px 0;
  font-size: 24px; font-weight: 700; color: var(--accent);
}
.bc-segment-count span { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.bc-progress-wrap { background: var(--bg-hover); border-radius: 8px; overflow: hidden; height: 8px; margin: 10px 0; }
.bc-progress-bar { background: var(--accent); height: 100%; transition: width 0.3s; }
.bc-song-pick {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; margin-bottom: 6px;
}
.bc-channel-list {
  max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px;
}
.bc-channel-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 12.5px;
  border-radius: 6px; cursor: pointer;
}
.bc-channel-row:hover { background: var(--bg-hover); }
.bc-channel-row span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-channel-slug { color: var(--text-faint); font-size: 11px; flex: 0 0 auto; }
.bc-song-pick img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.bc-img-preview { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; margin-top: 8px; }

/* ---------- Day-grouped sections (broadcasts) ---------- */
.day-group { padding: 0; overflow: hidden; }
.day-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.day-group-date { font-size: 13.5px; font-weight: 700; }
.day-group-stats { font-size: 11.5px; color: var(--text-dim); }
.day-group table.data-table { margin: 0; }
.day-group .table-scroll { padding: 0; }

/* table-layout:auto + no fixed width lets the table grow past its container
   on narrow screens instead of squeezing every column unreadably thin — the
   .table-scroll wrapper (overflow-x:auto) then scrolls it horizontally,
   with the row-label column pinned via position:sticky below. */
table.ht-table { table-layout: auto; width: auto; min-width: 100%; }
table.ht-table th, table.ht-table td { padding: 3px 5px; font-size: 10px; text-align: right; white-space: nowrap; min-width: 32px; }
table.ht-table th:first-child, table.ht-table td:first-child {
  text-align: left; position: sticky; left: 0; background: var(--bg-card); min-width: 78px; padding-right: 6px;
}
table.ht-table th:nth-child(2), table.ht-table td:nth-child(2) { font-weight: 600; padding-right: 6px; min-width: 56px; }
table.ht-table tr.ht-today-row td { background: var(--accent-soft); font-weight: 600; }
table.ht-table tr.ht-today-row td:first-child { background: var(--accent-soft); }
table.ht-table td.ht-future { color: var(--text-faint); font-weight: 400; }
.ht-total-full { font-size: 9px; font-weight: 400; color: var(--text-dim); white-space: nowrap; }

/* ---------- Chat sessions ---------- */
.chat-session { padding: 0; overflow: hidden; }
.chat-session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.chat-count { color: var(--text-dim); font-weight: 400; }
.chat-meta { color: var(--text-dim); font-size: 11.5px; font-weight: 400; }
.chat-messages { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.chat-bubble {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.chat-bubble.ai { border-color: rgba(109, 125, 252, 0.35); background: var(--accent-soft); }
.chat-bubble.human { background: var(--bg-hover); }
.chat-bubble-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 4px;
}
.chat-bubble-content { white-space: pre-wrap; line-height: 1.5; }

/* ---------- Mobile navigation (hamburger + off-canvas sidebar) ---------- */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 210;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 190;
}
.sidebar-overlay.visible { display: block; }

/* ---------- Unit Economics ---------- */
.ue-lever { margin-bottom: 18px; }
.ue-lever:last-child { margin-bottom: 0; }
.ue-lever .top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 5px; }
.ue-lever .top .name { color: var(--text-dim); }
.ue-lever .top .out { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ue-lever input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 18px;
}
.ue-lever .fact { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

.ue-funnel-step { margin-bottom: 14px; }
.ue-funnel-step:last-child { margin-bottom: 0; }
.ue-funnel-step .lab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; margin-bottom: 5px; }
.ue-funnel-step .lab b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ue-funnel-bar-track { height: 10px; border-radius: 5px; background: var(--bg-elev); border: 1px solid var(--border); overflow: hidden; }
.ue-funnel-bar-fill { height: 100%; border-radius: 4px; transition: width 0.15s ease; }

.ue-ledger-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}
.ue-ledger-row:last-child { border-bottom: none; padding-top: 12px; font-weight: 700; color: var(--text); font-size: 14px; }
.ue-ledger-row .v { font-variant-numeric: tabular-nums; color: var(--text); }
.ue-ledger-row .v.green { color: var(--green); }
.ue-ledger-row .v.red { color: var(--red); }
.ue-ledger-row:last-child .v.green { color: var(--green); }
.ue-ledger-row:last-child .v.red { color: var(--red); }

/* ---------- Responsive breakpoints ---------- */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .mobile-menu-btn { display: flex; }
  .mobile-menu-btn.hidden { display: none; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 82vw;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 200;
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 68px 16px 28px; max-width: 100%; }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .main { padding: 62px 10px 24px; }
  .page-title { font-size: 17px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 18px; }
  .card { padding: 14px 12px; }
  .segmented button, .tabs-inline button { padding: 6px 10px; font-size: 11.5px; }
  table.data-table th, table.data-table td { padding: 7px 8px; font-size: 11.5px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .login-card { width: 88vw; max-width: 320px; padding: 28px 22px; }
  .user-header-row { flex-wrap: wrap; }
  .chat-messages { max-height: 320px; }
  .lightbox { padding: 16px; }
}
