/* file: assets/app.css — Transporter Monitor v2 */

/* ──────────────────────────────────────────────────
   1. CSS VARIABLES
   ────────────────────────────────────────────────── */
:root {
  --font-sans: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;
  --ease: 0.18s ease;
  --ease-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg:           #06091a;
  --bg-2:         #090d20;
  --bg-3:         #0d1228;
  --sidebar-bg:   #070923;
  --sidebar-bd:   #1a2245;
  --sidebar-item: rgba(255,255,255,0.04);
  --sidebar-item-act: rgba(74,158,255,0.14);
  --sidebar-text: #b8c8e8;
  --sidebar-text-act: #6eb8ff;
  --sidebar-text-muted: #4a5e80;
  --card-bg:      #0c1428;
  --card-bg-2:    #101b33;
  --border:       #182240;
  --border-2:     #223050;
  --text-1:       #e4ecff;
  --text-2:       #7a92b5;
  --text-3:       #4a5e7a;
  --accent:       #4a9eff;
  --accent-2:     #2563eb;
  --accent-hover: #3a8ef0;
  --accent-dim:   rgba(74,158,255,0.12);
  --accent-glow:  rgba(74,158,255,0.25);
  --success-c:    #22c55e;
  --success-bg:   rgba(34,197,94,0.1);
  --success-text: #4ade80;
  --success-bd:   rgba(74,222,128,0.2);
  --warning-c:    #eab308;
  --warning-bg:   rgba(234,179,8,0.1);
  --warning-text: #facc15;
  --warning-bd:   rgba(250,204,21,0.2);
  --danger-c:     #ef4444;
  --danger-bg:    rgba(239,68,68,0.1);
  --danger-text:  #f87171;
  --danger-bd:    rgba(248,113,113,0.2);
  --neutral-bg:   rgba(255,255,255,0.04);
  --neutral-bg-2: rgba(255,255,255,0.07);
  --chart-grid:   rgba(255,255,255,0.04);
  --chart-blue:   #4a9eff;
  --chart-green:  #34d399;
  --chart-red:    #fb7185;
  --chart-cyan:   #22d3ee;
  --chart-orange: #fb923c;
  --chart-purple: #a78bfa;
  --chart-gray:   #64748b;
  /* new aliases */
  --chart-1: #4a9eff;
  --chart-2: #34d399;
  --chart-3: #fb7185;
  --chart-4: #22d3ee;
  --chart-5: #fb923c;
  --chart-6: #a78bfa;
  --chart-7: #64748b;
  --sh-sm:  0 1px 4px rgba(0,0,0,0.5);
  --sh-md:  0 4px 20px rgba(0,0,0,0.6);
  --sh-lg:  0 12px 48px rgba(0,0,0,0.7);
  --sh-card: 0 2px 12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.025);
  --topbar-bg: rgba(6,9,26,0.88);
}

