/* Datum Flota — estilos · creado por Yerko Baeza */
/* Colores de Kypra: morado #6941B4 (marca) y naranja #FA931C (impulso). Claro por defecto, oscuro según el sistema o el selector. */
:root {
  --bg: #f6f4fb; --bg2: #efebf7; --card: #ffffff; --card2: #f8f6fc; --line: #e4dff0; --line2: #d4cce6;
  --text: #1d1830; --text2: #433b5d; --muted: #6f6889;
  --accent: #6941b4; --accent2: #7b52c9; --accent-ink: #ffffff; --accent-soft: rgba(105, 65, 180, 0.10); --accent-text: #6941b4;
  --hl: #fa931c; --hl-text: #c2680a; --hl-soft: rgba(250, 147, 28, 0.12);
  --hero1: #6941b4; --hero2: #4c2a8f; --hero-ink: #ffffff; --m-body: #2a1752; --m-dark: #3c2470; --m-hub: #fa931c;
  --ok: #12935f; --bad: #d63a37; --warn: #c97a0a; --violet: #8a5cd6; --blue: #2b7fe0;
  --side: #ffffff;
  --shadow: 0 10px 30px rgba(45, 25, 90, 0.12);
  --r: 12px;
  --r-sm: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100c19; --bg2: #151022; --card: #1b1629; --card2: #231c34; --line: #2e2642; --line2: #3d3356;
    --text: #efecf6; --text2: #c6bfdb; --muted: #958cab;
    --accent: #7d55d8; --accent2: #9270e6; --accent-ink: #ffffff; --accent-soft: rgba(150, 110, 235, 0.16); --accent-text: #b89df7;
    --hl: #fa931c; --hl-text: #ffab4a; --hl-soft: rgba(250, 147, 28, 0.14);
    --hero1: #5a35a3; --hero2: #2f1a63; --hero-ink: #ffffff; --m-body: #170d30; --m-dark: #24164a; --m-hub: #fa931c;
    --ok: #34c38f; --bad: #f0524f; --warn: #f3b23c; --violet: #a78bfa; --blue: #4ea1ff;
    --side: #151022;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100c19; --bg2: #151022; --card: #1b1629; --card2: #231c34; --line: #2e2642; --line2: #3d3356;
  --text: #efecf6; --text2: #c6bfdb; --muted: #958cab;
  --accent: #7d55d8; --accent2: #9270e6; --accent-ink: #ffffff; --accent-soft: rgba(150, 110, 235, 0.16); --accent-text: #b89df7;
  --hl: #fa931c; --hl-text: #ffab4a; --hl-soft: rgba(250, 147, 28, 0.14);
  --hero1: #5a35a3; --hero2: #2f1a63; --hero-ink: #ffffff; --m-body: #170d30; --m-dark: #24164a; --m-hub: #fa931c;
  --ok: #34c38f; --bad: #f0524f; --warn: #f3b23c; --violet: #a78bfa; --blue: #4ea1ff;
  --side: #151022;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.ic { width: 18px; height: 18px; flex: none; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); text-align: center; padding: 24px; }
.boot img { width: 84px; height: 84px; border-radius: 20px; }

/* ---------- Botones y controles ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line2); background: var(--card2); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; height: 42px; }
.btn .ic { width: 16px; height: 16px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--card2); }
.link { background: none; border: 0; color: var(--accent-text); cursor: pointer; padding: 6px 0; font-weight: 600; }
.x-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-grid; place-items: center; }
.x-btn:hover { color: var(--bad); background: var(--card2); }
.x-btn .ic { width: 14px; height: 14px; }

input, select, textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 38px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 500; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--text2); font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip:hover { border-color: var(--line2); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip b { font-weight: 700; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--card2); color: var(--text2); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.violet { color: var(--violet); background: color-mix(in srgb, var(--violet) 14%, transparent); }
.badge.mute { color: var(--muted); }
.badge.acc { color: var(--accent-ink); background: var(--accent); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: var(--card2); border: 1px solid var(--line); color: var(--text2); white-space: nowrap; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px; gap: 14px; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; background: #fff; }
.brand b { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 11px; }
.me { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.me b { display: block; font-size: 13px; }
.me small { color: var(--muted); font-size: 11.5px; }
.av { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 12px; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text2); font-weight: 500; font-size: 13.5px; position: relative; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); }
.nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a.on .ic { color: var(--accent-text); }
.nav em { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: var(--card2); color: var(--text2); }
.nav em.red { background: var(--bad); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-actions { display: flex; gap: 4px; align-items: center; }
.side-actions .btn { margin-right: auto; }
.pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 9px; padding: 7px 10px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); background: var(--card); color: var(--text2); cursor: pointer; text-align: left; line-height: 1.25; }
.pill .ic { width: 16px; height: 16px; }
.pill.ok .ic { color: var(--ok); }
.pill.off { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.pill.off .ic, .pill.warn .ic { color: var(--warn); }
.pill.busy .ic { color: var(--accent-text); }
.pill.demo { cursor: default; }
.pill.demo .ic { color: var(--violet); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 28px; min-height: 52px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.tb-brand { display: none; align-items: center; gap: 8px; }
.tb-brand img { width: 28px; height: 28px; border-radius: 7px; background: #fff; }
.tb-right { margin-left: auto; }
.viewas { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.viewas span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 8px; }
.viewas button { border: 0; background: transparent; color: var(--text2); font-weight: 600; font-size: 12px; padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.viewas button.on { background: var(--accent); color: var(--accent-ink); }
.view { padding: 26px 28px 60px; max-width: 1280px; width: 100%; outline: none; }
.tabbar { display: none; }

/* ---------- Encabezado de pantalla ---------- */
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head .grow { min-width: 220px; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 4px; }
.head h1 { font-size: 28px; line-height: 1.15; }
.head .sub { color: var(--muted); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.back:hover { color: var(--text); }
.back .ic { width: 15px; height: 15px; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card.pad0 { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h3 { font-size: 14.5px; }
.card-h small { color: var(--muted); }
.card-h .act { margin-left: auto; display: flex; gap: 6px; }
.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-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.kpi .k { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.hl { border-color: color-mix(in srgb, var(--hl) 60%, var(--line)); background: linear-gradient(180deg, var(--hl-soft), transparent 80%), var(--card); }
.kpi.hl .v { color: var(--hl-text); }

.fleetbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--line); gap: 2px; }
.fleetbar i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend b { color: var(--text); }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line); min-width: 0; }
.li:first-child { border-top: 0; }
.li[data-href] { cursor: pointer; }
.li[data-href]:hover { background: color-mix(in srgb, var(--card2) 70%, transparent); }
.li .li-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--card2); display: grid; place-items: center; color: var(--muted); flex: none; }
.li .li-ic.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); }
.li .li-ic.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.li .li-ic.acc { color: var(--accent-text); background: var(--accent-soft); }
.li .li-b { min-width: 0; flex: 1; }
.li .li-b b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .li-b small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .li-r { text-align: right; flex: none; }
.code { font-weight: 800; color: var(--hl-text); letter-spacing: .01em; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card); }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr[data-href] { cursor: pointer; }
.t tr[data-href]:hover td { background: var(--card2); }
.t td small { display: block; color: var(--muted); }
.t .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tfoot td { font-weight: 700; border-top: 1px solid var(--line2); }

