@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600&family=Bebas+Neue&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink-950:   #060910;
  --ink-900:   #0c1220;
  --ink-800:   #111827;
  --ink-700:   #1a2540;
  --ink-600:   #243050;
  --jade:      #10b981;
  --jade-light:#34d399;
  --ember:     #ef4444;
  --ember-light:#f87171;
  --amber:     #f59e0b;
  --amber-light:#fbbf24;
  --cobalt:    #3b82f6;
  --cobalt-light:#60a5fa;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --sidebar-w: 240px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono:    'Space Mono', monospace;
  --font-body:    'DM Sans', sans-serif;
}

html, body {
  background: var(--ink-950);
  color: #cbd5e1;
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grid background */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(16,185,129,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,185,129,.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* ── Layout ───────────────────────────────────── */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: fixed; left: 0; top: 0;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0a1020 0%, var(--ink-950) 100%);
  border-right: 1px solid rgba(45,58,82,.6);
  z-index: 100;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar-brand {
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(45,58,82,.5);
}
.brand-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.brand-icon {
  width: 32px; height: 32px; border-radius: 6px;
  background: linear-gradient(135deg, #008751 0%, var(--jade) 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: #fff;
}
.brand-name { font-family: var(--font-display); letter-spacing: .2em; font-size: 13px; color: #fff; }
.brand-sub  { font-size: 11px; color: var(--slate-500); line-height: 1.3; }
.live-badge {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 10px; color: var(--jade-light);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--jade); animation: ping 1.5s infinite;
}
@keyframes ping {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: .6; }
}

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  text-decoration: none; font-size: 13.5px; color: var(--slate-400);
  transition: all .15s; margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav-link:hover  { color: var(--slate-300); background: rgba(45,58,82,.4); }
.nav-link.active { color: var(--jade-light); background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.2); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer { padding: 14px 12px; border-top: 1px solid rgba(45,58,82,.5); }
.btn-pipeline {
  width: 100%; padding: 8px;
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25);
  color: var(--jade-light); border-radius: 6px; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .2s;
}
.btn-pipeline:hover { background: rgba(16,185,129,.18); }
.cron-note { text-align: center; font-size: 10px; color: var(--slate-600); margin-top: 6px; }

/* ── Page header ──────────────────────────────── */
.page-header { margin-bottom: 24px; }
.section-label {
  font-family: var(--font-display); letter-spacing: .15em; font-size: 11px;
  color: rgba(16,185,129,.7); text-transform: uppercase; margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-display); letter-spacing: .05em;
  font-size: 36px; color: #fff; line-height: 1;
}
.page-header-row { display: flex; align-items: flex-end; justify-content: space-between; }

/* ── Cards ────────────────────────────────────── */
.card {
  background: var(--ink-900);
  border: 1px solid rgba(45,58,82,.8);
  border-radius: 8px; padding: 20px;
  transition: border-color .2s;
}
.card:hover { border-color: rgba(16,185,129,.25); }

/* ── Grid ─────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }

/* ── KPI stat ─────────────────────────────────── */
.stat-label { font-size: 10px; font-family: var(--font-display); letter-spacing: .12em; color: var(--slate-500); text-transform: uppercase; }
.stat-icon  { font-size: 15px; opacity: .7; }
.stat-value { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; line-height: 1.1; margin-top: 8px; }
.stat-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* ── Badge ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em;
}
.badge-high     { background: rgba(239,68,68,.15);  color: var(--ember-light); border: 1px solid rgba(239,68,68,.3); }
.badge-medium   { background: rgba(245,158,11,.15); color: var(--amber-light); border: 1px solid rgba(245,158,11,.3); }
.badge-low      { background: rgba(16,185,129,.15); color: var(--jade-light);  border: 1px solid rgba(16,185,129,.3); }
.badge-critical { background: rgba(239,68,68,.25);  color: #fff;               border: 1px solid var(--ember); }

/* ── Polarity colors ──────────────────────────── */
.pol-positive { color: var(--jade-light); }
.pol-negative { color: var(--ember-light); }
.pol-neutral  { color: var(--slate-400); }
.pol-mixed    { color: var(--amber-light); }

/* ── Table / feed ─────────────────────────────── */
.post-card {
  background: var(--ink-900); border: 1px solid rgba(45,58,82,.7);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 10px;
}
.post-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; color: var(--slate-500); }
.post-content { font-size: 13.5px; color: var(--slate-300); line-height: 1.6; }
.post-explanation { font-size: 11px; color: var(--slate-600); margin-top: 8px; font-style: italic; border-top: 1px solid rgba(45,58,82,.4); padding-top: 8px; }
.post-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--slate-500); }

/* ── Source badge ─────────────────────────────── */
.src-badge { padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; background: rgba(59,130,246,.15); color: var(--cobalt-light); border: 1px solid rgba(59,130,246,.25); }

