/* =====================================================================
   Chip.IT Mechanical — Enterprise Design System v2
   ---------------------------------------------------------------------
   Mobile-first, accessible, production-grade.
   - Royal blue brand, layered neutrals, true dark mode
   - 4pt spacing grid, Inter typography, consistent radii & shadows
   - Defensive SVG sizing (no more 300x150 icon blowouts)
   - Responsive app shell (off-canvas sidebar on mobile)
   - Split-panel auth that collapses gracefully on phones
   ===================================================================== */

/* =====================================================================
   1. Design tokens
   ===================================================================== */
:root,
:root[data-theme="light"] {
  /* Brand — royal blue */
  --brand-50:  #eef3ff;
  --brand-100: #dbe4ff;
  --brand-200: #b8c9ff;
  --brand-300: #8ea8ff;
  --brand-400: #5c80ff;
  --brand-500: #2a5dff;
  --brand-600: #1e50e0;
  --brand-700: #153fb8;
  --brand-800: #0a2d8f;
  --brand-900: #051c66;

  /* Surfaces */
  --bg:            #f4f6fb;
  --bg-elev:       #ffffff;
  --surface:       #ffffff;
  --surface-2:     #f1f4fa;
  --surface-3:     #e6ebf4;
  --border:        #e1e6f0;
  --border-strong: #ccd4e2;
  --overlay:       rgba(10, 16, 32, .55);

  /* Text */
  --text:    #0b1b3d;
  --text-2:  #31405f;
  --muted:   #6a7489;
  --muted-2: #96a0b4;

  /* Semantic */
  --primary:       var(--brand-600);
  --primary-fg:    #ffffff;
  --primary-hover: var(--brand-700);
  --primary-soft:  var(--brand-50);

  --success:    #0c8c54;
  --success-bg: #e6f6ee;
  --success-bd: #a8dfc2;
  --warn:       #b36b00;
  --warn-bg:    #fff3dc;
  --warn-bd:    #f0cd88;
  --danger:     #c9302c;
  --danger-bg:  #fde8e8;
  --danger-bd:  #f0b4b4;
  --info:       var(--brand-600);
  --info-bg:    var(--brand-50);
  --info-bd:    var(--brand-200);

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(13, 35, 90, .05);
  --shadow-sm: 0 1px 3px rgba(13, 35, 90, .07), 0 1px 2px rgba(13, 35, 90, .04);
  --shadow-md: 0 4px 14px rgba(13, 35, 90, .09), 0 2px 4px rgba(13, 35, 90, .05);
  --shadow-lg: 0 12px 32px rgba(13, 35, 90, .14), 0 4px 8px rgba(13, 35, 90, .06);
  --shadow-xl: 0 24px 60px rgba(13, 35, 90, .18);
  --focus-ring: 0 0 0 3px rgba(30, 80, 224, .24);

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Layout */
  --sidebar-w:   264px;
  --topbar-h:    60px;
  --content-max: 1240px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand-50:  rgba(59, 109, 255, .10);
  --brand-100: rgba(59, 109, 255, .18);
  --brand-200: rgba(59, 109, 255, .28);
  --brand-300: #6a8bff;
  --brand-400: #5478ff;
  --brand-500: #3b6dff;
  --brand-600: #3b6dff;
  --brand-700: #1e50e0;
  --brand-800: #153fb8;
  --brand-900: #0a2d8f;

  --bg:            #05070f;
  --bg-elev:       #0a1020;
  --surface:       #0e1528;
  --surface-2:     #141d38;
  --surface-3:     #1a2547;
  --border:        #1f2a4a;
  --border-strong: #2a3863;
  --overlay:       rgba(0, 0, 0, .65);

  --text:    #eef2fa;
  --text-2:  #c4cde0;
  --muted:   #8c97b2;
  --muted-2: #5f6a85;

  --primary:       var(--brand-500);
  --primary-fg:    #ffffff;
  --primary-hover: var(--brand-400);
  --primary-soft:  rgba(59, 109, 255, .14);

  --success:    #3ec47a;
  --success-bg: rgba(34, 197, 94, .10);
  --success-bd: rgba(34, 197, 94, .35);
  --warn:       #f5b042;
  --warn-bg:    rgba(245, 158, 11, .12);
  --warn-bd:    rgba(245, 158, 11, .35);
  --danger:     #f06363;
  --danger-bg:  rgba(239, 68, 68, .10);
  --danger-bd:  rgba(239, 68, 68, .38);
  --info:       var(--brand-500);
  --info-bg:    rgba(59, 109, 255, .10);
  --info-bd:    rgba(59, 109, 255, .38);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .5);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, .65);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, .75);
  --focus-ring: 0 0 0 3px rgba(59, 109, 255, .34);

  color-scheme: dark;
}

/* =====================================================================
   2. Reset
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }

/* ---------------------------------------------------------------------
   DEFENSIVE SVG SIZING — prevents icon blow-outs.
   Any inline <svg> without explicit width/height defaults to 1em,
   so icons can never balloon to 300x150. Specific sizes still override.
   --------------------------------------------------------------------- */
svg:not([width]):not([height]) {
  width: 1em;
  height: 1em;
}
svg { flex-shrink: 0; max-width: 100%; }

button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; }

/* =====================================================================
   3. Typography
   ===================================================================== */
h1, h2, h3, h4, h5 {
  font-family: "Inter Tight", "Inter Display", "Inter", sans-serif;
  letter-spacing: -.015em;
  color: var(--text);
  line-height: 1.25;
  margin: 0;
  font-weight: 700;
}
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.75rem); }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: .95rem; font-weight: 600; }

p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--brand-600); color: #fff; }

code, kbd, pre {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .88em;
}
code {
  background: var(--surface-2);
  padding: .08em .35em;
  border-radius: 5px;
  border: 1px solid var(--border);
}

/* Text scale */
.text-xs  { font-size: .75rem;  line-height: 1.4; }
.text-sm  { font-size: .8125rem; line-height: 1.45; }
.text-md  { font-size: .875rem; line-height: 1.5; }
.text-lg  { font-size: 1rem;    line-height: 1.5; }
.text-xl  { font-size: 1.125rem; line-height: 1.4; }
.text-2xl { font-size: 1.375rem; line-height: 1.3; }

.muted    { color: var(--muted); }
.muted-2  { color: var(--muted-2); }
.text-2   { color: var(--text-2); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.small  { font-size: .8125rem; color: var(--muted); }
.center { text-align: center; }

.kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: inherit;
  font-size: .72rem;
  color: var(--muted);
  background: var(--surface-2);
}

