/* ============================================================
   SparkysM8 — design system v3
   Concept: a test instrument, not a dashboard. Dark chassis,
   hairline panel seams, and yellow used ONLY where it carries
   meaning — primary action, active item, live state, C1.
   See ART-DIRECTION.md. Dark is the default; light is a
   supported override.
   ============================================================ */

/* Self-hosted. The old sheet hotlinked Inter while declaring Plus
   Jakarta Sans, so it rendered in neither. */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/static/fonts/spacegrotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
                 U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/static/fonts/spacegrotesk-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jetbrainsmono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
                 U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jetbrainsmono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ============================================================
   DESIGN TOKENS — dark is the default
   ============================================================ */
:root {
  --font: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Readings only: Zs, Ω, MΩ, currents, reference numbers. */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Four text sizes and nothing else. */
  --fs-xs: 0.74rem;
  --fs-sm: 0.82rem;
  --fs: 0.9rem;
  --fs-lg: 1.05rem;
  --fs-title: 1.35rem;
  --fs-display: 1.9rem;

  /* Shape & motion — an instrument changes state, it does not perform. */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --ease: 0.12s linear;
  --ease-spring: 0.12s linear;

  /* Chassis */
  --bg: #101215;
  --bg1: #161a1e;
  --surface: #1b1f24;
  --surface-2: #22272e;
  --t: #f1f3f6;
  --t2: #c8ced7;
  --tm: #8d95a1;
  --td: #626b77;
  --bd: #2b3138;
  --border: #2b3138;

  /* The instrument yellow. Functional only. */
  --accent: #ffc400;
  --accent-hover: #ffd23f;
  --accent-dim: #c99a00;
  --accent-ink: #14171b;
  --accent-soft: rgba(255, 196, 0, 0.13);
  --accent-line: rgba(255, 196, 0, 0.34);

  /* Legacy names kept so 2,000 lines below and 67 templates keep working. */
  --amber: var(--accent);
  --amber-hover: var(--accent-hover);
  --amber-light: var(--accent-soft);
  --amber-subtle: rgba(255, 196, 0, 0.07);

  /* The primary action IS the accent — there is no second brand colour. */
  --primary: #ffc400;
  --primary-hover: #ffd23f;
  --primary-ink: #14171b;
  --primary-light: rgba(255, 196, 0, 0.13);

  /* Status — semantic, and the only other colours in the system. */
  --green: #35c46b;
  --green-light: rgba(53, 196, 107, 0.14);
  --red: #ff5f56;
  --red-light: rgba(255, 95, 86, 0.14);
  --blue: #4aa8ff;
  --blue-light: rgba(74, 168, 255, 0.14);
  --purple: #a78bfa;
  --purple-light: rgba(167, 139, 250, 0.14);
  --warning: #ffc400;
  --warning-light: rgba(255, 196, 0, 0.14);
  --info: #4aa8ff;
  --info-light: rgba(74, 168, 255, 0.14);
  --ok: var(--green);
  --ok-light: var(--green-light);
  --rd: var(--red);
  --rd-light: var(--red-light);
  --ac: var(--purple);
  --ac-light: var(--purple-light);

  /* Depth is a surface step and a hairline, not a blur. */
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow: none;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.6);

  /* Sidebar — flat, same chassis, one seam */
  --sidebar-bg: #0c0e11;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active-bg: rgba(255, 196, 0, 0.10);
  --sidebar-active-border: var(--accent);
  /* The sidebar is dark in both themes; its ink is fixed, not themed. */
  --sidebar-t: #e9ecf1;
  --sidebar-tm: #7f8896;
  --sidebar-w: 244px;
  --topbar-h: 60px;

  /* Aliases. Templates reach for these names; without them the var() falls
     through to nothing and the element renders unstyled against the chassis. */
  --card: var(--surface);
  --card-bg: var(--surface);
  --bg2: var(--surface-2);
  --fg: var(--t);
  --ink: var(--t);
  --text: var(--t);
  --txt: var(--t);
  --tx2: var(--t2);
  --muted: var(--tm);
  --line: var(--bd);
  --brand: var(--accent);
  --link: var(--accent);
  --danger: var(--red);
  --success: var(--green);
  --gn: var(--green);
  --p: var(--accent);
  --font-sans: var(--font);
}

/* ------------------------------------------------------------
   Light — the same instrument in daylight. Yellow is unchanged;
   only the chassis and the ink invert.
   ------------------------------------------------------------ */
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg1: #eceef1;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --t: #14171b;
  --t2: #3c434c;
  --tm: #646d7a;
  --td: #8b939f;
  --bd: #e2e5ea;
  --border: #e2e5ea;

  --accent-soft: rgba(255, 196, 0, 0.18);
  --accent-line: rgba(196, 150, 0, 0.5);
  --amber-subtle: rgba(255, 196, 0, 0.09);
  --primary-light: rgba(255, 196, 0, 0.18);

  /* Status hues darkened so they hold 4.5:1 on white. */
  --green: #0f8a43;
  --green-light: rgba(15, 138, 67, 0.12);
  --red: #cf2f26;
  --red-light: rgba(207, 47, 38, 0.12);
  --blue: #1668c4;
  --blue-light: rgba(22, 104, 196, 0.12);
  --purple: #6d43d6;
  --purple-light: rgba(109, 67, 214, 0.12);
  --warning: #9a7400;
  --warning-light: rgba(255, 196, 0, 0.18);
  --info: #1668c4;
  --info-light: rgba(22, 104, 196, 0.12);

  --shadow-md: 0 8px 24px rgba(20, 23, 27, 0.10);
  --shadow-lg: 0 16px 40px rgba(20, 23, 27, 0.13);
  --shadow-xl: 0 24px 60px rgba(20, 23, 27, 0.16);

  --sidebar-bg: #14171b;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(255, 196, 0, 0.13);
}

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  /* Flat chassis. The old sheet washed two radial gradients over everything,
     which is the "dark SaaS template" tell the direction rules out. */
  background: var(--bg);
  color: var(--t);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.6;
}

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

