/* =============================================================================
   DriverMate Admin — design system
   Black & white first; colour is reserved for status and chart series.
   Light / Dark / System: tokens on :root, dark overrides for the OS setting
   (unless the admin picked Light) and for an explicit Dark choice.
   ============================================================================= */

@font-face { font-family: "Inter"; src: url("../fonts/Inter-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-alt: #f4f4f5;
  --surface-hover: #efeff1;
  --border: #e6e6e8;
  --border-strong: #d4d4d8;
  --text: #0a0a0a;
  --text-2: #3f3f46;
  --muted: #6b6b70;
  --inverse: #0a0a0a;
  --on-inverse: #ffffff;
  --success: #15803d;
  --warning: #b45309;
  --danger: #dc2626;
  --info: #1d4ed8;
  --star: #e8a300;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #ececee;
  --overlay: rgba(10, 10, 10, 0.45);
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-md: 0 8px 24px rgba(10, 10, 10, 0.08), 0 1px 3px rgba(10, 10, 10, 0.06);
  --shadow-lg: 0 24px 64px rgba(10, 10, 10, 0.18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-alt: #1c1c1e;
    --surface-hover: #222225;
    --border: #2a2a2d;
    --border-strong: #3a3a3e;
    --text: #f5f5f5;
    --text-2: #d4d4d8;
    --muted: #a1a1a6;
    --inverse: #ffffff;
    --on-inverse: #0a0a0a;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #93c5fd;
    --star: #fbbf24;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #232326;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow-sm: none;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-alt: #1c1c1e;
  --surface-hover: #222225;
  --border: #2a2a2d;
  --border-strong: #3a3a3e;
  --text: #f5f5f5;
  --text-2: #d4d4d8;
  --muted: #a1a1a6;
  --inverse: #ffffff;
  --on-inverse: #0a0a0a;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #93c5fd;
  --star: #fbbf24;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #232326;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-sm: none;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
}

/* ---- Base -------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--mono); }
code, .table .mono, .tiny.mono, .small.mono { font-size: 12.5px; }
h1.mono { font-size: 22px; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--inverse); color: var(--on-inverse); }
[hidden] { display: none !important; }
.noscript { padding: 24px; text-align: center; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }

/* Logo */
.logo-mark { color: var(--text); overflow: hidden; }
.logo-mark .logo-road-gap { stroke: var(--logo-bg, var(--surface)); }
.logo-mark .logo-lane { stroke: var(--logo-bg, var(--surface)); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.wordmark-text { font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.wordmark-sub { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; margin-top: 3px; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 56px; height: 56px; --logo-bg: var(--bg); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---- Layout ------------------------------------------------------------------ */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px;
  --logo-bg: var(--surface);
}
.sidebar-brand { padding: 4px 8px 20px; }
.sidebar-brand .logo-mark { width: 30px; height: 30px; }
.sidebar-brand .wordmark-text { font-size: 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  text-decoration: none; color: var(--text-2); font-weight: 500; min-height: 40px;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--inverse); color: var(--on-inverse); }
.nav a .nav-count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center;
  background: var(--surface-alt); color: var(--text);
}
.nav a[aria-current="page"] .nav-count { background: var(--on-inverse); color: var(--inverse); }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; font-size: 15px; min-width: 0; }
.topbar-title .crumb { color: var(--muted); font-weight: 500; text-decoration: none; }
.topbar-title .crumb:hover { color: var(--text); }
.topbar-spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 28px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.scrim { display: none; }

@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
  }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: var(--overlay); }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
}

/* ---- Grid helpers ------------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.grow { flex: 1; min-width: 0; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---- Cards ------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card.flush .card-body { padding: 8px 0 0; }

/* KPI tiles */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--border-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-alt); color: var(--text); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.kpi-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta .icon { width: 14px; height: 14px; }