[data-theme="light"] {
  color-scheme: light;
  --bg:           #f0f4fc;
  --bg-2:         #e8eef8;
  --bg-3:         #dde5f5;
  --sidebar-bg:   #0f1a35;
  --sidebar-bd:   #1a2a50;
  --sidebar-item: rgba(255,255,255,0.04);
  --sidebar-item-act: rgba(74,158,255,0.18);
  --sidebar-text: #b8cce8;
  --sidebar-text-act: #6eb8ff;
  --sidebar-text-muted: #4a6080;
  --card-bg:      #ffffff;
  --card-bg-2:    #f8faff;
  --border:       #dde5f5;
  --border-2:     #c8d5ec;
  --text-1:       #0f172a;
  --text-2:       #4b6080;
  --text-3:       #8fa0be;
  --accent:       #2563eb;
  --accent-2:     #1d4ed8;
  --accent-hover: #1a56d6;
  --accent-dim:   rgba(37,99,235,0.08);
  --accent-glow:  rgba(37,99,235,0.2);
  --success-c:    #16a34a;
  --success-bg:   rgba(22,163,74,0.08);
  --success-text: #15803d;
  --success-bd:   rgba(22,163,74,0.2);
  --warning-c:    #ca8a04;
  --warning-bg:   rgba(202,138,4,0.08);
  --warning-text: #92400e;
  --warning-bd:   rgba(202,138,4,0.2);
  --danger-c:     #dc2626;
  --danger-bg:    rgba(220,38,38,0.08);
  --danger-text:  #991b1b;
  --danger-bd:    rgba(220,38,38,0.2);
  --neutral-bg:   rgba(0,0,0,0.04);
  --neutral-bg-2: rgba(0,0,0,0.07);
  --chart-grid:   #e8f0fe;
  --chart-blue:   #2563eb;
  --chart-green:  #16a34a;
  --chart-red:    #dc2626;
  --chart-cyan:   #0891b2;
  --chart-orange: #ea580c;
  --chart-purple: #7c3aed;
  --chart-gray:   #64748b;
  --chart-1: #2563eb;
  --chart-2: #16a34a;
  --chart-3: #dc2626;
  --chart-4: #0891b2;
  --chart-5: #ea580c;
  --chart-6: #7c3aed;
  --chart-7: #64748b;
  --sh-sm:  0 1px 4px rgba(0,0,0,0.08);
  --sh-md:  0 4px 20px rgba(0,0,0,0.1);
  --sh-lg:  0 12px 48px rgba(0,0,0,0.14);
  --sh-card: 0 2px 12px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  --topbar-bg: rgba(240,244,252,0.9);
}

/* ──────────────────────────────────────────────────
   2. RESET & BASE
   ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  background: var(--bg);
  color: var(--text-1);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

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

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 22px; color: var(--text-1); }
h2 { font-size: 15px; color: var(--text-1); }
h3 { font-size: 13px; color: var(--text-2); font-weight: 600; }

p { margin: 0 0 12px; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ──────────────────────────────────────────────────
   3. LAYOUT — SIDEBAR + SHELL
   ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-bd);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: transform var(--ease-smooth);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.shell {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--ease-smooth);
}

/* ──────────────────────────────────────────────────
   4. SIDEBAR INTERNALS
   ────────────────────────────────────────────────── */
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-bd);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(74,158,255,0.3);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  stroke: white;
  fill: none;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  color: #e4ecff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  margin-top: -1px;
}

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--ease);
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-item);
  color: #e4ecff;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-item-act);
  color: var(--sidebar-text-act);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--sidebar-bd);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--sidebar-text-muted);
}

/* ──────────────────────────────────────────────────
   5. TOPBAR (within shell)
   ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 6px;
  border-radius: var(--r-sm);
  align-items: center;
  justify-content: center;
  transition: all var(--ease);
  flex-shrink: 0;
}
.topbar-hamburger:hover {
  background: var(--neutral-bg);
  color: var(--text-1);
}
.topbar-hamburger svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Theme toggle */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  transition: all var(--ease);
  gap: 6px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.theme-switch:hover {
  background: var(--neutral-bg-2);
  color: var(--text-1);
}
.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-switch .slider {
  width: 32px;
  height: 18px;
  background: var(--border-2);
  border-radius: var(--r-full);
  position: relative;
  transition: background var(--ease);
}
.theme-switch .slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-2);
  transition: all var(--ease);
}
.theme-switch input:checked + .slider {
  background: var(--accent);
}
.theme-switch input:checked + .slider::after {
  transform: translateX(14px);
  background: white;
}
.theme-switch .sun, .theme-switch .moon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-theme="dark"] .theme-switch .sun { opacity: 0.4; }
[data-theme="dark"] .theme-switch .moon { opacity: 1; }
[data-theme="light"] .theme-switch .sun { opacity: 1; }
[data-theme="light"] .theme-switch .moon { opacity: 0.4; }

/* ──────────────────────────────────────────────────
   6. MAIN CONTENT
   ────────────────────────────────────────────────── */
.wrap {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
  width: 100%;
}