/* Spacing helpers */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* Flex helpers */
.row         { display: flex; align-items: center; gap: .5rem; }
.row-wrap    { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.stack       { display: flex; flex-direction: column; gap: .75rem; }
.stack-lg    { display: flex; flex-direction: column; gap: 1.25rem; }
.hstack      { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.spacer      { flex: 1; }

/* =====================================================================
   4. App shell — mobile-first
   ===================================================================== */
.app {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar"
    "content";
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* -------- Sidebar (off-canvas on mobile) -------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: min(86vw, 300px);
  height: 100%;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform .22s cubic-bezier(.3, .8, .3, 1);
  box-shadow: var(--shadow-xl);
  padding: .5rem .5rem;
  padding-top: calc(.5rem + env(safe-area-inset-top));
}
.sidebar.is-open { transform: translateX(0); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .75rem;
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--text);
}
.sidebar-brand:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.sidebar-brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.sidebar-brand-text .name {
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.sidebar-brand-text .tag {
  font-size: .65rem;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
}
.sidebar-brand .dot { color: var(--primary); margin: 0 2px; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}
.nav-section {
  padding: 0 .25rem;
  margin-bottom: 1rem;
}
.nav-section-label {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: .5rem .75rem .3rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .75rem;
  margin: 1px 0;
  border-radius: var(--r-md);
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -.5rem;
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
}
.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}
.nav-link .badge {
  margin-left: auto;
  font-size: .7rem;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600;
}
.nav-link.is-active .badge {
  background: var(--brand-600);
  color: #fff;
}

/* Sidebar footer / user block */
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: .75rem .5rem;
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
}
.user-card {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .65rem;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: .02em;
}
.user-info { min-width: 0; flex: 1; }
.user-info .name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info .email {
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-card a.logout {
  color: var(--muted);
  padding: 6px;
  border-radius: var(--r-sm);
  display: inline-grid;
  place-items: center;
}
.user-card a.logout:hover {
  background: var(--surface-3);
  color: var(--danger);
}
.user-card a.logout svg { width: 16px; height: 16px; }

/* -------- Topbar -------- */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  padding-top: env(safe-area-inset-top);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
@media (min-width: 640px) {
  .topbar { gap: .75rem; padding: 0 1rem; }
}

/* Topbar actions are desktop-only; on mobile they move to page-actions-bar. */
.topbar-actions-desktop { display: none; }
@media (min-width: 640px) {
  .topbar-actions-desktop { display: inline-flex; gap: .5rem; align-items: center; }
}

/* Page-level action bar (Add vehicle, Log service, etc.). Full-width stack on
   mobile so primary actions stay thumb-reachable; right-aligned on desktop.
   Hidden on desktop to avoid duplicating the topbar actions. */
.page-actions-bar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  margin-top: -.25rem;
}
.page-actions-bar > .btn,
.page-actions-bar > a,
.page-actions-bar > form {
  flex: 1 1 auto;
  min-width: 0;
}
.page-actions-bar > .btn { width: 100%; }
@media (min-width: 640px) {
  .page-actions-bar { display: none; }
}
.topbar-title-group {
  min-width: 0;
  line-height: 1.2;
  flex: 1;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* -------- Content -------- */
.content {
  grid-area: content;
  padding: 1rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.content-inner {
  width: 100%;
  max-width: min(var(--content-max), 100%);
  margin: 0 auto;
  min-width: 0;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 .2rem; }
.page-head .page-sub {
  color: var(--muted);
  font-size: .88rem;
}
.page-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* -------- Footer -------- */
.footer {
  padding: 1.25rem 1rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .78rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-elev);
}
.footer .brand-line {
  font-weight: 600;
  color: var(--text-2);
}

/* -------- Sidebar toggle (hamburger) -------- */
.sidebar-toggle { display: inline-grid; }

/* -------- Desktop (>= 960px): persistent sidebar -------- */
@media (min-width: 960px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar content";
  }
  .sidebar {
    position: sticky;
    grid-area: sidebar;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: auto;
    transform: none;
    box-shadow: none;
    padding: .75rem .55rem;
    padding-top: calc(.75rem + env(safe-area-inset-top));
  }
  .sidebar-backdrop { display: none !important; }
  .sidebar-toggle { display: none; }
  .topbar { padding: 0 1.5rem; }
  .content { padding: 1.5rem; padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
}

/* =====================================================================
   5. Icon buttons / theme toggle
   ===================================================================== */
.icon-btn {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--primary);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.subtle { border-color: transparent; }
.icon-btn.subtle:hover { background: var(--surface-2); }

.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Optional topbar search */
.searchbar {
  display: none;
  align-items: center;
  gap: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 .65rem;
  height: 38px;
  min-width: 260px;
  color: var(--muted);
}
.searchbar input {
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  width: 100%;
  font-size: .875rem;
}
.searchbar:focus-within {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
@media (min-width: 1100px) { .searchbar { display: flex; } }

/* =====================================================================
   6. Alerts / flash messages
   ===================================================================== */
.alert {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .8rem .95rem;
  border-radius: var(--r-lg);
  border: 1px solid;
  font-size: .88rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}
.alert svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}
.alert-ok   { background: var(--success-bg); border-color: var(--success-bd); color: var(--success); }
.alert-err  { background: var(--danger-bg);  border-color: var(--danger-bd);  color: var(--danger); }
.alert-info { background: var(--info-bg);    border-color: var(--info-bd);    color: var(--info); }
.alert-warn { background: var(--warn-bg);    border-color: var(--warn-bd);    color: var(--warn); }
.alert strong { color: inherit; font-weight: 600; }

.flash {
  padding: .8rem .95rem;
  border-radius: var(--r-lg);
  border: 1px solid;
  font-size: .88rem;
  margin-bottom: 1rem;
}
.flash-ok   { background: var(--success-bg); border-color: var(--success-bd); color: var(--success); }
.flash-err  { background: var(--danger-bg);  border-color: var(--danger-bd);  color: var(--danger); }
.flash-info { background: var(--info-bg);    border-color: var(--info-bd);    color: var(--info); }

/* =====================================================================
   7. Cards & surfaces
   ===================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem;
  box-shadow: var(--shadow-xs);
}
@media (min-width: 640px) { .card { padding: 1.25rem; } }
.card + .card { margin-top: 1rem; }
.card.padded-0 { padding: 0; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 1.1rem; }
.card-foot {
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.section-title {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.75rem 0 .75rem;
}

a.card {
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
a.card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
a.card:active { transform: translateY(1px); }

/* =====================================================================
   8. KPI stats
   ===================================================================== */

/* =====================================================================
   Instrument Cluster — automotive-style dashboard hero
   ===================================================================== */
.instrument-cluster {
  position: relative;
  padding: 1.1rem 1.15rem 1rem;
  border-radius: 20px;
  background:
    radial-gradient(160% 110% at 0% 0%, rgba(100, 140, 255, .22), transparent 55%),
    linear-gradient(180deg, #0a1d54 0%, #040d36 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow:
    0 24px 50px -28px rgba(5, 20, 60, .6),
    0 6px 18px -6px rgba(5, 20, 60, .25),
    inset 0 1px 0 rgba(255, 255, 255, .06);
  overflow: hidden;
  margin-bottom: 1.5rem;
  isolation: isolate;
}
.instrument-cluster::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,.025) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.025) 0 2px, transparent 2px 6px);
  pointer-events: none;
  z-index: 0;
}
.instrument-cluster::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg, #1E50E0 0 14px, rgba(255,255,255,.85) 14px 28px);
  opacity: .5;
  z-index: 1;
}
.instrument-cluster > * { position: relative; z-index: 2; }

