/* ==========================================================================
   TMS GLA · Sistema de diseño
   Tema oscuro (torre de control) por defecto + tema claro.
   Escala de espaciado: 4 · 8 · 12 · 16 · 24 · 32 · 48
   ========================================================================== */

:root,
[data-theme="dark"] {
    --bg: #0b0f14;
    --side: #090d12;
    --card: #12181f;
    --card-2: #161d26;
    --card-3: #1b2430;
    --line: #243041;
    --line-soft: #1c2633;
    --ink: #e7eef6;
    --ink-2: #c5d0dc;
    --muted: #8b98a8;
    --faint: #667588;
    --metric: #5ec8ff;
    --primary: #1f8f6a;
    --primary-ink: #ffffff;
    --accent-bg: #17324a;
    --accent-line: #24506e;
    --ok: #3ddc97;
    --ok-dim: rgba(61, 220, 151, .14);
    --warn: #f5c16c;
    --warn-dim: rgba(245, 193, 108, .14);
    --bad: #ff6b6b;
    --bad-dim: rgba(255, 107, 107, .14);
    --info: #5ec8ff;
    --info-dim: rgba(94, 200, 255, .12);
    --btn-warn: #8a5a12;
    --btn-bad: #8d2f2f;
    --btn-ok: #146b48;
    --input: #0e141b;
    --hover: rgba(255, 255, 255, .04);
    --row-hover: rgba(255, 255, 255, .025);
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
    --topbar: rgba(11, 15, 20, .92);
    --focus: #5ec8ff;
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f3f5f8;
    --side: #ffffff;
    --card: #ffffff;
    --card-2: #f8fafc;
    --card-3: #eef2f6;
    --line: #dde3ea;
    --line-soft: #e9edf2;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #5b6778;
    --faint: #7b8794;
    --metric: #0369a1;
    --primary: #0f766e;
    --primary-ink: #ffffff;
    --accent-bg: #e0f2fe;
    --accent-line: #7dd3fc;
    --ok: #15803d;
    --ok-dim: #dcfce7;
    --warn: #b45309;
    --warn-dim: #fef3c7;
    --bad: #b91c1c;
    --bad-dim: #fee2e2;
    --info: #0369a1;
    --info-dim: #e0f2fe;
    --btn-warn: #b45309;
    --btn-bad: #b91c1c;
    --btn-ok: #15803d;
    --input: #ffffff;
    --hover: #f1f5f9;
    --row-hover: #f8fafc;
    --shadow: 0 12px 32px rgba(15, 23, 42, .14);
    --topbar: rgba(255, 255, 255, .92);
    --focus: #0369a1;
    color-scheme: light;
}

:root { font-family: "Segoe UI", "Inter", "Helvetica Neue", system-ui, sans-serif; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }
.icon.sm { width: 14px; height: 14px; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
    background: var(--side);
    border-right: 1px solid var(--line);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 16px; }
.brand strong { display: block; font-size: 14px; letter-spacing: .04em; }
.brand span { color: var(--muted); font-size: 12px; }
.mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--accent-bg); color: var(--metric);
    display: grid; place-items: center; font-weight: 700;
}
.nav { overflow: auto; flex: 1; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; margin-bottom: 2px; border-radius: 8px;
    text-decoration: none; color: var(--ink-2); font-size: 14px;
    border-left: 2px solid transparent;
}
.nav a .icon { color: var(--faint); }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.active { background: var(--accent-bg); color: var(--ink); border-left-color: var(--metric); }
.nav a.active .icon { color: var(--metric); }
.nav .count { margin-left: auto; font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--warn-dim); color: var(--warn); }
.nav .group {
    margin: 16px 10px 6px; color: var(--faint);
    font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 4px; }
.side-foot form { margin: 0; }
.side-foot button, .side-foot .linkish {
    width: 100%; display: flex; align-items: center; gap: 10px;
    background: transparent; border: 0; color: var(--muted);
    text-align: left; padding: 8px 10px; cursor: pointer; border-radius: 8px;
}
.side-foot button:hover { background: var(--hover); color: var(--ink); }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 24px; border-bottom: 1px solid var(--line);
    background: var(--topbar); backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 15;
}
.icon-btn.menu-btn { display: none; }
.search { flex: 1; max-width: 440px; position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 34px; padding-right: 44px; background: var(--input); }
.search kbd {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font: 11px/1 ui-monospace, Consolas, monospace; color: var(--faint);
    border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px;
}
.search-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 34px; height: 34px; display: inline-grid; place-items: center;
    border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.theme-dark-only, .theme-light-only { display: inline-grid; }
[data-theme="dark"] .theme-light-only, [data-theme="light"] .theme-dark-only { display: none; }
.userchip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.userchip b { display: block; color: var(--ink); font-weight: 600; font-size: 13px; line-height: 1.2; }
.userchip small { display: block; font-size: 11px; line-height: 1.2; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    display: grid; place-items: center; background: var(--ok-dim); color: var(--ok); font-weight: 700;
}
.main { padding: 20px 24px 48px; width: 100%; }

