/* ==========================================================================
   FLUVIO PANEL v1.0 — Dashboard Ejecutivo del Dueño (Fluvio 3A Design System)
   Modo Claro + Modo Oscuro · Telemetría Multi-Flota · Bento KPIs · Gráficas
   ========================================================================== */

:root {
  --bg: #f3f7fc;
  --surface: #ffffff;
  --surface-2: #edf3fa;
  --border: #e1e9f3;
  --border-strong: #c6d5e6;
  --ink: #0b1629;
  --ink-2: #334155;
  --muted: #64748b;
  --brand: #0b4f9e;
  --brand-vivid: #1d64d8;
  --brand-sky: #0284c7;
  --brand-indigo: #4f46e5;
  --brand-soft: #eff6ff;
  --brand-ink: #0b4f9e;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-soft: #ecfdf5;
  --emerald-ink: #047857;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --amber-ink: #b45309;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --danger-ink: #b91c1c;
  --shadow-xs: 0 2px 6px rgba(11, 22, 41, 0.045);
  --shadow-sm: 0 8px 22px rgba(11, 22, 41, 0.065);
  --shadow-md: 0 18px 38px rgba(11, 22, 41, 0.11);
  --shadow-lg: 0 26px 56px rgba(2, 6, 23, 0.25);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --sidebar-w: 264px;
  --font-head: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

body.theme-dark {
  --bg: #070d19;
  --surface: #0e1729;
  --surface-2: #152238;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --ink: #f8fafc;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --brand: #2563eb;
  --brand-vivid: #38bdf8;
  --brand-sky: #38bdf8;
  --brand-indigo: #818cf8;
  --brand-soft: rgba(37, 99, 235, 0.2);
  --brand-ink: #93c5fd;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-soft: rgba(16, 185, 129, 0.18);
  --emerald-ink: #6ee7b7;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.18);
  --amber-ink: #fcd34d;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.18);
  --danger-ink: #fca5a5;
  --shadow-xs: 0 2px 6px rgba(0, 0, 0, 0.26);
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 18px 38px rgba(0, 0, 0, 0.48);
  --shadow-lg: 0 28px 60px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: 2px solid var(--brand-vivid); outline-offset: 2px; }

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(880px 400px at 8% -4%, rgba(29, 100, 216, 0.13), transparent 64%),
    radial-gradient(760px 360px at 94% 4%, rgba(16, 185, 129, 0.13), transparent 62%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.theme-dark {
  background-image:
    radial-gradient(880px 420px at 10% -4%, rgba(37, 99, 235, 0.24), transparent 64%),
    radial-gradient(760px 380px at 94% 6%, rgba(16, 185, 129, 0.18), transparent 62%);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
img, svg { display: block; max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }
.is-hidden { display: none !important; }

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= ONBOARDING ================= */
.onboarding-screen {
  min-height: 100svh; min-height: 100dvh;
  background:
    radial-gradient(780px 460px at 82% 10%, rgba(29, 100, 216, 0.28), transparent 60%),
    radial-gradient(560px 380px at 14% 86%, rgba(16, 185, 129, 0.22), transparent 65%),
    #080e1a;
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
}
.onboarding-card { width: 100%; max-width: 960px; display: grid; grid-template-columns: 1fr; gap: 26px; align-items: center; }
.onb-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.onb-brand-name { font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.03em; }
.onb-brand-pill {
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.22); color: #7dd3fc; letter-spacing: 0.04em; text-transform: uppercase;
}
.onb-title {
  font-family: var(--font-head); font-weight: 800;
  font-size: clamp(1.9rem, 4vw, 2.8rem); line-height: 1.07; letter-spacing: -0.035em; margin-bottom: 14px;
}
.onb-sub { color: #cbd5e1; font-size: 0.98rem; max-width: 48ch; margin-bottom: 24px; }
.onb-panel {
  background: rgba(15, 23, 42, 0.88); border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 22px; padding: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.onb-panel h2 { font-family: var(--font-head); font-size: 1.15rem; margin-bottom: 4px; }
.onb-panel p { font-size: 0.86rem; color: #94a3b8; margin-bottom: 16px; }
.onb-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-size: 0.74rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.onb-divider::before, .onb-divider::after { content: ''; flex: 1; height: 1px; background: rgba(148, 163, 184, 0.18); }
.onb-saved-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.onb-saved-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.18); color: #ffffff; text-align: left;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.onb-saved-item:hover { transform: translateY(-1px); background: rgba(56, 189, 248, 0.14); border-color: rgba(56, 189, 248, 0.45); }
.onb-saved-item small { display: block; font-size: 0.78rem; color: #94a3b8; }

/* ================= SHELL & TOPBAR ================= */
.app-shell { min-height: 100svh; display: flex; flex-direction: column; }
.desktop-sidebar { display: none; }

.mobile-topbar {
  position: sticky; top: 0; z-index: 60;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(243, 247, 252, 0.88);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
body.theme-dark .mobile-topbar { background: rgba(7, 13, 25, 0.88); }

.top-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-brand-title { font-family: var(--font-head); font-weight: 800; font-size: 0.98rem; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-brand-sub { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: var(--emerald-soft); color: var(--emerald-ink); white-space: nowrap;
  border: 1px solid rgba(16, 185, 129, 0.24);
}
.sync-pill.is-offline { background: var(--amber-soft); color: var(--amber-ink); border-color: rgba(245, 158, 11, 0.28); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulseRing 2.4s infinite; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 140ms ease, background 150ms ease, border-color 150ms ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.95); }

.app-main {
  flex: 1; width: 100%; max-width: 1320px; margin: 0 auto;
  padding: 16px 16px calc(114px + env(safe-area-inset-bottom));
}
.view-panel { display: none; animation: fadeSlide 200ms cubic-bezier(0.22, 1, 0.36, 1); }
.view-panel.is-active { display: block; }

.exec-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 16px;
}
.fleet-filter-wrap {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.fleet-select {
  min-height: 40px; padding: 7px 12px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: 0.84rem; font-weight: 700; box-shadow: var(--shadow-xs);
}
.period-tabs {
  display: inline-flex; padding: 3px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.period-btn {
  padding: 6px 12px; border-radius: 9px; font-size: 0.78rem; font-weight: 700; color: var(--muted);
  transition: all 150ms ease;
}
.period-btn.is-active { background: var(--ink); color: var(--bg); }

.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.view-head h1 { font-family: var(--font-head); font-weight: 800; font-size: clamp(1.35rem, 2.4vw, 1.75rem); letter-spacing: -0.03em; line-height: 1.14; }
.view-head p { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

/* ================= EXECUTIVE TELEMETRY HERO ================= */
.exec-hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl); padding: 22px; color: #ffffff;
  background:
    radial-gradient(460px 280px at 94% 6%, rgba(56, 189, 248, 0.3), transparent 64%),
    radial-gradient(380px 260px at 6% 96%, rgba(16, 185, 129, 0.28), transparent 64%),
    linear-gradient(138deg, #0b4f9e 0%, #092145 55%, #071122 100%);
  box-shadow: 0 22px 48px rgba(11, 79, 158, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(147, 197, 253, 0.22);
  margin-bottom: 18px;
}
.eh-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; }
.eh-status-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.live-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(52, 211, 153, 0.38);
  color: #a7f3d0; font-size: 0.72rem; font-weight: 700;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; animation: pulseRing 2.1s infinite; }
.eh-clock {
  font-size: 0.74rem; font-weight: 700; color: rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px 10px; border-radius: 999px;
}
.eh-main-kpi {
  font-family: var(--font-head); font-weight: 800;
  font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1; letter-spacing: -0.04em;
  background: linear-gradient(180deg, #ffffff 0%, #bae6fd 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.eh-sub-kpi { font-size: 0.84rem; color: rgba(203, 213, 225, 0.88); margin-top: 4px; }

.eh-reconcile {
  background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px; padding: 12px 15px; min-width: 225px;
}
.eh-reconcile small { display: block; font-size: 0.69rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #93c5fd; margin-bottom: 4px; }
.eh-reconcile strong { font-family: var(--font-head); font-size: 1rem; font-weight: 800; color: #ffffff; display: block; }
.eh-reconcile span { font-size: 0.75rem; color: #a7f3d0; }

.eh-split-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px;
}
.eh-mini-stat {
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; padding: 11px 13px;
}
.eh-mini-stat small { display: block; font-size: 0.71rem; color: rgba(203, 213, 225, 0.84); font-weight: 600; }
.eh-mini-stat strong { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; color: #ffffff; }

.eh-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }

/* ================= BENTO KPIS & CHARTS ================= */
.kpi-grid-4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 15px 16px; box-shadow: var(--shadow-xs);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.kpi-card::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--brand-vivid); }
.kpi-card.k-emerald::before { background: var(--emerald); }
.kpi-card.k-amber::before { background: var(--amber); }
.kpi-card.k-danger::before { background: var(--danger); }
.kpi-card small { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.kpi-card strong { display: block; font-family: var(--font-head); font-weight: 800; font-size: clamp(1.25rem, 2.2vw, 1.55rem); margin: 4px 0 2px; letter-spacing: -0.025em; }
.kpi-card span { font-size: 0.75rem; color: var(--muted); }

.charts-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
.chart-wrap { position: relative; height: 245px; width: 100%; }

/* ================= RED ALERTS MONITOR ================= */
.alerts-list { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
.alert-row {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--danger);
  border-radius: 16px; padding: 13px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow-xs);
}
.alert-row.is-warn { border-left-color: var(--amber); }
.alert-row.is-ok { border-left-color: var(--emerald); }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex-shrink: 0; animation: pulseRed 2s infinite; }
.alert-row.is-warn .alert-dot { background: var(--amber); animation: none; }
.alert-row.is-ok .alert-dot { background: var(--emerald); animation: pulseRing 2.2s infinite; }

/* ================= CARDS, BARS, AVATARS, MAP ================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 17px; box-shadow: var(--shadow-xs); }
.card-elevated { box-shadow: var(--shadow-sm); }
.card-subtle { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; }
.card-head-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head-row h3 { font-family: var(--font-head); font-weight: 800; font-size: 0.98rem; }

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

.tx-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-left { display: flex; align-items: center; gap: 11px; min-width: 0; }

.avatar {
  width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-family: var(--font-head);
  font-weight: 800; font-size: 0.84rem; color: #ffffff;
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.14);
}
.avatar.av-0 { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.avatar.av-1 { background: linear-gradient(135deg, #10b981, #059669); }
.avatar.av-2 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.avatar.av-3 { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.avatar.av-4 { background: linear-gradient(135deg, #ec4899, #e11d48); }
.avatar.av-5 { background: linear-gradient(135deg, #06b6d4, #0284c7); }

.meter-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 7px; }
.meter-fill { height: 100%; border-radius: 999px; transition: width 360ms ease; }
.meter-fill.m-ok { background: linear-gradient(90deg, #10b981, #34d399); }
.meter-fill.m-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.meter-fill.m-low { background: linear-gradient(90deg, #ef4444, #fb7185); }

.map-box {
  position: relative; z-index: 1; isolation: isolate;
  width: 100%; height: 320px; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-xs); margin-bottom: 16px;
}

/* ================= BUTTONS, BADGES, FORMS ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 15px; border-radius: 12px;
  font-weight: 700; font-size: 0.85rem; border: 1px solid transparent;
  transition: transform 140ms ease, filter 160ms ease, background 160ms ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #2563eb 0%, #0b4f9e 100%); color: #ffffff; box-shadow: 0 8px 18px rgba(11, 79, 158, 0.28); }
.btn-emerald { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #ffffff; box-shadow: 0 8px 20px rgba(16, 185, 129, 0.32); }
.btn-amber { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: #ffffff; }
.btn-glass { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.24); color: #ffffff; }
.btn-glass:hover { background: rgba(255, 255, 255, 0.22); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger-ink); }
.btn-sm { min-height: 35px; padding: 6px 11px; font-size: 0.78rem; border-radius: 10px; }
.btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.badge-blue { background: var(--brand-soft); color: var(--brand-ink); }
.badge-green { background: var(--emerald-soft); color: var(--emerald-ink); }
.badge-amber { background: var(--amber-soft); color: var(--amber-ink); }
.badge-red { background: var(--danger-soft); color: var(--danger-ink); }
.badge-neutral { background: var(--surface-2); color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field label { font-size: 0.79rem; font-weight: 700; color: var(--ink-2); }
.onboarding-screen .field label { color: #cbd5e1; }
.input, .select, .textarea {
  width: 100%; min-height: 43px; padding: 10px 13px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: 0.91rem; outline: none;
}
.onboarding-screen .input { background: rgba(255, 255, 255, 0.06); border-color: rgba(148, 163, 184, 0.25); color: #ffffff; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; min-height: 35px; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  font-size: 0.8rem; font-weight: 700;
}
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ================= MOBILE DOCK & DESKTOP SIDEBAR ================= */
.mobile-dock {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 70; background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 22px; padding: 5px;
  box-shadow: var(--shadow-md);
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px;
}
body.theme-dark .mobile-dock { background: rgba(14, 23, 41, 0.94); }
.dock-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 52px; border-radius: 14px; color: var(--muted);
  font-size: 0.62rem; font-weight: 700; transition: all 150ms ease;
}
.dock-btn.is-active { background: linear-gradient(135deg, #2563eb 0%, #0b4f9e 100%); color: #ffffff; box-shadow: 0 6px 14px rgba(11, 79, 158, 0.3); }

/* ================= SHEETS & TOASTS ================= */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 2000; background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(5px); display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.is-open { display: flex; }
.sheet {
  width: 100%; max-width: 540px; max-height: 88svh; overflow-y: auto;
  background: var(--surface); color: var(--ink); border-radius: 26px 26px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
}
.sheet-handle { width: 42px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-head h3 { font-family: var(--font-head); font-weight: 800; font-size: 1.12rem; }

.toast-stack {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 2200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(92vw, 380px);
}
.toast {
  background: #0f172a; color: #ffffff; border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px; padding: 12px 16px; font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow-md);
}
.toast.is-success { border-left: 4px solid var(--emerald); }
.toast.is-warning { border-left: 4px solid var(--amber); }
.toast.is-error { border-left: 4px solid var(--danger); }

/* ================= RESPONSIVE ================= */
@media (min-width: 768px) {
  .onboarding-card { grid-template-columns: 1.05fr 0.95fr; gap: 40px; }
  .eh-split-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .charts-grid { grid-template-columns: 1.55fr 1fr; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sheet-backdrop { align-items: center; padding: 20px; }
  .sheet { border-radius: 24px; padding: 22px 24px 24px; }
  .sheet-handle { display: none; }
}

@media (min-width: 1024px) {
  .app-shell { flex-direction: row; }
  .mobile-topbar, .mobile-dock { display: none; }
  .desktop-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 20px 14px; display: flex; flex-direction: column; justify-content: space-between; z-index: 60;
    box-shadow: 4px 0 24px rgba(11, 22, 41, 0.03);
  }
  .sb-brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
  .sb-brand-name { font-family: var(--font-head); font-weight: 800; font-size: 1.16rem; letter-spacing: -0.03em; }
  .sb-brand-sub { font-size: 0.72rem; color: var(--muted); }
  .sb-plant-pill {
    width: 100%; padding: 11px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
    text-align: left; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  }
  .sb-plant-pill strong { display: block; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sb-plant-pill small { display: block; font-size: 0.72rem; color: var(--muted); }
  .sb-nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding-right: 2px; }
  .sb-cat {
    font-size: 0.67rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted); padding: 10px 10px 4px; opacity: 0.85;
  }
  .sb-cat:first-child { padding-top: 2px; }
  .sb-btn {
    width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 11px;
    border-radius: 12px; font-size: 0.84rem; font-weight: 700; color: var(--muted); text-align: left;
    transition: background 150ms ease, color 150ms ease;
  }
  .sb-btn:hover { background: var(--surface-2); color: var(--ink); }
  .sb-btn.is-active { background: linear-gradient(135deg, #2563eb 0%, #0b4f9e 100%); color: #ffffff; box-shadow: 0 8px 20px rgba(11, 79, 158, 0.3); }
  .nav-pill-count {
    margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--danger-soft); color: var(--danger-ink); font-size: 0.7rem; font-weight: 800; display: grid; place-items: center;
  }
  .sb-btn.is-active .nav-pill-count { background: rgba(255, 255, 255, 0.22); color: #ffffff; }
  .sb-footer { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
  .sb-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .app-main { margin-left: var(--sidebar-w); padding: 26px 32px 52px; max-width: calc(100% - var(--sidebar-w)); }
}

/* ================= V2.0 OMNIBAR, NOTIFICATIONS DRAWER, TABLES, ESCANDALLO ================= */
.global-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.omnibar-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex: 1; min-width: 220px; max-width: 420px; min-height: 42px; padding: 8px 13px;
  border-radius: 13px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--muted); font-size: 0.84rem; box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.omnibar-btn:hover { border-color: var(--brand-vivid); color: var(--ink); }
.kbd-tag {
  font-size: 0.7rem; font-weight: 800; padding: 2px 7px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
}

.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #ffffff;
  font-size: 0.65rem; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface);
}

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 2100; background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px); display: none; justify-content: flex-end;
}
.drawer-backdrop.is-open { display: flex; }
.drawer-panel {
  width: min(92vw, 410px); height: 100%; background: var(--surface); color: var(--ink);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.drawer-head {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; min-width: 620px; }
.data-table th {
  text-align: left; padding: 9px 10px; font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }

.escandallo-box {
  background: linear-gradient(135deg, rgba(29, 100, 216, 0.08), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(29, 100, 216, 0.22);
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 16px;
}
.esc-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.esc-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 11px 13px; }
.esc-tile small { display: block; font-size: 0.7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.esc-tile strong { font-family: var(--font-head); font-size: 1.18rem; font-weight: 800; }

.subtabs-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.subtab-btn {
  padding: 8px 14px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); font-size: 0.82rem; font-weight: 700;
}
.subtab-btn.is-active { background: var(--brand); border-color: var(--brand); color: #ffffff; }

.delta-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 800; background: rgba(16, 185, 129, 0.2); color: #6ee7b7;
}
.delta-pill.is-down { background: rgba(239, 68, 68, 0.22); color: #fca5a5; }

.map-night-filter .leaflet-tile-pane {
  filter: invert(93%) hue-rotate(185deg) saturate(88%) brightness(92%) contrast(94%);
}

.route-stop-row { cursor: grab; transition: background 140ms ease, opacity 140ms ease; border-radius: 12px; padding-left: 6px; padding-right: 6px; }
.route-stop-row.is-dragging { opacity: 0.45; background: var(--brand-soft); }
.route-stop-row.is-drag-over { border-top: 2px solid var(--brand-vivid); }
.order-btns { display: inline-flex; flex-direction: column; gap: 2px; margin-right: 2px; }
.order-mini {
  width: 24px; height: 20px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink-2); font-size: 0.68rem; font-weight: 800;
  display: grid; place-items: center; line-height: 1;
}
.order-mini:hover { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-vivid); }
