/* ══════════════════════════════════════════════
   GDB Dashboard — Shared CSS v4.0
   Used by ALL pages: summary, channel, initiative
══════════════════════════════════════════════ */
:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2330;
  --border:    #30363d;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --text3:     #484f58;
  --up:        #3fb950;
  --down:      #f85149;
  --accent:    #58a6ff;
  --accent2:   #3fb950;
  --radius:    8px;
  --header-h:  52px;
  --nav-h:     40px;
  --purple:    #a78bfa;
  --amber:     #f59e0b;
  --teal:      #22d3a4;
  --chart-blue:   #58a6ff;
  --chart-green:  #3fb950;
  --chart-orange: #f0900d;
  --chart-purple: #d2a8ff;
  --chart-teal:   #22d3a4;
  --chart-red:    #f85149;
  --chart-amber:  #f59e0b;
  --chart-dim:    #484f58;
}

[data-theme="light"] {
  /* ── Eye Comfort — warm tone, reduced blue light ─────────
     Inspired by Solarized / paper reading modes.
     bg/surface use warm parchment instead of cold white.
     Text uses warm dark brown instead of near-black.
     Accent shifted to amber-brown, away from cold blue.
  ────────────────────────────────────────────────────────── */
  --bg:        #fdf6e3;
  --surface:   #f5efe0;
  --surface2:  #ede7d3;
  --border:    #d5c9b0;
  --text:      #3a2e1e;
  --text2:     #7a6a55;
  --text3:     #a8967e;
  --up:        #2d6a3f;
  --down:      #a63228;
  --accent:    #7c5c1e;
  --accent2:   #2d6a3f;
  --purple:    #6b4fa0;
  --amber:     #8a6200;
  --teal:      #1a6b62;
  /* Chart palette — warmer, softer versions */
  --chart-blue:   #4a7eb5;
  --chart-green:  #2d6a3f;
  --chart-orange: #b05a00;
  --chart-purple: #6b4fa0;
  --chart-teal:   #1a6b62;
  --chart-red:    #a63228;
  --chart-amber:  #8a6200;
  --chart-dim:    #a8967e;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 13px;
  min-height: 100vh; padding-top: calc(var(--header-h) + var(--nav-h));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── GLOBAL HEADER ──────────────────────────── */
.gdb-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 0;
}
.gdb-header-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  flex-shrink: 0;
}
.gdb-header-brand:hover { text-decoration: none; }
.gdb-logo {
  width: 32px; height: 32px; border-radius: 7px;
  background: linear-gradient(135deg,#1a3a6c,#2563eb);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.gdb-brand-name { font-size: 14px; font-weight: 700; }
.gdb-brand-sub  { font-size: 10px; color: var(--text2); }
.gdb-header-spacer { flex: 1; }
.gdb-header-right {
  display: flex; align-items: center; gap: 12px;
}
.gdb-update-time {
  font-size: 11px; color: var(--text2); white-space: nowrap;
}
.gdb-user {
  display: flex; align-items: center; gap: 7px;
}
.gdb-user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text2);
  overflow: hidden; flex-shrink: 0;
}
.gdb-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.gdb-user-name { font-size: 12px; color: var(--text2); }
.gdb-signout-btn {
  padding: 4px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); border-radius: 6px;
  font-size: 11px; cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.gdb-signout-btn:hover { border-color: var(--down); color: var(--down); }

/* ── NAV BAR ─────────────────────────────────── */
.gdb-nav {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 299;
  height: var(--nav-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: stretch; padding: 0 20px; gap: 2px;
  overflow-x: auto;
}
.gdb-nav::-webkit-scrollbar { height: 0; }
.gdb-nav-item {
  display: flex; align-items: center; padding: 0 14px;
  font-size: 12px; font-weight: 500; color: var(--text2);
  text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all .15s; cursor: pointer;
}
.gdb-nav-item:hover { color: var(--text); text-decoration: none; }
.gdb-nav-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.gdb-nav-divider {
  width: 1px; background: var(--border); margin: 10px 6px;
}
.gdb-nav-channel-dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; margin-right: 6px; flex-shrink: 0;
}