/* Page section headings */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ──────────────────────────────────────────────────
   7. CARDS
   ────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--sh-card);
  animation: fadeUp 0.3s ease-out both;
}

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

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.card-meta {
  font-size: 12px;
  color: var(--text-3);
}

/* ──────────────────────────────────────────────────
   8. KPI CARDS
   ────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform var(--ease), box-shadow var(--ease);
  box-shadow: var(--sh-card);
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--kpi-accent, var(--accent)) 0%, transparent 100%);
  opacity: 0.7;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  background: var(--kpi-icon-bg, var(--accent-dim));
}
.kpi-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--kpi-icon-color, var(--accent));
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kpi-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.kpi .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.kpi .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 4px 0 8px;
  font-variant-numeric: tabular-nums;
}

.kpi .sub {
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

.kpi-trend { flex-shrink: 0; }

.kpi-modern { /* alias */ }
.kpi-grid-modern { /* alias */ }

/* ──────────────────────────────────────────────────
   9. BADGES
   ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.b-ok {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-bd);
}
.b-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-bd);
}
.b-bad {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-bd);
}
.b-neutral {
  background: var(--neutral-bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ──────────────────────────────────────────────────
   10. BUTTONS
   ────────────────────────────────────────────────── */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--ease);
  line-height: 1.4;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
button:hover, .button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
  color: #fff;
}
button:active, .button:active {
  transform: translateY(0);
  box-shadow: none;
}

button.secondary, .button.secondary {
  background: var(--neutral-bg);
  border-color: var(--border);
  color: var(--text-1);
  box-shadow: none;
}
button.secondary:hover, .button.secondary:hover {
  background: var(--neutral-bg-2);
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

button.danger, .button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger-text);
  box-shadow: none;
}
button.danger:hover, .button.danger:hover {
  background: var(--danger-c);
  border-color: var(--danger-c);
  color: #fff;
  transform: translateY(-1px);
}

.small-btn {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ──────────────────────────────────────────────────
   11. FORMS
   ────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 7px 11px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  line-height: 1.5;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type="range"] {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

label.dashboard-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
}

/* ──────────────────────────────────────────────────
   12. TABLES
   ────────────────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
}
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-track { background: var(--bg); border-radius: 3px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

th {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  background: rgba(255,255,255,0.02);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  color: var(--text-1);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

table.compact th,
table.compact td { padding: 7px 12px; font-size: 12px; }

.simple-table { border: none; border-radius: 0; overflow: visible; }
.simple-table th, .simple-table td {
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 10px 0;
}
.simple-table tr:last-child th,
.simple-table tr:last-child td { border-bottom: none; }
.simple-table th {
  color: var(--text-2);
  width: 160px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
}

.truncate {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ──────────────────────────────────────────────────
   13. MISC HELPERS
   ────────────────────────────────────────────────── */
.small { font-size: 12px; color: var(--text-2); }
.sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 8px;
  vertical-align: middle;
}

.error {
  color: var(--danger-text);
  background: var(--danger-bg);
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--danger-bd);
  margin: 12px 0;
  font-size: 13px;
}
.success {
  color: var(--success-text);
  background: var(--success-bg);
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--success-bd);
  margin: 12px 0;
  font-size: 13px;
}

/* ──────────────────────────────────────────────────
   14. SCANNER CARDS
   ────────────────────────────────────────────────── */
.scanner-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.scanner-mini-card {
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  transition: all var(--ease);
  overflow: hidden;
}
.scanner-mini-card:hover {
  background: var(--neutral-bg-2);
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

.scanner-mini-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.scanner-mini-label { min-width: 0; flex: 1; }

.scanner-mini-card a.mono {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.scanner-mini-card a.mono:hover { color: var(--accent); }

/* Status dots */
.dot-online, .dot-offline {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-online {
  background: var(--success-c);
  box-shadow: 0 0 6px var(--success-c);
  animation: pulse-dot 2s ease-in-out infinite;
}
.dot-offline { background: var(--text-3); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--success-c); }
  50% { box-shadow: 0 0 12px var(--success-c), 0 0 20px rgba(34,197,94,0.3); }
}

/* ──────────────────────────────────────────────────
   15. DASHBOARD LAYOUT HELPERS
   ────────────────────────────────────────────────── */
.dashboard-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--card-bg), var(--card-bg-2));
}
.dashboard-hero::after {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  right: -60px; top: -140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,158,255,0.1), transparent 68%);
  pointer-events: none;
}