/* Attention strip */
.attention { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.attention a {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-weight: 500;
}
.attention a:hover { border-color: var(--border-strong); }
.attention .count { font-weight: 700; }
.attention .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.attention .dot.danger { background: var(--danger); }

/* ---- Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--inverse); color: var(--on-inverse); }
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }
.btn-success { background: var(--success); color: #fff; }
:root[data-theme="dark"] .btn-success, :root[data-theme="dark"] .btn-danger { color: #0a0a0a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-success, :root:not([data-theme="light"]) .btn-danger { color: #0a0a0a; } }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 14.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.btn .spinner { width: 14px; height: 14px; }
.link { color: var(--text); font-weight: 500; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; cursor: pointer; background: none; border: 0; padding: 0; }
.link:hover { text-decoration-color: var(--text); }
a.row-link { text-decoration: none; font-weight: 600; }
a.row-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Segmented control (theme switch, small toggles) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-alt); border-radius: 10px; border: 1px solid var(--border); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  min-height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); outline: 1px solid var(--border); }
.segmented .icon { width: 15px; height: 15px; }

/* ---- Tabs --------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }
.tab-count { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-alt); color: var(--text-2); }

/* ---- Forms -------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error-text { font-size: 12px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 12%, transparent); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.input-sm, .select-sm { min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: 13px; border-radius: 8px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; }
.input-group .icon-btn { position: absolute; right: 3px; width: 34px; height: 34px; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12.5px; font-weight: 600; pointer-events: none; }
.input-affix .input { padding-right: 52px; }
.search { position: relative; min-width: 220px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search .input { padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.checkbox { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; min-height: 32px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--inverse); cursor: pointer; flex: none; }
.checkbox .muted { font-weight: 400; }
.checkbox.top { align-items: flex-start; }
.checkbox.top input { margin-top: 2px; }
.form-error { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-weight: 500; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.form-note { padding: 10px 12px; border-radius: 10px; background: var(--surface-alt); color: var(--text-2); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--inverse); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--on-inverse); }
.switch input:focus-visible + .track { outline: 2px solid var(--text); outline-offset: 2px; }

/* Filters row */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .select, .filters .input { width: auto; min-width: 150px; }
.filters .search { flex: 1 1 240px; max-width: 360px; }

/* ---- Tables ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td, .table tbody tr:focus-within td { background: var(--surface-alt); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.compact td { padding: 9px 16px; }
.table.inputs td { padding: 8px 12px; }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.cell-user .name { font-weight: 600; }
.cell-user .sub { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) { .hide-sm { display: none; } }
@media (max-width: 1100px) { .hide-md { display: none; } }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; align-items: center; }
.pagination button {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2);
  display: inline-grid; place-items: center;
}
.pagination button:hover:not(:disabled) { background: var(--surface-hover); }
.pagination button[aria-current="page"] { background: var(--inverse); color: var(--on-inverse); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .gap { color: var(--muted); padding: 0 4px; }

/* ---- Badges, chips, avatars ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-alt); color: var(--text-2);
  border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge.plain::before { display: none; }
.badge.success { color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.badge.warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, transparent); border-color: color-mix(in srgb, var(--warning) 28%, transparent); }
.badge.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.badge.info { color: var(--info); background: color-mix(in srgb, var(--info) 10%, transparent); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.badge.dark { background: var(--inverse); color: var(--on-inverse); border-color: var(--inverse); }
.badge.dark::before { display: none; }
.badge.outline { background: transparent; }
.badge .icon { width: 13px; height: 13px; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--surface-alt); color: var(--text); font-weight: 700; font-size: 12.5px;
  border: 1px solid var(--border); overflow: hidden; object-fit: cover;
}
.avatar.lg { width: 72px; height: 72px; font-size: 22px; border-radius: 20px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.level { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12.5px; }
.stars { color: var(--star); display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.stars .val { color: var(--text); }
.stars .icon { fill: currentColor; width: 14px; height: 14px; stroke: none; }

/* Key-value lists */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* Money breakdown */
.breakdown { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.breakdown .line { display: flex; justify-content: space-between; gap: 12px; }
.breakdown .line span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; }
.breakdown .total { border-top: 1px solid var(--border); padding-top: 10px; font-weight: 700; font-size: 15px; }
.breakdown .split { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 24px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 12px; bottom: -8px; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 2px solid var(--text); }
.timeline .when { font-size: 12px; color: var(--muted); }

/* Progress / meter */
.meter { height: 6px; border-radius: 999px; background: var(--surface-alt); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--text); }

