/* ── 256 Logistics Compliance Hub — Design System ─────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --sidebar-w: 256px;

  /* Brand */
  --navy:         #0a1628;
  --navy-mid:     #0f2042;
  --navy-light:   #162136;
  --navy-border:  rgba(255,255,255,0.07);
  --primary:      #2563eb;
  --primary-h:    #1d4ed8;
  --primary-glow: rgba(37,99,235,0.25);

  /* Semantic */
  --success:   #10b981;
  --success-bg:#ecfdf5;
  --success-t: #065f46;
  --warning:   #f59e0b;
  --warning-bg:#fffbeb;
  --warning-t: #92400e;
  --danger:    #ef4444;
  --danger-bg: #fef2f2;
  --danger-t:  #991b1b;
  --notice:    #8b5cf6;
  --notice-bg: #f5f3ff;
  --notice-t:  #5b21b6;
  --info:      #06b6d4;
  --info-bg:   #ecfeff;
  --info-t:    #164e63;

  /* Neutrals */
  --bg:        #f0f4f8;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --border-md: #cbd5e1;
  --text:      #0f172a;
  --text-2:    #334155;
  --text-muted:#64748b;
  --text-light:#94a3b8;

  /* Geometry */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.07), 0 4px 6px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.08), 0 10px 10px -5px rgba(0,0,0,.04);

  /* ── macOS layer ───────────────────────────────── */
  --mac-window-radius: 16px;
  --mac-ctrl-radius:   8px;
  --mac-shadow:        0 1px 1px rgba(15,23,42,.04), 0 12px 30px -12px rgba(15,23,42,.18);
  --mac-shadow-lg:     0 2px 6px rgba(15,23,42,.05), 0 30px 60px -20px rgba(15,23,42,.28);
  --mac-hairline:      rgba(15,23,42,.08);
  --mac-glass:         rgba(255,255,255,.72);
  --mac-glass-strong:  rgba(255,255,255,.86);
  --mac-titlebar:      linear-gradient(180deg, rgba(255,255,255,.9) 0%, rgba(248,250,253,.82) 100%);
  --traffic-red:       #ff5f57;
  --traffic-amber:     #febc2e;
  --traffic-green:     #28c840;
  --desktop:           radial-gradient(1200px 700px at 80% -10%, #e8f0fe 0%, rgba(232,240,254,0) 55%),
                       radial-gradient(900px 600px at -10% 110%, #eef2fb 0%, rgba(238,242,251,0) 50%),
                       linear-gradient(160deg, #eef2f8 0%, #e6ecf6 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', sans-serif;
  background: var(--desktop);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, rgba(13,24,46,.86) 0%, rgba(9,17,34,.9) 100%);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  position: fixed; top: 0; left: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,.06);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
}
/* Mobile drawer backdrop */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 99;
  background: rgba(8,15,30,.45);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .26s ease;
}
.sidebar-overlay.show { opacity: 1; }
/* Hamburger (hidden on desktop) */
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border: 1px solid var(--mac-hairline); border-radius: 9px;
  background: rgba(255,255,255,.6); color: var(--text-2); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:hover { background: #fff; }
.nav-toggle:active { transform: scale(.94); }
.nav-toggle svg { width: 19px; height: 19px; }
/* macOS traffic lights at the top of the source list */
.sidebar-traffic { display: flex; align-items: center; gap: 8px; padding: 16px 18px 0; }
.sidebar-traffic i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18); }
.sidebar-traffic i.r { background: var(--traffic-red); }
.sidebar-traffic i.y { background: var(--traffic-amber); }
.sidebar-traffic i.g { background: var(--traffic-green); }

/* Subtle gradient shimmer at top */
.sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59,130,246,.6), transparent);
}