h1,h2,h3,h4,h5,h6 {
  font-family: var(--font);
  font-weight: 600;
  color: var(--t);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  text-wrap: balance;
}

/* The readout. Measured values only — Zs, Ω, MΩ, currents, references. */
.num, .readout, .kpi-value, .stat-card-value, code, kbd, samp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.table td { font-variant-numeric: tabular-nums; }

/* Yellow is the focus ring too — one accent, doing work. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.text-muted { color: var(--tm) !important; }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green) !important; }

/* An instrument changes state; it does not perform. Reduced motion is the
   house default and must leave nothing broken. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  /* Flat. The seam does the work a shadow used to. */
  background: var(--sidebar-bg);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--accent-ink);
  flex-shrink: 0;
  box-shadow: none;
}

.brand-name {
  font-weight: 600;
  color: var(--sidebar-t);
  font-size: var(--fs);
  display: block;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--sidebar-tm);
  display: block;
  font-weight: 400;
  margin-top: 1px;
}

/* A section's sub-pages. Quiet, indented, and only on screen while you are
   in that section — so the menu is eight things, not twenty-five. */
.sidebar-sub {
  display: block;
  padding: 6px 10px 6px 40px;
  font-size: var(--fs-xs);
  color: var(--sidebar-tm);
  text-decoration: none;
  border-radius: var(--radius);
  border-left: 2px solid transparent;
  transition: color var(--ease);
}
.sidebar-sub:hover { color: var(--sidebar-t); }
.sidebar-sub.here { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 12px;
}

.sidebar-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  padding: 14px 10px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-tm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--ease);
  text-decoration: none;
  position: relative;
  border-left: 2px solid transparent;
}

.sidebar-link i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-t);
  border-left-color: transparent;
}

.sidebar-link.active {
  /* The one yellow thing in the sidebar: a left rule and yellow text. */
  background: var(--sidebar-active-bg);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
  text-shadow: none;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--red);
  color: #14171b;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-bottom: 14px;
}

.sidebar-footer-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 8px 10px;
  font-size: 0.65rem;
}

.sidebar-footer-links a {
  color: rgba(255,255,255,0.25);
  text-decoration: none;
  transition: color var(--ease);
}

.sidebar-footer-links a:hover { color: rgba(255,255,255,0.5); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-name {
  color: rgba(255,255,255,0.85);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.user-role {
  color: rgba(255,255,255,0.3);
  font-size: 0.67rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  color: rgba(255,255,255,0.35) !important;
  font-size: 0.82rem !important;
}

.sidebar-logout:hover {
  color: var(--red) !important;
  background: rgba(220,38,38,0.1) !important;
  border-left-color: rgba(220,38,38,0.3) !important;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Without this a wide table stretches the flex item and the whole page
     scrolls sideways instead of the table scrolling inside its wrapper. */
  min-width: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: var(--topbar-h);
  /* Part of the chassis, not a floating pane of glass. */
  background: var(--bg);
  border-bottom: 1px solid var(--bd);
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: none;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--t);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

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

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: transparent;
  color: var(--tm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--ease);
  position: relative;
  font-size: 0.95rem;
}

.topbar-btn:hover {
  background: var(--bg);
  color: var(--t);
  border-color: var(--primary);
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--surface);
}

/* ============================================================
   SEARCH
   ============================================================ */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(15,23,42,0.06);
  border: 1.5px solid transparent;
  border-radius: 22px;
  padding: 0 14px;
  height: 36px;
  min-width: 220px;
  transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.search-box:hover {
  background: rgba(15,23,42,0.09);
}

.search-box:focus-within {
  background: var(--surface);
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.13);
}

.search-box i {
  color: var(--tm);
  font-size: 0.82rem;
  margin-right: 8px;
  flex-shrink: 0;
  transition: color var(--ease);
}

.search-box:focus-within i {
  color: var(--amber);
}

.search-box input {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  font-family: var(--font);
  font-size: 0.84rem;
  color: var(--t);
  width: 100%;
  padding: 0;
}

.search-box input::placeholder { color: var(--td); }

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  max-height: 340px;
  overflow-y: auto;
  z-index: 300;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  transition: background var(--ease);
  border-bottom: 1px solid var(--bd);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }

.search-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.search-item-body { flex: 1; min-width: 0; }
.search-item-title { font-weight: 600; font-size: 0.85rem; color: var(--t); display: block; line-height: 1.4; }
.search-item-sub { font-size: 0.73rem; color: var(--tm); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 20px; text-align: center; color: var(--tm); font-size: 0.84rem; }

.search-inline { min-width: 180px; }
.search-inline form { display: contents; }
.search-inline input {
  border: none; background: none; outline: none;
  font-family: var(--font); font-size: 0.84rem; color: var(--t); width: 100%;
}

/* ============================================================
   NOTIFICATION DRAWER
   ============================================================ */
.notif-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--bd);
  box-shadow: var(--shadow-xl);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notif-drawer.open { transform: translateX(0); }

.notif-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bd);
  font-weight: 700;
  font-size: 0.95rem;
}

.notif-drawer-header button {
  background: none;
  border: none;
  color: var(--tm);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--ease), background var(--ease);
}

