/* Layout: barra lateral de cristal + contenido en rejilla de tarjetas sobre un fondo con brasas difuminadas */
:root {
  --bg: #060a13;
  --bg-2: #0b1222;
  --glass: rgba(20, 28, 46, .58);
  --glass-2: rgba(30, 40, 64, .55);
  --glass-hi: rgba(255, 255, 255, .06);
  --line: rgba(150, 175, 220, .13);
  --line-2: rgba(150, 175, 220, .22);
  --fg: #e9eef8;
  --fg-2: #b9c4d8;
  --muted: #7f8ba3;
  --accent: #2f7bff;
  --accent-2: #63a4ff;
  --accent-ink: #ffffff;
  --ember: #ff7a2f;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --teal: #2dd4bf;
  --violet: #a78bfa;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, .7);
  --orb-op: .55;
  --f-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 18px;
  --r-sm: 11px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #e9eef6;
  --bg-2: #f4f7fb;
  --glass: rgba(255, 255, 255, .66);
  --glass-2: rgba(255, 255, 255, .8);
  --glass-hi: rgba(255, 255, 255, .7);
  --line: rgba(30, 50, 90, .1);
  --line-2: rgba(30, 50, 90, .18);
  --fg: #0e1626;
  --fg-2: #33405a;
  --muted: #5f6b82;
  --accent: #1d63e8;
  --accent-2: #1d63e8;
  --ember: #e8621b;
  --ok: #0f9f6e;
  --warn: #b7791f;
  --bad: #dc3d3d;
  --teal: #0f9c8c;
  --violet: #7c5cdb;
  --shadow: 0 18px 40px -22px rgba(20, 40, 80, .35);
  --orb-op: .35;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
.num, td.num, .tab { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

/* fondo con orbes */
.orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orbs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: var(--orb-op); }
.orbs i:nth-child(1) { width: 520px; height: 520px; background: radial-gradient(circle at 35% 35%, #ff9a4d, #c2410c 70%); top: -180px; right: 6%; }
.orbs i:nth-child(2) { width: 640px; height: 640px; background: radial-gradient(circle at 40% 40%, #3b82f6, #1e3a8a 70%); bottom: -320px; left: -160px; }
.orbs i:nth-child(3) { width: 420px; height: 420px; background: radial-gradient(circle at 40% 40%, #2dd4bf, #0e7490 70%); bottom: -160px; right: -120px; }
.orbs i:nth-child(4) { width: 260px; height: 260px; background: radial-gradient(circle at 40% 40%, #34d399, #047857 70%); top: 55%; left: 45%; opacity: calc(var(--orb-op) * .45); }
@media (prefers-reduced-motion: no-preference) {
  .orbs i { animation: flota 26s ease-in-out infinite alternate; }
  .orbs i:nth-child(2) { animation-duration: 34s; }
  .orbs i:nth-child(3) { animation-duration: 30s; animation-delay: -8s; }
  @keyframes flota { to { transform: translate(40px, -30px) scale(1.06); } }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
}

/* ---------- estructura ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 16px; min-height: 100%; padding: 14px max(14px, env(safe-area-inset-right, 0px)) 14px max(14px, env(safe-area-inset-left, 0px)); }
.side { position: sticky; top: 14px; height: calc(100vh - 28px); display: flex; flex-direction: column; padding: 14px 12px; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg, var(--ember), #b91c1c); color: #fff; box-shadow: 0 6px 18px -6px var(--ember); }
.brand b { font-family: var(--f-display); font-size: 17px; display: block; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }
.nav-label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 12px; color: var(--fg-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--glass-2); color: var(--fg); }
.nav a.on { background: linear-gradient(135deg, var(--accent), #1b4fd0); color: #fff; box-shadow: 0 8px 22px -10px var(--accent); }
.nav a .cnt { margin-left: auto; font-size: 12px; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 99px; background: var(--glass-2); color: var(--fg-2); }
.nav a.on .cnt { background: rgba(255, 255, 255, .22); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 10px; }
.row-toggle { display: flex; align-items: center; gap: 10px; padding: 8px 11px; color: var(--fg-2); }
.switch { margin-left: auto; width: 42px; height: 24px; border-radius: 99px; border: 0; background: var(--ok); position: relative; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 21px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch[aria-checked="false"] { background: var(--line-2); }
.switch[aria-checked="false"]::after { left: 3px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: linear-gradient(145deg, #334155, #1e293b); color: #e2e8f0; flex: none; }
.me b { display: block; font-size: 14px; }
.me small { color: var(--muted); font-size: 12px; }
.me button { margin-left: auto; }

.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }
#vista { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
#vista > .filters { margin-top: -4px; }
#vista > .back { align-self: flex-start; }
.top { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; padding: 6px 0; }
.top h1 { font-size: 22px; font-weight: 600; }
.top .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.top .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.burger { display: none; }

/* buscador */
.search { position: relative; }
.search input { width: 260px; padding: 9px 12px 9px 36px; border-radius: 99px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(16px); }
.search > svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--muted); }
.search-res { position: absolute; right: 0; top: calc(100% + 6px); width: min(380px, 90vw); max-height: 60vh; overflow: auto; padding: 6px; z-index: 30; background: var(--bg-2); }
.search-res a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--fg); text-decoration: none; }
.search-res a:hover, .search-res a.sel { background: var(--glass-2); }
.search-res small { color: var(--muted); display: block; font-size: 12px; }

/* botones */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--glass-2); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; color: var(--fg); }
.btn:hover { border-color: var(--accent-2); }
.btn.pri { background: linear-gradient(135deg, var(--accent), #1b4fd0); border-color: transparent; color: #fff; box-shadow: 0 8px 22px -10px var(--accent); }
.btn.pri:hover { filter: brightness(1.1); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn svg { width: 16px; height: 16px; }
.ibtn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); cursor: pointer; color: var(--fg-2); flex: none; }
.ibtn:hover { color: var(--fg); border-color: var(--line-2); }
.ibtn svg { width: 17px; height: 17px; }
.ibtn.sm { width: 30px; height: 30px; }
.ibtn.sm svg { width: 15px; height: 15px; }

/* rejilla del panel */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c5 { grid-column: span 5; } .c7 { grid-column: span 7; }
.card { padding: 18px 20px; min-width: 0; }
.card-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-h h2 { font-size: 16px; font-weight: 600; }
.card-h small { color: var(--muted); font-size: 13px; }
.card-h .r { margin-left: auto; }
.link { color: var(--accent-2); font-weight: 600; font-size: 13px; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.kpi small { color: var(--muted); font-size: 13px; }
.kpi .v { font-family: var(--f-display); font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.delta { font-weight: 700; padding: 1px 7px; border-radius: 99px; font-size: 12px; }
.delta.up { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.delta.down { color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.delta.flat { color: var(--muted); background: var(--glass-2); }

.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 99px; cursor: pointer; font-size: 13px; color: var(--fg-2); font-weight: 600; }
.seg button.on { background: var(--fg); color: var(--bg); }

.chart { width: 100%; height: 240px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--f-body); }
.chart .grid-l { stroke: var(--line); }
.chart-tip { position: fixed; pointer-events: none; z-index: 40; padding: 7px 11px; border-radius: 10px; font-size: 12.5px; background: var(--bg-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); }

/* anillo */
.ring-wrap { display: flex; gap: 18px; align-items: center; }
.ring { width: 128px; height: 128px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; rotate: -90deg; }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lbl b { font-family: var(--f-display); font-size: 28px; line-height: 1; }
.ring .lbl small { color: var(--muted); font-size: 12px; }
.kv { display: grid; gap: 8px; flex: 1; min-width: 0; font-size: 14px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; }
.kv span { color: var(--muted); }

/* barras de flota */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 110px; padding-top: 6px; }
.bars a { flex: 1; min-width: 0; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, var(--accent-2), color-mix(in srgb, var(--accent) 40%, transparent)); position: relative; min-height: 4px; }
.bars a.cero { background: var(--line-2); }
.bars a:hover { filter: brightness(1.25); }
.bars-x { display: flex; gap: 5px; margin-top: 6px; }
.bars-x span { flex: 1; min-width: 0; text-align: center; font-size: 10px; color: var(--muted); overflow: hidden; }

/* listas */
.list { display: grid; gap: 4px; }
.li { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 12px; min-width: 0; }
.li:hover { background: var(--glass-2); }
.li .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--glass-2); border: 1px solid var(--line); }
.li .ic svg { width: 17px; height: 17px; }
.li .tx { min-width: 0; flex: 1; }
.li .tx b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .tx small { color: var(--muted); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
a.li { color: inherit; text-decoration: none; }

.empty { text-align: center; padding: 26px 12px; color: var(--muted); font-size: 14px; display: grid; gap: 10px; justify-items: center; }
.empty svg { width: 30px; height: 30px; opacity: .6; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--glass-2); border: 1px solid var(--line); color: var(--fg-2); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.nodot::before { display: none; }
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); border-color: transparent; }
.chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: transparent; }
.chip.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: transparent; }
.chip.blue { color: var(--accent-2); background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: transparent; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fchip { border: 1px solid var(--line); background: var(--glass); padding: 6px 13px; border-radius: 99px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--fg-2); display: inline-flex; gap: 6px; align-items: center; }
.fchip span { color: var(--muted); font-weight: 500; }
.fchip.on { background: var(--accent); color: #fff; border-color: transparent; }
.fchip.on span { color: rgba(255, 255, 255, .8); }

/* matrícula estilo española */
.plate { display: inline-flex; align-items: stretch; border-radius: 5px; overflow: hidden; border: 1.5px solid #1b1f2a; background: #f7f7f2; color: #111; font-family: var(--f-mono); font-weight: 700; font-size: 13px; letter-spacing: .06em; line-height: 1; box-shadow: 0 2px 6px -2px rgba(0, 0, 0, .5); }
.plate i { background: #1f45b5; color: #ffd84a; font-style: normal; font-size: 8px; padding: 3px 3px 2px; display: grid; place-items: end center; letter-spacing: 0; }
.plate span { padding: 5px 8px 4px; }
.plate.lg { font-size: 18px; }
.plate.lg i { font-size: 10px; padding: 4px; }
.plate.lg span { padding: 7px 12px 6px; }

/* cabecera de página */
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.ph h2 { font-size: 34px; font-weight: 600; letter-spacing: -.02em; }
.ph p { margin: 2px 0 0; color: var(--muted); }
.ph .r { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* tarjetas de camión */
.trucks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.truck { display: flex; flex-direction: column; gap: 12px; padding: 16px; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.truck:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.truck-top { display: flex; align-items: center; gap: 8px; }
.puesto { font-family: var(--f-mono); font-size: 12px; font-weight: 700; color: var(--ember); background: color-mix(in srgb, var(--ember) 14%, transparent); padding: 2px 8px; border-radius: 6px; }
.truck h3 { font-size: 20px; font-weight: 600; line-height: 1.15; }
.truck-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.truck-stats small { display: block; color: var(--muted); font-size: 11.5px; }
.truck-stats b { font-variant-numeric: tabular-nums; font-size: 14px; }

/* tablas */
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--glass-hi); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl .acts { white-space: nowrap; text-align: right; }
.tbl .strike { text-decoration: line-through; color: var(--muted); }
.tbl tr.grp td { background: var(--glass-2); font-weight: 700; font-family: var(--f-display); font-size: 15px; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); }
.tel { font-family: var(--f-mono); font-size: 13px; white-space: nowrap; }
.tel a { color: inherit; text-decoration: none; }
.tel a:hover { color: var(--accent-2); }

/* detalle de camión */
.hero-truck { display: flex; flex-wrap: wrap; gap: 18px 26px; align-items: center; padding: 22px; }
.hero-truck h2 { font-size: 36px; font-weight: 600; letter-spacing: -.02em; line-height: 1.05; }
.hero-truck .meta { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 10px; color: var(--muted); font-size: 13px; }
.hero-truck .r { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.facts small { display: block; color: var(--muted); font-size: 12px; }
.facts b { font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--fg); border-color: var(--accent); }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.back:hover { color: var(--fg); }
.back svg { width: 16px; height: 16px; }

.legend { display: grid; gap: 9px; margin-top: 14px; font-size: 14px; }
.legend div { display: flex; align-items: center; gap: 9px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .p { margin-left: auto; color: var(--muted); font-size: 13px; width: 42px; text-align: right; }
.legend .a { font-weight: 700; width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 3px; background: var(--line); }
.stack i { display: block; height: 100%; }

/* modal */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 12, .55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; background: var(--bg-2); }
.modal h3 { font-size: 20px; margin-bottom: 14px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.form label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--fg-2); }
.form input, .form select, .form textarea { width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--glass); color: var(--fg); font-weight: 400; font-size: 15px; }
.form textarea { min-height: 80px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.form .chk { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form .chk input { width: auto; }
.form .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal-f .l { margin-right: auto; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }
.drop { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; font-weight: 500; }
.drop.over, .drop:hover { border-color: var(--accent-2); color: var(--fg); }
.drop b { color: var(--fg); }

/* visor */
.viewer { width: min(1000px, 100%); height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--bg-2); }
.viewer header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.viewer header b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer header .r { margin-left: auto; display: flex; gap: 8px; }
.viewer .body { flex: 1; min-height: 0; display: grid; place-items: center; background: var(--bg); }
.viewer iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* toast */
.toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom, 0px)); translate: -50% 0; z-index: 60; padding: 11px 18px; border-radius: 99px; background: var(--glass-2); backdrop-filter: blur(20px); border: 1px solid var(--line-2); box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; }
.toast svg { width: 16px; height: 16px; color: var(--ok); }
.toast.bad svg { color: var(--bad); }