.dashboard-hero-main {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.dashboard-eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 6px;
}

.dashboard-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-1);
  margin: 0 0 6px;
  line-height: 1.2;
}

.dashboard-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dashboard-control-wide { min-width: 160px; }

.dashboard-meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.dashboard-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.dashboard-card-head h2 { margin: 0; }

.dashboard-inline-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dashboard-chart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 20px;
}
.dashboard-chart-grid > * { margin: 0 !important; }

.dashboard-list-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 20px;
  align-items: start;
}
.dashboard-list-grid > * { margin: 0 !important; }

.dashboard-action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.dashboard-action-grid > * { margin: 0 !important; }

.dashboard-chart-card h2 { margin: 0; }
.dashboard-action-card button { white-space: nowrap; }

/* ──────────────────────────────────────────────────
   16. CHARTS
   ────────────────────────────────────────────────── */
.line-chart { min-height: 220px; }

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-axis-label {
  fill: var(--text-3);
  font-size: 10px;
  font-family: var(--font-mono);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  font-weight: 500;
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-chart-wrap {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.donut-chart {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  position: relative;
}

.donut-core {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
}

.donut-core .mono {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.donut-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ──────────────────────────────────────────────────
   17. MAP
   ────────────────────────────────────────────────── */
#map {
  height: 380px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg);
  margin-top: 4px;
  overflow: hidden;
}
.leaflet-container { background: var(--bg) !important; }
[data-theme="dark"] .leaflet-tile {
  filter: brightness(0.5) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}
.leaflet-bar a {
  background-color: var(--card-bg) !important;
  color: var(--text-1) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-bar a:hover { background-color: var(--neutral-bg-2) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--card-bg) !important;
  color: var(--text-1) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--sh-md) !important;
}

/* ──────────────────────────────────────────────────
   18. IMAGES GRID
   ────────────────────────────────────────────────── */
.dashboard-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.dash-thumb {
  position: relative;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all var(--ease);
  background: white;
}
.dash-thumb:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
  border-color: var(--accent);
}
.dash-thumb img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.dash-thumb-meta {
  padding: 8px 10px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  position: absolute;
  bottom: 0; left: 0; right: 0;
  font-size: 11px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.thumb {
  width: 110px;
  height: 82px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: white;
  transition: transform var(--ease);
}
.thumb:hover { transform: scale(1.06); }

/* ──────────────────────────────────────────────────
   19. LOGIN PAGE
   ────────────────────────────────────────────────── */
.login-page {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.login-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.login-bg::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  left: -200px; top: -100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,158,255,0.08), transparent 68%);
}
.login-bg::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  right: -100px; bottom: -100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.07), transparent 68%);
}

.login-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  padding: 40px 24px;
  position: relative;
  z-index: 1;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(74,158,255,0.3);
}
.login-brand-icon svg {
  width: 24px;
  height: 24px;
  stroke: white;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-brand-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px;
  box-shadow: var(--sh-lg);
  animation: fadeUp 0.4s ease-out;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 6px;
}
.login-card .login-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: all var(--ease);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--bg-3);
}

.btn-full { width: 100%; }

.login-notice {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}

/* ──────────────────────────────────────────────────
   20. SPECIALIZED COMPONENTS
   ────────────────────────────────────────────────── */