.notif-drawer-header button:hover {
  color: var(--t);
  background: var(--bg);
}

.notif-drawer-body { flex: 1; overflow-y: auto; padding: 8px 0; }

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--bd);
  transition: background var(--ease);
  cursor: default;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }

.notif-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--amber);
  flex-shrink: 0;
}

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-text { font-size: 0.83rem; color: var(--t); line-height: 1.5; display: block; }
.notif-item-time { font-size: 0.7rem; color: var(--td); margin-top: 3px; display: block; }

.notif-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--tm);
  font-size: 0.84rem;
}

.notif-empty i {
  font-size: 2.2rem;
  color: var(--td);
  display: block;
  margin-bottom: 10px;
}

.notif-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 499;
  backdrop-filter: blur(2px);
}

.notif-drawer-overlay.open { display: block; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  padding: 24px 28px 100px;
  flex: 1;
  min-width: 0;
  background: transparent;
}

/* ============================================================
   MOBILE NAV
   ============================================================ */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--bd);
  display: flex;
  z-index: 100;
  padding: 6px 0 max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.07);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--td);
  font-size: 0.6rem;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--ease);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.mobile-nav-item i { font-size: 1.2rem; }
.mobile-nav-item.active { color: var(--amber); }
.mobile-nav-item:hover { color: var(--t); }

.mobile-more-menu {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: flex-end;
  backdrop-filter: blur(4px);
}

.mobile-more-menu.show { display: flex; }

.mobile-more-inner {
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 6px 0 max(20px, env(safe-area-inset-bottom));
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-more-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--bd);
  font-weight: 700;
  font-size: 0.95rem;
}

.mobile-more-header button {
  background: var(--bg);
  border: none;
  color: var(--tm);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-more-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  color: var(--t);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--ease);
}

.mobile-more-link:hover { background: var(--bg); }
.mobile-more-link i { font-size: 1.05rem; color: var(--tm); width: 22px; text-align: center; }
.mobile-more-logout { color: var(--red) !important; border-top: 1px solid var(--bd); margin-top: 6px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--bd);
  margin-bottom: 18px;
  overflow: hidden;
  /* Depth is the surface step against --bg, not a blur. */
  box-shadow: none;
  transition: border-color var(--ease);
}

.card:hover { border-color: var(--surface-2); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--tm);
  border-bottom: 1px solid var(--bd);
  background: transparent;
}

.card-header i { color: var(--tm); }
.card-body { padding: 20px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: none;
  transition: border-color var(--ease);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity var(--ease);
}

.kpi-card:hover { border-color: var(--surface-2); }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Flat tint, hairline border, colour carried by the icon. No gradients. */
.kpi-green { background: var(--green-light);   color: var(--green); }
.kpi-amber { background: var(--warning-light); color: var(--warning); }
.kpi-blue  { background: var(--blue-light);    color: var(--blue); }
.kpi-purple{ background: var(--purple-light);  color: var(--purple); }
.kpi-red   { background: var(--red-light);     color: var(--red); }

.kpi-body { display: flex; flex-direction: column; min-width: 0; }

.kpi-value {
  font-size: var(--fs-display);
  /* 700 is the top of the variable face — 800 would be faux-bold. */
  font-weight: 700;
  color: var(--t);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-label {
  font-size: 0.73rem;
  color: var(--tm);
  font-weight: 500;
  margin-top: 3px;
  letter-spacing: 0.1px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.bt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--ease);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

.bt:hover { text-decoration: none; }

/* Primary — the instrument yellow. One per view. */
.bt-p {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.bt-p:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

/* Everything that is not the primary action is a ghost: 1px border,
   transparent fill. This is what keeps one yellow thing on the screen. */
.bt-s {
  background: transparent;
  color: var(--t2);
  border-color: var(--bd);
}
.bt-s:hover {
  background: var(--surface-2);
  border-color: var(--tm);
  color: var(--t);
}

.bt-g {
  background: transparent;
  color: var(--tm);
  border-color: transparent;
}
.bt-g:hover {
  background: var(--surface-2);
  color: var(--t);
}

/* Destructive stays quiet until you hover it. */
.bt-d {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.bt-d:hover {
  background: var(--red);
  color: var(--surface);
  border-color: var(--red);
}

.bt-ok {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}
.bt-ok:hover {
  background: var(--green);
  color: var(--surface);
  border-color: var(--green);
}

/* .bt-amber predates the accent being yellow. It is now the primary. */
.bt-amber {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.bt-amber:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

.bt-sm { padding: 5px 12px; font-size: 0.78rem; }
.bt-xs { padding: 3px 9px; font-size: 0.72rem; border-radius: var(--radius-sm); }
.bt:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   BADGES
   ============================================================ */
.bd {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.2px;
  background: var(--bg1);
  color: var(--tm);
  border: 1px solid var(--bd);
  white-space: nowrap;
}

/* One tint rule, driven by the status tokens, so a badge is correct in both
   themes without a second set of rules. Flat — no gradients. */
.bd-active,   .bd-info      { background: var(--blue-light);   color: var(--blue);   border-color: var(--blue); }
.bd-pending,  .bd-paused,
.bd-warning                 { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.bd-in-progress             { background: var(--blue-light);   color: var(--blue);   border-color: var(--blue); }
.bd-completed, .bd-paid,
.bd-accepted                { background: var(--green-light);  color: var(--green);  border-color: var(--green); }
.bd-overdue,  .bd-declined  { background: var(--red-light);    color: var(--red);    border-color: var(--red); }
.bd-sent,     .bd-scheduled { background: var(--purple-light); color: var(--purple); border-color: var(--purple); }
.bd-cancelled               { background: var(--bg1);          color: var(--tm);     border-color: var(--bd); }

/* Classification codes carry their letters as well as their colour, so the
   badge is never the only signal. */
.code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
}
.code-C1  { background: var(--red-light);     color: var(--red); }
.code-C2  { background: var(--warning-light); color: var(--warning); }
.code-C3  { background: var(--blue-light);    color: var(--blue); }
.code-FI  { background: var(--purple-light);  color: var(--purple); }
.code-NV,
.code-LIM { background: var(--bg1);           color: var(--tm); }
.code-NA  { background: var(--bg1);           color: var(--td); }

/* ============================================================
   FORMS
   ============================================================ */
.fg { margin-bottom: 14px; }

.fl {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--tm);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.fi, .fs {
  width: 100%;
  padding: 9px 13px;
  border-radius: 8px;
  border: 1.5px solid var(--bd);
  font-size: 0.88rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--t);
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
  line-height: 1.5;
}

.fi:hover, .fs:hover {
  border-color: var(--td);
}

.fi:focus, .fs:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.12);
  background: var(--surface);
}

.fi::placeholder { color: var(--td); }

textarea.fi {
  min-height: 80px;
  resize: vertical;
  line-height: 1.6;
}

.fr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Select arrow — suppress native and Bootstrap arrows, apply custom one */
.fs, select.fi, select.fi.form-select {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 34px;
}


/* Phone input */
.phone-wrap { display: flex; }

.phone-wrap .phone-code {
  width: 88px;
  flex-shrink: 0;
  border-radius: 8px 0 0 8px;
  border-right: none;
  padding: 9px 8px;
  font-size: 0.84rem;
  background: var(--surface);
  color: var(--t);
  border: 1.5px solid var(--bd);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2364748b'%3E%3Cpath d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 18px;
}

.phone-wrap .fi { border-radius: 0 8px 8px 0; flex: 1; min-width: 0; }

/* Checkbox */
input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ============================================================
   MODALS — TWO SYSTEMS (both in use across templates)
   ============================================================ */

/* System 1: .mo / .ml (used in customers, invoices, etc.) */
.mo {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,14,26,0.55);
  z-index: 1050;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(6px);
}