.cluster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
}
.cluster-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: rgba(255, 255, 255, .72);
}
.cluster-label svg { color: rgba(255, 255, 255, .55); }
.cluster-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.cluster-pill.ok   { background: rgba(34, 197, 94, .15); border: 1px solid rgba(34, 197, 94, .35); color: #86efac; }
.cluster-pill.warn { background: rgba(245, 158, 11, .14); border: 1px solid rgba(245, 158, 11, .35); color: #fcd34d; }
.cluster-pill.bad  { background: rgba(239, 68, 68, .14);  border: 1px solid rgba(239, 68, 68, .4);  color: #fca5a5; }
.cluster-pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.cluster-pill.ok .dot   { background: #22c55e; animation: showcasePulse 1.8s ease-in-out infinite; }
.cluster-pill.warn .dot { background: #f59e0b; }
.cluster-pill.bad  .dot { background: #ef4444; animation: showcasePulse 1.4s ease-in-out infinite; }

.cluster-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: center;
}
.cluster-gauge-wrap {
  display: flex;
  justify-content: center;
  max-width: 280px;
  margin: 0 auto;
  filter: drop-shadow(0 8px 18px rgba(30, 80, 224, .4));
}

.cluster-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .55rem;
}
.cluster-stat {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  min-width: 0;
  transition: border-color .15s, background .15s;
}
.cluster-stat:hover {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .15);
}
.cluster-stat-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  background: rgba(59, 130, 246, .18);
  color: #93c5fd;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.cluster-stat.warn .cluster-stat-icon { background: rgba(245, 158, 11, .18); color: #fcd34d; }
.cluster-stat.bad  .cluster-stat-icon { background: rgba(239, 68, 68, .18);  color: #fca5a5; }
.cluster-stat-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cluster-stat .label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .5);
}
.cluster-stat .value {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cluster-stat.bad .value { color: #fca5a5; }
.cluster-stat .sub {
  font-size: .7rem;
  color: rgba(255, 255, 255, .5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cluster-foot {
  margin-top: .8rem;
  padding: .6rem .8rem;
  border-radius: 10px;
  background: rgba(59, 130, 246, .12);
  border: 1px solid rgba(59, 130, 246, .25);
  color: rgba(255, 255, 255, .88);
  font-size: .82rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.cluster-foot svg { color: #93c5fd; flex-shrink: 0; }
.cluster-foot strong { color: #fff; font-weight: 700; }
.cluster-foot.warn { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .3); }
.cluster-foot.warn svg { color: #fcd34d; }
.cluster-foot.bad  { background: rgba(239, 68, 68, .12);  border-color: rgba(239, 68, 68, .3); }
.cluster-foot.bad  svg { color: #fca5a5; }

@media (min-width: 820px) {
  .instrument-cluster { padding: 1.5rem 1.75rem 1.25rem; }
  .cluster-head { margin-bottom: .75rem; }
  .cluster-grid {
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 1.75rem;
    align-items: center;
  }
  .cluster-gauge-wrap { max-width: 360px; margin: 0; }
  .cluster-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: .7rem;
  }
}
@media (min-width: 1200px) {
  .cluster-grid { grid-template-columns: minmax(300px, 380px) 1fr; }
  .cluster-stats { grid-template-columns: repeat(4, 1fr); }
  .cluster-stat { padding: .85rem .9rem; }
  .cluster-stat .value { font-size: 1.3rem; }
}

/* Asset-card status badge (automotive pill overlaid on the thumb) */
.asset-status-badge {
  position: absolute;
  top: .6rem;
  right: .6rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}
.asset-status-badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.asset-status-badge.ok {
  background: rgba(220, 252, 231, .9);
  border: 1px solid rgba(34, 197, 94, .45);
  color: #15803d;
}
.asset-status-badge.ok .dot { background: #22c55e; }
.asset-status-badge.warn {
  background: rgba(254, 243, 199, .9);
  border: 1px solid rgba(245, 158, 11, .5);
  color: #a16207;
}
.asset-status-badge.warn .dot { background: #f59e0b; }
.asset-status-badge.bad {
  background: rgba(254, 226, 226, .92);
  border: 1px solid rgba(239, 68, 68, .55);
  color: #b91c1c;
}
.asset-status-badge.bad .dot { background: #ef4444; animation: showcasePulse 1.4s ease-in-out infinite; }
:root[data-theme="dark"] .asset-status-badge.ok   { background: rgba(34, 197, 94, .2);  color: #86efac; }
:root[data-theme="dark"] .asset-status-badge.warn { background: rgba(245, 158, 11, .18); color: #fcd34d; }
:root[data-theme="dark"] .asset-status-badge.bad  { background: rgba(239, 68, 68, .2);  color: #fca5a5; }

.asset-card.status-warn { border-left: 3px solid var(--warn); }
.asset-card.status-bad  { border-left: 3px solid var(--danger); }

.stats-grid {
  display: grid;
  gap: .85rem;
  grid-template-columns: 1fr;
  margin-bottom: 1.25rem;
}
@media (min-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}
@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: .35rem;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
a.stat { color: inherit; text-decoration: none; }
a.stat:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.stat .stat-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.stat .stat-label svg { width: 14px; height: 14px; }
.stat .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-family: "Inter Tight", "Inter Display", "Inter", sans-serif;
  color: var(--text);
  line-height: 1.1;
}
.stat .stat-foot { font-size: .78rem; color: var(--muted); }
.stat .stat-foot .chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-bd);
  font-weight: 600;
  font-size: .72rem;
}
.stat .stat-foot .chip.bad {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-bd);
}
.stat.brand {
  background:
    radial-gradient(600px 200px at 100% 0%, rgba(255,255,255,.18), transparent 60%),
    linear-gradient(135deg, var(--brand-600), var(--brand-800));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(30, 80, 224, .32);
  position: relative;
}
.stat.brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(135deg, #000, transparent 70%);
  -webkit-mask-image: linear-gradient(135deg, #000, transparent 70%);
  pointer-events: none;
  opacity: .7;
}
.stat.brand > * { position: relative; z-index: 1; }
.stat.brand .stat-label,
.stat.brand .stat-value,
.stat.brand .stat-foot { color: #fff; }
.stat.brand .stat-label { color: rgba(255, 255, 255, .82); }
.stat.brand .stat-foot  { color: rgba(255, 255, 255, .84); }

/* =====================================================================
   9. Forms
   ===================================================================== */
.form-row {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .9rem;
}
.form-row label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-2);
}
.form-row .hint { font-size: .75rem; color: var(--muted); }

/* Use explicit type selectors (lower specificity than :not() chains)
   so per-case overrides like the icon-prefixed input can win cleanly. */
.input,
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row input[type="tel"],
.form-row input[type="url"],
.form-row input[type="search"],
.form-row input[type="date"],
.form-row input[type="datetime-local"],
.form-row input[type="time"],
.form-row input:not([type]),
.form-row select,
.form-row textarea {
  width: 100%;
  padding: .7rem .85rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: .92rem;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
:root[data-theme="dark"] .input,
:root[data-theme="dark"] .form-row input[type="text"],
:root[data-theme="dark"] .form-row input[type="email"],
:root[data-theme="dark"] .form-row input[type="password"],
:root[data-theme="dark"] .form-row input[type="number"],
:root[data-theme="dark"] .form-row input[type="tel"],
:root[data-theme="dark"] .form-row input[type="url"],
:root[data-theme="dark"] .form-row input[type="search"],
:root[data-theme="dark"] .form-row input[type="date"],
:root[data-theme="dark"] .form-row input[type="datetime-local"],
:root[data-theme="dark"] .form-row input[type="time"],
:root[data-theme="dark"] .form-row input:not([type]),
:root[data-theme="dark"] .form-row select,
:root[data-theme="dark"] .form-row textarea {
  background: var(--bg);
  border-color: var(--border-strong);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}
.form-row textarea { min-height: 120px; resize: vertical; }
.form-row input[type="file"] {
  display: block;
  width: 100%;
  padding: .55rem .6rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: .85rem;
}

/* Icon-prefixed input — reserve left padding for the icon.
   Selector is specific enough to win against every base input rule above. */
.form-row .input-with-icon { position: relative; }
.form-row .input-with-icon > input,
.form-row .input-with-icon > input[type="text"],
.form-row .input-with-icon > input[type="email"],
.form-row .input-with-icon > input[type="password"],
.form-row .input-with-icon > input[type="number"],
.form-row .input-with-icon > input[type="tel"],
.form-row .input-with-icon > input[type="url"],
.form-row .input-with-icon > input[type="search"] {
  padding-left: 2.6rem;
}
.form-row .input-with-icon > svg {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.form-row .input-with-icon:focus-within > svg { color: var(--primary); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .9rem;
}
@media (min-width: 640px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.form-help { font-size: .78rem; color: var(--muted); margin-top: .3rem; }

/* =====================================================================
   10. Buttons
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: 0 1rem;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s, box-shadow .15s;
  box-shadow: var(--shadow-xs);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--text);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--primary);
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-700) 100%);
  border-color: var(--brand-700);
  color: var(--primary-fg);
  box-shadow:
    0 1px 2px rgba(13, 35, 90, .18),
    0 4px 14px rgba(30, 80, 224, .28),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand-400) 0%, var(--brand-600) 100%);
  border-color: var(--brand-700);
  color: var(--primary-fg);
  box-shadow:
    0 2px 4px rgba(13, 35, 90, .22),
    0 8px 22px rgba(30, 80, 224, .34),
    inset 0 1px 0 rgba(255, 255, 255, .26);
}
.btn-primary:active {
  box-shadow:
    0 1px 2px rgba(13, 35, 90, .18),
    inset 0 1px 2px rgba(0, 0, 0, .18);
}
.btn-secondary {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}
.btn-secondary:hover {
  background: var(--brand-100);
  color: var(--primary);
  border-color: transparent;
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger);
  filter: brightness(1.08);
  color: #fff;
  border-color: var(--danger);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}

.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 .75rem; font-size: .82rem; }
.btn-lg { height: 46px; padding: 0 1.25rem; font-size: .95rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* =====================================================================
   11. Tables
   ===================================================================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.table-wrap + .table-wrap { margin-top: 1rem; }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .88rem;
  min-width: 600px;
}
table.data th,
table.data td {
  padding: .75rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: .3rem; }
table.data td code { font-size: .78rem; }

.filter-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
  align-items: center;
}
.filter-row .filter-input {
  flex: 1 1 200px;
  min-width: 0;
}
.filter-row .filter-select {
  flex: 0 0 auto;
  max-width: 160px;
}
@media (max-width: 520px) {
  .filter-row { gap: .4rem; }
  .filter-row .filter-input { flex-basis: 100%; }
  .filter-row .filter-select { flex-basis: 100%; max-width: none; }
  .filter-row .btn { flex: 1 1 auto; }
}

/* Badges / pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
  line-height: 1.55;
}
.badge.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}
.badge-ok    { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.badge-warn  { background: var(--warn-bg);    color: var(--warn);    border-color: var(--warn-bd); }
.badge-err   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-bd); }
.badge-info  { background: var(--info-bg);    color: var(--info);    border-color: var(--info-bd); }
.badge-muted { background: var(--surface-2);  color: var(--muted);   border-color: var(--border); }

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.tag-pill.ok  { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.tag-pill.off { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-bd); }

/* =====================================================================
   12. Asset grid
   ===================================================================== */
.asset-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 520px) {
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}
.asset-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: transform .12s, border-color .15s, box-shadow .15s;
}
.asset-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}
.asset-thumb {
  aspect-ratio: 16 / 10;
  width: 100%;
  background: var(--surface-2) center / cover no-repeat;
  position: relative;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  border-bottom: 1px solid var(--border);
}
.asset-thumb svg { width: 36px; height: 36px; opacity: .5; }
.asset-thumb .asset-type-badge {
  position: absolute;
  top: .6rem;
  left: .6rem;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(6px);
}
:root[data-theme="dark"] .asset-thumb .asset-type-badge {
  background: rgba(14, 21, 40, .85);
}
.asset-body {
  padding: .9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.asset-name {
  font-weight: 600;
  margin: 0;
  font-size: .95rem;
  color: var(--text);
  letter-spacing: -.005em;
}
.asset-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
  color: var(--muted);
  margin-top: .2rem;
  gap: .5rem;
}

/* Dashboard two-column */
.dash-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 1100px) {
  .dash-layout { grid-template-columns: 1fr 360px; }
}

/* Empty state */
.empty {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.empty .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  margin: 0 auto .9rem;
}
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 {
  color: var(--text);
  margin: .1rem 0 .35rem;
}
.empty p {
  max-width: 420px;
  margin: 0 auto 1rem;
  color: var(--muted);
  font-size: .88rem;
}

/* =====================================================================
   13. Timeline (maintenance logs)
   ===================================================================== */
.timeline {
  position: relative;
  padding-left: 1.25rem;
  margin-top: .5rem;
}
.timeline::before {
  content: "";
  position: absolute;
  left: .35rem;
  top: .3rem;
  bottom: .3rem;
  width: 2px;
  background: var(--border);
}
.tl-item {
  position: relative;
  margin: 0 0 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -1.05rem;
  top: 1.2rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--bg);
}
.tl-head {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.tl-title {
  font-weight: 600;
  margin: 0;
  font-size: .95rem;
  color: var(--text);
}
.tl-date { color: var(--muted); font-size: .8rem; }
.tl-meta { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.tl-notes {
  margin: .5rem 0 .3rem;
  white-space: pre-wrap;
  font-size: .88rem;
  color: var(--text-2);
}
.tl-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
}
.tl-thumbs a {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  background: var(--surface-2) center / cover no-repeat;
  border: 1px solid var(--border);
}
.tl-due {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-top: .5rem;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: .72rem;
  font-weight: 600;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-bd);
}
.tl-due.overdue {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-bd);
}

/* =====================================================================
   14. Detail hero (asset view)
   ===================================================================== */
.detail-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
}
@media (min-width: 720px) {
  .detail-hero {
    grid-template-columns: 320px 1fr;
    padding: 1.25rem;
  }
}
.hero-img {
  aspect-ratio: 4 / 3;
  background: var(--surface-2) center / cover no-repeat;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--border);
  width: 100%;
}
.hero-img svg { width: 48px; height: 48px; opacity: .55; }
.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem 1.25rem;
  margin: .5rem 0 0;
}
.detail-meta dt {
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
}
.detail-meta dd {
  margin: .15rem 0 0;
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
}

/* Reminder banner */
.reminder-banner {
  display: flex;
  gap: .85rem;
  align-items: center;
  background: linear-gradient(135deg, var(--warn-bg), transparent);
  border: 1px solid var(--warn-bd);
  color: var(--warn);
  padding: .9rem 1.1rem;
  border-radius: var(--r-lg);
  margin-bottom: 1.25rem;
}
.reminder-banner .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--warn-bg);
  display: grid;
  place-items: center;
  color: var(--warn);
  flex-shrink: 0;
}
.reminder-banner .icon svg { width: 18px; height: 18px; }
.reminder-banner .text { flex: 1; min-width: 0; }
.reminder-banner .text strong {
  color: var(--text);
  display: block;
}
.reminder-banner .text .sub {
  color: var(--muted);
  font-size: .82rem;
}
.reminder-banner a {
  color: var(--warn);
  font-weight: 600;
  text-decoration: underline;
}

/* NFC chip reference panel */
.chip-ref {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-xs);
}
.chip-ref img {
  width: 64px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .15));
}
.chip-ref-text strong {
  display: block;
  color: var(--text);
  font-weight: 600;
  margin-bottom: .15rem;
}
.chip-ref-text .muted {
  color: var(--muted);
  font-size: .85rem;
}

