/* Campaign Dashboard — Slate Design System
   Clean, modern palette. Works in light and dark modes.
*/
:root {
  --pblue: #2563EB;
  --pgreen: #059669;
  --pred: #DC2626;
  --brass: #D97706;
  --brass-light: #F59E0B;
  --silver: #94A3B8;
  --black: #0F172A;
  --dark: #1E293B;
  --mid: #64748B;
  --light: #E2E8F0;
  --offwhite: #F8FAFC;
  --white: #FFFFFF;

  --tint-blue: #EFF6FF;
  --tint-green: #ECFDF5;
  --tint-red: #FEF2F2;
  --tint-brass: #FFFBEB;
  --tint-silver: #F1F5F9;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --ring: 0 0 0 1px rgba(0,0,0,0.04);
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --pblue: #60A5FA;
  --pgreen: #34D399;
  --pred: #F87171;
  --brass: #FBBF24;
  --brass-light: #FCD34D;
  --silver: #64748B;
  --black: #F1F5F9;
  --dark: #E2E8F0;
  --mid: #94A3B8;
  --light: #334155;
  --offwhite: #0F172A;
  --white: #1E293B;

  --tint-blue: #1A2744;
  --tint-green: #132E23;
  --tint-red: #2E1B1E;
  --tint-brass: #2C2414;
  --tint-silver: #252D38;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.2);
  --ring: 0 0 0 1px rgba(255,255,255,0.06);
}
[data-theme="dark"] body { color-scheme: dark; }

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--offwhite);
  color: var(--dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pblue); }

/* ===== Auth Gate ===== */
#auth-gate {
  display: none;
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: var(--offwhite);
  align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 9999;
}
#auth-gate .gate-box {
  background: var(--white);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg), var(--ring);
}
#auth-gate .gate-logo {
  width: 100px; height: 100px; border-radius: 50%; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
#auth-gate h1 { font-size: 22px; color: var(--black); margin-bottom: 8px; font-weight: 700; }
#auth-gate p { color: var(--mid); margin-bottom: 24px; font-size: 14px; }
#auth-gate input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--light);
  border-radius: 8px; font-size: 16px; margin-bottom: 16px;
  background: var(--offwhite); color: var(--dark);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#auth-gate input:focus { outline: none; border-color: var(--pblue); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
[data-theme="dark"] #auth-gate input:focus { box-shadow: 0 0 0 3px rgba(96,165,250,0.15); }
#auth-gate .btn-login {
  width: 100%; padding: 10px; background: var(--pblue); color: #FFFFFF;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
#auth-gate .btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
[data-theme="dark"] #auth-gate .btn-login { color: #0F172A; }
#auth-error { display: none; color: var(--pred); font-size: 14px; margin-bottom: 12px; }

#app-content { display: none; }