.mo.show { display: flex; }

.ml {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
  border: 1px solid var(--bd);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ml > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ml-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}

.ml-hd h3 { margin: 0; font-size: 1rem; font-weight: 700; }

.ml-bd {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.ml-bd::-webkit-scrollbar { width: 6px; }
.ml-bd::-webkit-scrollbar-track { background: transparent; }
.ml-bd::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
.ml-bd::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

.ml-ft {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--bd);
  background: var(--bg1);
  flex-shrink: 0;
}

/* System 2: .modal-overlay / .modal-card (used in jobs, etc.) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,14,26,0.55);
  z-index: 1050;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(6px);
}

.modal-overlay.show { display: flex; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
  border: 1px solid var(--bd);
}

.modal-lg { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--bd);
  font-weight: 700;
  font-size: 1rem;
}

.modal-header button {
  background: none;
  border: none;
  color: var(--tm);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), color var(--ease);
}

.modal-header button:hover { background: var(--bg); color: var(--t); }

.modal-body { padding: 20px 22px; }
.modal-body .fg:last-child,
.modal-body .fr:last-child { margin-bottom: 0; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--bd);
  background: var(--bg1);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; max-width: 100%; }
/* Any wide block scrolls inside itself rather than pushing the page out. */
.item-table-wrap, .tw { max-width: 100%; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--tm);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--bg1);
  border-bottom: 1px solid var(--bd);
  white-space: nowrap;
}

.table td {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--bd);
  color: var(--t);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--ease);
}

.table tbody tr:hover td {
  background: var(--bg1);
}

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

.table-actions { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }

/* Table inside card (no border wrapper needed) */
.card .table th:first-child { padding-left: 20px; }
.card .table td:first-child { padding-left: 20px; }
.card .table th:last-child  { padding-right: 20px; }
.card .table td:last-child  { padding-right: 20px; }

/* .tw wrapper table (alternate) */
.tw { overflow-x: auto; border-radius: 8px; border: 1px solid var(--bd); }
.tw table { width: 100%; border-collapse: collapse; }
.tw th, .tw td { padding: 10px 14px; text-align: left; }
.tw th { background: var(--bg1); font-weight: 700; color: var(--tm); text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.68rem; border-bottom: 1px solid var(--bd); }
.tw td { border-top: 1px solid var(--bd); font-size: 0.84rem; }
.tw tr:hover td { background: var(--bg1); }

/* ============================================================
   PAGE TOOLBAR & FILTERS
   ============================================================ */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }

/* Every horizontal control row scrolls inside itself on a narrow screen
   rather than stretching its parent — that is what pushed the list pages
   sideways at 360px. `min-width: 0` is the half people forget: a flex item
   defaults to min-width:auto and refuses to shrink below its content. */
.page-toolbar > *,
.filter-tabs,
.filter-search { min-width: 0; max-width: 100%; }
.filter-tabs { overflow-x: auto; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }

/* Filter pills (segment control style) */
.filter-pills {
  display: flex;
  gap: 2px;
  background: var(--bg1);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--bd);
  /* On a phone the pill row scrolls inside itself rather than stretching the
     toolbar — which is what pushed every list page sideways at 360px. */
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-pills::-webkit-scrollbar { display: none; }

.filter-pill {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--tm);
  transition: all var(--ease);
  text-decoration: none;
  white-space: nowrap;
}

.filter-pill:hover { background: var(--surface); color: var(--t); }