.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .c8, .c4, .c7, .c5 { grid-column: span 12; }
  .c6 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); padding-top: 8px; }
  .side { position: fixed; z-index: 45; top: 8px; left: 8px; bottom: 8px; height: auto; width: 270px; translate: calc(-100% - 20px) 0; transition: translate .25s; background: var(--bg-2); }
  .side.open { translate: 0 0; }
  .scrim { position: fixed; inset: 0; z-index: 44; background: rgba(0, 0, 0, .45); }
  .burger { display: inline-grid; }
  .search input { width: 180px; }
  .top h1 { font-size: 18px; }
}
@media (max-width: 620px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .kpi .v { font-size: 26px; }
  .search { display: none; }
  .search.open { display: block; position: absolute; left: 0; right: 0; top: 100%; }
  .search.open input { width: 100%; }
  .top .new-lbl { display: none; }
  .ph h2 { font-size: 28px; }
  .hero-truck h2 { font-size: 28px; }
  .form { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .ring-wrap { flex-direction: column; align-items: stretch; }
  .ring { align-self: center; }
  .top .sub { display: none; }
  .tbl .hide-m { display: none; }
}
@media (min-width: 621px) { .only-m { display: none !important; } }

/* =================== lector de facturas =================== */
.drop.lector { padding: 16px; min-height: 92px; display: grid; align-items: center; position: relative; overflow: hidden; background: color-mix(in srgb, var(--accent) 6%, transparent); border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line-2)); transition: border-color .2s, background .2s; }
.drop.lector:hover { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.lector-vacio { display: grid; gap: 4px; justify-items: center; }
.lector-vacio svg { width: 24px; height: 24px; color: var(--accent-2); }
.lector-vacio b { font-size: 15px; }
.lector-vacio span { font-size: 13px; }
.drop.busy { cursor: progress; border-style: solid; border-color: var(--accent-2); }
.drop.busy::after { content: ""; position: absolute; left: 0; right: 0; top: -45%; height: 45%; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent-2) 30%, transparent) 70%, color-mix(in srgb, var(--accent-2) 70%, transparent) 98%, transparent); animation: escanear 1.7s cubic-bezier(.5, 0, .5, 1) infinite; pointer-events: none; }
@keyframes escanear { to { top: 100%; } }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--accent-2) 25%, transparent); border-top-color: var(--accent-2); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.lector-msg { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; padding: 11px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; }
.lector-msg svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.lector-msg.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); }
.lector-msg.ok svg { color: var(--ok); }
.lector-msg.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.lector-msg.warn svg { color: var(--warn); }
.lector-msg.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.lector-msg.bad svg { color: var(--bad); }
.form .auto { border-color: var(--accent-2); }
.form .falta { border-color: var(--bad) !important; }

