/* ═══════════════════════════════════════════════════════════════════════
   TRUSTWAY — sistema visual común (logistics + carrier + app del operador)
   Tema oscuro por defecto (torre de control), tema claro opcional.
   ═══════════════════════════════════════════════════════════════════════ */
/* Open Sans (misma tipografía que la plataforma de rastreo), servida desde el propio servidor. */
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url(/assets/fonts/open-sans-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url(/assets/fonts/open-sans-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root, [data-theme="light"] {
  --bg: #f5f6f8;
  --bg-grad: #f5f6f8;
  --side: #ffffff;
  --side-text: #3f4652;
  --side-text-h: #191c22;
  --side-hover: #f2f4f7;
  --side-sep: #8a919c;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --panel-3: #eef0f3;
  --border: #e6e8ec;
  --border-2: #d5d9e0;
  --text: #191c22;
  --text-2: #3f4652;
  --muted: #6b7280;
  --green: #15803d;  --green-soft: #e8f5ec;
  --amber: #b45309;  --amber-soft: #fdf3e1;
  --orange: #c2410c; --orange-soft: #fdeee4;
  --red: #c0262d;    --red-soft: #fcebeb;
  --violet: #6d28d9; --violet-soft: #f1ecfc;
  --teal: #0f766e;   --teal-soft: #e3f4f2;
  --blue: #1d4ed8;   --blue-soft: #e8eefb;
  --grey: #4b5563;   --grey-soft: #f1f2f4;
  --shadow: 0 1px 2px rgba(16,24,40,.04);
  --radius: 10px;
  --radius-sm: 7px;
  --row-hover: #f8f9fb;
  --input: #ffffff;
  --map-filter: none;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f141c;
  --bg-grad: #0f141c;
  --side: #121821;
  --side-text: #aeb6c2;
  --side-text-h: #f1f3f6;
  --side-hover: #1a212c;
  --side-sep: #6b7480;
  --panel: #151b24;
  --panel-2: #1a212c;
  --panel-3: #222a36;
  --border: #252d39;
  --border-2: #313a48;
  --text: #e8ebef;
  --text-2: #b9c0cb;
  --muted: #858e9b;
  --green: #3fb96c;  --green-soft: rgba(63,185,108,.14);
  --amber: #e2a336;  --amber-soft: rgba(226,163,54,.14);
  --orange: #e8823f; --orange-soft: rgba(232,130,63,.14);
  --red: #e5534b;    --red-soft: rgba(229,83,75,.14);
  --violet: #a78bfa; --violet-soft: rgba(167,139,250,.14);
  --teal: #2fb3a6;   --teal-soft: rgba(47,179,166,.14);
  --blue: #5b8def;   --blue-soft: rgba(91,141,239,.14);
  --grey: #8f98a6;   --grey-soft: rgba(143,152,166,.14);
  --shadow: none;
  --row-hover: #1a212c;
  --input: #10151d;
  color-scheme: dark;
}
/* Color de marca por portal (logos): Logistics #0865CE · Carrier #008F91 */
[data-portal="logistics"], :root { --primary: #0865CE; --primary-2: #0652a6; --primary-soft: rgba(8,101,206,.09); }
[data-portal="carrier"] { --primary: #008F91; --primary-2: #007274; --primary-soft: rgba(0,143,145,.10); }
[data-theme="dark"][data-portal="logistics"] { --primary: #3b8ae6; --primary-2: #2f78cf; --primary-soft: rgba(59,138,230,.16); }
[data-theme="dark"][data-portal="carrier"] { --primary: #1fb0b2; --primary-2: #179597; --primary-soft: rgba(31,176,178,.16); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13.5px; line-height: 1.45; color: var(--text); background: var(--bg-grad);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum";
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.svg-i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.svg-i.sm { width: 15px; height: 15px; }
.svg-i.lg { width: 22px; height: 22px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.hide { display: none !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Estructura ──────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--side); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 12px 14px; color: var(--side-text); z-index: 40;
}
.brand { display: flex; align-items: center; padding: 2px 10px 22px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { height: 34px; width: auto; max-width: 180px; display: block; }
.brand .logo-dark, [data-theme="dark"] .brand .logo-light { display: none; }
[data-theme="dark"] .brand .logo-dark { display: block; }
.nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--side-text);
  font-weight: 500; font-size: 13.5px; text-decoration: none; position: relative;
}
.nav a .svg-i { width: 18px; height: 18px; stroke-width: 1.7; color: var(--side-sep); }
.nav a:hover { background: var(--side-hover); color: var(--side-text-h); text-decoration: none; }
.nav a:hover .svg-i { color: var(--side-text-h); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a.active .svg-i { color: var(--primary); }
.nav .sep { margin: 16px 10px 6px; font-size: 11.5px; color: var(--side-sep); font-weight: 500; }
.nav .count { margin-left: auto; background: var(--red-soft); color: var(--red); border-radius: 9px; font-size: 11px; padding: 0 7px; font-weight: 600; line-height: 18px; }
.nav .count.blue { background: var(--primary-soft); color: var(--primary); }
.side-help { margin-top: 10px; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); color: var(--side-text); text-decoration: none; font-size: 12.5px; }
.side-help:hover { text-decoration: none; color: var(--side-text-h); }
.side-help .svg-i { width: 20px; height: 20px; stroke-width: 1.6; color: var(--primary); }
.side-help b { display: block; font-weight: 600; color: var(--side-text-h); }
.side-help small { color: var(--muted); font-size: 11.5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }
.dot.grey { background: var(--grey); }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border);
  background: var(--panel); position: sticky; top: 0; z-index: 30;
}
.top .burger { display: none; }
.top .spacer { flex: 1; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--text-2);
  background: transparent; border: 1px solid transparent; cursor: pointer; position: relative;
}
.iconbtn:hover { background: var(--panel-2); color: var(--text); }
.iconbtn .svg-i { stroke-width: 1.7; }
.iconbtn .badge-n { position: absolute; top: 3px; right: 3px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 0 5px; line-height: 15px; }
.userbox { display: flex; align-items: center; gap: 10px; padding-left: 10px; border-left: 1px solid var(--border); }
.userbox .n { font-weight: 600; font-size: 12.5px; line-height: 1.15; }
.userbox .r { color: var(--muted); font-size: 11.5px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-weight: 600; color: var(--primary); font-size: 12px; }
.content { padding: 22px 24px 32px; flex: 1; }
.page-h { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-h h1 { font-size: 20px; font-weight: 650; text-transform: none; letter-spacing: -.015em; }
.page-h .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.page-h .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 24px; color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ── Tarjetas ────────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); min-height: 48px; }
.card-h h3 { font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.card-h h3 .svg-i { color: var(--muted); stroke-width: 1.7; }
.card-h .link { margin-left: auto; font-size: 12.5px; white-space: nowrap; }
.card-h .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-b { padding: 16px; }
.card-b.flush { padding: 0; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 11.5px; font-weight: 500; text-transform: none; letter-spacing: 0; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.g-dash { grid-template-columns: minmax(0, 1.3fr) minmax(0, .95fr) minmax(0, 1.15fr); }
.g-detail { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* KPIs (fila superior del resumen ejecutivo) */
.kpis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 12px 11px; display: flex; gap: 10px; min-width: 0; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--border-2); text-decoration: none; background: var(--panel-2); }
.kpi { padding: 14px; }
.kpi .ic { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--panel-2) !important; border: 1px solid var(--border); }
.kpi .ic .svg-i { width: 19px; height: 19px; stroke-width: 1.7; }
.kpi .t { font-size: 12px; color: var(--text-2); font-weight: 500; line-height: 1.25; min-height: 15px; }
.kpi .v { font-size: 24px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.kpi .d b { font-weight: 600; }
.ic.blue { background: var(--blue-soft); color: var(--blue); }
.ic.green { background: var(--green-soft); color: var(--green); }
.ic.amber { background: var(--amber-soft); color: var(--amber); }
.ic.red { background: var(--red-soft); color: var(--red); }
.ic.violet { background: var(--violet-soft); color: var(--violet); }
.ic.teal { background: var(--teal-soft); color: var(--teal); }
.ic.orange { background: var(--orange-soft); color: var(--orange); }
.ic.grey { background: var(--grey-soft); color: var(--grey); }
.c-green { color: var(--green); } .c-red { color: var(--red); } .c-amber { color: var(--amber); } .c-blue { color: var(--blue); }
.c-violet { color: var(--violet); } .c-teal { color: var(--teal); } .c-orange { color: var(--orange); } .c-muted { color: var(--muted); }

/* Contadores por fase (torre) */
.phasebar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.phasebar a { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.phasebar a:hover { border-color: var(--border-2); }
.phasebar a.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; background: var(--primary-soft); }
.phasebar .t { font-size: 11.5px; color: var(--muted); }
.phasebar .v { font-size: 22px; font-weight: 650; }

/* ── Tablas ──────────────────────────────────────────────────────────── */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--panel-2); z-index: 1; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--row-hover); }
.tbl tr.click { cursor: pointer; }
.tbl .sub { color: var(--muted); font-size: 11.5px; }
.tbl.compact td { padding: 6px 8px; }
.tbl.compact th { padding: 8px 8px; }
.tbl.dense td, .tbl.dense th { white-space: nowrap; font-size: 12px; }
.tbl .clip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .ico-status { width: 18px; }
.tbl-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.tbl-legend span { display: inline-flex; gap: 6px; align-items: center; }