.filter-pill.active {
  background: var(--surface);
  color: var(--t);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* Filter bar (used in jobs.html) */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg1);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--bd);
}

.filter-tab {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--tm);
  text-decoration: none;
  transition: all var(--ease);
  white-space: nowrap;
}

.filter-tab:hover { background: var(--surface); color: var(--t); }

.filter-tab.active {
  background: var(--surface);
  color: var(--t);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.filter-search {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* View toggle */
.view-toggle {
  display: flex;
  border: 1px solid var(--bd);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tm);
  background: var(--bg1);
  text-decoration: none;
  transition: all var(--ease);
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.view-btn:hover { background: var(--surface); color: var(--t); }
.view-btn.active { background: var(--primary); color: var(--surface); }

/* ============================================================
   GRIDS
   ============================================================ */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.dash-grid { display: flex; flex-direction: column; gap: 16px; }
.dash-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ============================================================
   QUICK ACTIONS
   ============================================================ */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

.quick-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--surface), var(--bg1));
  border: 1.5px solid var(--bd);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--t2);
  text-decoration: none;
  transition: all var(--ease);
  cursor: pointer;
  font-family: var(--font);
  box-shadow: var(--shadow-xs);
}

.quick-action i { color: var(--amber); font-size: 1rem; }

.quick-action:hover {
  border-color: rgba(245,158,11,0.55);
  background: linear-gradient(135deg, var(--amber-subtle), var(--warning-light));
  color: var(--t);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(245,158,11,0.18), var(--shadow-sm);
}

/* ============================================================
   DASHBOARD SPECIFICS
   ============================================================ */
.job-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bd);
  font-size: 0.84rem;
}

.job-row:last-child { border-bottom: none; }

.job-time {
  font-weight: 700;
  color: var(--amber-hover);
  min-width: 50px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.team-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

.job-info { flex: 1; min-width: 0; }

.job-name {
  font-weight: 600;
  color: var(--t);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-detail {
  font-size: 0.73rem;
  color: var(--tm);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-price { font-weight: 700; color: var(--green); white-space: nowrap; font-size: 0.88rem; }

/* Week ahead rows */
.week-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bd);
}

.week-day-row:last-child { border-bottom: none; }

.week-day-today {
  background: linear-gradient(90deg, var(--amber-subtle), transparent);
  margin: 0 -18px;
  padding: 10px 18px;
  border-radius: 6px;
  border-bottom-color: transparent !important;
}

.week-day-info { display: flex; flex-direction: column; }
.week-day-name { font-weight: 600; font-size: 0.88rem; display: flex; align-items: center; gap: 8px; }
.week-day-date { font-size: 0.73rem; color: var(--tm); margin-top: 1px; }
.week-day-stats { text-align: right; }
.week-day-count { font-size: 0.78rem; color: var(--tm); display: block; }
.week-day-total { font-weight: 700; color: var(--green); font-size: 0.88rem; }

/* Overdue / alert rows */
.overdue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bd);
  gap: 12px;
}

.overdue-row:last-child { border-bottom: none; }

.overdue-info { flex: 1; min-width: 0; }

.overdue-num {
  font-weight: 600;
  color: var(--purple);
  display: block;
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overdue-cust {
  font-size: 0.73rem;
  color: var(--tm);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overdue-right { text-align: right; flex-shrink: 0; }
.overdue-date { font-size: 0.73rem; color: var(--tm); display: block; }
.overdue-amt { font-weight: 700; color: var(--red); font-size: 0.88rem; display: block; }

/* Revenue bar chart (CSS fallback) */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding-bottom: 24px;
  position: relative;
}

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

.bar {
  width: 100%;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--primary), rgba(37,99,235,0.4));
  min-height: 3px;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-green { background: linear-gradient(180deg, var(--green), rgba(22,163,74,0.3)); }
.bar-label { font-size: 0.65rem; color: var(--tm); font-weight: 500; margin-top: 6px; text-align: center; }

/* Activity feed */
.activity-row {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--bd);
}

.activity-row:last-child { border-bottom: none; }

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--warning-light), var(--warning-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber-hover);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 0.82rem; color: var(--t); display: block; line-height: 1.5; }
.activity-time { font-size: 0.68rem; color: var(--td); margin-top: 2px; display: block; }

/* Empty states */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--tm);
}

.empty-state i {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 12px;
  color: var(--td);
}

.empty-state p {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: var(--tm);
}

/* ============================================================
   SCHEDULE / WEEK VIEW
   ============================================================ */
.week-grid { margin-top: 8px; }
.week-nav { display: flex; justify-content: space-between; margin-bottom: 12px; align-items: center; }
.week-cols { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }

.week-col {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  min-height: 200px;
  box-shadow: var(--shadow-xs);
}

.week-col-today {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber);
}

.week-col-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bd);
  background: var(--bg1);
  border-radius: var(--radius) var(--radius) 0 0;
  text-align: center;
}

.week-col-name { font-weight: 700; font-size: 0.8rem; display: block; }
.week-col-date { font-size: 0.7rem; color: var(--tm); }
.week-col-total { font-size: 0.7rem; color: var(--green); font-weight: 700; display: block; }
.week-col-body { padding: 8px; }

.week-job {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg1);
  margin-bottom: 6px;
  border-left: 3px solid var(--bd);
  border: 1px solid var(--bd);
  border-left-width: 3px;
}

.bd-left-pending    { border-left-color: var(--warning) !important; }
.bd-left-in-progress{ border-left-color: var(--primary) !important; }
.bd-left-completed  { border-left-color: var(--green)   !important; }