/* ---------- Equipos ---------- */
.search { position: relative; flex: 1; min-width: 220px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.eq-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.eq-card:hover { border-color: var(--line2); transform: translateY(-1px); }
.eq-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.eq-top h4 { font-size: 16px; font-weight: 800; }
.eq-model { font-size: 12px; color: var(--muted); margin-top: -6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eq-meta { display: flex; justify-content: space-between; align-items: flex-end; }
.eq-meta .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.eq-meta b { font-size: 15px; font-variant-numeric: tabular-nums; }
.prog { height: 5px; background: var(--line); border-radius: 4px; overflow: hidden; flex: 1; }
.prog i { display: block; height: 100%; border-radius: 4px; }
.eq-prev { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--muted); }
.eq-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.eq-foot .bad { color: var(--bad); }

.hero { position: relative; border-radius: var(--r); overflow: hidden; background: radial-gradient(420px 220px at 85% 110%, rgba(250, 147, 28, .35), transparent 70%), linear-gradient(120deg, var(--hero1) 0%, var(--hero2) 100%); color: var(--hero-ink); padding: 22px 24px; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: center; margin-bottom: 14px; }
.hero::after { content: ""; position: absolute; right: 26%; top: -40%; width: 60px; height: 200%; background: rgba(255, 255, 255, .07); transform: rotate(18deg); }
.hero .kicker { color: rgba(255, 255, 255, .75); }
.hero h1 { font-size: 40px; font-weight: 900; letter-spacing: -0.03em; }
.hero .hsub { font-weight: 600; opacity: .8; }
.hero .row { margin-top: 12px; position: relative; z-index: 1; }
.hero .btn { background: #ffffff; color: #4c2a8f; border-color: transparent; }
.hero .btn.ghost { background: rgba(255, 255, 255, .16); color: #ffffff; }
.hero .badge { background: rgba(255, 255, 255, .92); }
.machine { width: 100%; height: auto; position: relative; z-index: 1; }
.m-body { fill: var(--m-body); }
.m-dark { fill: var(--m-dark); }
.m-glass { fill: rgba(255, 255, 255, .7); }
.m-track { fill: var(--m-body); }
.m-wheel { fill: var(--m-body); }
.m-hub { fill: var(--m-hub); }
.m-shadow { fill: rgba(0, 0, 0, .18); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.facts .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.facts .v { font-weight: 700; font-size: 15px; }
.prev-box { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); }
.ring-t { font-weight: 800; font-size: 17px; fill: var(--text); text-anchor: middle; dominant-baseline: middle; }
.ring-s { font-size: 9px; fill: var(--muted); text-anchor: middle; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 10px 12px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--accent); }

/* ---------- OT ---------- */
.ot-cards { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 12px; margin-bottom: 12px; }
.ot-cards .card small { color: var(--muted); }
.costs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.sec { margin-bottom: 14px; }
.ot-mobile { display: none; }
.line-item { display: grid; gap: 2px; }
.note { padding: 10px 12px; border-radius: 9px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); color: var(--text); font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }
.note .ic { color: var(--accent-text); }
.note.bad { background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.note.bad .ic { color: var(--bad); }
.file-link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-text); font-weight: 600; cursor: pointer; background: none; border: 0; padding: 0; font-size: 12.5px; }
.file-link .ic { width: 14px; height: 14px; }