/* ── Filters ──────────────────────────────────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-group label { display: block; font-family: var(--font-display); font-size: 10px; letter-spacing: .1em; color: var(--slate-500); text-transform: uppercase; margin-bottom: 4px; }
.filter-group select, .filter-group input[type=text] {
  background: var(--ink-900); border: 1px solid rgba(45,58,82,.7);
  color: var(--slate-300); border-radius: 6px; padding: 7px 10px;
  font-size: 12px; font-family: var(--font-mono);
}
.filter-group select:focus, .filter-group input:focus { outline: 1px solid rgba(16,185,129,.4); }

/* ── Narrative item ───────────────────────────── */
.narrative-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px; cursor: pointer;
  transition: all .15s; border: 1px solid transparent; margin-bottom: 2px;
}
.narrative-item:hover  { background: rgba(45,58,82,.3); }
.narrative-item.active { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.2); color: var(--jade-light); }
.nar-num   { font-family: var(--font-mono); font-size: 10px; color: var(--jade); width: 20px; text-align: right; }
.nar-info  { flex: 1; min-width: 0; }
.nar-name  { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nar-meta  { font-size: 11px; color: var(--slate-500); display: flex; gap: 8px; margin-top: 2px; }

/* ── Alert item ───────────────────────────────── */
.alert-item {
  padding: 14px 16px; border-radius: 8px; margin-bottom: 10px;
  display: flex; align-items: flex-start; gap: 12px;
}
.alert-icon { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.alert-title { font-size: 14px; font-weight: 600; color: var(--slate-200); margin-bottom: 4px; }
.alert-desc  { font-size: 12px; color: var(--slate-400); line-height: 1.5; }
.alert-time  { font-size: 10px; color: var(--slate-600); margin-top: 6px; font-family: var(--font-mono); }
.read-link   { font-size: 11px; color: var(--jade-light); cursor: pointer; text-decoration: none; white-space: nowrap; }
.read-link:hover { text-decoration: underline; }

/* ── Tabs ─────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab {
  padding: 7px 16px; border-radius: 6px; cursor: pointer;
  font-size: 12px; border: 1px solid transparent;
  font-family: var(--font-mono); letter-spacing: .05em;
  color: var(--slate-400); background: transparent; transition: all .15s;
}
.tab.active { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.25); color: var(--jade-light); }
.tab:hover:not(.active) { color: var(--slate-300); background: rgba(45,58,82,.3); }

/* ── Regional bars ────────────────────────────── */
.region-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 1px; margin-top: 6px; }
.region-bar-seg { transition: flex .3s; }

/* ── Empty state ──────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--slate-600); }
.empty-icon  { font-size: 40px; margin-bottom: 12px; }

/* ── Misc ─────────────────────────────────────── */
.text-jade   { color: var(--jade-light); }
.text-ember  { color: var(--ember-light); }
.text-amber  { color: var(--amber-light); }
.text-slate  { color: var(--slate-400); }
.text-dim    { color: var(--slate-500); }
.mono        { font-family: var(--font-mono); }
.divider     { border: none; border-top: 1px solid rgba(45,58,82,.5); margin: 12px 0; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.between     { justify-content: space-between; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mt-16       { margin-top: 16px; }
.mt-20       { margin-top: 20px; }
.mb-16       { margin-bottom: 16px; }

/* ── Loading ──────────────────────────────────── */
.loading-overlay { position: fixed; inset: 0; background: rgba(6,9,16,.7); display: flex; align-items: center; justify-content: center; z-index: 999; }
.loading-text { font-family: var(--font-mono); font-size: 12px; color: var(--jade-light); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--ink-900); }
::-webkit-scrollbar-thumb { background: #2d3a52; border-radius: 2px; }

/* ── Slide-up animation ───────────────────────── */
@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.animate { animation: slideUp .35s ease-out; }

/* ── Login page ───────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--ink-900); border: 1px solid rgba(45,58,82,.8); border-radius: 12px; padding: 40px; width: 360px; }
.login-title { font-family: var(--font-display); font-size: 32px; color: #fff; letter-spacing: .1em; margin-bottom: 6px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; font-family: var(--font-display); letter-spacing: .1em; color: var(--slate-500); text-transform: uppercase; margin-bottom: 6px; }
.form-group input { width: 100%; padding: 10px 12px; background: var(--ink-800); border: 1px solid rgba(45,58,82,.8); border-radius: 6px; color: var(--slate-300); font-size: 14px; }
.form-group input:focus { outline: 1px solid rgba(16,185,129,.4); }
.btn-submit { width: 100%; padding: 11px; background: var(--jade); border: none; border-radius: 6px; color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .2s; margin-top: 4px; }
.btn-submit:hover { background: var(--jade-light); }
.form-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: var(--ember-light); padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