.week-job-time   { font-size: 0.65rem; font-weight: 700; color: var(--purple); }
.week-job-name   { font-size: 0.76rem; font-weight: 600; color: var(--t); display: block; }
.week-job-detail { font-size: 0.66rem; color: var(--tm); }
.week-col-empty  { text-align: center; color: var(--td); font-size: 0.73rem; padding: 20px 4px; }

.team-chips { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.team-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; background: var(--bg1);
  border-radius: 20px; border: 1px solid var(--bd);
  font-size: 0.72rem; font-weight: 500;
}

/* Schedule day view */
.jr {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: box-shadow var(--ease), border-color var(--ease);
  box-shadow: var(--shadow-xs);
}

.jr:hover { box-shadow: var(--shadow-sm); border-color: var(--bd); }

.jr-time { font-weight: 700; color: var(--amber-hover); min-width: 50px; font-size: 0.84rem; }
.jr-info { flex: 1; min-width: 0; }

.jr-name {
  font-weight: 600;
  color: var(--t);
  display: block;
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jr-name:hover { color: var(--primary); }
.jr-detail { font-size: 0.73rem; color: var(--tm); display: block; }
.jr-price { font-weight: 700; color: var(--green); white-space: nowrap; }
.jr-actions { display: flex; gap: 4px; }
.jr-recurring { border-left: 3px solid var(--purple); }
.week-job-recurring { border-left-color: var(--purple) !important; }

.schedule-summary {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--tm);
}

.schedule-total { font-weight: 700; color: var(--green); }

/* ============================================================
   DETAIL PAGES
   ============================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--tm);
  margin-bottom: 16px;
  text-decoration: none;
  transition: color var(--ease);
}

.back-link:hover { color: var(--primary); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 14px;
}

.detail-name {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.3px;
}

.detail-address {
  font-size: 0.84rem;
  color: var(--tm);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

.detail-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-xs);
}

.stat-card-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--tm);
  margin-bottom: 5px;
  font-weight: 700;
  display: block;
}

.stat-card-value { font-size: 1.3rem; font-weight: 800; display: block; color: var(--t); }
.stat-green  { color: var(--green)  !important; }
.stat-blue   { color: var(--primary)!important; }
.stat-purple { color: var(--purple) !important; }
.stat-red    { color: var(--red)    !important; }
.stat-amber  { color: var(--amber-hover) !important; }

.detail-fields { display: flex; flex-direction: column; gap: 14px; }

.detail-field-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--tm);
  margin-bottom: 3px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-field-value { font-size: 0.88rem; font-weight: 500; color: var(--t); }

.payment-alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.payment-danger { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.payment-ok { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }

.round-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg1);
  border-left: 3px solid var(--amber);
}

/* ============================================================
   TEAM
   ============================================================ */
.team-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.team-avatar {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--surface);
  flex-shrink: 0;
  font-weight: 800;
}

.team-info { flex: 1; }
.team-name { font-weight: 700; font-size: 0.92rem; display: block; }
.team-role { font-size: 0.72rem; font-weight: 600; }
.team-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }

.team-stat {
  background: var(--bg1);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--bd);
}

.team-stat-label { font-size: 0.62rem; color: var(--tm); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; display: block; }
.team-stat-value { font-size: 1.1rem; font-weight: 800; margin-top: 2px; display: block; color: var(--t); }
.team-contact { font-size: 0.77rem; color: var(--tm); display: flex; align-items: center; gap: 6px; margin-top: 4px; }

.team-chips { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.team-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; background: var(--bg1);
  border-radius: 20px; border: 1px solid var(--bd);
  font-size: 0.72rem; font-weight: 500;
}

/* ============================================================
   REPORTS
   ============================================================ */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--bd);
}

.metric-row:last-child { border-bottom: none; }
.metric-label { font-size: 0.84rem; color: var(--tm); }
.metric-value { font-weight: 700; font-size: 0.88rem; color: var(--t); }
.metric-total { padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--bd); border-bottom: none; }

/* ============================================================
   SETTINGS
   ============================================================ */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--bd);
  cursor: pointer;
}

.toggle-group:last-of-type { border-bottom: none; }
.toggle-label { font-size: 0.88rem; font-weight: 500; color: var(--t); }

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--bd);
  border-radius: 11px;
  transition: background var(--ease);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-group input { display: none; }
.toggle-group input:checked + .toggle-switch { background: var(--primary); }
.toggle-group input:checked + .toggle-switch::after { transform: translateX(18px); }

.hours-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.hours-day { min-width: 90px; font-size: 0.84rem; font-weight: 500; color: var(--t); }
.hours-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hours-closed-label { display: flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--tm); cursor: pointer; }
.hours-closed-label input { accent-color: var(--primary); }
.hours-time:disabled { opacity: 0.4; }

/* ============================================================
   BULK BAR
   ============================================================ */
.bulk-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 2px solid var(--primary);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ============================================================
   WEATHER WIDGET
   ============================================================ */
.weather-days { display: flex; gap: 8px; overflow-x: auto; }

.weather-day {
  flex: 1;
  min-width: 88px;
  text-align: center;
  padding: 12px 8px;
  border-radius: 9px;
  background: var(--bg1);
  border: 1px solid var(--bd);
}