.compact-table {
  width: 100%;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: rgba(0,0,0,0.15);
}
.compact-table th { font-size: 10px; background: rgba(255,255,255,0.02); padding: 6px 10px; }
.compact-table td { padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.compact-table tr:last-child td { border-bottom: none; }

.barcode-well {
  background: white;
  padding: 10px;
  border-radius: var(--r-xs);
  display: inline-block;
}
.barcode-well svg { display: block; }

.zending-header {
  background: rgba(255,255,255,0.04) !important;
  color: var(--text-1);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.goods-row { background: rgba(255,255,255,0.02) !important; font-weight: 600; }
.goods-row td:first-child {
  padding-left: 20px;
  color: var(--text-2);
  font-size: 12px;
}

/* Refresh indicator */
.refresh-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
  flex-shrink: 0;
}
.refreshing .refresh-indicator { opacity: 1; animation: pulse-dot 1s infinite; }

/* Progress refresh bar at top of shell */
.refresh-bar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--ease-smooth);
  z-index: 500;
  pointer-events: none;
}
.refreshing .refresh-bar { transform: scaleX(0.7); }

/* ──────────────────────────────────────────────────
   21. SIDEBAR OVERLAY (mobile)
   ────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 250;
  backdrop-filter: blur(2px);
}

/* ──────────────────────────────────────────────────
   22. ANIMATIONS
   ────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

/* Staggered card animations */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 50ms; }
.card:nth-child(3) { animation-delay: 100ms; }
.card:nth-child(4) { animation-delay: 150ms; }

.kpi:nth-child(1) { animation: fadeUp 0.35s ease-out 0ms both; }
.kpi:nth-child(2) { animation: fadeUp 0.35s ease-out 60ms both; }
.kpi:nth-child(3) { animation: fadeUp 0.35s ease-out 120ms both; }
.kpi:nth-child(4) { animation: fadeUp 0.35s ease-out 180ms both; }

/* ──────────────────────────────────────────────────
   23. RESPONSIVE
   ────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .dashboard-chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-list-grid,
  .dashboard-action-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--sh-lg);
  }
  .sidebar-overlay.open { display: block; }

  .shell { margin-left: 0; }
  .refresh-bar { left: 0; }

  .topbar-hamburger { display: flex; }
  .wrap { padding: 16px; }

  .dashboard-title { font-size: 18px; }
  .dashboard-chart-grid,
  .dashboard-list-grid,
  .dashboard-action-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .scanner-mini-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-image-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ──────────────────────────────────────────────────
   COMPONENTS — added for list views
   ────────────────────────────────────────────────── */

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Action bar (bulk ops) */
.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}
.action-bar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  white-space: nowrap;
}
.action-bar-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 20px;
  overflow-y: auto;
}
.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--sh-lg);
  animation: fadeUp 0.2s ease-out;
  flex-shrink: 0;
}
.modal-content.modal-lg { max-width: 860px; }
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Fieldset */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin: 0;
}
legend {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  padding: 0 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 20px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  transition: all var(--ease);
}
.back-link:hover {
  color: var(--text-1);
  background: var(--neutral-bg-2);
  border-color: var(--border-2);
  text-decoration: none;
}
.back-link svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round;
}

/* Page stat */
.page-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.page-stat strong { color: var(--text-1); font-weight: 700; }

/* Clear filter badge */
a.clear-filters, .clear-filters {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warning-text);
  background: var(--warning-bg);
  border: 1px solid var(--warning-bd);
  padding: 3px 10px;
  border-radius: var(--r-full);
  text-decoration: none;
  transition: all var(--ease);
  white-space: nowrap;
}
a.clear-filters:hover, .clear-filters:hover {
  background: var(--warning-c);
  color: #000;
  border-color: var(--warning-c);
}

/* Checkbox items in forms */
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
}
.check-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  border-radius: 3px;
  flex-shrink: 0;
  margin: 0;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--ease);
}
.page-btn:hover {
  background: var(--neutral-bg-2);
  color: var(--text-1);
  border-color: var(--border-2);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff !important;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Form group (reused from login) */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  background: var(--bg-2, var(--bg));
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: all var(--ease);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Info table (key-value) */
.info-table { width: 100%; border-collapse: collapse; }
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table tr:last-child { border-bottom: none; }
.info-table th {
  width: 180px;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-align: left;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.info-table td {
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-1);
  border: none;
}
.info-table td .mono { font-size: 13px; }
