/* ==========================================================================
   SK PERFORMANCE — DESIGN SYSTEM
   Concept: instrument cluster. Dark, dense, legible under workshop light.
   Fonts loaded via Google Fonts <link> in includes/header.php.
   $LOCAL_FONTS — for offline/self-hosted install, download Barlow Condensed
   (600,700), Inter (400,500,600) and JetBrains Mono (500) as woff2 and swap
   the <link> tags in header.php for local @font-face rules.
   ========================================================================== */

/* ---- 1. Tokens ---------------------------------------------------------- */

:root {
  /* Palette */
  --ink:        #0B0D10;
  --surface:    #14181D;
  --surface-2:  #1B2027;
  --surface-3:  #232A32;
  --line:       #262C35;
  --line-hover: #333B46;
  --text:       #EDF0F4;
  --muted:      #8B95A3;
  --muted-2:    #5B6774;
  --redline:    #E11D2E;
  --redline-rgb: 225, 29, 46;
  --ember:      #FF8A1F;
  --go:         #2FBF71;
  --steel:      #5B6774;

  /* Fonts */
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Type scale */
  --fs-11: 0.6875rem;
  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-18: 1.125rem;
  --fs-24: 1.5rem;
  --fs-34: 2.125rem;
  --fs-52: 3.25rem;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;
  --container-max: 1280px;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur-fast: 120ms;
  --dur-med: 160ms;
}

/* ---- 2. Reset ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html, body, div, span, h1, h2, h3, h4, h5, h6, p, ul, ol, li, form, fieldset, table, th, td { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-15);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
ul, ol { list-style: none; }

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--redline);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---- 3. Typography -------------------------------------------------------- */

.h-display {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.05;
}

.eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-11);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.mono {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.text-muted { color: var(--muted); }
.text-go { color: var(--go); }
.text-redline { color: var(--redline); }
.text-ember { color: var(--ember); }

h1, .text-h1 { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: var(--fs-34); letter-spacing: .01em; }
h2, .text-h2 { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: var(--fs-24); letter-spacing: .01em; }
h3, .text-h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--fs-18); }
p { color: var(--text); }

/* ---- 4. Layout shell ------------------------------------------------------ */

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

.app-main {
  flex: 1;
  padding: 20px 16px calc(var(--bottomnav-h) + 24px);
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 900px) {
  .app-shell { flex-direction: row; }
  .app-main { padding: 28px 32px; }
}

/* ---- 5. Utility layer ------------------------------------------------------ */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.grid { display: grid; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

@media (min-width: 900px) {
  .desktop-only { display: initial; }
  .mobile-only { display: none !important; }
}
@media (max-width: 899px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: initial; }
}

/* ---- 6. Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-15);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
  min-width: 44px;
}

.btn-primary {
  background: var(--redline);
  color: #fff;
  border: 1px solid var(--redline);
}
.btn-primary:hover { background: #c8192a; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--line-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  height: 40px;
  padding: 0 12px;
}
.btn-ghost:hover { color: var(--text); }

.btn-destructive {
  background: transparent;
  color: var(--redline);
  border: 1px solid transparent;
  height: 40px;
  padding: 0 8px;
}

.btn-sm { height: 40px; padding: 0 14px; font-size: var(--fs-13); }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottomnav-h) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--redline);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(var(--redline-rgb), .35);
  z-index: 40;
}

/* Sticky mobile save bar — long forms (job-form.php) pin the live total + primary action */
.save-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--bottomnav-h);
  z-index: 35;
  background: rgba(20, 24, 29, .97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.save-bar .save-bar-total {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-24);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.save-bar .save-bar-label { font-size: var(--fs-11); }

/* ---- 7. Inputs -------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-13);
  color: var(--muted);
}

.input, select.input, textarea.input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  height: 48px;
  padding: 0 14px;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }

select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238B95A3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.input::placeholder { color: var(--muted-2); }

.input:focus {
  outline: none;
  border-color: var(--redline);
  box-shadow: 0 0 0 3px rgba(var(--redline-rgb), .18);
}

.input.has-error { border-color: var(--redline); }
.field-error { color: var(--redline); font-size: var(--fs-13); }
.field-hint { color: var(--muted-2); font-size: var(--fs-13); }

.input-group { display: flex; }
.input-group > * { border-radius: 0; position: relative; }
.input-group > * + * { margin-left: -1px; }
.input-group > *:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group > *:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-group > *:focus { z-index: 1; }

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background var(--dur-med) var(--ease);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--dur-med) var(--ease), background var(--dur-med) var(--ease);
}
.toggle input:checked + .toggle-track { background: rgba(var(--redline-rgb), .25); border-color: var(--redline); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: var(--redline); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--redline); outline-offset: 2px; }

/* ---- 8. Cards --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .card:hover { border-color: var(--line-hover); }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ---- 9. Stat tiles ------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 900px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stat-tile.is-primary { border-top: 1px solid var(--redline); }

.stat-tile .stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-34);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 900px) {
  .stat-tile .stat-value { font-size: clamp(1.75rem, 2vw + 1rem, var(--fs-52)); }
}

.stat-tile .stat-footer {
  font-size: var(--fs-13);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Page-load animation */
@media (prefers-reduced-motion: no-preference) {
  .stat-tile {
    animation: tile-in 320ms var(--ease) both;
  }
  .stat-tile:nth-child(1) { animation-delay: 0ms; }
  .stat-tile:nth-child(2) { animation-delay: 60ms; }
  .stat-tile:nth-child(3) { animation-delay: 120ms; }
  .stat-tile:nth-child(4) { animation-delay: 180ms; }
}
@keyframes tile-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- 10. Status pills ---------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-11);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.pill.is-garage    { color: var(--redline); background: rgba(var(--redline-rgb), .12); }
.pill.is-progress  { color: var(--ember);   background: rgba(255, 138, 31, .12); }
.pill.is-ready     { color: var(--go);      background: rgba(47, 191, 113, .12); }
.pill.is-delivered { color: var(--steel);   background: rgba(91, 103, 116, .12); }
.pill.is-paid      { color: var(--go);      background: rgba(47, 191, 113, .12); }
.pill.is-unpaid    { color: var(--redline); background: rgba(var(--redline-rgb), .12); }