/* ---------- Encabezado de página ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { opacity: .6; }
.page-head { margin-bottom: 20px; }
.page-title-row { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.page-title-row > div:first-child { flex: 1 1 360px; min-width: 0; }
.page-actions { flex: none; }
.page-title-row h1 { display: flex; align-items: center; gap: 8px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; font-weight: 650; line-height: 1.2; }
.lede { color: var(--muted); margin: 6px 0 0; font-size: 14px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Superficies ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 12px; padding: 16px;
}
.card + .card, .split + .card, .grid-stats + .split, .grid-stats + .card,
.card + .split, .callout + .card, .toolbar + .card, .card + details.panel, details.panel + .card,
.section-title + .grid-stats, .grid-stats + .section-title, .card + .section-title { margin-top: 16px; }
.grid-stats > *, .split > *, .stack > *, .layout-aside > *, .tiles > *, .checks > * { margin-top: 0 !important; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 14px 16px 0; }
.card.flush > .table-wrap { border-top: 1px solid var(--line-soft); }
.section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600;
    margin: 0 0 8px;
}
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr); gap: 16px; align-items: start; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.layout-aside > aside { position: sticky; top: 72px; }

/* ---------- KPI ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.grid-stats + .toolbar, .grid-stats + .callout { margin-top: 16px; }
.stat { position: relative; }
.stat span.k {
    display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px;
    letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}
.stat > span:not(.k) {
    display: block; color: var(--muted); font-size: 11px;
    letter-spacing: .08em; text-transform: uppercase;
}
.stat b {
    display: block; margin-top: 10px; font-size: 28px; line-height: 1;
    color: var(--metric); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.stat em { display: block; margin-top: 8px; color: var(--muted); font-style: normal; font-size: 12px; }
.stat.ok b { color: var(--ok); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat a.stretch { position: absolute; inset: 0; border-radius: 12px; }
.stat a.stretch:hover { background: var(--row-hover); }

/* Pipeline de etapas (dashboard) */
.pipeline { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.pipeline a {
    text-decoration: none; display: grid; gap: 6px; padding: 10px 8px; border-radius: 10px;
    background: var(--card-2); border: 1px solid var(--line); min-width: 0;
}
.pipeline a:hover { border-color: var(--accent-line); }
.pipeline b { font-size: 22px; line-height: 1; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.pipeline a.has b { color: var(--metric); }
.pipeline span { font-size: 11px; color: var(--muted); line-height: 1.25; }
.pipeline .bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.pipeline .bar i { display: block; height: 100%; background: var(--metric); }

/* Barra apilada */
.stacked { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--line); margin: 8px 0 12px; }
.stacked i { display: block; height: 100%; }
.legend { display: grid; gap: 8px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.c1 { background: var(--metric); } .c2 { background: var(--warn); } .c3 { background: var(--ok); }

.bars { display: grid; gap: 8px; }
.bars .row { display: grid; grid-template-columns: 160px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.bars .track { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bars .track i { display: block; height: 100%; background: var(--metric); }
.bars b { text-align: right; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile header { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.tile b { font-size: 14px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
    white-space: nowrap; background: var(--card); position: sticky; top: 0;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--row-hover); }
.table a { color: var(--metric); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table a.btn { color: var(--primary-ink); text-decoration: none; }
.table a.btn.ghost { color: var(--ink); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .strong { font-weight: 600; }
.table tr.is-hidden { display: none; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table.kv th { width: 180px; text-transform: none; letter-spacing: 0; font-size: 13px; position: static; background: transparent; }
.mono { font-family: ui-monospace, "JetBrains Mono", Consolas, monospace; font-size: 13px; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 600; letter-spacing: .02em; }

/* ---------- Lista de definición (detalle) ---------- */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; min-width: 0; }
.dl + .dl, .dl-block + .dl-block { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.dl-block h3 { margin-bottom: 10px; }

/* Ruta origen → destino */
.route { display: grid; gap: 0; position: relative; padding-left: 22px; }
.route::before { content: ""; position: absolute; left: 6px; top: 10px; bottom: 10px; border-left: 2px dashed var(--line); }
.route div { position: relative; padding: 4px 0 10px; }
.route div::before {
    content: ""; position: absolute; left: -22px; top: 8px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--card); border: 3px solid var(--metric);
}
.route div:last-child::before { border-color: var(--ok); }
.route small { display: block; color: var(--muted); }

/* ---------- Botones ---------- */
.btn, button.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: 8px; padding: 8px 14px; text-decoration: none; cursor: pointer;
    border: 1px solid transparent; background: var(--primary); color: var(--primary-ink);
    font-weight: 500; line-height: 1.3; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--hover); }
.btn.warn { background: var(--btn-warn); color: #fff; }
.btn.bad { background: var(--btn-bad); color: #fff; }
.btn.ok { background: var(--btn-ok); color: #fff; }
.btn.link { background: transparent; color: var(--metric); padding-left: 0; padding-right: 0; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.form-actions .left { margin-right: auto; }

/* ---------- Formularios ---------- */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 16px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.full { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset + fieldset { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
legend { font-size: 13px; font-weight: 600; color: var(--ink); padding: 0; margin-bottom: 12px; display: flex; gap: 6px; align-items: center; }
label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
label > .help { order: 2; }
.field:has(> input[required], > select[required], > textarea[required]) > label::after {
    content: "*"; color: var(--bad); order: 1; font-weight: 600;
}
input, select, textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 10px; background: var(--input); min-height: 38px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); border-color: var(--focus); }
input.invalid, select.invalid, textarea.invalid, [aria-invalid="true"] { border-color: var(--bad); }
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); padding: 0; }
.hint { display: block; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.field-error { display: block; margin: 6px 0 0; font-size: 12px; color: var(--bad); }
.input-group { display: flex; align-items: stretch; }
.input-group > span {
    display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); background: var(--card-2);
    color: var(--muted); font-size: 13px;
}
.input-group > span:first-child { border-radius: 8px 0 0 8px; border-right: 0; }
.input-group > span:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.input-group > input { border-radius: 0; }
.input-group > input:first-child { border-radius: 8px 0 0 8px; }
.input-group > input:last-child { border-radius: 0 8px 8px 0; }

/* Interruptor (checkbox) con descripción */
.check {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin: 0;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); cursor: pointer; font-weight: 400;
    flex-wrap: nowrap;
}
.check:hover { border-color: var(--accent-line); }
.check .txt { display: grid; gap: 2px; }
.check .txt b { color: var(--ink); font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.check .txt small { color: var(--muted); font-size: 12px; }
.check:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.check.inline { padding: 8px 10px; background: transparent; }
input.toggle {
    appearance: none; -webkit-appearance: none; flex: none; position: relative; cursor: pointer;
    width: 36px; height: 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--line); margin-top: 1px;
    transition: background .15s;
}
input.toggle::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: #fff; transition: transform .15s;
}
input.toggle:checked { background: var(--primary); border-color: var(--primary); }
input.toggle:checked::after { transform: translateX(16px); }
.checks { display: grid; gap: 8px; }
.checks.cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Control segmentado (radio) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--muted); border-right: 1px solid var(--line); flex-wrap: nowrap; }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent-bg); color: var(--ink); }
.seg label.ok:has(input:checked) { background: var(--ok-dim); color: var(--ok); }
.seg label.bad:has(input:checked) { background: var(--bad-dim); color: var(--bad); }
.seg label.warn:has(input:checked) { background: var(--warn-dim); color: var(--warn); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ---------- Mensajes ---------- */
.flash, .errors, .callout {
    border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start;
}
.flash { background: var(--ok-dim); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.errors { background: var(--bad-dim); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.callout { background: var(--info-dim); color: var(--ink-2); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.callout .icon { color: var(--info); margin-top: 1px; }
.callout.warn { background: var(--warn-dim); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout.warn .icon { color: var(--warn); }
.callout.bad { background: var(--bad-dim); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.callout.bad .icon { color: var(--bad); }
.callout.ok { background: var(--ok-dim); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.callout.ok .icon { color: var(--ok); }
.callout p { margin: 0; }
.callout p + p { margin-top: 4px; }
.callout.compact { margin-bottom: 12px; padding: 8px 10px; font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: var(--card-3); color: var(--ink-2); white-space: nowrap; line-height: 1.5; }
.badge.ok { background: var(--ok-dim); color: var(--ok); }
.badge.warn { background: var(--warn-dim); color: var(--warn); }
.badge.bad { background: var(--bad-dim); color: var(--bad); }
.badge.info { background: var(--info-dim); color: var(--info); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); } .warn-text { color: var(--warn); }

/* ---------- Ayuda contextual (?) ---------- */
.help { position: relative; display: inline-flex; vertical-align: middle; }
.help-btn {
    width: 18px; height: 18px; border-radius: 50%; padding: 0; cursor: help;
    display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; line-height: 1;
    border: 1px solid var(--line); background: var(--card-2); color: var(--muted);
}
.help-btn:hover, .help.open .help-btn { color: var(--metric); border-color: var(--accent-line); background: var(--accent-bg); }
h1 .help-btn { width: 22px; height: 22px; font-size: 12px; }
.help-pop {
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    width: max-content; max-width: min(340px, 80vw); z-index: 40;
    background: var(--card); color: var(--ink-2); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow); padding: 12px 14px; font-size: 13px; font-weight: 400; line-height: 1.5;
    letter-spacing: 0; text-transform: none; text-align: left; white-space: normal;
    display: none;
}
.help.wide .help-pop { max-width: min(460px, 86vw); }
.help-pop strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 13px; }
.help-pop p { margin: 0 0 6px; }
.help-pop p:last-child, .help-pop ul:last-child, .help-pop ol:last-child { margin-bottom: 0; }
.help-pop ul, .help-pop ol { margin: 4px 0 6px; padding-left: 18px; }
.help-pop li + li { margin-top: 2px; }
.help.open .help-pop { display: block; }
.help.align-start .help-pop { left: -8px; transform: none; }
.help.align-end .help-pop { left: auto; right: -8px; transform: none; }

/* ---------- Barra de herramientas / filtros ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    border: 1px solid var(--line); background: var(--card); color: var(--muted);
    border-radius: 999px; padding: 5px 12px; font-size: 13px;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--accent-bg); border-color: var(--accent-line); color: var(--ink); }
.chip .n { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--card-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip.on .n { background: var(--card); }
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.settings-nav a.chip { text-decoration: none; }
.log-search { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.log-search input { width: min(280px, 100%); }
.dt-pager a { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 8px; padding: 5px 10px; text-decoration: none; }
.table th a { color: inherit; text-decoration: none; }
.table th a:hover { color: var(--ink); }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: var(--faint); margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty p { margin: 0 auto 12px; max-width: 420px; font-size: 13px; }
.empty-row td { padding: 0 !important; }
.no-results td { text-align: center; color: var(--muted); padding: 24px !important; }
.table tr.is-paged { display: none; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable .sort { display: inline-block; width: 0; height: 0; margin-left: 6px; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid var(--faint); vertical-align: middle; opacity: .45; }
.table th.sorted .sort { opacity: 1; border-bottom-color: var(--metric); }
.table th.sorted.desc .sort { border-bottom: 0; border-top: 5px solid var(--metric); }
.who-cell .strong { white-space: nowrap; }
.dt-foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13px; }
.dt-pager { display: flex; gap: 8px; align-items: center; }
.dt-pager select { width: auto; padding: 4px 8px; }
.dt-pager button { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.dt-pager button:disabled { opacity: .4; cursor: default; }
.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell .muted { display: block; }
.role-filter { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 13px; }
.role-filter select { width: auto; min-width: 180px; padding: 6px 10px; }

/* ---------- Paneles colapsables ---------- */
details.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
details.panel > summary {
    list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px;
    font-weight: 600; border-radius: 12px;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary:hover { background: var(--hover); }
details.panel > summary .chev { margin-left: auto; transition: transform .15s; color: var(--muted); }
details.panel[open] > summary { border-bottom: 1px solid var(--line-soft); border-radius: 12px 12px 0 0; }
details.panel[open] > summary .chev { transform: rotate(180deg); }
details.panel > summary small { font-weight: 400; color: var(--muted); }
details.panel > .panel-body { padding: 16px; }
details.panel.accent > summary .icon:first-child { color: var(--metric); }
details.panel.warn > summary .icon:first-child { color: var(--warn); }
details.inline > summary { cursor: pointer; color: var(--metric); font-size: 13px; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] > summary { margin-bottom: 8px; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -4px -16px 16px; padding: 0 12px; overflow-x: auto; }
.tabs button {
    background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer;
    color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--metric); }
.tabs .n { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--card-3); }
[role="tabpanel"][hidden] { display: none; }

/* ---------- Riel de etapas del viaje ---------- */
.rail {
    display: grid; grid-template-columns: repeat(var(--steps, 9), minmax(0, 1fr)); gap: 0;
    margin: 0 0 20px; padding: 14px 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    list-style: none; counter-reset: stage;
}
.rail li { position: relative; text-align: center; padding: 0 4px; min-width: 0; }
.rail li::before {
    counter-increment: stage; content: counter(stage);
    display: grid; place-items: center; margin: 0 auto 6px; position: relative; z-index: 1;
    width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 600;
    background: var(--card-2); border: 2px solid var(--line); color: var(--muted);
}
.rail li::after {
    content: ""; position: absolute; top: 13px; left: calc(-50% + 15px); right: calc(50% + 15px);
    height: 2px; background: var(--line);
}
.rail li:first-child::after { display: none; }
.rail li span { display: block; font-size: 11px; line-height: 1.25; color: var(--muted); }
.rail li.done::before { content: "✓"; background: var(--ok-dim); border-color: var(--ok); color: var(--ok); }
.rail li.done::after, .rail li.on::after { background: var(--ok); }
.rail li.on::before { background: var(--accent-bg); border-color: var(--metric); color: var(--metric); box-shadow: 0 0 0 4px var(--info-dim); }
.rail li.on span { color: var(--ink); font-weight: 600; }
.rail.hold li.on::before { border-color: var(--warn); color: var(--warn); background: var(--warn-dim); box-shadow: 0 0 0 4px var(--warn-dim); }

/* Bloque "siguiente paso" */
.next-step { border-left: 3px solid var(--metric); }
.next-step.hold { border-left-color: var(--warn); }
.next-step .eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--metric); font-weight: 600; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.next-step.hold .eyebrow { color: var(--warn); }
.owner { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }

/* Mapa del viaje (Leaflet + OpenStreetMap) */
.map { height: 360px; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; background: var(--card-2); z-index: 0; }
.map .empty { padding-top: 120px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.truck-pin span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #dc2626; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(220, 38, 38, .25); }
.leaflet-container { font: inherit; }
.trip-truck span { background: #2563eb; box-shadow: 0 0 0 6px rgba(37, 99, 235, .25); }
.map-label { font-size: 11px; font-weight: 600; padding: 2px 6px; }
.map-note { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; max-width: 320px; box-shadow: var(--shadow); }
/* Tono del mapa: «Por defecto» sigue el tema; nunca se filtra una capa satelital ni una ya clara/oscura */
[data-theme="dark"] .map:not(.map-tone-light):not(.map-tone-gray):not(.map-base-imagery):not(.map-base-neutral) .leaflet-tile-pane,
.map.map-tone-dark:not(.map-base-imagery):not(.map-base-neutral) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9); }
.map.map-tone-gray:not(.map-base-imagery) .leaflet-tile-pane { filter: grayscale(1) contrast(1.05); }
[data-theme="dark"] .map.map-tone-gray:not(.map-base-imagery) .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.9) contrast(.9); }

/* Leaflet: sin recuadro de foco al hacer clic en una figura */
.leaflet-container path.leaflet-interactive:focus, .leaflet-container .leaflet-marker-icon:focus { outline: none; }

/* Indicadores de gestión */
.kpi-toolbar { justify-content: space-between; }
.kpi-toolbar .chip { text-decoration: none; }
.kpi-grid .stat em { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.delta { font-size: 12px; color: var(--muted); font-style: normal; white-space: nowrap; }
.delta.good { color: var(--ok); }
.delta.bad { color: var(--bad); }
.alert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.alert-item { display: flex; gap: 10px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card-2); }
.alert-item p { margin: 2px 0 4px; font-size: 13px; color: var(--ink-2); }
.alert-item.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-dim); }
.alert-item.bad .icon { color: var(--bad); }
.alert-item.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-dim); }
.alert-item.warn .icon { color: var(--warn); }
.alert-item.info .icon { color: var(--info); }
.alert-item.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-dim); }
.alert-item.ok .icon { color: var(--ok); }
.trend-wrap { overflow-x: auto; }
.trend { width: 100%; min-width: 560px; height: 240px; display: block; }
.trend .grid { stroke: var(--line); stroke-width: 1; }
.trend .axis { fill: var(--muted); font-size: 10px; }
.mini-stats .help-pop, .cash-flow .help-pop { text-transform: none; letter-spacing: 0; font-weight: 400; }
.trend .bar-rev { fill: var(--metric); }
.trend .bar-mar { fill: var(--ok); }
.trend .bar-mar.neg { fill: var(--bad); }
.trend g:hover rect { opacity: .8; }
.cash-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 8px; align-items: center; }
.cash-flow > div { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; }
.cash-flow > i { color: var(--muted); font-style: normal; }
.cash-flow > div > span, .mini-stats > div > span:first-child { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.cash-flow b { display: block; font-size: 18px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cash-flow small { color: var(--muted); font-size: 12px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-stats > div { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; display: grid; gap: 2px; }
.mini-stats b { font-size: 20px; font-variant-numeric: tabular-nums; }
.risk-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.risk-list li { padding: 6px 10px; border-radius: 8px; border-left: 3px solid var(--line); background: var(--card-2); }
.risk-list li.bad { border-left-color: var(--bad); }
.risk-list li.warn { border-left-color: var(--warn); }
.risk-list li.ok { border-left-color: var(--ok); }
.share { display: flex; align-items: center; gap: 8px; }
.share .track { flex: 1; height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.share .track i { display: block; height: 100%; background: var(--metric); }
.share small { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) { .mini-stats, .cash-flow { grid-template-columns: 1fr; } .cash-flow > i { display: none; } }
@media print { .alert-item, .card { break-inside: avoid; } .kpi-toolbar .chips { display: none; } }

/* Modal */
dialog.modal {
    border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--ink);
    box-shadow: var(--shadow); width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog.modal.modal-xl { width: min(1400px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(2, 6, 12, .6); backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { margin: 2px 0; font-size: 18px; }
.modal-body { padding: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.row-actions.nowrap { flex-wrap: nowrap; justify-content: flex-end; }
.btn.danger-text { color: var(--bad); }
.btn.danger-text:hover { background: var(--bad-dim); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.sm-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.sm-map { height: min(72vh, 720px); border: 0; border-radius: 0 0 0 14px; }
.sm-panel { border-left: 1px solid var(--line-soft); padding: 16px; overflow: auto; max-height: min(72vh, 720px); }
.sm-list { list-style: none; margin: 0; padding: 0; }
.sm-list li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line-soft); }
.sm-focus { flex: 1; text-align: left; background: transparent; border: 0; color: inherit; padding: 8px 0; cursor: pointer; }
.sm-focus small { display: block; color: var(--muted); font-size: 12px; }
.sm-del { width: 28px; height: 28px; }
.sm-steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.sm-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.sm-stats > div { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 6px 8px; }
.sm-stats span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sm-stats b { font-variant-numeric: tabular-nums; }
.sm-vertex span {
    display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #dc2626; color: #fff;
    border: 2px solid #fff; font-size: 10px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: grab;
}
@media (max-width: 900px) { .sm-body { grid-template-columns: 1fr; } .sm-map { height: 50vh; border-radius: 0; } .sm-panel { border-left: 0; border-top: 1px solid var(--line-soft); max-height: none; } }

/* Lote histórico (Integraciones) */
.batch-form { display: grid; grid-template-columns: 180px 180px auto auto; gap: 12px 16px; align-items: start; }
.batch-totals { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
@media (max-width: 860px) { .batch-form { grid-template-columns: 1fr 1fr; } }

/* Barra de opciones de los mapas */
.map-toolbar { position: absolute; top: 10px; right: 10px; z-index: 800; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 70px); }
.mt-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; cursor: pointer;
    background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 1px 4px rgba(0,0,0,.18);
    font: 600 12px/1 inherit; white-space: nowrap;
}
.mt-btn:hover, .mt-menu.open > .mt-btn { border-color: var(--accent-line); background: var(--accent-bg); }
.mt-caret { font-size: 10px; color: var(--muted); }
.mt-menu { position: relative; }
.mt-drop {
    display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; padding: 6px;
    background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.mt-drop-end, .mt-menu:last-child .mt-drop { left: auto; right: 0; }
.mt-menu.open .mt-drop { display: grid; gap: 2px; }
.mt-drop label, .mt-drop > button {
    display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 8px; border-radius: 6px; cursor: pointer;
    font-size: 13px; font-weight: 400; color: var(--ink); background: transparent; border: 0; text-align: left; width: 100%;
}
.mt-drop label:hover, .mt-drop > button:hover { background: var(--hover); }
.mt-drop input { width: 15px; height: 15px; }
.mt-note { margin: 4px 8px 2px; font-size: 11px; color: var(--muted); max-width: 240px; }
.mt-empty { color: var(--muted); }
.map-measure {
    position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 800;
    background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
    padding: 6px 10px; font-size: 12px; display: flex; gap: 8px; align-items: center;
}
.map-measure[hidden] { display: none; }
.map-measure b { font-size: 15px; }
.map-measure span { color: var(--muted); }
.map-measure button, .mt-copy { border: 1px solid var(--line); background: var(--card-2); color: var(--ink); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.map-measuring { cursor: crosshair; }
.map-is-full, .map:fullscreen { width: 100vw !important; height: 100vh !important; background: var(--bg); }
.map-is-full > .map { height: 100vh !important; }
.map-is-full .unit-card { max-height: calc(100vh - 24px); }
@media (max-width: 860px) {
    .mt-btn span:not(.mt-caret) { display: none; }
    .mt-btn { padding: 0 8px; }
}
[data-theme="dark"] .leaflet-popup-content-wrapper, [data-theme="dark"] .leaflet-popup-tip,
[data-theme="dark"] .leaflet-tooltip { background: var(--card); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .leaflet-bar a { background: var(--card); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(18, 24, 31, .8); color: var(--muted); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--metric); }
@media (max-width: 860px) { .map { height: 280px; } }

/* Viaje en ruta: avance y datos en vivo */
.trip-progress { margin: 4px 0 16px; }
.tp-ends, .tp-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.tp-ends span { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 500; }
.tp-bar { position: relative; height: 8px; border-radius: 8px; background: var(--line); margin: 10px 0 8px; }
.tp-bar > i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #2563eb, #16a34a); }
.tp-truck {
    position: absolute; top: 50%; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; background: var(--card); border: 2px solid #dc2626; color: #dc2626; box-shadow: var(--shadow);
}
.live-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.live-tiles > div { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.live-tiles span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.live-tiles b { display: block; font-size: 20px; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.live-tiles b small { font-size: 12px; font-weight: 400; color: var(--muted); }
.live-tiles em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-tiles em.warn-text { color: var(--warn); } .live-tiles em.bad-text { color: var(--bad); } .live-tiles em.ok-text { color: var(--ok); }
@media (max-width: 1200px) { .live-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Monitoreo activo */
.mon-tabs { margin: 0 0 16px; padding: 0; }
.mon-tabs a { padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.mon-tabs a:hover { color: var(--ink); }
.mon-tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--metric); }
.tabs .n.bad { background: var(--bad); color: #fff; }
.mon-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mon-tiles b span, .mon-tiles small span { display: inline; font-size: inherit; text-transform: none; letter-spacing: 0; color: inherit; font-weight: inherit; }
.mon-tiles small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.mon-tiles > div.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-dim); }
.mon-tiles > div.bad b { color: var(--bad); }
.mon-tiles > div.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-dim); }
.mon-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 16px; align-items: stretch; }
.mon-inbox { display: flex; flex-direction: column; max-height: calc(min(66vh, 640px) + 44px); }
.mon-list { list-style: none; margin: 0; padding: 0 10px 10px; overflow: auto; flex: 1; }
.mon-item { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--card-2); }
.mon-item.bad { border-left-color: var(--bad); }
.mon-item.warn { border-left-color: var(--warn); }
.mon-item.info { border-left-color: var(--info); }
.mon-item p { margin: 6px 0 8px; color: var(--ink-2); }
.mon-item-head { display: flex; gap: 8px; align-items: flex-start; }
.mon-item-title { min-width: 0; }
.mon-item .row-actions { margin-top: 6px; }
.mon-hold { display: inline-block; }
.mon-hold summary { list-style: none; }
.mon-hold summary::-webkit-details-marker { display: none; }
.mon-hold[open] { display: block; width: 100%; }
.mon-hold form { display: grid; gap: 6px; margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.mon-empty { display: grid; gap: 4px; text-align: center; padding: 28px 12px; }
.sev { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; margin-top: 4px; }
.sev.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); }
.sev.warn { background: var(--warn); }
.sev.info { background: var(--info); }
.mon-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.mon-dot.ok, .mon-pin-dot.ok { background: #16a34a; }
.mon-dot.info, .mon-pin-dot.info { background: #2563eb; }
.mon-dot.warn, .mon-pin-dot.warn { background: #d97706; }
.mon-dot.bad, .mon-pin-dot.bad { background: #dc2626; }
.mon-pin { background: transparent; border: 0; display: inline-flex !important; align-items: center; gap: 4px; white-space: nowrap; }
.mon-pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); flex: none; }
.mon-pin-dot.bad { animation: mon-pulse 1.6s infinite; }
.mon-pin b { font-size: 11px; background: rgba(255, 255, 255, .92); color: #0f172a; padding: 1px 5px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
@keyframes mon-pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .6); } 70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.rule-card.off { opacity: .65; }
.rule-flags { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 13px; }
.rule-flags label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
@media (max-width: 1100px) { .mon-layout { grid-template-columns: 1fr; } .mon-inbox { max-height: none; } .mon-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .rule-grid { grid-template-columns: 1fr; } }

.trip-monitor-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; max-height: 240px; overflow: auto; }
.trip-monitor-list li { display: grid; grid-template-columns: 12px 84px 1fr; gap: 8px; align-items: start; padding: 6px 4px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }

/* Consolidado de flota */
.fleet-kpis .stat { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.fleet-kpis [data-state]:hover { border-color: var(--accent-line); }
.fleet-kpis .stat.on { border-color: var(--metric); box-shadow: 0 0 0 1px var(--metric) inset; }
.fleet-kpis .swatch { width: 8px; height: 8px; border-radius: 50%; }
.fleet-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.fleet-map { height: 600px; border: 0; border-radius: 0; }
.fleet-list { max-height: 650px; display: flex; flex-direction: column; }
.unit-list { list-style: none; margin: 0 -16px -16px; padding: 0; overflow: auto; flex: 1; border-top: 1px solid var(--line-soft); }
.unit-list button {
    width: 100%; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center;
    padding: 10px 16px; background: transparent; border: 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; text-align: left; color: inherit;
}
.unit-list button:hover { background: var(--row-hover); }
.unit-list .dot-state { width: 10px; height: 10px; border-radius: 50%; }
.unit-list .u-main { min-width: 0; }
.unit-list .u-main small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-list .u-side { text-align: right; display: grid; line-height: 1.2; }
.unit-list .u-side b { font-variant-numeric: tabular-nums; }
.unit-list .u-side small { color: var(--muted); font-size: 11px; }
.unit-pin { position: relative; }
.unit-pin span { position: absolute; inset: 3px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.unit-pin .unit-arrow {
    position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin: -22px 0 0 -6px;
    border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid #16a34a;
    transform-origin: 6px 22px;
}
/* Ficha del equipo: ubicación y recorrido */
.vt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.vt-panel { border-left: 1px solid var(--line); padding: 16px; max-height: 480px; overflow: auto; display: flex; flex-direction: column; }
.vt-routes { border-top: 1px solid var(--line-soft); margin-top: 14px; padding-top: 14px; }
.vt-periods { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
.vt-periods label { justify-content: center; }
.vt-status { margin: 10px 0; display: grid; gap: 6px; }
.vt-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.vt-summary > div { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px; }
.vt-summary span { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.vt-summary b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.vt-summary small { color: var(--muted); font-size: 11px; }
.vt-days { list-style: none; margin: 0; padding: 0; }
.vt-days button { width: 100%; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 4px; background: transparent; border: 0; border-bottom: 1px solid var(--line-soft); text-align: left; color: inherit; cursor: pointer; font-size: 13px; }
.vt-days button:hover:not(:disabled) { background: var(--row-hover); }
.vt-days button:disabled { cursor: default; opacity: .7; }
.vt-days small { display: block; color: var(--muted); font-size: 11px; }
.vt-days .num { font-variant-numeric: tabular-nums; }
@media (max-width: 1024px) { .vt-layout { grid-template-columns: minmax(0, 1fr); } .vt-panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; } }

/* Tarjeta flotante de telemetría (Consolidado) */
.map-wrap { position: relative; }
.unit-card {
    position: absolute; top: 12px; left: 12px; bottom: 12px; z-index: 500; width: 360px; max-width: calc(100% - 24px);
    overflow: auto; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow); padding: 14px 16px; font-size: 13px;
}
.leaflet-left .leaflet-control { transition: margin .15s; }
.map-wrap:has(.unit-card:not([hidden])) .leaflet-left .leaflet-control { margin-left: 384px; }
.uc-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.uc-head h3 { margin: 2px 0 6px; font-size: 18px; color: var(--ink); display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.uc-head h3 small { font-size: 12px; font-weight: 400; color: var(--muted); }
.uc-eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--metric); font-weight: 600; }
.uc-sec { border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 10px; }
.uc-sec h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.uc-sec h4 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 11px; }
.uc-sec p { margin: 0; }
.uc-where { font-weight: 600; margin-bottom: 6px !important; }
.uc-dl { display: grid; grid-template-columns: 96px 1fr; gap: 4px 10px; margin: 0; }
.uc-dl dt { color: var(--muted); }
.uc-dl dd { margin: 0; text-align: right; }
.uc-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.uc-tiles .tm { border: 1px solid var(--line-soft); background: var(--card-2); border-radius: 10px; padding: 8px 6px; text-align: center; }
.uc-tiles .tm b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink); }
.uc-tiles .tm b small { font-size: 10px; font-weight: 400; color: var(--muted); }
.uc-tiles .tm span { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.uc-tiles .tm.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-dim); }
.uc-tiles .tm.ok b { color: var(--ok); }
.uc-tiles .tm.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-dim); }
.uc-tiles .tm.warn b { color: var(--warn); }
.uc-tiles .tm.bad b { color: var(--bad); }
.uc-tiles .tm.info b { color: var(--info); }
.uc-track { margin-top: 10px; }
.uc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); position: sticky; bottom: -14px; background: var(--card); padding-bottom: 4px; }
.unit-pin.selected span { inset: -2px; border-width: 4px; box-shadow: 0 0 0 6px rgba(37, 99, 235, .35), 0 2px 8px rgba(0,0,0,.5); }
.unit-list button.on { background: var(--accent-bg); }
@media (max-width: 860px) {
    .unit-card { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 70%; }
    .map-wrap:has(.unit-card:not([hidden])) .leaflet-left .leaflet-control { margin-left: 10px; }
}
@media (max-width: 1200px) { .fleet-layout { grid-template-columns: minmax(0, 1fr); } .fleet-list { max-height: 420px; } }
@media (max-width: 860px) { .fleet-map { height: 380px; } }