/* Splash overlay */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity .5s ease;
}
#splash.hidden { opacity: 0; pointer-events: none; }
#splash img {
  max-width: 60vw;
  max-height: 50vh;
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
}
#splash .splash-brand {
  margin-top: 1.2rem;
  color: var(--muted);
  letter-spacing: .5px;
  text-align: center;
}

/* =====================================================================
   15. AUTH SHELL — split-panel (brand + form), mobile-first
   ===================================================================== */
body.auth-body {
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  max-width: 100%;
}
.auth-split {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* Floating theme toggle */
.theme-toggle-wrap {
  position: absolute;
  top: calc(.75rem + env(safe-area-inset-top));
  right: .75rem;
  z-index: 3;
}

/* ---------- Auth hero (brand panel) ---------- */
.auth-hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(59, 109, 255, .38), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(30, 80, 224, .55), transparent 55%),
    linear-gradient(160deg, #0a2d8f 0%, #051c66 55%, #020611 100%);
  padding: 1.75rem 1.25rem;
  padding-top: calc(1.75rem + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  isolation: isolate;
}
/* Industrial blueprint grid — evokes CAD / engineering */
.auth-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px;
  mask-image: radial-gradient(ellipse at 30% 20%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 20%, #000 10%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}
/* Subtle orbit glow */
.auth-hero::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -180px;
  top: -180px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(90, 140, 255, .35), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100%;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-width: 0;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.auth-brand img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .3));
}
.auth-brand .name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.auth-brand .name .dot { color: var(--brand-300); margin: 0 2px; }
.auth-brand .tag {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .7);
  font-weight: 600;
  margin-top: 2px;
}