/* ---- 11. Status rail — signature element ---------------------------------------- */

.rail {
  display: flex;
  gap: 3px;
  height: 8px;
}

.rail-segment {
  flex: 1;
  height: 100%;
  background: rgba(255, 255, 255, .08);
  transform: skewX(-12deg);
  transition: background var(--dur-med) var(--ease);
}

.rail-segment.is-complete { background: var(--steel); }
.rail-segment.is-complete.stage-garage   { background: var(--redline); }
.rail-segment.is-complete.stage-progress { background: var(--ember); }
.rail-segment.is-complete.stage-ready    { background: var(--go); }
.rail-segment.is-complete.stage-delivered{ background: var(--steel); }

.rail-segment.is-current.stage-garage    { background: var(--redline); }
.rail-segment.is-current.stage-progress  { background: var(--ember); }
.rail-segment.is-current.stage-ready     { background: var(--go); }
.rail-segment.is-current.stage-delivered { background: var(--steel); }

@media (prefers-reduced-motion: no-preference) {
  .rail-segment.is-current {
    animation: rail-glow 2s ease-in-out infinite;
  }
}
@keyframes rail-glow {
  0%, 100% { filter: brightness(1); opacity: 1; }
  50%      { filter: brightness(1.6); opacity: .85; }
}

/* Interactive rail (job-view.php): each segment is a real button */
.rail-interactive { height: 14px; }
.rail-interactive .rail-segment {
  cursor: pointer;
  border: 0;
  padding: 0;
}
.rail-interactive .rail-segment:focus-visible {
  outline: 2px solid var(--redline);
  outline-offset: 3px;
}

.rail-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}
.rail-labels span {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.rail-labels span.is-active { color: var(--text); }

/* ---- 12. Job card ------------------------------------------------------------- */

.job-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-card-invoice {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-13);
  color: var(--muted);
}

.plate-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-18);
  letter-spacing: .04em;
  color: #283359;
  background-image: url('../img/plate-bg.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: var(--r-sm);
  padding: 6px 16px;
  min-width: 150px;
  aspect-ratio: 4 / 1;
  box-sizing: border-box;
}

.job-card-vehicle { font-size: var(--fs-15); color: var(--text); }
.job-card-customer { font-size: var(--fs-13); color: var(--muted); }
.job-card-services { font-size: var(--fs-13); color: var(--muted); }

.job-card-divider { border-top: 1px solid var(--line); margin: 2px 0; }

.job-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.job-card-total {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-18);
}

/* ---- 13. Service chips ---------------------------------------------------------- */

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--fs-13);
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.chip.is-selected {
  background: rgba(var(--redline-rgb), .14);
  border-color: var(--redline);
  color: var(--text);
}

.chip .chip-check { display: none; color: var(--redline); }
.chip.is-selected .chip-check { display: inline-flex; }

/* ---- 13b. Job line items (job-form.php service lines) ---------------------------- */

.job-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.job-line:last-child { border-bottom: none; }
.job-line .job-line-name { flex: 1; min-width: 140px; }
.job-line .job-line-price { width: 100px; }
.job-line .job-line-qty { width: 64px; }
.job-line .job-line-total {
  width: 90px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-13);
}
.job-line .job-line-description {
  flex-basis: 100%;
  width: 100%;
  font-size: var(--fs-13);
}
.job-line-header {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.job-line-header .job-line-total { font-family: var(--font-body); }
.job-line-header-spacer { width: 44px; flex-shrink: 0; }

/* ---- 14. Tables ------------------------------------------------------------------ */

.table-wrap { width: 100%; }

table.data-table {
  width: 100%;
  font-size: var(--fs-13);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--ink);
  text-align: left;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-11);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

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

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .cell-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Below 900px: table becomes a stack of cards */
@media (max-width: 899px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 12px;
    margin-bottom: 10px;
  }
  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 8px 2px;
  }
  .data-table td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: var(--fs-11);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
  }
}

