:root {
  --bg: #08080d;
  --surface: #111118;
  --surface2: #181822;
  --surface3: #222233;
  --border: #252538;
  --border-sub: #1c1c2c;
  --text: #e8e8f0;
  --text-dim: #b4b4c4;
  --text-muted: #8a8aa0;
  --accent: #6366f1;
  --accent-dim: rgba(99, 102, 241, 0.14);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --sidebar-w: 208px;
  --panel-w: 440px;
  --header-h: 48px;
  --radius: 8px;
  --radius-sm: 5px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  overflow: hidden;
  font-size: 13px;
}
button { cursor: pointer; font-family: inherit; border: none; outline: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
input, textarea, select {
  font-family: inherit;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
}
textarea { resize: vertical; min-height: 120px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border-sub);
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-sub);
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
}
.brand-name { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-section {
  padding: 12px 16px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.nav-link {
  display: block;
  padding: 7px 16px;
  color: var(--text-dim);
  font-size: 13px;
  border-left: 2px solid transparent;
  cursor: pointer;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active {
  background: var(--accent-dim);
  color: var(--text);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border-sub);
  font-size: 11px;
  color: var(--text-muted);
}
.foot-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.topbar {
  height: var(--header-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-sub);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
}
.crumbs {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.actions { display: flex; gap: 8px; }
.view { flex: 1; overflow-y: auto; padding: 20px; }

/* Buttons */
.btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface3); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}
.btn-primary:hover { background: #5457e0; border-color: #5457e0; }
.btn-danger { color: var(--red); border-color: rgba(239,68,68,0.4); }
.btn-danger:hover { background: var(--red-dim); }
.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-sub);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.card-sub { font-size: 11px; color: var(--text-muted); }
.card-body { padding: 0; }
.card-body-pad { padding: 16px; }
.card-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface2);
  border-bottom: 1px solid var(--border-sub);
  white-space: nowrap;
}
.tbl td {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-sub);
  vertical-align: top;
}
.tbl tbody tr { cursor: pointer; transition: background 0.1s; }
.tbl tbody tr:hover { background: var(--surface2); }
.tbl tbody tr.active { background: var(--accent-dim); }
.tbl .muted { color: var(--text-muted); }
.tbl .num { font-variant-numeric: tabular-nums; }

/* Pills */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill-t1 { background: rgba(34,197,94,0.15); color: #4ade80; }
.pill-t2 { background: rgba(59,130,246,0.15); color: #60a5fa; }
.pill-t3 { background: rgba(148,163,184,0.15); color: #cbd5e1; }
.pill-t4 { background: rgba(100,116,139,0.15); color: #9aa5b5; }
.pill-day { background: var(--accent-dim); color: #a5b4fc; }
.pill-risk {
  background: var(--amber-dim);
  color: #fbbf24;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.pill-state {
  background: var(--surface3);
  color: var(--text-dim);
}
.pill-state.flagged { background: var(--red-dim); color: #fca5a5; }
.pill-state.edited { background: var(--blue-dim); color: #93c5fd; }

/* Pulse (KPI cards) */
.pulse-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pulse {
  background: var(--surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.pulse-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.pulse-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pulse-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Hero (draft review) */
.hero-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border-sub);
}
.hero-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); }
.hero-meta b { color: var(--text); font-weight: 600; }

/* Side panel */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-w);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 20;
}
.side-panel.open { transform: translateX(0); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-sub);
}
.panel-title { font-size: 14px; font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.panel-section { margin-bottom: 20px; }
.panel-section h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.panel-kv { display: grid; grid-template-columns: 100px 1fr; gap: 6px 12px; font-size: 12px; }
.panel-kv dt { color: var(--text-muted); }
.panel-kv dd { color: var(--text-dim); }
.email-preview {
  background: var(--surface2);
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
}
.email-subject {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-sub);
}
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: var(--green); color: white; }
.toast.err { background: var(--red); color: white; }
.toast.info { background: var(--accent); color: white; }

/* Loader */
.loader {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Funnel (simple bars) */
.funnel-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  gap: 12px;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-sub);
  font-size: 12px;
}
.funnel-row:last-child { border-bottom: none; }
.funnel-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface3);
  overflow: hidden;
}
.funnel-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.funnel-count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Planned heatmap */
.planned-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  padding: 16px;
}
.planned-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--surface2);
  position: relative;
  cursor: default;
}
.planned-cell[data-count="0"] { background: var(--surface2); }
.planned-cell.has-count { background: var(--accent); }
.planned-hour {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  padding: 2px 0;
}

/* Flag buttons */
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* Search */
.search {
  padding: 6px 10px;
  min-width: 240px;
}