/* =================== animaciones =================== */
@keyframes subir { from { opacity: 0; transform: translateY(16px) scale(.985); } }
@keyframes aparecer { from { opacity: 0; } }
@keyframes crecer { from { transform: scaleY(0); } }
@keyframes ancho { from { transform: scaleX(0); } }
@keyframes latir { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(3.4); opacity: 0; } }
@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }
@keyframes popOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes hojaIn { from { transform: translateY(100%); } }
@keyframes hojaOut { to { transform: translateY(100%); } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(24px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px) scale(.95); } }
@keyframes rellenado {
  0% { background: color-mix(in srgb, var(--accent) 34%, var(--glass)); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 60%, transparent); transform: scale(1.02); }
  40% { transform: scale(1); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
@keyframes sacudir { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* menú lateral: píldora que se desliza */
.nav { position: relative; }
.nav a { position: relative; z-index: 1; transition: color .25s, background .2s; }
.nav a.on { background: transparent; box-shadow: none; }
.nav-pill { position: absolute; left: 0; right: 0; top: 0; z-index: 0; border-radius: 12px; background: linear-gradient(135deg, var(--accent), #1b4fd0); box-shadow: 0 10px 26px -10px var(--accent); transition: transform .5s cubic-bezier(.3, 1.25, .4, 1), height .3s, opacity .2s; pointer-events: none; }

/* tarjetas: luz que sigue al cursor */
.truck, .card, .hero-truck { position: relative; }
.truck::after, .glass.card::after, .hero-truck::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s; background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 45%); }
.truck:hover::after, .glass.card:hover::after, .hero-truck:hover::after { opacity: 1; }
.truck { transition: transform .35s cubic-bezier(.2, .8, .2, 1), border-color .25s, box-shadow .35s; }
.truck:hover { box-shadow: var(--shadow), 0 18px 40px -18px color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-4px); }
.truck .plate { transition: transform .35s cubic-bezier(.3, 1.4, .5, 1); }
.truck:hover .plate { transform: scale(1.06) rotate(-1.5deg); }

/* botones */
.btn, .ibtn, .fchip, .seg button, .tabs button { transition: transform .18s cubic-bezier(.3, 1.5, .5, 1), background .2s, color .2s, border-color .2s, box-shadow .25s, filter .2s; }
.btn:active, .ibtn:active, .fchip:active { transform: scale(.95); }
.btn.pri { position: relative; overflow: hidden; isolation: isolate; }
.btn.pri::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, .32) 50%, transparent 75%); transform: translateX(-130%); }
.btn.pri:hover::after { transform: translateX(130%); transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
.btn.pri:hover { box-shadow: 0 12px 30px -10px var(--accent); transform: translateY(-1px); }
.ibtn:hover { transform: translateY(-1px); }
.switch::after { transition: left .35s cubic-bezier(.3, 1.5, .5, 1); }
.li { transition: background .2s, transform .25s cubic-bezier(.2, .8, .2, 1); }
.li:hover { transform: translateX(3px); }

/* esqueleto de carga */
.skel { border-radius: var(--r); background: linear-gradient(90deg, var(--glass) 0%, var(--glass-2) 40%, var(--glass) 80%); background-size: 200% 100%; border: 1px solid var(--line); animation: brillo 1.6s linear infinite; }

@media (prefers-reduced-motion: no-preference) {
  .in { animation: subir .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
  .in-row { animation: subir .55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--j, 0) * 40ms + 260ms); }
  .bars a { transform-origin: bottom; animation: crecer .9s cubic-bezier(.2, .9, .25, 1.05) both; animation-delay: calc(var(--i, 0) * 40ms + 350ms); }
  .stack i { transform-origin: left; animation: ancho 1s cubic-bezier(.65, 0, .25, 1) both; animation-delay: .35s; }
  .bars.quieto a, .stack.quieto i { animation: none; }
  .ch-pulse { transform-box: fill-box; transform-origin: center; animation: latir 2.2s ease-out 1.9s infinite; }
  .ch-dot { transform-box: fill-box; transform-origin: center; }
  .tab-body { animation: subir .4s cubic-bezier(.2, .8, .2, 1) both; }
  .top { animation: aparecer .6s both; }
  .side { animation: subir .7s cubic-bezier(.2, .8, .2, 1) both; }
  .delta { animation: popIn .5s cubic-bezier(.3, 1.6, .5, 1) .9s both; }
  .modal-bg { animation: aparecer .22s ease-out both; }
  .modal-bg > .glass { animation: popIn .42s cubic-bezier(.2, 1.15, .3, 1) both; }
  .modal-bg.saliendo { animation: fadeOut .2s ease-in forwards; }
  .modal-bg.saliendo > .glass { animation: popOut .2s ease-in forwards; }
  .toast { animation: toastIn .5s cubic-bezier(.2, 1.3, .3, 1) both; }
  .toast.out { animation: toastOut .3s ease-in forwards; }
  .lector-msg { animation: subir .4s cubic-bezier(.2, .8, .2, 1) both; }
  .form .auto { animation: rellenado 1.6s cubic-bezier(.2, .8, .2, 1) both; }
  .form .falta { animation: sacudir .45s; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-pulse { display: none; }
  .drop.busy::after, .skel { animation: none; }
}

/* =================== MÓVIL (uso principal) =================== */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
.tabbar, .top-brand, .chip-m, .grip { display: none; }
.pcard { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.pcard:last-child { border-bottom: 0; }
.pcard .tx { flex: 1; min-width: 0; }
.pcard .tx b { display: block; font-weight: 600; }
.pcard .tx small { display: block; color: var(--muted); font-size: 13px; }
.pcard .tx .mono { color: var(--fg-2); margin-top: 2px; }
.pcard.baja .tx b { text-decoration: line-through; color: var(--muted); }
.pcard .avatar { width: 40px; height: 40px; }
.llamar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.llamar svg { width: 20px; height: 20px; }
.llamar:active { transform: scale(.92); background: color-mix(in srgb, var(--ok) 30%, transparent); }
.total-m { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 8px 2px; margin-top: 6px; border-top: 1px solid var(--line-2); font-weight: 600; }
.total-m b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* sin ratón: nada de efectos de "hover" que se quedan pegados */
@media (hover: none) {
  .truck:hover, .btn.pri:hover, .ibtn:hover { transform: none; }
  .li:hover { transform: none; background: transparent; }
  .truck:hover::after, .glass.card:hover::after, .hero-truck:hover::after { opacity: 0; }
  .truck:hover .plate { transform: none; }
  .truck:active { transform: scale(.98); }
  .li:active { background: var(--glass-2); }
}

/* tablet y móvil: barra inferior en vez de menú lateral */
@media (max-width: 900px) {
  .app { display: block; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
  .side, .burger, .scrim, #nuevo { display: none !important; }
  .main { gap: 14px; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: color-mix(in srgb, var(--bg) 80%, transparent); }
  .top { top: env(safe-area-inset-top, 0px); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%); border-bottom: 1px solid var(--line); min-height: 58px; }
  .top-saludo { display: none; }
  .top-brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--fg); text-decoration: none; }
  .top-brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; flex: none; }
  .top-brand b { font-family: var(--f-display); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #buscar-m.only-m { display: inline-grid !important; }
  .search { display: none; }
  .search.open { display: block; position: absolute; left: 0; right: 0; top: 100%; padding: 8px max(16px, env(safe-area-inset-left, 0px)); background: var(--bg-2); border-bottom: 1px solid var(--line); }
  .search.open > svg { left: calc(max(16px, env(safe-area-inset-left, 0px)) + 12px); }
  .search.open input { width: 100%; font-size: 16px; padding: 12px 14px 12px 38px; }
  .search-res { position: static; width: 100%; max-height: 60vh; margin-top: 8px; }

  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--bg-2) 78%, transparent); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar > button:not(.fab) { position: relative; display: grid; justify-items: center; gap: 3px; padding: 6px 0 4px; min-height: 52px; color: var(--muted); text-decoration: none; background: none; border: 0; font-size: 11px; font-weight: 600; cursor: pointer; transition: color .2s; }
  .tabbar svg { width: 24px; height: 24px; transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); }
  .tabbar .on { color: var(--accent-2); }
  .tabbar .on svg { transform: translateY(-2px) scale(1.08); }
  .tabbar .on::before { content: ""; position: absolute; top: -7px; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2); }
  .tabbar a:active svg, .tabbar > button:active svg { transform: scale(.85); }
  .fab { justify-self: center; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; cursor: pointer; background: linear-gradient(145deg, var(--ember), #c2410c); box-shadow: 0 10px 26px -6px color-mix(in srgb, var(--ember) 75%, transparent), 0 0 0 5px var(--bg); transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
  .fab svg { width: 26px; height: 26px; }
  .fab:active { transform: scale(.9) rotate(90deg); }
  .mas-dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg-2); }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 32px); }
}