/* ---- States -------------------------------------------------------------------- */
.state { padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.state .state-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-alt); color: var(--text); margin-bottom: 4px; }
.state h3 { font-size: 15px; }
.state p { color: var(--muted); max-width: 420px; }
.state.error .state-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.skeleton { background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 37%, var(--surface-alt) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line { height: 12px; margin: 10px 0; }
.sk-kpi { height: 120px; border-radius: var(--radius-lg); }
.sk-block { height: 280px; border-radius: var(--radius-lg); }
.loading-rows td { padding: 16px; }
.refetching { opacity: 0.55; transition: opacity 0.15s; pointer-events: none; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toasts --------------------------------------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--inverse); color: var(--on-inverse); box-shadow: var(--shadow-lg); font-weight: 500;
  animation: toast-in 0.18s ease;
}
.toast.error .icon { color: #f87171; }
.toast.success .icon { color: #4ade80; }
:root[data-theme="dark"] .toast.error .icon { color: #dc2626; }
:root[data-theme="dark"] .toast.success .icon { color: #15803d; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---- Modal & drawer ---------------------------------------------------------------- */
dialog.modal {
  border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px);
}
dialog.modal.wide { width: min(880px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: var(--overlay); }
dialog.modal[open] { animation: modal-in 0.16s ease; display: flex; flex-direction: column; }
@keyframes modal-in { from { transform: translateY(6px) scale(0.99); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.doc-preview { background: var(--surface-alt); border-radius: 12px; min-height: 240px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); }
.doc-preview img { max-height: 60vh; object-fit: contain; }
.doc-preview iframe { width: 100%; height: 60vh; border: 0; background: #fff; }

/* ---- Auth screen ------------------------------------------------------------------ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-brand {
  background: #0a0a0a; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  --logo-bg: #0a0a0a; position: relative; overflow: hidden;
}
.auth-brand .logo-mark { color: #fff; width: 88px; height: 88px; }
.auth-brand h1 { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; margin-top: 20px; }
.auth-brand .tag { color: #a1a1a6; font-size: 16px; margin-top: 8px; }
.auth-brand .panel-label { display: inline-block; margin-top: 18px; padding: 4px 10px; border: 1px solid #3a3a3e; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #d4d4d8; }
.auth-points { display: grid; gap: 14px; max-width: 420px; }
.auth-points div { display: flex; gap: 12px; align-items: flex-start; color: #d4d4d8; }
.auth-points .icon { color: #fff; margin-top: 2px; }
.auth-road { position: absolute; right: -80px; bottom: -60px; width: 420px; height: 420px; opacity: 0.07; color: #fff; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; }
.auth-card .head p { color: var(--muted); margin-top: 6px; }
.auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-theme { position: fixed; top: 16px; right: 16px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { padding: 28px 24px; min-height: auto; }
  .auth-brand h1 { font-size: 30px; }
  .auth-brand .logo-mark { width: 56px; height: 56px; }
  .auth-points, .auth-road { display: none; }
  .auth-theme { top: 20px; }
}

/* ---- Charts ----------------------------------------------------------------------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-1 { stroke: var(--series-1); }
.chart .series-2 { stroke: var(--series-2); }
.chart .fill-1 { fill: var(--series-1); }
.chart .fill-2 { fill: var(--series-2); }
.chart .area-1 { fill: var(--series-1); opacity: 0.1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--border-strong); stroke-width: 1; }
.chart .bar { transition: opacity 0.1s; }
.chart .bar-group:hover .bar, .chart .bar-group:focus .bar { opacity: 0.8; }
.chart .bar-group:focus { outline: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .end-label { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .key-line { width: 14px; height: 2px; border-radius: 2px; }
.legend .key-rect { width: 10px; height: 10px; border-radius: 3px; }
.key-1 { background: var(--series-1); }
.key-2 { background: var(--series-2); }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); font-size: 12.5px;
  transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap;
}
.chart-tooltip .tt-title { color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tooltip .tt-row + .tt-row { margin-top: 4px; }
.chart-tooltip .tt-row strong { font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-row .tt-key { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.chart-tooltip .tt-row .tt-name { color: var(--muted); }

/* Horizontal bar list (single series ranking) */
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; }
.hbar .hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hbar-track { display: block; height: 10px; position: relative; }
.hbar .hbar-fill { display: block; height: 10px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar .hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; text-align: right; }
.hbar:hover .hbar-fill { opacity: 0.8; }

/* ---- Page specifics ------------------------------------------------------------------ */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-head h1 { font-size: 22px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.stat-strip > div { padding: 14px 16px; border-right: 1px solid var(--border); }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip .v { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.stat-strip .l { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat-strip > div:nth-child(2) { border-right: 0; } .stat-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); } }

.verify-list { display: flex; flex-direction: column; }
.verify-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.verify-item:first-child { border-top: 0; }
.verify-item .docs { display: flex; gap: 6px; flex-wrap: wrap; }
.check-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.check-row:first-child { border-top: 0; }
.doc-tile { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.doc-tile .doc-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-alt); display: grid; place-items: center; flex: none; }

.review-card { padding: 16px 20px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.review-card:first-child { border-top: 0; }
.review-card .cats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.review-card blockquote { margin: 0; font-size: 14px; color: var(--text); }

.chat { display: flex; flex-direction: column; gap: 10px; padding: 16px 20px; max-height: 60vh; overflow-y: auto; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; background: var(--surface-alt); align-self: flex-start; }
.bubble.alt { align-self: flex-end; background: var(--inverse); color: var(--on-inverse); }
.bubble .meta { font-size: 11.5px; opacity: 0.7; margin-top: 4px; }
.bubble.system { align-self: center; background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); font-size: 12.5px; }

.weights { display: flex; flex-direction: column; }
.weight-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 240px) 88px 64px; gap: 16px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }
.weight-row:first-child { border-top: 0; }
.weight-row input[type="range"] { width: 100%; accent-color: var(--inverse); }
@media (max-width: 760px) { .weight-row { grid-template-columns: minmax(0, 1fr) 80px 56px; } .weight-row input[type="range"] { display: none; } }
.total-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface); }
.total-bar span { background: var(--text); opacity: 0.85; }
.total-bar span:nth-child(even) { opacity: 0.45; }