/* ── PAGE CONTAINER ─────────────────────────── */
.gdb-page { padding: 20px; max-width: 1440px; margin: 0 auto; }

/* ── SECTION HEADER ─────────────────────────── */
.gdb-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.gdb-sec-title { font-size: 15px; font-weight: 700; }
.gdb-sec-sub   { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* ── REFRESH BUTTON ─────────────────────────── */
.gdb-refresh-btn {
  padding: 5px 13px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); border-radius: 6px;
  font-size: 12px; cursor: pointer; transition: all .15s;
}
.gdb-refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── KPI CARDS ───────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  border-top: 3px solid var(--border);
}
.kpi-card.accent  { border-top-color: var(--accent); }
.kpi-card.green   { border-top-color: var(--up); }
.kpi-card.purple  { border-top-color: #a78bfa; }
.kpi-card.orange  { border-top-color: #f59e0b; }
.kpi-label {
  font-size: 10px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}
.kpi-value { font-size: 22px; font-weight: 700; line-height: 1; }
.kpi-meta  { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; align-items: center; }
.kpi-chg   { font-size: 11px; font-weight: 600; }
.kpi-chg.up { color: var(--up); }
.kpi-chg.dn { color: var(--down); }
.kpi-vs    { font-size: 10px; color: var(--text3); }

/* ── CHART CARDS ─────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px; margin-bottom: 18px;
}
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.chart-card.full { grid-column: 1 / -1; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.chart-desc  { font-size: 11px; color: var(--text2); margin-bottom: 12px; }

/* ── TABLE ───────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { background: var(--surface2); }
th {
  padding: 8px 10px; text-align: right;
  font-size: 10px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
th:first-child { text-align: left; }
td { padding: 7px 10px; text-align: right; border-bottom: 1px solid rgba(48,54,61,.5); }
td:first-child { text-align: left; color: var(--text2); }
tr.yr26 td { color: var(--accent); font-weight: 600; }
tr:hover td { background: var(--surface2); }

/* ── TABS (inline page tabs) ────────────────── */
.page-tabs { display: flex; gap: 2px; margin-bottom: 18px; }
.page-tab-btn {
  padding: 7px 16px; font-size: 12px; font-weight: 600;
  color: var(--text2); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all .15s;
}
.page-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.page-tab-btn:hover:not(.active) { color: var(--text); }
.page-tab-panel { display: none; }
.page-tab-panel.active { display: block; }

/* ── YEAR TOGGLE ────────────────────────────── */
.yr-toggle { display: flex; gap: 6px; }
.yr-btn {
  padding: 4px 12px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text2);
  border-radius: 20px; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.yr-btn.active { background: color-mix(in srgb,var(--accent) 24%,var(--surface2)); border-color: var(--accent); color: var(--accent); }

/* ── BADGE / TAG ────────────────────────────── */
.channel-badge {
  font-size: 11px; font-weight: 600; padding: 2px 10px;
  border-radius: 20px; border: 1px solid currentColor;
}

/* ── PROGRESS BAR ───────────────────────────── */
#gdb-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); z-index: 10000;
  transform: scaleX(0); transform-origin: left;
  transition: transform .3s ease, opacity .5s ease;
  opacity: 0; pointer-events: none;
}

/* ── SKELETON SHIMMER ────────────────────────── */
@keyframes gdb-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.gdb-skel {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: gdb-shimmer 1.4s ease-in-out infinite;
}
.gdb-skel-wrap { padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.gdb-skel-row  { height: 13px; border-radius: 3px; }

/* ── LOADING / ERROR ────────────────────────── */
#gdb-loading {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 999; gap: 12px;
}
.gdb-spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gdb-loading-text { font-size: 13px; color: var(--text2); }

#gdb-error {
  display: none;
  background: #2d1b1b; border-bottom: 1px solid var(--down);
  color: var(--down); padding: 8px 20px; font-size: 12px;
  position: sticky; top: calc(var(--header-h) + var(--nav-h)); z-index: 50;
}