/* teléfono */
@media (max-width: 620px) {
  body { font-size: 15px; }
  .hide-m, .chip-d { display: none !important; }
  .chip-m { display: block; margin-top: 5px; }
  .grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: -8px auto 14px; }
  .grid { gap: 14px; }
  .card { padding: 16px; border-radius: 20px; }
  .ph { gap: 12px; }
  .ph h2 { font-size: 30px; line-height: 1.1; }
  .ph p { font-size: 14px; }
  .ph .r { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin: 0; }
  .ph .r .btn { justify-content: center; min-height: 48px; font-size: 15px; }
  .saludo-m p { margin: 0 0 2px; text-transform: capitalize; }
  .saludo-m h2 { font-size: 26px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 2px max(16px, env(safe-area-inset-left, 0px)); scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .fchip { flex: none; min-height: 40px; padding: 8px 14px; font-size: 14px; }
  select.fchip { max-width: 72vw; }
  .kpis { gap: 14px 12px; padding-bottom: 14px; }
  .card-h { flex-wrap: wrap; row-gap: 8px; }
  #ch-tot { display: none; }
  .seg button { padding: 7px 14px; }
  .chart { height: auto; }
  .li { padding: 11px 6px; gap: 12px; }
  .li .ic { width: 40px; height: 40px; border-radius: 12px; }
  .li .tx b { font-size: 15px; }
  .li .tx small { font-size: 13px; }
  .ibtn { width: 42px; height: 42px; }
  .ibtn.sm { width: 38px; height: 38px; }
  .trucks { grid-template-columns: 1fr; gap: 12px; }
  .truck { padding: 16px; }
  .hero-truck { padding: 18px; gap: 14px; }
  .hero-truck h2 { font-size: 30px; }
  .hero-truck .r { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
  .hero-truck .r .btn { flex-direction: column; gap: 4px; padding: 10px 4px; min-height: 64px; border-radius: 16px; font-size: 13px; justify-content: center; }
  .hero-truck .r .btn svg { width: 20px; height: 20px; }
  .facts { gap: 14px 12px; }
  .tabs { margin: -4px -16px 12px; padding: 0 12px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 12px 12px; font-size: 14px; }
  .form { gap: 12px; }
  .form input, .form select, .form textarea { font-size: 16px; padding: 12px 13px; min-height: 48px; }
  .form label { font-size: 13.5px; }
  .modal { padding: 20px max(18px, env(safe-area-inset-left, 0px)) 18px; }
  .modal-f { position: sticky; bottom: calc(-1 * max(22px, env(safe-area-inset-bottom, 0px))); margin: 18px -18px calc(-1 * max(22px, env(safe-area-inset-bottom, 0px))); padding: 12px 18px max(14px, env(safe-area-inset-bottom, 0px)); background: var(--bg-2); border-top: 1px solid var(--line); }
  .modal-f .btn { flex: 1; justify-content: center; min-height: 50px; font-size: 15px; }
  .modal-f .btn.l { flex: 0 0 auto; }
  .lector-vacio b { font-size: 16px; }
  .drop.lector { min-height: 110px; }
  .back { min-height: 40px; }
}

/* móvil: los formularios salen como hoja desde abajo */
@media (max-width: 620px) {
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal-bg > .modal { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 22px 22px 0 0; padding-bottom: max(22px, env(safe-area-inset-bottom, 0px)); }
  .modal-bg > .viewer { width: 100%; height: 94vh; border-radius: 22px 22px 0 0; }
}
@media (max-width: 620px) and (prefers-reduced-motion: no-preference) {
  .modal-bg > .glass { animation: hojaIn .45s cubic-bezier(.2, 1, .3, 1) both; }
  .modal-bg.saliendo > .glass { animation: hojaOut .22s ease-in forwards; }
}