.weather-day-name { font-size: 0.72rem; font-weight: 700; color: var(--tm); margin-bottom: 6px; display: block; }
.weather-icon { font-size: 1.4rem; color: var(--amber); display: block; margin-bottom: 4px; }
.weather-temp { font-size: 1.1rem; font-weight: 700; color: var(--t); }
.weather-detail { font-size: 0.66rem; color: var(--tm); }
.weather-warning { border-color: var(--warning); background: var(--warning-light); }
.weather-alert { font-size: 0.63rem; font-weight: 700; color: var(--warning); margin-top: 4px; }
.weather-loading { text-align: center; color: var(--tm); padding: 16px; font-size: 0.84rem; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   ROUNDS
   ============================================================ */
.round-card .card-body { padding: 18px; }
.round-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.round-color { width: 12px; height: 44px; border-radius: 6px; flex-shrink: 0; margin-top: 2px; }
.round-title { flex: 1; }
.round-name { font-size: 1rem; margin: 0; font-weight: 700; }
.round-day { font-size: 0.73rem; color: var(--tm); font-weight: 500; }
.round-area { font-size: 0.73rem; color: var(--tm); display: flex; align-items: center; gap: 4px; }
.round-actions { display: flex; gap: 4px; }
.round-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.round-stat { background: var(--bg1); border-radius: 8px; padding: 10px; text-align: center; border: 1px solid var(--bd); }
.round-stat-value { font-size: 1.1rem; font-weight: 800; display: block; color: var(--t); }
.round-stat-label { font-size: 0.63rem; color: var(--tm); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.round-cust-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--bd); }
.round-cust-row:last-child { border-bottom: none; }
.round-cust-name { font-weight: 600; font-size: 0.86rem; color: var(--t); text-decoration: none; display: block; }
.round-cust-name:hover { color: var(--primary); }
.round-cust-addr { font-size: 0.73rem; color: var(--tm); }
.round-cust-total { display: flex; justify-content: space-between; padding: 12px 0 0; border-top: 2px solid var(--bd); margin-top: 8px; font-weight: 700; font-size: 0.88rem; }
.round-assign-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bd); cursor: pointer; }
.round-assign-row:hover { background: var(--bg1); margin: 0 -20px; padding: 10px 20px; border-radius: 6px; }
.round-assign-row input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* ============================================================
   ACCOUNTS / EXPORT
   ============================================================ */
.export-list { display: flex; flex-direction: column; gap: 2px; }

.export-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--t);
  transition: background var(--ease);
}

.export-item:hover { background: var(--bg); color: var(--t); }

.export-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.export-body { flex: 1; min-width: 0; }
.export-title { font-weight: 600; font-size: 0.86rem; display: block; color: var(--t); }
.export-desc { font-size: 0.73rem; color: var(--tm); display: block; }
.export-dl { color: var(--tm); font-size: 1rem; }
.export-item:hover .export-dl { color: var(--primary); }

.quarter-block { padding: 14px 0; border-bottom: 1px solid var(--bd); }
.quarter-block:last-child { border-bottom: none; }
.quarter-header { font-weight: 700; font-size: 0.8rem; color: var(--tm); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.quarter-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quarter-stat { background: var(--bg1); border-radius: 8px; padding: 10px 12px; border: 1px solid var(--bd); }
.quarter-stat-label { font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--tm); font-weight: 700; display: block; }
.quarter-stat-value { font-size: 1rem; font-weight: 800; display: block; margin-top: 2px; color: var(--t); }

/* ============================================================
   DROPDOWNS
   ============================================================ */
.cc-dropdown { position: relative; display: inline-block; }

.cc-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  min-width: 200px;
  z-index: 300;
  padding: 6px 0;
  animation: dropIn 0.15s ease-out;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cc-dropdown.open .cc-dropdown-menu { display: block; }

.cc-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--t2);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--ease);
}

.cc-dropdown-item:hover { background: var(--bg); color: var(--t); }
.cc-dropdown-item i { color: var(--tm); width: 16px; text-align: center; }
.cc-dropdown-divider { height: 1px; background: var(--bd); margin: 4px 0; }

/* ============================================================
   TABLE CELL HELPERS
   ============================================================ */
.customer-name { font-weight: 600; font-size: 0.86rem; }
.customer-address { font-size: 0.73rem; color: var(--tm); margin-top: 2px; }
.invoice-number { font-weight: 700; color: var(--purple); }
.date { color: var(--tm); font-size: 0.8rem; }

/* ============================================================
   AUTH — SPLIT SCREEN
   ============================================================ */
.auth-split {
  min-height: 100vh;
  display: flex;
}

/* Left brand panel */
.auth-panel-l {
  flex: 0 0 42%;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 52px;
  position: relative;
  overflow: hidden;
}

.auth-panel-l::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -80px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(245,158,11,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.auth-panel-l::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(37,99,235,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.auth-brand-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--surface);
  margin-bottom: 28px;
  box-shadow: 0 8px 24px rgba(245,158,11,0.3);
}

.auth-brand-name {
  font-size: 2rem;
  font-weight: 900;
  color: var(--surface);
  letter-spacing: -0.5px;
  display: block;
  margin-bottom: 6px;
}

.auth-brand-tagline {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 44px;
  line-height: 1.5;
  max-width: 280px;
}

.auth-features { display: flex; flex-direction: column; gap: 16px; }

.auth-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.auth-feature-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  font-size: 0.82rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.auth-feature-text {
  display: flex;
  flex-direction: column;
}

.auth-feature-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  line-height: 1.3;
}

.auth-feature-sub {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.35);
  margin-top: 2px;
}

.auth-panel-l-footer {
  margin-top: 56px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.2);
}

/* Right form panel */
.auth-panel-r {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 40px 32px;
}

.auth-form-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-form-heading {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--t);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.auth-form-sub {
  font-size: 0.86rem;
  color: var(--tm);
  margin-bottom: 28px;
}

.auth-form-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bd);
  padding: 28px 28px;
  box-shadow: var(--shadow-md);
}