.sidebar-brand {
  padding: 14px 18px 16px;
  border-bottom: 1px solid var(--navy-border);
  position: relative;
}
.sidebar-brand-inner {
  display: flex; align-items: center; gap: 10px;
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 4px 10px rgba(37,99,235,0.4);
}
.brand-icon svg { width: 18px; height: 18px; color: #fff; }
.brand-text h1 { font-size: 13.5px; font-weight: 800; color: #fff; line-height: 1.2; letter-spacing: -.2px; }
.brand-text span { font-size: 10.5px; font-weight: 600; color: #7fa3cc; letter-spacing: .8px; text-transform: uppercase; }

/* Section headers */
.sidebar-section { padding: 18px 0 4px; }
.sidebar-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: #4a6b8a; padding: 0 18px 8px; display: flex; align-items: center; gap: 8px;
}
.sidebar-section-label::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.06);
}

/* Nav links — macOS source-list rows */
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 2px 10px; border-radius: 8px;
  color: #aebfd6; text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background .14s ease, color .14s ease;
  position: relative; white-space: nowrap;
}
.sidebar nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #eaf2ff;
}
.sidebar nav a.active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,.45);
}
.sidebar nav a svg {
  width: 16px; height: 16px; flex-shrink: 0; opacity: .75;
  color: #93c5fd;
}
.sidebar nav a:hover svg { opacity: 1; color: #dbeafe; }
.sidebar nav a.active svg { opacity: 1; color: #fff; }

.nav-badge {
  margin-left: auto; background: rgba(239,68,68,.9); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 100px;
  min-width: 20px; text-align: center; line-height: 1.4;
}

/* User footer */
.sidebar-footer {
  margin-top: auto; padding: 14px 18px;
  border-top: 1px solid var(--navy-border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info .user-name { font-size: 12.5px; font-weight: 600; color: #e2e8f0; }
.user-info .user-role {
  font-size: 10.5px; color: #6b90b5; text-transform: capitalize;
  margin-top: 1px;
}
.sidebar-footer a.signout {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #7fa3cc; text-decoration: none;
  padding: 6px 12px; border-radius: 8px;
  transition: all .15s; font-weight: 500;
}
.sidebar-footer a.signout:hover { background: rgba(239,68,68,.1); color: #f87171; }
.sidebar-footer a.signout svg { width: 13px; height: 13px; }

/* ECADEL maker's signature — shown on every app page */
.sidebar-credit {
  display: flex; align-items: center; gap: 9px; margin-top: 12px;
  padding: 9px 11px; border-radius: 10px; text-decoration: none;
  border: 1px solid rgba(245,158,11,.16);
  background: radial-gradient(ellipse 90% 180% at 0% 0%, rgba(245,158,11,.12), transparent 62%);
  transition: border-color .15s, transform .15s;
}
.sidebar-credit:hover { border-color: rgba(245,158,11,.42); transform: translateY(-1px); }
.sidebar-credit img { width: 22px; height: 22px; flex-shrink: 0; filter: drop-shadow(0 2px 7px rgba(245,158,11,.4)); }
.sidebar-credit .sc-text { line-height: 1.25; min-width: 0; }
.sidebar-credit .sc-by { font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: #94a3b8; }
.sidebar-credit .sc-name { font-size: 11px; font-weight: 800; letter-spacing: .2px; background: linear-gradient(100deg, #fffbeb, #fcd34d 60%, #f59e0b); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ══════════════════════════════════════════
   MAIN LAYOUT
══════════════════════════════════════════ */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar — macOS unified window titlebar */
.topbar {
  background: var(--mac-titlebar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--mac-hairline);
  padding: 0 22px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-left h2 { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-time {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: rgba(255,255,255,.6); padding: 5px 12px; border-radius: 100px;
  border: 1px solid var(--mac-hairline);
}
/* Topbar global search (macOS toolbar search) */
.topbar-search { position: relative; width: 230px; max-width: 30vw; }
.topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-light); pointer-events: none; }
.topbar-search input {
  width: 100%; padding: 6px 10px 6px 30px; font-size: 12.5px; font-family: inherit;
  border: 1px solid var(--mac-hairline); border-radius: 8px; color: var(--text);
  background: rgba(255,255,255,.65); transition: all .15s;
}
.topbar-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: #fff; }

/* Page body */
.page-body { padding: 22px 26px 32px; flex: 1; }

/* ── Page header (shared across pages) ───────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head-main { min-width: 0; }
.page-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.page-eyebrow svg { width: 13px; height: 13px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.6px; line-height: 1.1; }
.page-head .page-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 6px; max-width: 720px; line-height: 1.55; }
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
  background: var(--card); border-radius: var(--mac-window-radius);
  box-shadow: var(--mac-shadow); border: 1px solid var(--mac-hairline);
  overflow: hidden;
}
.card-header {
  padding: 15px 20px; border-bottom: 1px solid var(--mac-hairline);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, rgba(248,250,253,.6), rgba(255,255,255,0));
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.card-body { padding: 20px; }

/* ── macOS window primitive (reusable chrome) ────── */
.mac-window { background: var(--card); border: 1px solid var(--mac-hairline); border-radius: var(--mac-window-radius); box-shadow: var(--mac-shadow); overflow: hidden; }
.mac-titlebar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--mac-titlebar); border-bottom: 1px solid var(--mac-hairline);
}
.mac-traffic { display: flex; gap: 7px; flex-shrink: 0; }
.mac-traffic i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.16); }
.mac-traffic i.r { background: var(--traffic-red); }
.mac-traffic i.y { background: var(--traffic-amber); }
.mac-traffic i.g { background: var(--traffic-green); }
.mac-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: 8px; min-width: 0; }
.mac-title .mac-title-sub { font-weight: 500; color: var(--text-light); }
.mac-titlebar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }

.stat-card {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 18px; border: 1px solid var(--mac-hairline);
  box-shadow: var(--mac-shadow);
  display: flex; align-items: flex-start; gap: 14px;
  text-decoration: none; color: inherit;
  transition: all .2s ease; cursor: pointer;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  opacity: 0; transition: opacity .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:hover::after { opacity: 1; }

.stat-card.blue::after  { background: linear-gradient(90deg,#2563eb,#06b6d4); }
.stat-card.green::after { background: linear-gradient(90deg,#10b981,#34d399); }
.stat-card.red::after   { background: linear-gradient(90deg,#ef4444,#f97316); }
.stat-card.amber::after { background: linear-gradient(90deg,#f59e0b,#eab308); }

.stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: linear-gradient(135deg,#dbeafe,#bfdbfe); color: #1d4ed8; }
.stat-icon.green  { background: linear-gradient(135deg,#d1fae5,#a7f3d0); color: #065f46; }
.stat-icon.amber  { background: linear-gradient(135deg,#fef3c7,#fde68a); color: #92400e; }
.stat-icon.red    { background: linear-gradient(135deg,#fee2e2,#fecaca); color: #991b1b; }
.stat-icon.purple { background: linear-gradient(135deg,#ede9fe,#ddd6fe); color: #5b21b6; }
.stat-icon.slate  { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); color: #475569; }

.stat-value { font-size: 30px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -1px; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 5px; }
.stat-sub   { font-size: 11.5px; color: var(--text-light); margin-top: 5px; }

/* ══════════════════════════════════════════
   COMPLIANCE SCORE GAUGES
══════════════════════════════════════════ */
.score-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.score-card {
  background: var(--card); border-radius: var(--radius);
  padding: 22px 16px 18px; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); text-align: center;
  position: relative; overflow: hidden;
  transition: all .2s;
}
.score-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.score-ring { position: relative; width: 100px; height: 100px; margin: 0 auto 14px; }
.score-ring canvas { display: block; }
.score-num {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 22px; font-weight: 900; color: var(--text); letter-spacing: -1px;
}
.score-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.score-delta { font-size: 11px; color: var(--success); font-weight: 600; margin-top: 4px; }

/* Colour the card based on score */
.score-card.score-good  { border-top: 3px solid var(--success); }
.score-card.score-ok    { border-top: 3px solid var(--warning); }
.score-card.score-bad   { border-top: 3px solid var(--danger); }
.score-card.score-overall { background: linear-gradient(135deg,#0f172a 0%,#1e3a5f 100%); }
.score-card.score-overall .score-label { color: #94a3b8; }
.score-card.score-overall .score-num   { color: #fff; }

/* ══════════════════════════════════════════
   ALERT FEED
══════════════════════════════════════════ */
.alert-feed { padding: 0 4px; }
.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 4px;
  cursor: default; transition: background .15s;
  border: 1px solid transparent;
}
.alert-item:hover { background: #f8fafc; border-color: var(--border); }

.alert-item.critical { border-left: 3px solid var(--danger); background: rgba(239,68,68,.03); }
.alert-item.warning  { border-left: 3px solid var(--warning); background: rgba(245,158,11,.02); }
.alert-item.notice   { border-left: 3px solid var(--notice); background: rgba(139,92,246,.02); }

.alert-indicator {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}
.alert-indicator.critical { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.2); animation: blink 2s ease-in-out infinite; }
.alert-indicator.warning  { background: var(--warning); }
.alert-indicator.notice   { background: var(--notice); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

.alert-body { flex: 1; min-width: 0; }
.alert-msg  { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; text-transform: capitalize; }

.alert-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 100px; white-space: nowrap;
}
.alert-badge.critical { background: var(--danger-bg); color: var(--danger); }
.alert-badge.warning  { background: var(--warning-bg); color: #b45309; }
.alert-badge.notice   { background: var(--notice-bg); color: var(--notice-t); }

/* ══════════════════════════════════════════
   TABLES
══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 11px 16px; background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
tbody td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #f8fafc; }
tbody td a { color: var(--primary); text-decoration: none; font-weight: 600; }
tbody td a:hover { text-decoration: underline; }
.cell-muted { color: var(--text-muted); font-size: 12px; }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  letter-spacing: .2px;
}
.badge-green  { background: var(--success-bg); color: var(--success-t); }
.badge-red    { background: var(--danger-bg);  color: var(--danger-t); }
.badge-amber  { background: var(--warning-bg); color: var(--warning-t); }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-slate  { background: #f1f5f9; color: #475569; }
.badge-purple { background: var(--notice-bg); color: var(--notice-t); }
.badge-cyan   { background: var(--info-bg); color: var(--info-t); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--mac-ctrl-radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none;
  transition: all .14s ease; white-space: nowrap;
  font-family: inherit; letter-spacing: .1px;
}
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 2px 8px rgba(37,99,235,.28);
}
.btn-primary:hover { background: linear-gradient(180deg, #2f7af4 0%, #1f5fdb 100%); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,.36); }
.btn-primary:active { transform: translateY(0); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-ghost { background: rgba(255,255,255,.7); color: var(--text-2); border: 1px solid var(--mac-hairline); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { background: #fff; color: var(--text); border-color: var(--border-md); box-shadow: var(--shadow-sm); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn.is-loading {
  pointer-events: none;
  opacity: .92;
}
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  display: none;
  flex-shrink: 0;
  animation: btnSpin .7s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-flex; }
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-2);
  margin-bottom: 6px; letter-spacing: .2px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--border-md); border-radius: var(--mac-ctrl-radius);
  font-size: 13.5px; font-family: inherit; color: var(--text);
  background: #fff; transition: all .15s;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.04);
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.16);
}
.form-control::placeholder { color: #cbd5e1; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 20px; }

/* ══════════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════════ */
.progress-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width .5s ease;
}
.progress-bar-fill.green  { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-bar-fill.amber  { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.progress-bar-fill.red    { background: linear-gradient(90deg, var(--danger), #f87171); }

/* ══════════════════════════════════════════
   TRAINING MATRIX
══════════════════════════════════════════ */
.training-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px,1fr)); gap: 8px; }
.training-item {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  position: relative; transition: all .15s;
  background: #fafafa;
}
.training-item:hover { border-color: var(--border-md); background: #fff; }
.training-item.completed {
  border-color: #bbf7d0; background: linear-gradient(135deg,#f0fdf4,#ecfdf5);
  color: var(--success-t);
}
.training-item.in_progress {
  border-color: #fde68a; background: linear-gradient(135deg,#fffdf0,#fffbeb);
  color: var(--warning-t);
}
.training-item.expired {
  border-color: #fecaca; background: linear-gradient(135deg,#fff5f5,#fef2f2);
  color: var(--danger-t);
}
.training-item .ti-icon { position: absolute; top: 10px; right: 10px; font-size: 14px; }
.training-item .ti-label { font-size: 11.5px; line-height: 1.4; font-weight: 600; }
.training-item .ti-date  { font-size: 10px; font-weight: 400; color: var(--text-muted); margin-top: 5px; }

/* ══════════════════════════════════════════
   CHECK FORM
══════════════════════════════════════════ */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 8px; }
.check-item {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 13px 15px;
  cursor: pointer; transition: all .15s; background: #fafafa;
}
.check-item:hover { border-color: var(--primary); background: #eff6ff; }
.check-item.ok     { border-color: #86efac; background: linear-gradient(135deg,#f0fdf4,#ecfdf5); }
.check-item.defect { border-color: #fca5a5; background: linear-gradient(135deg,#fff5f5,#fef2f2); }
.check-item-label  { font-size: 13px; font-weight: 600; color: var(--text); }
.check-item-status { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ══════════════════════════════════════════
   MODALS
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: slideUp .2s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ══════════════════════════════════════════
   TOASTS
══════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  background: #1e293b; color: #fff; padding: 14px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 380px;
  pointer-events: all; animation: toastIn .25s cubic-bezier(.34,1.56,.64,1);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
@keyframes toastIn { from{opacity:0;transform:translateX(20px) scale(.95)} to{opacity:1;transform:translateX(0) scale(1)} }

/* ══════════════════════════════════════════
   EMPTY STATES
══════════════════════════════════════════ */
.empty-state { text-align: center; padding: 52px 20px; color: var(--text-muted); }
.empty-state .empty-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: var(--bg); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
}
.empty-state .empty-icon svg { width: 26px; height: 26px; opacity: .5; }
.empty-state p { font-size: 14px; font-weight: 500; }
.empty-state .empty-hint { font-size: 12.5px; color: var(--text-light); margin-top: 6px; }

/* ══════════════════════════════════════════
   UTILITY
══════════════════════════════════════════ */
.flex { display: flex; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.fw-600     { font-weight: 600; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 14px; }

/* Info box */
.info-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr));
  gap: 0;
}
.info-item { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.info-item:nth-child(odd) { border-right: 1px solid var(--border); }
.info-item .info-key { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.info-item .info-val { font-size: 13.5px; font-weight: 600; color: var(--text); }

/* Expiry indicator */
.expiry-ok     { color: var(--success); font-weight: 700; }
.expiry-warn   { color: var(--warning); font-weight: 700; }
.expiry-danger { color: var(--danger); font-weight: 700; }

/* ══════════════════════════════════════════
   PAGE-SPECIFIC
══════════════════════════════════════════ */

/* Defect timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-step { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 18px; position: relative; }
.timeline-step:not(:last-child)::after {
  content: ''; position: absolute; left: 13px; top: 28px; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; z-index: 1;
  transition: all .2s;
}
.timeline-dot.done    { background: var(--success); color: #fff; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.timeline-dot.current { background: var(--primary); color: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.2); animation: ringPulse 2s ease infinite; }
.timeline-dot.pending { background: var(--bg); color: var(--text-muted); border: 2px solid var(--border); }
@keyframes ringPulse { 0%,100%{box-shadow:0 0 0 3px rgba(37,99,235,.2)} 50%{box-shadow:0 0 0 6px rgba(37,99,235,.08)} }
.timeline-label  { font-size: 13.5px; font-weight: 600; padding-top: 5px; }
.timeline-sublabel { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Vehicle status strip */
.vehicle-status-strip {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 0;
}
.vss-item {
  padding: 16px 18px; border-right: 1px solid var(--border); text-align: center;
}
.vss-item:last-child { border-right: none; }
.vss-val { font-size: 20px; font-weight: 800; }
.vss-key { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-weight: 600; }

/* ══════════════════════════════════════════
   macOS COMPONENTS
══════════════════════════════════════════ */

/* Toolbar — a window's control strip */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--mac-hairline);
  background: linear-gradient(180deg, rgba(248,250,253,.7), rgba(255,255,255,0));
}
.toolbar .spacer { flex: 1; }
.toolbar-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

/* Search field (macOS rounded search) */
.search-field { position: relative; display: inline-flex; align-items: center; }
.search-field svg { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--text-light); pointer-events: none; }
.search-field input {
  padding: 8px 12px 8px 32px; min-width: 240px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border-md); border-radius: 999px; color: var(--text);
  background: #fff; transition: all .15s; box-shadow: inset 0 1px 2px rgba(15,23,42,.04);
}
.search-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.16); }
.search-field.grow { display: flex; flex: 1; min-width: 200px; }
.search-field.grow input { width: 100%; min-width: 0; }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #e9eef6; border: 1px solid var(--mac-hairline); border-radius: 9px;
}
.segmented button, .segmented a {
  appearance: none; border: none; cursor: pointer; text-decoration: none;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  padding: 5px 13px; border-radius: 7px; background: transparent; transition: all .14s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.segmented button:hover, .segmented a:hover { color: var(--text); }
.segmented button.active, .segmented a.active {
  background: #fff; color: var(--text); box-shadow: var(--shadow-sm);
}
.segmented .seg-count { font-size: 11px; font-weight: 700; opacity: .6; }

/* Filter chips */
.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--mac-hairline); background: rgba(255,255,255,.7); color: var(--text-2);
  transition: all .14s; user-select: none;
}
.chip:hover { background: #fff; border-color: var(--border-md); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.28); }
.chip .chip-count { font-size: 11px; opacity: .7; font-weight: 700; }
.chip.active .chip-count { opacity: .9; }

/* macOS list rows (cards-as-list) */
.mac-list { display: flex; flex-direction: column; }
.mac-row {
  display: grid; align-items: center; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--mac-hairline);
  text-decoration: none; color: var(--text); transition: background .12s;
}
.mac-row:last-child { border-bottom: none; }
.mac-row:hover { background: #f6f9ff; }
.mac-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.mac-row-title { font-size: 14px; font-weight: 700; color: var(--text); }
.mac-row-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.mono { font-family: 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, monospace; }

/* segmented-glass card body backdrop for framed lists */
.window-canvas { background: linear-gradient(180deg, #f7f9fd 0%, #eef3fb 100%); padding: 16px; }

/* Responsive filter bar (replaces fixed inline grids) */
.filter-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filter-form > div { flex: 1 1 160px; min-width: 140px; }
.filter-form > .filter-search { flex: 2 1 220px; }
.filter-form .btn { flex: 0 0 auto; }
@media (max-width: 560px) {
  .filter-form { gap: 10px; }
  .filter-form > div, .filter-form > .filter-search { flex: 1 1 100%; }
  .filter-form .btn { flex: 1 1 calc(50% - 5px); justify-content: center; }
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 1200px) {
  .score-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: 280px; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(8,15,30,.5); }
  .main    { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  body.nav-open { overflow: hidden; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-search { display: none; }
  .score-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid  { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page-body { padding: 16px 14px 26px; }
  .topbar-time { display: none; }
  .topbar-left h2 { font-size: 14px; }
  .page-head h1 { font-size: 22px; }
  .page-head-actions { width: 100%; }
  .stat-grid { grid-template-columns: 1fr; }
  .score-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 26px; }
  .card-body { padding: 16px; }
  .btn { padding: 8px 14px; }
  .toolbar { padding: 10px 12px; }
  .segmented { width: 100%; overflow-x: auto; }

  /* Header rows + button groups wrap instead of overflowing */
  .flex.justify-between { flex-wrap: wrap; gap: 12px; }
  .flex.gap-2, .flex.gap-3 { flex-wrap: wrap; }
  .page-head-actions .btn,
  .page-head-actions > * { flex: 1; justify-content: center; }

  /* Wide tables: tighter cells + pin the identifying first column */
  table { font-size: 12.5px; }
  thead th { padding: 9px 12px; }
  tbody td { padding: 11px 12px; }
  .table-wrap thead th:first-child,
  .table-wrap tbody td:first-child {
    position: sticky; left: 0; z-index: 1;
    box-shadow: 6px 0 8px -6px rgba(15,23,42,.18);
  }
  .table-wrap thead th:first-child { background: #f1f5f9; }
  .table-wrap tbody td:first-child { background: #fff; }
  .table-wrap tbody tr:hover td:first-child { background: #f8fafc; }
}