.auth-hero-copy { max-width: 520px; }
.auth-hero-copy h1 {
  color: #fff;
  font-family: "Inter Tight", "Inter Display", "Inter", sans-serif;
  font-size: clamp(1.5rem, 1.2rem + 2vw, 2.35rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 .7rem;
}
.auth-hero-copy p {
  color: rgba(255, 255, 255, .85);
  font-size: clamp(.92rem, .88rem + .2vw, 1.02rem);
  line-height: 1.55;
  max-width: 460px;
}

.auth-features {
  display: grid;
  gap: .75rem;
  margin-top: 1rem;
  max-width: 480px;
}
.auth-feature {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  color: rgba(255, 255, 255, .9);
  font-size: .88rem;
  line-height: 1.45;
}
.auth-feature .mark {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.auth-feature .mark svg {
  width: 14px !important;
  height: 14px !important;
  color: #fff;
}
.auth-feature strong {
  display: block;
  color: #fff;
  font-weight: 600;
  margin-bottom: 2px;
}

.auth-hero-foot {
  font-size: .72rem;
  color: rgba(255, 255, 255, .55);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: auto;
}

/* Decorative tachometer watermark (hidden by default, shown on desktop) */
.auth-hero-watermark {
  display: none;
  position: absolute;
  right: -90px;
  bottom: -90px;
  width: 520px;
  height: 520px;
  opacity: .5;
  pointer-events: none;
  z-index: 0;
  animation: watermarkDrift 18s ease-in-out infinite alternate;
}
@keyframes watermarkDrift {
  from { transform: rotate(-4deg) scale(1); }
  to   { transform: rotate(4deg)  scale(1.03); }
}

/* Capability strip (hidden on mobile, shown on desktop) */
.auth-capstrip {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-top: .5rem;
  max-width: 500px;
}
.auth-capstrip .cap {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  min-width: 0;
}
.auth-capstrip .cap svg {
  color: #93c5fd;
  flex-shrink: 0;
}
.auth-capstrip .cap > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.auth-capstrip .cap strong {
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: -.005em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-capstrip .cap span {
  color: rgba(255, 255, 255, .58);
  font-size: .68rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Automotive dashboard showcase card ---------- */
.auth-showcase {
  position: relative;
  display: block;
  margin: .25rem 0 .5rem;
}
.showcase-card {
  position: relative;
  padding: 1rem 1.1rem 1.1rem;
  border-radius: 20px;
  background:
    radial-gradient(130% 90% at 0% 0%, rgba(100, 140, 255, .22), transparent 55%),
    linear-gradient(180deg, rgba(9, 22, 66, .88) 0%, rgba(4, 11, 38, .92) 100%);
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow:
    0 30px 60px -30px rgba(0, 0, 0, .85),
    0 8px 24px -8px rgba(0, 0, 0, .6),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  overflow: hidden;
  isolation: isolate;
  animation: showcasePop .75s cubic-bezier(.2,.9,.2,1.02) both;
}
/* Carbon-fiber style texture */
.showcase-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,.02) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.02) 0 2px, transparent 2px 6px);
  pointer-events: none;
  z-index: 0;
}
/* Racing checker accent strip */
.showcase-card::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background:
    repeating-linear-gradient(90deg,
      #1E50E0 0 14px,
      rgba(255,255,255,.85) 14px 28px);
  opacity: .55;
  z-index: 1;
}
.showcase-card > * { position: relative; z-index: 2; }