/* ---- 14b. Pagination ----------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.pagination-info {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- 15. Toasts ------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + 16px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 360px;
  align-items: center;
}
@media (min-width: 900px) {
  .toast-container { left: auto; right: 24px; bottom: 24px; transform: none; align-items: flex-end; }
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--line-hover);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: var(--fs-13);
  color: var(--text);
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.toast.is-success { border-left: 3px solid var(--go); }
.toast.is-error { border-left: 3px solid var(--redline); }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in var(--dur-med) var(--ease) both; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- 16. Empty states --------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-state .empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-2);
}

/* ---- 17. Navigation ------------------------------------------------------------------- */

/* Topbar (both breakpoints) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: rgba(11, 13, 16, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.logo-mark-bg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: var(--r-sm);
  padding: 3px;
  flex-shrink: 0;
  box-sizing: border-box;
}
.logo-mark-bg img { width: 100%; height: 100%; object-fit: contain; display: block; }

.topbar-logo { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-logo .mark { color: var(--redline); flex-shrink: 0; }
.topbar-logo .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-18);
  text-transform: uppercase;
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.topbar-search {
  display: none;
  position: relative;
}
@media (min-width: 900px) {
  .topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    margin: 0 24px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    height: 40px;
    padding: 0 12px;
    color: var(--muted);
  }
  .topbar-search input {
    background: none; border: 0; color: var(--text); width: 100%; height: 100%; font-size: var(--fs-15);
  }
  .topbar-search input:focus { outline: none; }
  .topbar-search .kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted-2);
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2px 5px;
    flex-shrink: 0;
  }
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Search results panel — anchored directly under the search input itself */
.search-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
  z-index: 50;
  max-height: 70vh;
  overflow-y: auto;
}
.search-panel-group { padding: 8px; }
.search-panel-group + .search-panel-group { border-top: 1px solid var(--line); }
.search-panel-title { padding: 8px 8px 4px; }
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--r-sm);
}
.search-result:hover { background: var(--surface-2); }

/* Mobile bottom tab bar */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  height: var(--bottomnav-h);
  background: rgba(20, 24, 29, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 900px) {
  .bottom-nav { display: none; }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted-2);
  min-height: 44px;
}
.bottom-nav-item span { font-size: 10px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.bottom-nav-item.is-active { color: var(--redline); }

/* Desktop sidebar */
.sidebar {
  display: none;
}
@media (min-width: 900px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 30;
    padding: 20px 12px;
  }
  .sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; min-width: 0; }
  .sidebar-logo .mark { color: var(--redline); flex-shrink: 0; }
  .sidebar-logo .name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--fs-18);
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px;
    border-radius: var(--r-md);
    color: var(--muted);
    font-weight: 500;
    font-size: var(--fs-15);
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  }
  .sidebar-link:hover { background: var(--surface-2); color: var(--text); }
  .sidebar-link.is-active { background: rgba(var(--redline-rgb), .12); color: var(--text); border: 1px solid rgba(var(--redline-rgb), .3); }
  .sidebar-link.is-active svg { color: var(--redline); }
  .sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 8px;
    border-top: 1px solid var(--line);
  }
  .sidebar-user .name { font-size: var(--fs-13); font-weight: 600; }
  .sidebar-user .role { font-size: var(--fs-11); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
}

/* ---- 18. Login page ---------------------------------------------------------------------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(var(--redline-rgb), .08), transparent 55%),
    var(--ink);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-bottom: 4px;
}
.login-brand .mark { color: var(--redline); }
.login-brand .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-24);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.login-brand .tagline { font-size: var(--fs-13); color: var(--muted); }

.login-error {
  background: rgba(var(--redline-rgb), .1);
  border: 1px solid rgba(var(--redline-rgb), .3);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: var(--fs-13);
}

/* ---- 19. Misc components -------------------------------------------------------------------- */

.divider { border-top: 1px solid var(--line); }

/* Horizontal share bar — reports.php top services list */
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.bar-row:last-child { border-bottom: none; }
.bar-row-label { flex: 1; min-width: 0; font-size: var(--fs-13); }
.bar-row-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row-count { color: var(--muted); font-size: var(--fs-11); }
.bar-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  min-width: 60px;
}
.bar-fill { height: 100%; background: var(--redline); border-radius: 999px; }
.bar-row-value { width: 96px; text-align: right; font-family: var(--font-mono); font-size: var(--fs-13); flex-shrink: 0; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}

.timeline-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  font-size: var(--fs-13);
  border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-time { color: var(--muted-2); font-family: var(--font-mono); white-space: nowrap; }

.filter-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: var(--fs-13);
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.filter-tab.is-active { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.filter-tab .count { color: var(--muted-2); font-family: var(--font-mono); }
.filter-tab.is-active .count { color: var(--redline); }

/* ---- 20. Motion defaults --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
