:root {
  --bg-base: #f6f8fa;
  --bg-panel: #ffffff;
  --bg-subtle: #eef2f6;
  --bg-code: #0c1219;
  --border: #dde4eb;
  --border-line: #dde4eb;
  --border-strong: #c2cfd9;
  --ink-primary: #0f1720;
  --text-main: #0f1720;
  --text-muted: #4b5968;
  --text-dim: #768696;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --accent-ink: #0b6b62;
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.13);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.13);
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.12);
  --shadow-sm: 0 1px 3px rgba(15, 23, 32, 0.05);
  --shadow-md: 0 12px 32px rgba(15, 23, 32, 0.08);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

[data-theme="dark"] {
  --bg-base: #0b1016;
  --bg-panel: #121922;
  --bg-subtle: #18222e;
  --bg-code: #070b10;
  --border: #202d3c;
  --border-line: #202d3c;
  --border-strong: #2e4054;
  --ink-primary: #edf2f7;
  --text-main: #edf2f7;
  --text-muted: #9fb0c2;
  --text-dim: #6e8196;
  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-soft: rgba(20, 184, 166, 0.15);
  --accent-ink: #5eead4;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.45);
}

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

html, body {
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono, code, pre, .tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.input, input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-line);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: var(--bg-panel);
  color: var(--text-main);
  border-color: var(--border-line);
}

.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}

/* Badges & Filter Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}

.badge-teal {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.badge-green {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-red {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

.pill-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-line);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.pill-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Public Header & Hero */
.pub-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--bg-base) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-line);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-cube {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}

.hero-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  gap: 44px;
  align-items: center;
}

.hero-title {
  font-size: 42px;
  line-height: 1.13;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin-bottom: 14px;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 54ch;
  margin-bottom: 24px;
}

.code-window {
  background: var(--bg-code);
  color: #e2e8f0;
  border: 1px solid #243242;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: #080d13;
  border-bottom: 1px solid #1e293b;
  overflow-x: auto;
}

.code-tab {
  background: transparent;
  color: #94a3b8;
  border: none;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
}

.code-tab.active {
  background: rgba(20, 184, 166, 0.18);
  color: #5eead4;
}

.code-body {
  padding: 18px;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
  color: #e2e8f0;
}

.pub-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 52px;
}

.section-head {
  margin-bottom: 22px;
}

.section-head h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

/* Auth Screen */
.auth-shell {
  min-height: calc(100vh - 65px);
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow-md);
}

/* Authenticated Workspace Shell */
.app-layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 18px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 60px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-line);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.content-wrap {
  padding: 26px;
  max-width: 1300px;
  width: 100%;
}

/* Panels, KPI Grids & Charts */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid:has(> :nth-child(6)) {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  margin-bottom: 18px;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  height: 175px;
  align-items: end;
  padding-top: 20px;
}

.bar-col {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.bar-fill {
  width: 100%;
  max-width: 36px;
  min-height: 4px;
  background: var(--accent);
  border-radius: 5px 5px 2px 2px;
}

/* Packages */
.pkg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.pkg-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 11px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.pkg-card.featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

/* Tables */
.table-scroll {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-line);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-line);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Modals & Toasts */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 20, 0.62);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-box {
  width: 100%;
  max-width: 460px;
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  max-height: 90vh;
  overflow-y: auto;
}

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--ink-primary);
  color: var(--bg-panel);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

@media (max-width: 960px) {
  .hero-wrap, .grid-2 {
    grid-template-columns: 1fr;
  }
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-line);
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .hero-title {
    font-size: 31px;
  }
}