.showcase-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}
.showcase-vin {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .78);
  letter-spacing: .02em;
}
.showcase-vin svg { color: rgba(255, 255, 255, .6); }
.showcase-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(34, 197, 94, .14);
  border: 1px solid rgba(34, 197, 94, .35);
  color: #86efac;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.showcase-pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .7);
  animation: showcasePulse 1.8s ease-in-out infinite;
}
@keyframes showcasePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
  50%     { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.gauge {
  margin: .25rem auto .35rem;
  max-width: 240px;
  filter: drop-shadow(0 8px 18px rgba(30, 80, 224, .35));
}

.showcase-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  padding-top: .5rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-cell .label {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .5);
}
.stat-cell .value {
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-cell .value em {
  font-style: normal;
  font-weight: 600;
  color: rgba(255, 255, 255, .5);
  font-size: .7em;
  margin-left: 2px;
  letter-spacing: .04em;
}
.stat-cell .value.accent {
  color: #fbbf24;
}

.showcase-foot {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .7rem;
  padding: .55rem .7rem;
  border-radius: 10px;
  background: rgba(59, 130, 246, .12);
  border: 1px solid rgba(59, 130, 246, .25);
  color: rgba(255, 255, 255, .85);
  font-size: .72rem;
  line-height: 1.35;
}
.showcase-foot svg { color: #93c5fd; flex-shrink: 0; }

@keyframes showcasePop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* =====================================================================
   MOBILE AUTH — must fit in the viewport, no page scrolling.
   Hero is a compact branded header; form panel fills the rest.
   Showcase card + long marketing copy only show on taller phones that
   have room for it — otherwise every element is suppressed for fit.
   ===================================================================== */
@media (max-width: 639px) {
  /* Lock the auth page to the viewport so nothing leaks out */
  body.auth-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .auth-split {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  /* Hero: slim branded header */
  .auth-hero {
    padding: .7rem 1rem .85rem;
    padding-top: calc(.7rem + env(safe-area-inset-top));
    gap: .6rem;
    min-height: 0;
    flex: 0 0 auto;
  }
  .auth-hero-inner {
    gap: .55rem;
    height: auto;
    min-width: 0;
  }

  /* By default on mobile we strip EVERYTHING except brand. Taller phones
     (see min-height block below) get the showcase back. */
  .auth-hero-copy,
  .auth-showcase,
  .auth-features,
  .auth-hero-foot,
  .auth-capstrip { display: none; }

  .auth-brand { gap: .65rem; }
  .auth-brand img { width: 36px; height: 36px; }
  .auth-brand .name { font-size: .92rem; line-height: 1.05; }
  .auth-brand .tag { font-size: .6rem; margin-top: 1px; letter-spacing: .1em; }

  /* Form panel fills the remaining viewport. Internal scroll only as a
     safety net for extreme cases (e.g. keyboard open + small phone). */
  .auth-panel {
    flex: 1 1 auto;
    min-height: 0;
    padding: .95rem 1rem 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    max-width: 100%;
  }
  .auth-panel-inner {
    max-width: 100%;
    min-width: 0;
  }
  .auth-panel h2 {
    font-size: 1.2rem;
    margin: 0 0 .15rem;
  }
  .auth-panel .auth-sub {
    font-size: .82rem;
    line-height: 1.4;
    margin-bottom: .75rem;
  }
  .auth-panel .form-row { margin-bottom: .55rem; }
  .auth-panel .form-row label { margin-bottom: .28rem; font-size: .78rem; }
  .auth-panel .form-row input[type="text"],
  .auth-panel .form-row input[type="email"],
  .auth-panel .form-row input[type="password"],
  .auth-panel .form-row input[type="number"],
  .auth-panel .form-row input[type="tel"],
  .auth-panel .form-row select {
    padding: .6rem .8rem;
    font-size: .92rem;
  }
  .auth-panel .form-row .input-with-icon > input {
    padding-left: 2.45rem;
  }
  .auth-panel .btn-lg { height: 42px; padding: 0 1.1rem; font-size: .92rem; }
  .auth-panel .alert { padding: .6rem .75rem; font-size: .82rem; margin-bottom: .75rem; }
  .auth-panel .text-xs { font-size: .68rem; }
  .auth-foot { margin-top: .7rem; font-size: .8rem; }

  /* Compact Google button + divider on phones */
  .google-btn-wrap { margin-bottom: .65rem; }
  .auth-divider { margin-bottom: .65rem; font-size: .66rem; }
  .auth-divider::before,
  .auth-divider::after { width: calc(50% - 3rem); }

  /* Password + confirm side-by-side on any phone wider than 360px — saves a row */
}

/* Slightly wider phones: put password + confirm side-by-side so the
   register form loses an entire row of height. */
@media (max-width: 639px) and (min-width: 380px) {
  .auth-panel .form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
  }
}

/* Taller phones have room to bring back the cool dashboard preview */
@media (max-width: 639px) and (min-height: 760px) {
  .auth-hero {
    padding: .9rem 1rem 1.1rem;
    padding-top: calc(.9rem + env(safe-area-inset-top));
    gap: .9rem;
  }
  .auth-hero-inner { gap: .9rem; }
  .auth-showcase { display: block; margin: 0; }
  .auth-brand img { width: 40px; height: 40px; }
  .auth-brand .name { font-size: .98rem; }
  .gauge { max-width: 220px; margin: .1rem auto .25rem; }
  .showcase-card { padding: .9rem 1rem 1rem; border-radius: 18px; }
  .showcase-head { margin-bottom: .4rem; }
  .showcase-stats { padding-top: .4rem; gap: .4rem; }
  .stat-cell .value { font-size: .9rem; }
  .stat-cell .label { font-size: .56rem; }
  .showcase-foot {
    margin-top: .55rem;
    padding: .5rem .65rem;
    font-size: .68rem;
  }
}

/* Tablet: constrain showcase width */
@media (min-width: 640px) and (max-width: 979px) {
  .auth-showcase { max-width: 460px; margin: 0 auto; }
}

/* Desktop: showcase is too literal next to the marketing copy — hide it.
   The marketing copy + features carry the hero on desktop. */
@media (min-width: 980px) {
  .auth-showcase { display: none; }
}

/* ---------- Auth form panel ---------- */
.auth-panel {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem 1rem 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  background: var(--bg);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.auth-panel-inner {
  width: 100%;
  max-width: 420px;
  min-width: 0;
}
.auth-panel h2 {
  font-size: 1.45rem;
  letter-spacing: -.01em;
  margin: 0 0 .35rem;
}
.auth-panel .auth-sub {
  color: var(--muted);
  font-size: .92rem;
  margin-bottom: 1.15rem;
}
.auth-panel .form-row { margin-bottom: .75rem; }
.auth-foot {
  color: var(--muted);
  font-size: .85rem;
  margin-top: 1rem;
  text-align: center;
}

/* ---------- Google Sign-In button + "or" divider ---------- */
.google-btn-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 .85rem;
  min-width: 0;
  max-width: 100%;
}
/* Google renders the button inside an iframe — we just make sure the
   container can shrink on narrow phones without overflowing. */
.google-btn-wrap > .g_id_signin,
.google-btn-wrap > div {
  width: 100% !important;
  max-width: 360px !important;
  display: flex !important;
  justify-content: center;
}
.google-btn-wrap iframe {
  max-width: 100% !important;
  margin: 0 auto !important;
}

.auth-divider {
  position: relative;
  text-align: center;
  margin: 0 0 .85rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 2.4rem);
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-divider span {
  display: inline-block;
  padding: 0 .5rem;
  background: transparent;
  position: relative;
  z-index: 1;
}

/* Desktop: true split-panel — tightened so it fits a laptop viewport */
@media (min-width: 980px) {
  .auth-split {
    grid-template-columns: 1.05fr 1fr;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .auth-hero {
    padding: 2rem 2.5rem;
    gap: 1.1rem;
    justify-content: center;
  }
  .auth-hero-inner {
    justify-content: flex-start;
    gap: 1.25rem;
    max-width: 540px;
    margin: 0;
    height: auto;
  }
  .auth-hero-watermark { display: block; }
  .auth-capstrip { display: grid; }
  /* Features hidden on desktop — capstrip replaces them */
  .auth-features { display: none; }

  .auth-brand img { width: 42px; height: 42px; }
  .auth-brand .name { font-size: 1.05rem; }
  .auth-brand .tag { font-size: .65rem; }

  .auth-hero-copy { max-width: 500px; }
  .auth-hero-copy h1 {
    font-size: clamp(1.6rem, 1rem + 1.3vw, 2rem);
    line-height: 1.18;
    margin-bottom: .5rem;
  }
  .auth-hero-copy p {
    font-size: .92rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, .82);
    max-width: 480px;
  }
  .auth-hero-foot { margin-top: 1rem; font-size: .72rem; }

  /* Form panel: give it real presence */
  .auth-panel {
    align-items: center;
    padding: 1.5rem 1.75rem;
    background:
      radial-gradient(520px 360px at 100% 0%, var(--brand-50) 0%, transparent 60%),
      radial-gradient(420px 300px at 0% 100%, var(--brand-50) 0%, transparent 55%),
      var(--bg);
  }
  .auth-panel-inner {
    max-width: 380px;
    padding: 1.75rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow:
      0 40px 80px -40px rgba(15, 30, 80, .22),
      0 8px 20px -8px rgba(15, 30, 80, .08);
  }
  .auth-panel h2 {
    font-size: 1.45rem;
    margin-bottom: .35rem;
  }
  .auth-panel .auth-sub {
    margin-bottom: 1.1rem;
    font-size: .88rem;
  }
  .auth-panel .form-row { margin-bottom: .7rem; }
  .auth-foot { margin-top: 1rem; font-size: .82rem; }
}

/* Short viewports (laptops ~720–840px tall) — squeeze a touch more */
@media (min-width: 980px) and (max-height: 840px) {
  .auth-hero {
    padding: 1.25rem 2.25rem;
    gap: .85rem;
  }
  .auth-hero-inner { gap: .95rem; }
  .auth-brand img { width: 36px; height: 36px; }
  .auth-brand .name { font-size: .98rem; }
  .auth-hero-copy h1 { font-size: 1.4rem; line-height: 1.2; margin-bottom: .35rem; }
  .auth-hero-copy p { font-size: .85rem; line-height: 1.45; }
  .auth-capstrip { gap: .45rem; margin-top: .35rem; }
  .auth-capstrip .cap { padding: .45rem .55rem; }
  .auth-capstrip .cap strong { font-size: .75rem; }
  .auth-capstrip .cap span { font-size: .64rem; }
  .auth-hero-foot { margin-top: .6rem; font-size: .68rem; }

  .auth-panel { padding: 1.25rem 1.75rem; }
  .auth-panel-inner { padding: 1.5rem 1.85rem; border-radius: 16px; }
  .auth-panel h2 { font-size: 1.35rem; margin-bottom: .3rem; }
  .auth-panel .auth-sub { margin-bottom: .95rem; font-size: .85rem; }
  .auth-panel .form-row { margin-bottom: .6rem; }
  .auth-panel .form-row label { margin-bottom: .3rem; font-size: .84rem; }
  .auth-panel .btn-lg { padding: .8rem 1.1rem; font-size: .98rem; }
  .auth-foot { margin-top: .85rem; font-size: .8rem; }
}

/* Very short (~720p) — collapse capstrip to single column */
@media (min-width: 980px) and (max-height: 740px) {
  .auth-capstrip { grid-template-columns: 1fr 1fr; gap: .35rem; }
  .auth-capstrip .cap span { display: none; }
  .auth-capstrip .cap { padding: .4rem .55rem; }
}

/* =====================================================================
   16. Motion preferences
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* =====================================================================
   17. Micro-interactions & polish
   ===================================================================== */
/* Subtle body gradient so the app doesn't read as flat-flat-flat */
body {
  background:
    radial-gradient(1200px 600px at 100% -200px, rgba(30, 80, 224, .06), transparent 60%),
    radial-gradient(900px 500px at -200px 120%, rgba(30, 80, 224, .05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 100% -200px, rgba(59, 109, 255, .08), transparent 60%),
    radial-gradient(900px 500px at -200px 120%, rgba(30, 80, 224, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* Asset thumbnail hover — subtle zoom */
.asset-card .asset-thumb { transition: transform .3s ease; }
.asset-card:hover .asset-thumb { transform: scale(1.02); }

/* Ring the stats when hovered */
a.stat { cursor: pointer; }
a.stat:hover { transform: translateY(-1px); }

/* Input hover state (non-focus) */
.form-row input:hover:not(:focus),
.form-row select:hover:not(:focus),
.form-row textarea:hover:not(:focus),
.input:hover:not(:focus) {
  border-color: var(--border-strong);
}

/* Fade content in on first paint — fast and subtle */
@keyframes chipit-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.content-inner > * { animation: chipit-fade-up .35s ease both; }
.content-inner > *:nth-child(2) { animation-delay: .04s; }
.content-inner > *:nth-child(3) { animation-delay: .08s; }
.content-inner > *:nth-child(4) { animation-delay: .12s; }

/* =====================================================================
   19. List rows (dashboard side-cards) — mobile-first, crisp on tiny phones
   ===================================================================== */
.list-rows { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .75rem 1rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row:last-child { border-bottom: none; }
.list-row-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--warn-bg);
  color: var(--warn);
}
.list-row-icon.bad   { background: var(--danger-bg);  color: var(--danger); }
.list-row-icon.warn  { background: var(--warn-bg);    color: var(--warn); }
.list-row-icon.brand { background: var(--brand-50);   color: var(--primary); }
.list-row-icon.sm    { width: 32px; height: 32px; min-width: 32px; border-radius: 9px; }
.list-row-body { flex: 1; min-width: 0; }
.list-row-title {
  font-size: .86rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.list-row-sub {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}
.list-row-meta {
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  flex-shrink: 0;
}
.list-row-meta.bad   { color: var(--danger); }
.list-row-meta.warn  { color: var(--warn); }
.list-row-meta.muted { color: var(--muted); font-weight: 500; }

@media (max-width: 400px) {
  .list-row { padding: .65rem .85rem; gap: .6rem; }
  .list-row-icon { width: 32px; height: 32px; min-width: 32px; border-radius: 9px; }
  .list-row-icon.sm { width: 28px; height: 28px; min-width: 28px; }
}

/* =====================================================================
   20. Subnav (back link + utility action at top of detail pages)
   ===================================================================== */
.subnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.subnav-back {
  font-size: .82rem;
  color: var(--muted);
  text-decoration: none;
}
.subnav-back:hover { color: var(--text); text-decoration: underline; }
.subnav-danger { color: var(--danger); }
.subnav-danger:hover { color: var(--danger); border-color: var(--danger-bd); background: var(--danger-bg); }

/* =====================================================================
   21. Dashboard instrument cluster — tighter on narrow phones
   ===================================================================== */
@media (max-width: 480px) {
  .instrument-cluster {
    padding: .9rem .95rem .85rem;
    border-radius: 16px;
    margin-bottom: 1.1rem;
  }
  .cluster-head { margin-bottom: .45rem; }
  .cluster-label { font-size: .62rem; letter-spacing: .12em; }
  .cluster-pill { padding: 3px 8px; font-size: .6rem; }
  .cluster-grid { gap: .6rem; }
  .cluster-gauge-wrap { max-width: 260px; }
  .cluster-stats { gap: .45rem; }
  .cluster-stat {
    padding: .55rem .6rem;
    gap: .55rem;
  }
  .cluster-stat-icon {
    width: 32px; height: 32px; min-width: 32px;
    border-radius: 9px;
  }
  .cluster-stat .label { font-size: .55rem; letter-spacing: .1em; }
  .cluster-stat .value { font-size: 1.05rem; }
  .cluster-stat .sub   { font-size: .64rem; }
  .cluster-foot {
    padding: .55rem .7rem;
    font-size: .76rem;
    gap: .45rem;
  }
}

/* Extra-narrow phones (iPhone SE, 320–360px): switch stats to single column
   so each cell has breathing room and values don't collide with the labels. */
@media (max-width: 360px) {
  .cluster-stats { grid-template-columns: 1fr; }
  .cluster-stat { padding: .6rem .7rem; }
  .cluster-stat .value { font-size: 1.15rem; }
}

/* =====================================================================
   22. Dashboard 2-up on mobile — breathing room between sections
   ===================================================================== */
.dash-layout > section + aside,
.dash-layout > aside + section { margin-top: .25rem; }

/* Card header a touch tighter on phones so the list rows underneath don't
   fight for vertical space */
@media (max-width: 480px) {
  .card-header { padding: .75rem .9rem; }
  .card-header h2, .card-header h3 { font-size: .95rem; }
}

/* Content padding tightens on narrow phones */
@media (max-width: 400px) {
  .content { padding: .85rem; padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
  .card { padding: 1rem; }
}

/* =====================================================================
   18. Print
   ===================================================================== */
@media print {
  .sidebar, .topbar, .footer, .sidebar-backdrop, .sidebar-toggle,
  .theme-toggle, .btn, .page-actions { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body { background: #fff; color: #000; }
}