/* ── AUTH PAGE ───────────────────────────────── */
.auth-page {
  min-height: 100vh; padding-top: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.auth-card {
  background: #fff; border-radius: 12px;
  padding: 36px 32px; width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
.auth-logo {
  font-size: 22px; font-weight: 800; color: #1a3a5c;
  margin-bottom: 4px;
}
.auth-sub {
  font-size: 12px; color: #888; margin-bottom: 24px;
}
.auth-label { font-size: 11px; font-weight: 600; color: #555; display: block; margin-bottom: 5px; }
.auth-input {
  width: 100%; padding: 9px 12px; border: 1px solid #ddd;
  border-radius: 6px; font-size: 13px; margin-bottom: 14px;
  transition: border-color .15s; outline: none;
}
.auth-input:focus { border-color: #1a3a5c; }
.auth-btn {
  width: 100%; padding: 10px; background: #1a3a5c;
  color: #fff; border: none; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s; margin-top: 4px;
}
.auth-btn:hover { background: #254f7a; }
.auth-btn:disabled { opacity: .6; cursor: not-allowed; }
.auth-error { display: block; color: #e53e3e; font-size: 11px; margin-top: 8px; min-height: 16px; }

/* ── SUMMARY PAGE SPECIFIC ──────────────────── */
.summary-channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.summary-channel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  border-left: 4px solid var(--accent);
  cursor: pointer; transition: background .15s;
}
.summary-channel-card:hover { background: var(--surface2); }
.summary-ch-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.summary-ch-logo {
  width: 32px; height: 32px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.summary-ch-name { font-size: 13px; font-weight: 700; }
.summary-ch-sub  { font-size: 10px; color: var(--text2); }

/* Compare table */
.compare-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.compare-table th {
  padding: 8px 12px; background: var(--surface2);
  text-align: right; font-size: 10px; font-weight: 700;
  color: var(--text2); text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 2px solid var(--border);
}
.compare-table th:first-child { text-align: left; min-width: 120px; }
.compare-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid rgba(48,54,61,.4); }
.compare-table td:first-child { text-align: left; font-weight: 600; color: var(--text2); }
.compare-table tbody tr:hover td { background: var(--surface2); }
.compare-table .ch-col-header {
  display: flex; align-items: center; gap: 6px; justify-content: flex-end;
}

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  body { padding-top: calc(var(--header-h) + var(--nav-h)); }
  .gdb-page { padding: 12px; }
  .chart-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .gdb-user-name { display: none; }
  .compare-table th, .compare-table td { padding: 6px 8px; }
}

/* ── Global select dark theme ─────────────────── */
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }
select option { background: var(--surface2); color: var(--text); }


/* ── Dark Eye Comfort — warm amber tint on dark background ──
   Keeps dark bg but shifts all cool blue-gray tones warm.
   bg/surface: warm dark brown-gray (not cold blue-black)
   text: warm off-white with amber tint
   accent: amber-gold instead of cold blue
   Charts: warmer, slightly muted versions
────────────────────────────────────────────────────────── */
[data-theme="dark-warm"] {
  --bg:        #1a1510;
  --surface:   #221c15;
  --surface2:  #2b231a;
  --border:    #3d3228;
  --text:      #e8dcc8;
  --text2:     #a89880;
  --text3:     #6b5c48;
  --up:        #4a9e5c;
  --down:      #e06050;
  --accent:    #d4a040;
  --accent2:   #4a9e5c;
  --purple:    #b088e0;
  --amber:     #d4a040;
  --teal:      #40b8a8;
  --chart-blue:   #7ab0e0;
  --chart-green:  #4a9e5c;
  --chart-orange: #d4782a;
  --chart-purple: #b088e0;
  --chart-teal:   #40b8a8;
  --chart-red:    #e06050;
  --chart-amber:  #d4a040;
  --chart-dim:    #6b5c48;
}