/* Resumen económico */
.money { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.money div { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; }
.money span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.money b { display: block; font-size: 16px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.money .neg b { color: var(--bad); } .money .pos b { color: var(--ok); }

/* Progreso simple */
.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--metric); transition: width .2s; }

/* ---------- Wizard ---------- */
.wizard-head { margin-bottom: 20px; }
.wizard-steps { display: flex; gap: 0; margin: 0 0 12px; padding: 0; list-style: none; flex-wrap: wrap; row-gap: 8px; }
.wizard-steps li { display: flex; align-items: center; flex: 1 1 0; min-width: 120px; }
.wizard-steps li:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--line); margin: 0 10px; min-width: 16px; }
.wizard-steps li.done:not(:last-child)::after { background: var(--ok); }
.wizard-steps li:last-child { flex: 0 0 auto; }
.wizard-steps button {
    display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 0; padding: 0; cursor: pointer;
    color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.wizard-steps .num {
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600;
    border: 2px solid var(--line); background: var(--card-2);
}
.wizard-steps li.on button { color: var(--ink); }
.wizard-steps li.on .num { border-color: var(--metric); color: var(--metric); background: var(--accent-bg); }
.wizard-steps li.done .num { border-color: var(--ok); background: var(--ok-dim); color: var(--ok); }
.wizard-steps li.error .num { border-color: var(--bad); background: var(--bad-dim); color: var(--bad); }
.wizard-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.wizard-meta .progress { flex: 1; max-width: 240px; }
.wizard-pane > .pane-desc { color: var(--muted); font-size: 13px; margin: -4px 0 16px; }
.wizard-pane > .pane-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.wizard-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.wizard-actions .spacer { margin-right: auto; }
form[data-wizard].all-open .wizard-pane + .wizard-pane { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.review { display: grid; gap: 12px; }
.review section { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.review header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.review header b { font-size: 13px; }
.review .dl { grid-template-columns: 180px 1fr; gap: 6px 12px; font-size: 13px; }
.review .dl dd.empty-val { color: var(--faint); }
.form-card { max-width: none; }
/* Pedido nuevo: formulario + resumen en vivo */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.order-layout > aside { position: sticky; top: 72px; display: grid; gap: 16px; }
.order-summary .os-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.order-summary .os-row:last-child { border-bottom: 0; }
.order-summary .os-row .icon { color: var(--muted); margin-top: 2px; }
.order-summary .os-row > div > span:first-child { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.order-summary .os-row b { display: block; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.order-summary .os-row b.pending { color: var(--faint); font-weight: 400; }
.order-summary .os-row small { display: block; color: var(--muted); font-size: 12px; }
.order-map { height: 220px; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; }
.os-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.os-checks li { display: flex; gap: 8px; align-items: center; }
.os-checks li i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; background: var(--card-3); color: var(--muted); flex: none; }
.os-checks li.ok i { background: var(--ok-dim); color: var(--ok); }
.os-checks li.bad i { background: var(--bad-dim); color: var(--bad); }
@media (max-width: 1200px) { .order-layout { grid-template-columns: minmax(0, 1fr); } .order-layout > aside { position: static; } }

/* ---------- Marca configurable ---------- */
.mark.logo { object-fit: contain; padding: 3px; background: var(--logo, var(--accent-bg)); }
.color-line { display: flex; align-items: center; gap: 12px; }
input[type="color"] { width: 48px; height: 36px; padding: 4px; flex: none; }
.check.slim { margin: 0; }
.logo-preview { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); margin-bottom: 8px; }
.qr { display: grid; place-items: center; margin: 16px 0; padding: 12px; background: #fff; border-radius: 12px; }
.qr svg { width: 196px; height: 196px; }
.secret { letter-spacing: .12em; text-align: center; font-size: 14px; }
html[data-brand-side] .side,
html[data-brand-side] .side .brand strong,
html[data-brand-side] .side .nav a,
html[data-brand-side] .side .nav a.active { color: var(--side-ink); }
html[data-brand-side] .side .brand span,
html[data-brand-side] .side .nav .group,
html[data-brand-side] .side .nav a .icon,
html[data-brand-side] .side .side-foot button { color: color-mix(in srgb, var(--side-ink) 70%, transparent); }
html[data-brand-side] .side .nav a:hover,
html[data-brand-side] .side .side-foot button:hover { color: var(--side-ink); }
html[data-brand-header] .topbar { background: var(--topbar); color: var(--header-ink); }
html[data-brand-header] .topbar .userchip,
html[data-brand-header] .topbar .userchip b,
html[data-brand-header] .topbar .icon-btn { color: var(--header-ink); }
html[data-brand-section] .page-head,
html[data-brand-section] .page-head h1,
html[data-brand-section] .crumbs,
html[data-brand-section] .lede { color: var(--section-ink); }
html[data-brand-logo] .mark { background: var(--logo); color: var(--logo-ink); }

/* Cabecera del menú: logo a todo el ancho y la cuenta del usuario debajo */
.brand.brand-full { flex-direction: column; align-items: stretch; gap: 12px; padding: 0 4px 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.brand-full .brand-logo { display: block; width: 100%; height: auto; max-height: 120px; object-fit: contain; border-radius: 10px; background: var(--logo, #0b1622); padding: 8px; }
.brand-full > .mark { width: 100%; height: 64px; font-size: 28px; border-radius: 10px; }
.brand-user { display: grid; justify-items: center; text-align: center; gap: 2px; min-width: 0; }
.brand-user b { display: inline-block; font-weight: 700; font-size: 14px; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-user small { color: var(--muted); font-size: 12px; }
html[data-brand-side] .side .brand-user b { color: var(--side-ink); }
html[data-brand-side] .side .brand-user small { color: color-mix(in srgb, var(--side-ink) 70%, transparent); }
.heartbeat { animation: heartbeat 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes heartbeat {
    0%, 40%, 100% { transform: scale(1); }
    10% { transform: scale(1.08); }
    20% { transform: scale(1); }
    30% { transform: scale(1.05); }
}
@media (prefers-reduced-motion: reduce) { .heartbeat { animation: none; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, var(--accent-bg), var(--bg) 55%); }
.login-stack { width: min(420px, calc(100% - 32px)); display: grid; gap: 12px; }
.login { width: min(420px, calc(100% - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-stack .login { width: 100%; }
.login-shell { width: min(1080px, calc(100% - 32px)); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, 420px); gap: 28px; align-items: center; padding: 32px 0; }
.login-shell .login { width: 100%; }
.login-pitch { border: 1px solid var(--line); border-radius: 18px; padding: 32px; background: linear-gradient(160deg, color-mix(in srgb, var(--accent-bg) 70%, transparent), color-mix(in srgb, var(--card) 85%, transparent)); box-shadow: var(--shadow); }
.pitch-eyebrow { display: inline-block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--metric); font-weight: 700; margin-bottom: 10px; }
.login-pitch h1 { font-size: 30px; line-height: 1.15; margin-bottom: 10px; }
.pitch-lede { color: var(--ink-2); font-size: 15px; margin: 0 0 22px; max-width: 560px; }
.pitch-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.pitch-list li { display: flex; gap: 12px; align-items: flex-start; }
.pitch-list b { display: block; font-size: 14px; color: var(--ink); }
.pitch-list small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; }
.pitch-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--card); border: 1px solid var(--accent-line); color: var(--metric); }
.pitch-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.pitch-stats b { display: block; font-size: 24px; color: var(--metric); font-variant-numeric: tabular-nums; line-height: 1.1; }
.pitch-stats span { font-size: 12px; color: var(--muted); }
.login-brand { margin-bottom: 18px; }
.login-logo { display: block; width: 100%; max-height: 120px; object-fit: contain; border-radius: 12px; background: var(--logo, #0b1622); padding: 12px; }
.login-brand > .mark { width: 100%; height: 72px; font-size: 30px; border-radius: 12px; }
.login-title { font-size: 20px; margin: 0 0 4px; }
.login-foot { margin: 16px 0 0; font-size: 12px; color: var(--faint); text-align: center; }
@media (max-width: 900px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-shell .login { order: -1; }
    .pitch-list { grid-template-columns: 1fr; }
    .login-pitch { padding: 22px; }
    .login-pitch h1 { font-size: 24px; }
}
.login .btn { width: 100%; margin-top: 16px; }
.login .field + .field { margin-top: 12px; }
.demo-users { margin-top: 16px; font-size: 12px; color: var(--muted); }
.demo-users summary { cursor: pointer; }
.demo-users .badges { margin-top: 8px; }
.demo-users button { border: 1px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 2px 8px; font-size: 12px; cursor: pointer; color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .layout-aside { grid-template-columns: minmax(0, 1fr) 300px; }
    .pipeline { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
    .tiles, .split, .split.even, .layout-aside { grid-template-columns: minmax(0, 1fr); }
    .layout-aside > aside { position: static; }
    .checks.cols, .fields.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rail { grid-template-columns: repeat(var(--steps, 9), minmax(64px, 1fr)); overflow-x: auto; }
}
@media (max-width: 860px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .side {
        position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%);
        transition: transform .2s; box-shadow: var(--shadow);
    }
    body.nav-open .side { transform: none; }
    body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }
    .icon-btn.menu-btn { display: inline-grid; }
    .topbar { padding: 10px 16px; }
    .userchip .who { display: none; }
    .top-actions > .btn { display: none; }
    .search { min-width: 0; }
    .form-actions { justify-content: stretch; }
    .form-actions > *, .form-actions .btn { flex: 1 1 auto; }
    .search kbd, .search-count { display: none; }
    .fields, .fields.three, .checks.cols { grid-template-columns: 1fr; }
    .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .main { padding: 16px; }
    .dl, .review .dl { grid-template-columns: 1fr; gap: 2px; }
    .dl dd { margin-bottom: 8px; }
    .money { grid-template-columns: 1fr; }
    .bars .row { grid-template-columns: 110px 1fr 32px; }
    .wizard-steps li { min-width: 0; }
    .wizard-steps .txt { display: none; }
    .wizard-steps li.on .txt { display: inline; }
}
@media print {
    .side, .topbar, .page-actions, .help, form, .tabs { display: none !important; }
    .app { display: block; }
    [role="tabpanel"][hidden] { display: block !important; }
}