/* Legacy auth classes (kept for compat) */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 2rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 36px; border: 1px solid var(--bd); }
.auth-logo { font-size: 2rem; text-align: center; margin-bottom: 4px; color: var(--amber); }
.auth-title { text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--t); margin-bottom: 4px; }
.auth-sub { text-align: center; font-size: 0.84rem; color: var(--tm); margin-bottom: 24px; }
.auth-form .fg { margin-bottom: 16px; }
.auth-form .bt { width: 100%; justify-content: center; padding: 11px; font-size: 0.92rem; margin-top: 8px; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 0.84rem; color: var(--tm); }
.auth-alt a { color: var(--primary); font-weight: 600; }

/* Flash messages */
.flash {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-weight: 500;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash-error   { background: var(--red-light);     color: var(--red);     border: 1px solid var(--red); }
.flash-success { background: var(--green-light);   color: var(--green);   border: 1px solid var(--green); }
.flash-warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-light); }

/* ============================================================
   ALERTS (Bootstrap override)
   ============================================================ */
.alert { background: var(--surface); border: 1px solid var(--bd); color: var(--t); border-radius: var(--radius); }
.alert-success { background: var(--green-light); color: var(--green); border-color: var(--green); }
.alert-error,
.alert-danger  { background: var(--red-light); color: var(--red); border-color: var(--red); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: var(--accent); }
.alert-info    { background: var(--blue-light); color: var(--primary-hover); border-color: var(--blue); }


.btn-close { filter: none; }

/* ============================================================
   BOOTSTRAP OVERRIDES
   ============================================================ */
body { color: var(--t); background: var(--bg); }

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--t);
  --bs-table-border-color: var(--bd);
  color: var(--t);
}

.table th { background: var(--bg1) !important; color: var(--tm) !important; border-color: var(--bd) !important; }
.table td { color: var(--t); border-color: var(--bd) !important; }
.table tr:hover td { background: var(--bg1) !important; }
.tw table th { color: var(--tm); }
.tw table td { color: var(--t); }

.form-control, .form-select, input, select, textarea {
  color: var(--t);
  background-color: var(--surface);
  border-color: var(--bd);
  font-family: var(--font);
}

.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
  color: var(--t);
  background-color: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

select option { background: var(--surface); color: var(--t); }

input[type="checkbox"] { accent-color: var(--primary); }

/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg1) 25%, var(--bd) 50%, var(--bg1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { display: none !important; }
  .main-content { margin-left: 0; }

  /* Topbar — compact mobile */
  .topbar { padding: 0 12px; height: 56px; }
  .topbar-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.3px; }
  .search-box { display: none; }
  .topbar-btn { width: 38px; height: 38px; }

  /* Content area with nav clearance */
  .page-content { padding: 14px 14px 100px; }

  /* Grid layouts */
  .dash-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .g2, .g3, .dash-two-col, .settings-grid { grid-template-columns: 1fr; }
  .week-cols { grid-template-columns: repeat(3, 1fr); }
  .fr { grid-template-columns: 1fr; }

  /* Toolbar */
  .page-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar-left { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: flex-end; }

  /* Scrollable pills */
  .filter-pills, .filter-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .filter-pills::-webkit-scrollbar, .filter-tabs::-webkit-scrollbar { display: none; }

  /* Detail header */
  .detail-header { flex-direction: column; }

  /* Job row */
  .jr { flex-wrap: wrap; gap: 8px; }
  .jr-actions { width: 100%; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--bd); }

  /* Quick actions horizontal scroll */
  .quick-actions { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 4px; }
  .quick-actions::-webkit-scrollbar { display: none; }
  .quick-action { flex-shrink: 0; min-width: 72px; }

  /* Filter bar */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-search { flex-wrap: wrap; }

  /* Cards — slightly more breathing room */
  .card { border-radius: var(--radius-lg); }
  .card-header { font-size: 0.9rem; }
  .kpi-card { border-radius: var(--radius-lg); }

  /* Buttons — bigger touch targets */
  .bt { min-height: 40px; }

  /* Auth */
  .auth-split { flex-direction: column; }
  .auth-panel-l { flex: none; min-height: auto; padding: 32px 28px; }
  .auth-panel-r { padding: 32px 20px; }
  .auth-features { display: none; }

  /* Notifications drawer */
  .notif-drawer { width: 100%; }

  /* Tables — swipeable. Must stay horizontally scrollable: `overflow:hidden`
     clipped wide tables and made columns like Status unreachable on phones. */
  .table-responsive { border-radius: var(--radius); overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; }
  .table { font-size: 0.85rem; }
  /* Keep cells on one line so dates don't break into ugly 3-line stacks; the
     table scrolls instead. Secondary/muted sub-text may still wrap. */
  .table th, .table td { white-space: nowrap; }
  .table td .muted, .table td .sub, .table td small, .table td .addr { white-space: normal; }
}

/* ============================================================
   DETAIL VIEW — two-column record layout
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--bd);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--tm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 130px;
  flex-shrink: 0;
  padding-top: 3px;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .dash-kpis { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .week-cols { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.35rem; }
  .auth-panel-l { padding: 24px 20px; }
  .auth-form-card { padding: 22px 18px; }
}

@media (min-width: 1400px) {
  :root { --sidebar-w: 260px; }
  .page-content { padding: 28px 36px 100px; }
  .topbar { padding: 0 36px; }
}

/* Keep the essential-cookie notice clear of the mobile navigation. */
@media (max-width: 991px) { :root { --cookie-bottom: calc(68px + env(safe-area-inset-bottom)); } }