/* ── Etiquetas ───────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 6px; white-space: nowrap; line-height: 1.6; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.teal { background: var(--teal-soft); color: var(--teal); }
.pill.muted { background: var(--grey-soft); color: var(--grey); }
.tag { display: inline-block; font-size: 11px; border: 1px solid var(--border-2); border-radius: 5px; padding: 0 6px; color: var(--text-2); background: var(--panel-2); white-space: nowrap; }
.status-up { font-weight: 500; font-size: 11.5px; padding: 1px 8px; border-radius: 6px; white-space: nowrap; line-height: 1.6; display: inline-block; }
.status-up.red { background: var(--red-soft); color: var(--red); }
.status-up.orange { background: var(--orange-soft); color: var(--orange); }
.status-up.amber { background: var(--amber-soft); color: var(--amber); }
.status-up.green { background: var(--green-soft); color: var(--green); }
.status-up.blue { background: var(--blue-soft); color: var(--blue); }
.status-up.violet { background: var(--violet-soft); color: var(--violet); }
.status-up.teal { background: var(--teal-soft); color: var(--teal); }
.status-up.muted { background: var(--grey-soft); color: var(--grey); }

/* Barras de progreso */
.bar { height: 6px; border-radius: 3px; background: var(--panel-3); overflow: hidden; min-width: 44px; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--green); }
.bar.amber > i { background: var(--amber); } .bar.red > i { background: var(--red); } .bar.blue > i { background: var(--blue); } .bar.orange > i { background: var(--orange); }
.riskbar { display: flex; align-items: center; gap: 8px; }
.riskbar .bar { flex: 1; }

