:root {
  --bg:           #0f1117;
  --bg2:          #1a1d27;
  --bg3:          #21253a;
  --border:       #2a2d3a;
  --text:         #c9cdd8;
  --text-h:       #f0f1f5;
  --muted:        #6b7280;
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.12);
  --yellow:       #eab308;
  --red:          #ef4444;
  --accent:       #7c3aed;
  --accent-2:     #6d28d9;
  --accent-light: #a78bfa;
  --accent-dim:   rgba(124,58,237,0.15);
  --mono: ui-monospace, Consolas, 'Courier New', monospace;
  --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
  --radius:       8px;
  --sidebar-w:    220px;
  --sidebar-w-sm: 56px;
  --header-h:     48px;

  font: 14px/1.6 var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }

/* ── Shell ──────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

.shell.collapsed {
  grid-template-columns: var(--sidebar-w-sm) 1fr;
}

/* ── Titlebar (Tauri drag region) ───────────────────────── */

.titlebar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  /* Tauri: makes the header the drag region */
  -webkit-app-region: drag;
  user-select: none;
}

.titlebar .logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-light);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.titlebar .proxy-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  -webkit-app-region: no-drag;
}

.titlebar .collapse-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  -webkit-app-region: no-drag;
  transition: background 0.15s, color 0.15s;
}
.titlebar .collapse-btn:hover { background: var(--border); color: var(--text); }

/* ── Sidebar ────────────────────────────────────────────── */

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 6px;
  margin: 2px 6px;
  color: var(--muted);
  background: none;
  border: none;
  width: calc(100% - 12px);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  position: relative;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover { background: var(--border); color: var(--text); }

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-light);
}

.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.6;
}

.nav-spacer { flex: 1; }

/* ── Main content ───────────────────────────────────────── */

.main {
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-h);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── KPI grid ───────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card .kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-h);
  line-height: 1.1;
}

.kpi-card .kpi-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Progress bar ───────────────────────────────────────── */

.bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ── Section card ───────────────────────────────────────── */

.section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.section-body { padding: 16px; }

/* ── Table ──────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg3); }

/* ── Skill cards ────────────────────────────────────────── */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.skill-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.skill-card:hover { border-color: var(--accent); }

.skill-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.skill-card-header strong { color: var(--text-h); font-size: 14px; }

.skill-card p { font-size: 13px; color: var(--muted); line-height: 1.4; }

.skill-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.skill-card-meta span { display: flex; align-items: center; gap: 4px; }

/* ── Badges / Tags ──────────────────────────────────────── */

.tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-purple { background: var(--accent-dim); color: var(--accent-light); }
.badge-gray   { background: var(--bg3);        color: var(--muted); border: 1px solid var(--border); }

/* ── Status dot ─────────────────────────────────────────── */

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-green  { background: var(--green); box-shadow: 0 0 4px var(--green); }
.dot-red    { background: var(--red); }
.dot-yellow { background: var(--yellow); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ── Live feed ──────────────────────────────────────────── */

.feed-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Pending cards ──────────────────────────────────────── */

.pending-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.pending-card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.pending-card-header strong { color: var(--text-h); font-size: 15px; }

.code-preview {
  background: #0a0c12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  color: #a5b4fc;
  max-height: 200px;
  overflow-y: auto;
}

.pending-actions { display: flex; gap: 8px; }

/* ── Buttons ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s;
}

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-2); }
.btn-success  { background: var(--green); color: #000; }
.btn-success:hover  { opacity: 0.85; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-danger:hover   { opacity: 0.85; }
.btn-ghost    { background: var(--border); color: var(--text); }
.btn-ghost:hover    { background: var(--bg3); }

/* ── Billing ────────────────────────────────────────────── */

.billing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.billing-row:last-child { border-bottom: none; }
.billing-row .label { color: var(--muted); }
.billing-row .value { font-weight: 600; color: var(--text-h); }
.billing-row .value.green { color: var(--green); }

/* ── Sparkline (SVG bar chart) ──────────────────────────── */

.sparkline-wrap { margin: 12px 0; }
.sparkline-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

/* ── Empty / loading states ─────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state svg { opacity: 0.3; margin-bottom: 8px; }

/* ── Month picker ───────────────────────────────────────── */

.month-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.month-picker select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font: inherit;
  font-size: 13px;
}

/* ── Utilities ──────────────────────────────────────────── */

.muted    { color: var(--muted); }
.fine     { font-size: 11px; }
.mono     { font-family: var(--mono); }
.green    { color: var(--green); }
.yellow   { color: var(--yellow); }
.red      { color: var(--red); }
.error    { color: var(--red); }
.flex     { display: flex; align-items: center; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.ml-auto  { margin-left: auto; }
.nowrap   { white-space: nowrap; }
.text-h   { color: var(--text-h); }

/* ── Scrollbar ──────────────────────────────────────────── */

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

/* ── Update banner ──────────────────────────────────────── */

.update-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  color: var(--green);
  font-size: 13px;
}

.update-btn {
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
}
.update-btn:disabled { opacity: 0.6; cursor: default; }
.update-btn:hover:not(:disabled) { filter: brightness(1.1); }

.update-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
}
.update-dismiss:hover { color: var(--text); }