/* ---------- Gráficos ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.ch-axis { stroke: var(--line2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-val { font-size: 10px; fill: var(--text2); text-anchor: middle; font-weight: 600; }
.ch-val.sm { font-size: 9px; }
.ch-lab { font-size: 10px; fill: var(--muted); text-anchor: middle; }
.rank { display: flex; flex-direction: column; gap: 7px; }
.rank-row { display: grid; grid-template-columns: 150px 1fr 110px; align-items: center; gap: 10px; font-size: 12.5px; }
.rank-row[data-href] { cursor: pointer; }
.rank-row[data-href]:hover b { color: var(--accent-text); }
.rank-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-l b { color: var(--hl-text); }
.rank-l small { color: var(--muted); }
.rank-bar { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 5px; }
.rank-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Centros ---------- */
.cc-card { cursor: pointer; transition: border-color .15s; }
.cc-card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cc-card .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cc-card h4 { font-size: 13.5px; margin: 6px 0 2px; }
.cc-card .v { font-size: 20px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.kv:first-child { border-top: 0; }
.kv b { font-variant-numeric: tabular-nums; }

/* ---------- Configuración ---------- */
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sys { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sys-h { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills span { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; padding: 3px 4px 3px 9px; border-radius: 7px; background: var(--card); border: 1px solid var(--line); }
.sys input { min-height: 30px; padding: 5px 9px; font-size: 12.5px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { cursor: pointer; }
.swatches input { display: none; }
.swatches span { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--card); }
.swatches input:checked + span { border-color: var(--text); }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg input { display: none; }
.seg span { display: block; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text2); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }

/* ---------- Usuarios ---------- */
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.ucard { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.ucard.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ucard b { display: block; font-size: 13.5px; }
.ucard small { color: var(--muted); display: block; }
.ucard .av.off { background: var(--line2); color: var(--muted); }
.switch { position: relative; width: 36px; height: 21px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line2); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%; left: 3px; top: 3px; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(15px); }
.switch input:disabled + span { opacity: .55; cursor: not-allowed; }
.perm-t td:not(:first-child), .perm-t th:not(:first-child) { text-align: center; width: 120px; }

/* ---------- Modales ---------- */
body.has-modal { overflow: hidden; }
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(5, 6, 8, .62); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; overflow-y: auto; }
.modal-wrap.out { opacity: 0; transition: opacity .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); background: var(--card); border: 1px solid var(--line2); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; animation: pop .18s ease; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { width: min(760px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-intro { margin: -4px 0 0; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.field { grid-column: span 6; min-width: 0; }
.field.half { grid-column: span 3; }
.field.third { grid-column: span 2; }
.help { display: block; color: var(--muted); margin-top: 4px; }
.form-error { color: var(--bad); margin: 0; font-size: 13px; font-weight: 600; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 76px; border: 1.5px dashed var(--line2); border-radius: 10px; cursor: pointer; text-align: center; padding: 10px; background: var(--bg2); }
.file-drop input { display: none; }
.file-drop .fd-name { font-weight: 700; }
.file-drop small { color: var(--muted); }
.file-drop.drag, .file-drop.has { border-color: var(--accent); background: var(--accent-soft); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Avisos ---------- */
#toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: 24px; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; box-shadow: var(--shadow); animation: pop .2s ease; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn); color: #1d1830; }
.toast.out { opacity: 0; transition: opacity .4s; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .ic { width: 30px; height: 30px; margin-bottom: 6px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 10% 0%, var(--accent-soft), transparent 60%), radial-gradient(700px 420px at 100% 100%, var(--hl-soft), transparent 60%), var(--bg); }
.login-card { width: min(400px, 100%); text-align: center; }
.login-logo { width: 260px; max-width: 80%; height: auto; }
.login h1 { font-size: 38px; font-weight: 900; margin-top: 16px; letter-spacing: -0.02em; }
.login h1 span { color: var(--hl-text); }
.login .kicker { margin-bottom: 22px; }
.login-form { text-align: left; display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 10px; }
.login-form .lbl { margin-top: 6px; }
.login-form .btn { margin-top: 10px; }
.adv summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.adv input { margin-bottom: 6px; }
.login-note { color: var(--text2); margin: 0 0 16px; }
.login-foot { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- Hoja "Más" (celular) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(5, 6, 8, .55); display: flex; align-items: flex-end; animation: fade .15s; }
.sheet { width: 100%; background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-me { display: flex; gap: 10px; align-items: center; }
.sheet-me b { display: block; }
.sheet-me small { color: var(--muted); }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sheet-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; text-align: center; position: relative; }
.sheet-grid a .ic { color: var(--accent-text); width: 22px; height: 22px; }
.sheet-grid em { position: absolute; top: 6px; right: 8px; font-style: normal; background: var(--bad); color: #fff; font-size: 10px; font-weight: 800; border-radius: 8px; padding: 1px 6px; }
.sheet-foot { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr 220px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 8px; }
  .tb-brand { display: flex; }
  .tb-right .pill span { display: none; }
  .tb-right .pill { padding: 7px; }
  .viewas span { display: none; }
  .viewas button { padding: 5px 7px; font-size: 11px; }
  .view { padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 4px 0; position: relative; cursor: pointer; }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar .on { color: var(--accent-text); }
  .tabbar em { position: absolute; top: 0; left: calc(50% + 6px); font-style: normal; background: var(--bad); color: #fff; font-size: 9.5px; font-weight: 800; border-radius: 8px; padding: 0 5px; line-height: 15px; }
  .head h1 { font-size: 23px; }
  .head { margin-bottom: 14px; gap: 10px; }
  .head > .row { width: 100%; }
  .head > .row .btn { flex: 1; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 21px; }
  .hero { grid-template-columns: 1fr; padding: 18px; }
  .hero h1 { font-size: 32px; }
  .hero .machine { max-width: 240px; margin: -10px auto -6px; }
  .ot-cards { grid-template-columns: 1fr; }
  .costs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ot-table { display: none; }
  .ot-mobile { display: block; }
  .rank-row { grid-template-columns: 100px 1fr 86px; }
  .field.half, .field.third { grid-column: span 6; }
  .modal-wrap { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .t th, .t td { padding: 9px 8px; }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .perm-t td:not(:first-child), .perm-t th:not(:first-child) { width: 70px; }
}
@media (max-width: 420px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
}
@media print {
  .side, .topbar, .tabbar { display: none !important; }
  .shell { display: block; }
}

.credit { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.login-author { margin-top: 6px; font-size: 12px; color: var(--muted); }
.login-author b { color: var(--text2); }

.brand small { display: block; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Marca Kypra */
.brand img, .tb-brand img { background: #ffffff; padding: 3px; object-fit: contain; border: 1px solid var(--line); }
.logo-oscuro { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-claro { display: none; } :root:not([data-theme="light"]) .logo-oscuro { display: inline-block; } }
:root[data-theme="dark"] .logo-claro { display: none; }
:root[data-theme="dark"] .logo-oscuro { display: inline-block; }
.kypra-credit { display: grid; gap: 4px; padding: 8px 4px 0; border-top: 1px solid var(--line); }
.kypra-credit small { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kypra-credit img { width: 140px; height: auto; }
.login-app { margin-top: 18px; }
.login-app h1 { font-size: 30px; margin-top: 0; }
.hero h1 { color: #ffffff; }
