/* ============================================================
   Design tokens — see ui/ux.md for the full rationale.
   Layered on top of Bootstrap 5 (grid/utilities kept, look re-themed here).
   ============================================================ */

@font-face { font-family: 'Plex Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Plex Serif'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-serif-600.woff2') format('woff2'); }
@font-face { font-family: 'Plex Serif'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-serif-700.woff2') format('woff2'); }
@font-face { font-family: 'Plex Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'Plex Mono'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2'); }

:root {
  --bg: hsl(220 20% 97%);
  --surface: hsl(0 0% 100%);
  --surface-2: hsl(220 16% 94%);
  --border: hsl(220 14% 87%);
  --ink: hsl(222 30% 14%);
  --ink-muted: hsl(220 12% 45%);

  --accent: hsl(350 85% 52%);
  --accent-strong: hsl(350 80% 42%);
  --accent-soft: hsl(350 85% 95%);
  --on-accent: hsl(0 0% 100%);

  --success: hsl(162 55% 38%);
  --success-soft: hsl(162 50% 93%);
  --warning: hsl(42 95% 46%);
  --warning-soft: hsl(42 90% 93%);
  --danger: hsl(350 85% 52%);
  --danger-soft: hsl(350 85% 95%);

  --chrome: hsl(215 22% 14%);
  --chrome-strong: hsl(215 25% 9%);

  --shadow-sm: 0 1px 2px hsl(222 30% 14% / 0.06);
  --shadow-md: 0 4px 16px hsl(222 30% 14% / 0.08), 0 1px 3px hsl(222 30% 14% / 0.06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(220 22% 9%);
    --surface: hsl(220 18% 13%);
    --surface-2: hsl(220 16% 17%);
    --border: hsl(218 14% 24%);
    --ink: hsl(210 20% 92%);
    --ink-muted: hsl(214 10% 62%);
    --accent: hsl(350 80% 62%);
    --accent-strong: hsl(350 75% 72%);
    --accent-soft: hsl(350 45% 20%);
    --on-accent: hsl(220 30% 8%);
    --success: hsl(162 50% 55%);
    --success-soft: hsl(162 40% 16%);
    --warning: hsl(42 85% 58%);
    --warning-soft: hsl(42 55% 16%);
    --danger: hsl(350 80% 62%);
    --danger-soft: hsl(350 45% 18%);
    --chrome: hsl(215 22% 10%);
    --chrome-strong: hsl(215 25% 6%);
    --shadow-sm: 0 1px 2px hsl(0 0% 0% / 0.3);
    --shadow-md: 0 4px 20px hsl(0 0% 0% / 0.4), 0 1px 3px hsl(0 0% 0% / 0.3);
  }
}

/* ============================================================
   Base
   ============================================================ */

html { font-size: 15px; position: relative; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plex Sans', system-ui, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: 'Plex Serif', Georgia, serif; font-weight: 600; text-wrap: balance; color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

.mono, .table td.mono, td.mono {
  font-family: 'Plex Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Sidebar
   ============================================================ */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: linear-gradient(180deg, var(--chrome-strong), var(--chrome));
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 200ms ease;
}

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { width: 100%; padding: 20px 16px 48px; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--chrome);
    position: sticky;
    top: 0;
    z-index: 900;
  }
  .mobile-topbar .brand { color: #fff; font-family: 'Plex Serif', serif; font-weight: 700; }
  .mobile-topbar button {
    background: transparent;
    border: 1px solid hsl(0 0% 100% / 0.3);
    border-radius: 6px;
    color: #fff;
    padding: 6px 10px;
    font-size: 1rem;
    line-height: 1;
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: hsl(0 0% 0% / 0.4);
    z-index: 999;
  }
}
.sidebar .brand {
  font-family: 'Plex Serif', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  padding: 0 10px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid hsl(0 0% 100% / 0.18);
  display: block;
}
.sidebar .nav-group-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: hsl(0 0% 100% / 0.5);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
  color: hsl(0 0% 100% / 0.85);
  border-left: 3px solid transparent;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.sidebar .nav-item:hover { background: hsl(0 0% 100% / 0.08); color: #fff; }
.sidebar .nav-item.active {
  background: hsl(350 85% 52% / 0.22);
  color: #fff;
  border-left-color: var(--accent);
}

.main-content { flex: 1; min-width: 0; padding: 28px 34px 60px; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin-bottom: 0; }
.page-head p { margin: 4px 0 0; color: var(--ink-muted); font-size: 0.88rem; }

/* ============================================================
   Cards, tables
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.table {
  --bs-table-bg: var(--surface);
  color: var(--ink);
}
.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background-color 120ms ease; }
.table-hover tbody tr:hover { background-color: var(--accent-soft); }
.table td.num, .table th.num { text-align: right; }

/* ============================================================
   Chips
   ============================================================ */

.chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   Buttons
   ============================================================ */

.btn { border-radius: 7px; font-weight: 500; transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 100ms ease; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
  box-shadow: var(--shadow-md);
}

.btn-outline-secondary, .btn-outline-primary {
  color: var(--ink);
  border-color: var(--border);
  background: transparent;
}
.btn-outline-secondary:hover, .btn-outline-primary:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.btn-link { color: var(--ink-muted); }
.btn-link:hover { color: var(--ink); }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================================================
   Forms
   ============================================================ */

.form-control, .form-select {
  border-color: var(--border);
  border-radius: 7px;
  color: var(--ink);
  background-color: var(--surface);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
}
.form-label { font-size: 0.78rem; font-weight: 600; color: var(--ink-muted); }

.price-tier-card {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 16px 18px;
}
.price-tier-card h5 { color: var(--accent-strong); font-size: 0.95rem; margin-bottom: 12px; }

/* ============================================================
   Stat tiles (dashboard)
   ============================================================ */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 600; }
.stat-value { font-family: 'Plex Mono', monospace; font-variant-numeric: tabular-nums; font-size: 1.55rem; font-weight: 500; margin-top: 8px; color: var(--ink); }
.stat-tile.accent .stat-value { color: var(--accent); }
.stat-tile.warn .stat-value { color: var(--warning); }
.stat-foot { font-size: 0.78rem; color: var(--ink-muted); margin-top: 4px; }

/* ============================================================
   Motion
   ============================================================ */

.page-enter { animation: rise 380ms ease both; }
@media (prefers-reduced-motion: reduce) {
  .page-enter { animation: none; }
  .btn, .stat-tile, .table tbody tr, .form-control, .form-select, .sidebar .nav-item { transition: none; }
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

body { margin-bottom: 0; }