/* ===== Navigation ===== */
.main-nav {
  background: #0F172A;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
[data-theme="dark"] .main-nav { background: #0A0F1E; border-bottom-color: #334155; }
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px;
}
.nav-brand {
  color: #F1F5F9; font-weight: 700; font-size: 16px; text-decoration: none;
  letter-spacing: -0.3px;
}
.nav-links { display: flex; align-items: center; gap: 1px; }
.nav-links a {
  color: rgba(241,245,249,0.6); text-decoration: none; padding: 6px 10px;
  border-radius: 6px; font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.nav-links a:hover { color: #F1F5F9; background: rgba(255,255,255,0.06); }
.nav-links a.active { color: #60A5FA; background: rgba(96,165,250,0.1); }
.btn-logout {
  background: transparent; color: rgba(241,245,249,0.4); border: 1px solid rgba(255,255,255,0.1);
  padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
  margin-left: 10px; transition: all 0.15s; font-weight: 500;
}
.btn-logout:hover { color: #F1F5F9; border-color: rgba(255,255,255,0.25); }
.nav-toggle { display: none; background: none; border: none; color: #F1F5F9; font-size: 22px; cursor: pointer; }

/* Theme toggle */
.theme-toggle {
  background: none; border: 1px solid rgba(255,255,255,0.1); color: rgba(241,245,249,0.5);
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  margin-left: 8px; transition: all 0.15s; flex-shrink: 0;
}
.theme-toggle:hover { color: #F1F5F9; border-color: rgba(255,255,255,0.25); }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 26px; color: var(--black); margin-bottom: 4px; font-weight: 700; letter-spacing: -0.5px; }
.page-header .subtitle { color: var(--mid); font-size: 14px; }

/* ===== Hero Section ===== */
.hero-section {
  background: linear-gradient(135deg, #1E3A5F 0%, #0F172A 100%);
  color: #F1F5F9;
  border-radius: 10px;
  padding: 28px 40px;
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(96,165,250,0.08) 0%, transparent 70%);
  border-radius: 50%;
}
.hero-section .hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.5;
  margin-bottom: 6px;
  font-weight: 600;
}
.hero-section .hero-number {
  font-size: 48px;
  font-weight: 800;
  color: #FBBF24;
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -1px;
}
.hero-section .hero-detail {
  font-size: 13px;
  opacity: 0.55;
}
[data-theme="dark"] .hero-section {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: 1px solid rgba(255,255,255,0.04);
}
[data-theme="dark"] .hero-section .hero-number {
  color: #FCD34D;
}

/* ===== Metric Cards ===== */
.metrics-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px;
}
.metric-card {
  background: var(--white); border-radius: 8px; padding: 18px;
  box-shadow: var(--shadow), var(--ring);
  border-left: 3px solid var(--pblue);
  transition: transform 0.12s, box-shadow 0.12s;
}
.metric-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.metric-card.alert { border-left-color: var(--pred); }
.metric-card.warn { border-left-color: var(--brass); }
.metric-card.good { border-left-color: var(--pgreen); }
.metric-label { font-size: 11px; color: var(--mid); text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 4px; font-weight: 600; }
.metric-value { font-size: 22px; font-weight: 700; color: var(--pblue); letter-spacing: -0.3px; }
.metric-value.red { color: var(--pred); }
.metric-value.gold { color: var(--brass); }
.metric-detail { font-size: 12px; color: var(--mid); margin-top: 3px; }

/* ===== Charts ===== */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 28px; }
.chart-card {
  background: var(--white); border-radius: 8px; padding: 20px;
  box-shadow: var(--shadow), var(--ring);
}
.chart-card.full { grid-column: 1 / -1; }
.chart-card h3 { font-size: 14px; color: var(--black); margin-bottom: 14px; font-weight: 600; }
.chart-card canvas { width: 100% !important; height: 300px !important; }

/* ===== Tables ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--tint-silver); color: var(--dark); padding: 10px 12px;
  text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 2px solid var(--light);
}
[data-theme="dark"] .data-table th { background: rgba(255,255,255,0.04); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--light); }
.data-table tr:hover td { background: var(--tint-silver); }
[data-theme="dark"] .data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.data-table .highlight { background: var(--tint-brass); font-weight: 600; }
.data-table .alert-row { background: var(--tint-red); }

/* ===== Nav Cards ===== */
.nav-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 28px; }
.nav-card {
  background: var(--white); border-radius: 8px; padding: 20px;
  text-decoration: none; color: var(--dark);
  box-shadow: var(--shadow), var(--ring);
  border-top: 3px solid var(--pblue); transition: all 0.15s;
}
.nav-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.nav-card h3 { color: var(--pblue); margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.nav-card p { font-size: 13px; color: var(--mid); line-height: 1.5; }

/* ===== Content Sections ===== */
.section { margin-bottom: 36px; }
.section h2 {
  font-size: 18px; color: var(--black); margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--light); font-weight: 700; letter-spacing: -0.3px;
}
.section h3 { font-size: 15px; color: var(--dark); margin-bottom: 10px; }

/* ===== Callout Boxes ===== */
.callout {
  border-radius: 6px; padding: 14px 18px; margin-bottom: 14px;
  font-size: 14px; line-height: 1.7;
}
.callout.red { background: var(--tint-red); border-left: 3px solid var(--pred); }
.callout.gold { background: var(--tint-brass); border-left: 3px solid var(--brass); }
.callout.blue { background: var(--tint-blue); border-left: 3px solid var(--pblue); }
.callout.green { background: var(--tint-green); border-left: 3px solid var(--pgreen); }
.callout strong { color: var(--pblue); }
[data-theme="dark"] .callout strong { color: var(--pblue); }

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 32px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--light); }
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-item::before {
  content: ''; position: absolute; left: -26px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--pblue); border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--pblue);
}
.timeline-item.failed::before { background: var(--pred); box-shadow: 0 0 0 2px var(--pred); }
.timeline-item .tl-date { font-size: 12px; color: var(--mid); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.timeline-item .tl-content { font-size: 14px; margin-top: 2px; }

/* ===== Heatmap ===== */
.heatmap-cell { padding: 6px 10px; text-align: center; font-weight: 600; font-size: 13px; }
.heat-strong { background: rgba(5,150,105,0.12); color: #047857; }
.heat-good { background: rgba(5,150,105,0.07); color: var(--pgreen); }
.heat-mid { background: rgba(217,119,6,0.1); color: #B45309; }
.heat-weak { background: rgba(220,38,38,0.07); color: var(--pred); }
.heat-very-weak { background: rgba(220,38,38,0.12); color: #B91C1C; }
[data-theme="dark"] .heat-strong { background: rgba(52,211,153,0.15); color: #34D399; }
[data-theme="dark"] .heat-good { background: rgba(52,211,153,0.08); color: #34D399; }
[data-theme="dark"] .heat-mid { background: rgba(251,191,36,0.12); color: #FBBF24; }
[data-theme="dark"] .heat-weak { background: rgba(248,113,113,0.08); color: #F87171; }
[data-theme="dark"] .heat-very-weak { background: rgba(248,113,113,0.15); color: #F87171; }

/* ===== Talking Points ===== */
.talking-point {
  background: var(--white); border-radius: 6px; padding: 14px 18px; margin-bottom: 10px;
  box-shadow: var(--shadow), var(--ring);
  border-left: 3px solid var(--brass);
}
.talking-point .tp-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--pred); font-weight: 700; margin-bottom: 3px; }
.talking-point .tp-text { font-size: 14px; font-weight: 600; color: var(--black); margin-bottom: 3px; line-height: 1.6; }
.talking-point .tp-source { font-size: 12px; color: var(--silver); }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge.red { background: rgba(220,38,38,0.08); color: var(--pred); }
.badge.gold { background: rgba(217,119,6,0.1); color: var(--brass); }
.badge.green { background: rgba(5,150,105,0.08); color: var(--pgreen); }
.badge.blue { background: rgba(37,99,235,0.06); color: var(--pblue); }
[data-theme="dark"] .badge.red { background: rgba(248,113,113,0.12); color: #F87171; }
[data-theme="dark"] .badge.gold { background: rgba(251,191,36,0.12); color: #FBBF24; }
[data-theme="dark"] .badge.green { background: rgba(52,211,153,0.12); color: #34D399; }
[data-theme="dark"] .badge.blue { background: rgba(96,165,250,0.1); color: #60A5FA; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 52px; left: 0; right: 0;
    background: #0F172A; flex-direction: column; padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }
  [data-theme="dark"] .nav-links { background: #0A0F1E; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 14px; font-size: 14px; }
  .btn-logout { margin: 6px 0 0 0; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 6px 8px; }
  .page-header h1 { font-size: 22px; }
  .hero-section { padding: 24px 20px; }
  .hero-section .hero-number { font-size: 36px; }
}

/* 5-column and 6-column grid overrides */
.metrics-grid-5 { grid-template-columns: repeat(5, 1fr); }
.metrics-grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 900px) {
  .metrics-grid-5, .metrics-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .metrics-grid-5, .metrics-grid-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .metrics-grid, .metrics-grid-5, .metrics-grid-6 { grid-template-columns: 1fr; }
  .hero-number { font-size: 32px; }
  .metric-value { font-size: 18px; }
  .container { padding: 16px 12px; }
  .nav-links a { font-size: 12px; padding: 5px 7px; }
}