/* ── Botones y formularios ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--panel); color: var(--text); font: inherit; font-weight: 500; font-size: 13px;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn .svg-i { width: 16px; height: 16px; stroke-width: 1.8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--red) 55%, transparent); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.lg { height: 46px; padding: 0 18px; font-size: 15px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 500; min-width: 0; }
label.f > span.l { display: flex; gap: 6px; align-items: center; }
.input, select.input, textarea.input {
  height: 36px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--input); color: var(--text); padding: 0 11px; font: inherit; font-size: 13px; width: 100%; min-width: 0;
}
textarea.input { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.err { border-color: var(--red); }
.ferr { color: var(--red); font-size: 11.5px; min-height: 0; }
.ferr:empty { display: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.select-sm { height: 32px; font-size: 12.5px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--panel); color: var(--text); font: inherit; }
.search { position: relative; }
.search .svg-i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; }
.search .input { padding-left: 32px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { border: 0; background: transparent; color: var(--text-2); padding: 5px 11px; border-radius: 6px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.seg a.on, .seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.seg .n { color: var(--muted); font-size: 11px; margin-left: 3px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* ── Donas / gráficas ────────────────────────────────────────────────── */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { position: relative; width: 140px; height: 140px; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .center b { font-size: 24px; font-weight: 650; display: block; line-height: 1; letter-spacing: -.02em; }
.donut .center span { font-size: 11.5px; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 9px; font-size: 13px; flex: 1; min-width: 160px; }
.legend .li { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.legend .sw { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.legend .v { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend .sym { width: 16px; text-align: center; font-weight: 800; font-size: 16px; line-height: 1; }
.spark { width: 100%; height: 160px; }

/* ── Mapa ────────────────────────────────────────────────────────────── */
.map { width: 100%; height: 100%; min-height: 300px; border-radius: 0 0 var(--radius) var(--radius); background: #e9ecef; z-index: 1; }
[data-theme="dark"] .map { background: #0f141c; }
.map-card { display: flex; flex-direction: column; }
.map-card .map { flex: 1; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 9px 14px; font-size: 12px; color: var(--text-2); border-top: 1px solid var(--border); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12.5px; line-height: 1.45; }
.leaflet-popup-content a { color: var(--primary); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-zoom a, .leaflet-control-layers { background: var(--panel) !important; color: var(--text) !important; border-color: var(--border-2) !important; }
.leaflet-control-layers-expanded { padding: 8px 10px; }
.leaflet-control-attribution { background: rgba(255,255,255,.75) !important; color: #4b5563 !important; font-size: 9.5px; }
.leaflet-control-attribution a { color: #374151 !important; }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(15,20,28,.7) !important; color: #8f98a6 !important; }
[data-theme="dark"] .leaflet-control-attribution a { color: #b9c0cb !important; }
.truck-pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.truck-pin svg { width: 15px; height: 15px; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.truck-pin.green { background: #16a34a; } .truck-pin.amber { background: #e09113; } .truck-pin.red { background: #dc2626; }
.truck-pin.violet { background: #9333ea; } .truck-pin.grey { background: #64748b; } .truck-pin.blue { background: #2563eb; } .truck-pin.teal { background: #0d9488; }
.site-pin { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: #fff; border: 2px solid var(--primary); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.site-pin svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.map-tip { font-weight: 600; }

/* ── Línea de tiempo de fases ────────────────────────────────────────── */
.phases { display: flex; flex-direction: column; }
.ph { display: grid; grid-template-columns: 30px minmax(0, 1fr) 150px 84px; gap: 12px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.ph:last-child { border-bottom: 0; }
.ph .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--panel-3); color: var(--muted); border: 1px solid var(--border-2); }
.ph.done .n { background: #16a34a; border-color: #16a34a; color: #fff; }
.ph.current .n { background: var(--primary); border-color: var(--primary); color: #fff; }
.ph .t { font-weight: 600; }
.ph .s { color: var(--muted); font-size: 12px; }
.ph .when { font-size: 12px; color: var(--text-2); }
.ph .when b { display: block; font-weight: 600; }
.ph .when .real { color: var(--green); font-weight: 600; }
.ph .when .eta { color: var(--blue); font-weight: 600; }
.ph .when .late { color: var(--red); font-weight: 600; }
.ph .src { justify-self: end; }
.eta-box { margin-top: 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; gap: 22px; flex-wrap: wrap; font-size: 12.5px; }
.eta-box b { font-weight: 650; }

.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.kv .k { font-size: 11.5px; color: var(--muted); }
.kv .v { font-weight: 550; }
.checklist { margin-top: 12px; border-top: 1px solid var(--border); }
.checklist .it { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.checklist .it:last-child { border-bottom: 0; }
.checklist .ok { color: var(--green); font-weight: 600; } .checklist .warn { color: var(--amber); font-weight: 600; } .checklist .fail { color: var(--red); font-weight: 600; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.thumb { aspect-ratio: 1/1; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; overflow: hidden; position: relative; color: var(--muted); font-size: 11.5px; text-align: center; text-decoration: none; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; padding: 14px 6px 5px; font-size: 11px; }
.thumb:hover { border-color: var(--primary); text-decoration: none; }

.log { display: flex; flex-direction: column; }
.log .it { display: grid; grid-template-columns: 110px 190px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.log .it:last-child { border-bottom: 0; }

/* Lista de atención */
.attn { display: flex; flex-direction: column; }
.attn .it { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.attn .it:last-child { border-bottom: 0; }
.attn .it .t { font-weight: 600; font-size: 12.8px; }
.attn .it .s { color: var(--muted); font-size: 12px; }
.attn .it .acts { margin-left: auto; display: flex; gap: 4px; flex: none; }
.sev { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.sev.s4 { background: var(--red); } .sev.s3 { background: var(--orange); } .sev.s2 { background: var(--amber); } .sev.s1 { background: var(--blue); }

/* Calendario de andenes */
.cal { overflow-x: auto; }
.cal-grid { display: grid; min-width: 820px; }
.cal-h { font-size: 11px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--border); text-align: left; }
.cal-row { position: relative; height: 54px; border-bottom: 1px solid var(--border); }
.cal-row .lbl { position: absolute; left: 0; top: 0; bottom: 0; width: 90px; display: flex; align-items: center; font-weight: 600; font-size: 12.5px; }
.cal-lane { position: absolute; left: 90px; right: 0; top: 0; bottom: 0; background-image: linear-gradient(90deg, var(--border) 1px, transparent 1px); }
.cal-ev { position: absolute; top: 8px; bottom: 8px; border-radius: 6px; padding: 3px 6px; font-size: 10.5px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #fff; background: #1d4ed8; border: 1px solid rgba(255,255,255,.15); cursor: pointer; text-decoration: none; }
.cal-ev.pending { background: transparent; border: 1.5px dashed var(--amber); color: var(--amber); }
.cal-ev.done { background: #15803d; }
.cal-ev.late { background: #b91c1c; }
.cal-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 2; }

/* ── Diálogos y avisos ───────────────────────────────────────────────── */
dialog.modal { border: 1px solid var(--border-2); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 50px rgba(16,24,40,.18); }
dialog.modal.wide { width: min(980px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(16,24,40,.45); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-h h3 { font-size: 15px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 16px; overflow: auto; max-height: calc(100vh - 170px); }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--panel); border: 1px solid var(--border-2); border-left: 4px solid var(--green); color: var(--text); padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(16,24,40,.14); font-size: 13px; max-width: 380px; animation: tin .2s ease-out; }
.toast.err { border-left-color: var(--red); } .toast.warn { border-left-color: var(--amber); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty .svg-i { width: 34px; height: 34px; opacity: .5; margin-bottom: 8px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--panel-2); font-size: 12.8px; }
.notice.amber { border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: var(--amber-soft); }
.notice.red { border-color: color-mix(in srgb, var(--red) 45%, transparent); background: var(--red-soft); }
.notice.blue { border-color: color-mix(in srgb, var(--blue) 45%, transparent); background: var(--blue-soft); }
.notice.green { border-color: color-mix(in srgb, var(--green) 45%, transparent); background: var(--green-soft); }
.drop { position: relative; }
.drop-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: 0 12px 32px rgba(16,24,40,.14); min-width: 220px; padding: 6px; display: none; z-index: 60; }
.drop.open .drop-menu { display: block; }
.drop-menu a, .drop-menu button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; text-align: left; }
.drop-menu a:hover, .drop-menu button:hover { background: var(--panel-2); text-decoration: none; }
.drop-menu .hd { padding: 8px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.notif-list { max-height: 360px; overflow: auto; width: 340px; }

/* ── Acceso (login, recuperar, restablecer) ─────────────────────────── */
/* Colores de los logos: Logistics #0865CE · Carrier #008F91 · texto #191C22 */
.auth-body { margin: 0; background: #fff; color: #191c22; --brand: #0865CE; --brand-tint: #f3f6fb; --brand-tint-2: #e7eef8; --brand-line: #e1e8f2; }
.auth-body.auth-carrier { --brand: #008F91; --brand-tint: #f2f8f8; --brand-tint-2: #e2f0f0; --brand-line: #dcebeb; }
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 540px); }

/* Lado informativo */
.auth-aside { position: relative; overflow: hidden; padding: 44px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: linear-gradient(160deg, var(--brand-tint) 0%, #fff 55%, var(--brand-tint-2) 100%); border-right: 1px solid var(--brand-line); }
.auth-art { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--brand); pointer-events: none; }
.auth-intro, .auth-foot { position: relative; }
.auth-intro { max-width: 460px; margin: auto 0; }
.auth-intro h2 { font-size: 28px; line-height: 1.22; font-weight: 650; color: #191c22; margin: 0 0 12px; letter-spacing: -.02em; }
.auth-intro p { color: #4f5866; font-size: 15px; line-height: 1.55; margin: 0 0 28px; }
.auth-intro ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-intro li { display: flex; align-items: center; gap: 12px; color: #343a46; font-size: 14.5px; }
.auth-intro li .svg-i { width: 34px; height: 34px; padding: 7px; border-radius: 9px; background: #fff; border: 1px solid var(--brand-line); stroke: var(--brand); stroke-width: 1.6; flex: none; }
.auth-foot { color: #8a93a2; font-size: 12px; }

/* Lado del formulario */
.auth { position: relative; display: flex; align-items: center; justify-content: center; padding: 56px 32px 40px; }
.auth-top { position: absolute; top: 20px; right: 24px; }
.lang-sw { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; color: #6b7280; }
.lang-sw .svg-i { width: 16px; height: 16px; stroke-width: 1.6; margin-right: 6px; }
.lang-sw a { color: #6b7280; padding: 4px 8px; border-radius: 6px; font-weight: 600; text-decoration: none; letter-spacing: .02em; }
.lang-sw a:hover { background: #f2f4f7; color: #191c22; text-decoration: none; }
.lang-sw a.on { color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, transparent); }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { display: block; height: 46px; width: auto; margin: 0 auto 32px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid #e6e8ec; margin-bottom: 24px; }
.auth-tabs.one { grid-template-columns: 1fr; }
.auth-tabs button, .auth-tabs span { background: none; border: 0; font: inherit; font-size: 14px; font-weight: 500; color: #7a828e; padding: 0 4px 12px; cursor: pointer; position: relative; text-align: center; }
.auth-tabs button:hover { color: #191c22; }
.auth-tabs .on { color: var(--brand); font-weight: 600; }
.auth-tabs .on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px; }
.auth form { display: flex; flex-direction: column; gap: 18px; }
.auth form[hidden] { display: none; }
.auth .hint { color: #5b6472; font-size: 13.5px; line-height: 1.5; margin: 0; }
.auth label.f { color: #6b7280; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; gap: 7px; }
.auth .ifield { position: relative; display: block; }
.auth .ifield > .svg-i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #9aa1ac; stroke-width: 1.6; pointer-events: none; }
.auth .input { height: 46px; font-size: 14.5px; background: #f6f7f9; color: #191c22; border: 1px solid #e6e8ec; border-radius: 10px; padding-left: 44px; text-transform: none; letter-spacing: 0; }
.auth .input::placeholder { color: #a7adb7; }
.auth .input:hover { border-color: #d5d9e0; }
.auth .input:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.auth .ifield:focus-within > .svg-i { color: var(--brand); }
.auth .ifield.pw .input { padding-right: 46px; }
.auth .ifield.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; background: none; border: 0; color: #8a919c; cursor: pointer; border-radius: 7px; }
.auth .ifield.pw button:hover { color: var(--brand); background: #eef0f3; }
.auth .ifield.pw button .svg-i { width: 18px; height: 18px; stroke-width: 1.6; }
.auth .btn-brand { height: 48px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 2px; }
.auth .btn-brand:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.auth .btn-brand:disabled { opacity: .65; cursor: default; }
.auth a { color: var(--brand); font-weight: 500; text-decoration: none; }
.auth a:hover { text-decoration: underline; }
.auth .opts { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; flex-wrap: wrap; }
.auth .opts a { display: inline-flex; align-items: center; gap: 6px; }
.auth .opts .svg-i { width: 16px; height: 16px; stroke-width: 1.6; }
.auth .chk { display: inline-flex; align-items: center; gap: 8px; color: #5b6472; cursor: pointer; user-select: none; }
.auth .chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.auth .op-link { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; padding-top: 18px; border-top: 1px solid #eef0f3; font-size: 13px; }
.auth .op-link .svg-i { width: 17px; height: 17px; stroke-width: 1.6; }
.auth .msg { font-size: 13px; border-radius: 8px; padding: 10px 12px; display: none; }
.auth .msg.err { display: block; background: #fdf2f2; color: #b42318; border: 1px solid #f5d5d2; }
.auth .msg.ok { display: block; background: #f0f9f4; color: #157f3b; border: 1px solid #d2ecdc; }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth { min-height: 100vh; align-items: flex-start; padding: 72px 20px 32px; }
  .auth-top { top: 14px; right: 14px; }
}

/* ── App del operador (móvil) ────────────────────────────────────────── */
.op { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.op-h { background: #071b35; color: #fff; padding: calc(12px + env(safe-area-inset-top)) 16px 14px; }
.op-h .brand-s { font-weight: 800; letter-spacing: .14em; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.op-h .net { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: rgba(34,197,94,.2); color: #86efac; letter-spacing: 0; }
.op-h .net.off { background: rgba(245,165,36,.22); color: #fcd34d; }
.op-h .folio { font-size: 21px; font-weight: 750; margin-top: 8px; }
.op-h .route { color: #b6c6e0; font-size: 13.5px; }
.op-b { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 12px; padding-bottom: 86px; }
.op-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.op-card .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.op-card h3 { font-size: 18px; margin: 4px 0 2px; }
.op-big { width: 100%; height: 58px; border-radius: 12px; border: 0; background: var(--primary); color: #fff; font: inherit; font-size: 17px; font-weight: 700; margin-top: 12px; cursor: pointer; }
.op-big:active { transform: scale(.99); }
.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.op-tile { border: 1px solid var(--border-2); background: var(--panel-2); border-radius: 12px; min-height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 600; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; position: relative; }
.op-tile.done { border-color: var(--green); }
.op-tile .ok { position: absolute; top: 6px; right: 8px; color: var(--green); }
.op-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.op-steps li.done { color: var(--green); }
.op-steps li.cur { color: var(--blue); font-weight: 650; }
.op-steps li.todo { color: var(--muted); }
.op-tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.op-tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.op-tabs button.on { color: var(--primary); }
.sig-pad { width: 100%; height: 220px; background: #fff; border-radius: 10px; touch-action: none; border: 1px solid var(--border-2); }

/* ── Responsivo ──────────────────────────────────────────────────────── */
@media (max-width: 1500px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1200px) {
  .g-main, .g-detail, .g-dash { grid-template-columns: minmax(0, 1fr); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phasebar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  body.nav-open .side { transform: none; }
  .top .burger { display: inline-grid; }
  .kpis, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g3, .g-dash, .form-grid, .form-grid.g3 { grid-template-columns: minmax(0, 1fr); }
  .phasebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .userbox .n, .userbox .r { display: none; }
  .content { padding: 14px 12px 24px; }
  .ph { grid-template-columns: 28px minmax(0, 1fr); }
  .ph .when, .ph .src { grid-column: 2; justify-self: start; }
  .log .it { grid-template-columns: 1fr; gap: 2px; }
  .top .hide-sm { display: none; }
}
@media print {
  .side, .top, .footer, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}