.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.settings-nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text-2); font-weight: 500; }
.settings-nav a:hover { background: var(--surface-hover); }
.settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: minmax(0, 1fr); } .settings-nav { display: none; } }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 320px); gap: 16px; padding: 16px 20px; border-top: 1px solid var(--border); align-items: center; }
.setting:first-child { border-top: 0; }
.setting .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.setting.bool { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 640px) { .setting { grid-template-columns: minmax(0, 1fr); } }
.save-bar {
  position: sticky; bottom: 16px; z-index: 10; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: 14px; background: var(--inverse); color: var(--on-inverse); box-shadow: var(--shadow-lg);
}
.save-bar .btn-secondary { background: transparent; color: var(--on-inverse); border-color: color-mix(in srgb, var(--on-inverse) 35%, transparent); }
.save-bar .btn-secondary:hover { background: color-mix(in srgb, var(--on-inverse) 12%, transparent); }
.save-bar .btn-primary { background: var(--on-inverse); color: var(--inverse); }

.user-menu { position: relative; }
.user-menu-btn { display: inline-flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.user-menu-btn .name { font-weight: 600; font-size: 13px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); z-index: 40;
}
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-decoration: none; font-weight: 500; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-hover); }
@media (max-width: 640px) { .user-menu-btn .name, .topbar .segmented .lbl { display: none; } }

.example-card { background: var(--surface-alt); border-radius: 14px; padding: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .filters, .pagination, .toasts { display: none !important; }
  .layout { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
@media (forced-colors: active) {
  .nav a[aria-current="page"], .btn-primary { border: 1px solid CanvasText; }
  .badge::before { forced-color-adjust: none; }
}

/* Payment attempts and refunds in the booking's payment card */
.attempt { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: 4px; }
.attempt .mono { overflow-wrap: anywhere; }
