/* Registro de Fallas — tema oscuro industrial, alto contraste, táctil (≥44 px). */
:root {
  --bg: #0F1318; --bar: #12171D; --surf: #171D25; --surf2: #1E252F; --line: #2C3541; --line2: #232B36;
  --text: #E8EDF3; --text2: #C7D0DB; --muted: #9AA6B4;
  --accent: #F5A524; --accent-hi: #FFC35C; --on-accent: #141414;
  --red: #D93A40; --red-bg: #3A1D20; --red-tx: #FF9A9D;
  --amb-bg: #3A2E14; --amb-tx: #F5C15A;
  --gray-bg: #262C35; --gray-tx: #B8C2CE;
  --ok: #3CC7A6; --ok-bg: #123A33;
  --warn: #C9B27A;
  --radius: 14px; --radius-sm: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Consolas", monospace;
}
:root { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent); } a:hover { color: var(--accent-hi); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- utilidades ---------- */
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
.accent { color: var(--accent); } .warn { color: var(--warn); } .ok { color: var(--ok); }
.t-strong { font-weight: 600; font-size: 16px; } .grow { flex: 1 1 auto; } .minw0 { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.h-cap { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.h-title { font-size: 20px; font-weight: 700; }
.sep { border: 0; height: 1px; background: var(--line2); margin: 4px 0; width: 100%; }
.empty { padding: 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.link { color: var(--accent); }
.center { text-align: center; align-items: center; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 16px; background: var(--bar); border-bottom: 1px solid #222A34; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand svg { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--text2); text-decoration: none; font-weight: 500; min-height: 40px; display: inline-flex; align-items: center; }
.nav a:hover { background: var(--surf2); color: var(--text); }
.nav a.on { background: var(--surf2); color: var(--accent); }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.who-name { font-weight: 600; font-size: 14px; } .who-rol { font-size: 12px; color: var(--muted); }
.btn-icon { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--surf2); border: 1px solid var(--line);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; flex: 0 0 auto; }
@media (max-width: 560px) { .who-rol { display: none; } .brand span { display: none; } .who { flex: 1 1 auto; } }

/* ---------- páginas ---------- */
.page { padding: 16px; display: flex; flex-direction: column; gap: 16px; margin: 0 auto; width: 100%; }
.tec-page { max-width: 680px; }
.wide { max-width: 1320px; }
.narrow { max-width: 520px; padding-top: 48px; }
.error-code { font: 600 64px var(--mono); color: var(--accent); }

/* ---------- avisos ---------- */
.flashes { position: sticky; top: 60px; z-index: 30; display: flex; flex-direction: column; gap: 8px; padding: 8px 16px 0; max-width: 1320px; margin: 0 auto; }
.flash { padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 500; transition: opacity .4s; }
.flash-ok { background: var(--ok-bg); color: #9BF0DA; border: 1px solid #1F5E52; }
.flash-error { background: var(--red-bg); color: var(--red-tx); border: 1px solid #5A2A2E; }
.flash.fade { opacity: 0; pointer-events: none; }

/* ---------- botones ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surf2);
  color: var(--text); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #3E4A5A; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hi); color: var(--on-accent); }
.btn-outline { background: var(--surf2); border-color: var(--accent); color: var(--amb-tx); }
.btn-danger { background: var(--red-bg); border-color: #5A2A2E; color: var(--red-tx); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn-xl { min-height: 64px; font-size: 18px; font-weight: 700; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn.is-disabled { background: #262C35; border-color: #262C35; color: #7E8A99; }

/* ---------- tarjetas ---------- */
.card { background: var(--surf); border: 1px solid var(--line2); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 12px; }
.card-open { border-color: #3A3120; }
.card-locked { background: #1A1A14; border-color: #3A3120; gap: 6px; align-items: flex-start; }
.live { display: flex; align-items: center; gap: 8px; color: var(--amb-tx); font-size: 13px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.list { padding: 0; gap: 0; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; align-items: center; }
.list-row + .list-row { border-top: 1px solid var(--line2); }
.list-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
.sec-head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; }

/* ---------- pills ---------- */
.pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; display: inline-block; }
.pill-total { background: var(--red-bg); color: var(--red-tx); }
.pill-parcial { background: var(--amb-bg); color: var(--amb-tx); }
.pill-sin { background: var(--gray-bg); color: var(--gray-tx); }
.pill-abierto { background: var(--amb-bg); color: var(--amb-tx); }
.pill-cerrado { background: var(--ok-bg); color: #8FE8D2; }
.pill-anulado { background: var(--gray-bg); color: var(--gray-tx); text-decoration: line-through; }

/* ---------- formularios ---------- */
.label { font-size: 12px; color: var(--muted); }
.input { width: 100%; min-height: 44px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line);
  color: var(--text); padding: 10px 12px; }
textarea.input { resize: vertical; min-height: 64px; }
select.input { appearance: auto; }
fieldset { margin: 0; min-width: 0; }
fieldset.card { border: 1px solid var(--line2); }
legend.sec-head { float: left; margin-bottom: 0; }
legend.sec-head + * { clear: both; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 720px) { .tec-page .grid-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.chip-in { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip { min-height: 44px; padding: 0 14px; border-radius: var(--radius-sm); background: var(--surf2); color: #D6DEE8;
  border: 1px solid var(--line); font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; white-space: nowrap; text-align: center; }
a.chip { text-decoration: none; }
.grid-3r { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 440px) { .grid-3r { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chip-full { width: 100%; white-space: normal; padding: 6px 8px; line-height: 1.2; }
.chip.on, .chip-in:checked + .chip { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.chip-in:focus-visible + .chip, .chip-in:focus-visible + .imp, .chip-in:focus-visible + .row-opt { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-in:disabled + .chip { cursor: default; }

.row-opt { min-height: 52px; width: 100%; padding: 0 14px; border-radius: var(--radius-sm); background: var(--surf2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
.chip-in:checked + .row-opt { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.badge-freq { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ok-bg); color: #6FE0C4; }
.chip-in:checked + .row-opt .badge-freq { background: rgba(0,0,0,.18); color: var(--on-accent); }
.causa-grupo { display: flex; flex-direction: column; gap: 8px; }

.imp { min-height: 92px; padding: 10px; border-radius: 12px; background: var(--surf2); border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; gap: 5px; cursor: pointer; color: #D6DEE8; }
.imp-dot { width: 10px; height: 10px; border-radius: 50%; }
.imp-total .imp-dot { background: #FF6B6F; } .imp-parcial .imp-dot { background: var(--accent); } .imp-sin .imp-dot { background: #8A96A6; }
.imp-t { font-weight: 700; line-height: 1.15; } .imp-d { font-size: 12px; opacity: .85; line-height: 1.25; }
.chip-in:checked + .imp-total { background: var(--red); border-color: var(--red); color: #fff; }
.chip-in:checked + .imp-parcial { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip-in:checked + .imp-sin { background: #A8B3C1; border-color: #A8B3C1; color: var(--on-accent); }
.chip-in:checked + .imp .imp-dot { background: currentColor; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; background: var(--surf);
  border: 1px solid var(--line2); border-radius: 12px; margin: 0; }
.seg > a, .seg > label { min-height: 44px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 500; text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.seg > a.on, .seg > input:checked + label { background: #2A3340; color: #fff; border-color: #3E4A5A; font-weight: 700; }
.seg > input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.sec .ok-mark { width: 18px; height: 18px; }
.sec.done .ok-mark { background: no-repeat center/18px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233CC7A6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E"); }
.shake { animation: shake .35s; border-color: var(--red) !important; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.tec-form .only-posterior { display: none; }
.tec-form.is-posterior .only-posterior { display: flex; }
.tec-form[data-modo="cerrar"] .only-posterior, .tec-form[data-modo="editar"] .only-posterior { display: flex; }
.form-spacer { height: 110px; }
.sticky-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--bar); border-top: 1px solid #222A34;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.sticky-foot > * { max-width: 648px; width: 100%; margin: 0 auto; }
.progress { position: sticky; top: 60px; z-index: 19; height: 3px; background: var(--surf2); }
.progress-bar { height: 3px; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 0 auto; padding: 32px 16px; display: flex; flex-direction: column; gap: 16px; }
.login-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--surf2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--accent); }
.pin-display { font: 600 24px var(--mono); letter-spacing: .4em; text-align: center; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad button { min-height: 60px; border-radius: 12px; background: var(--surf2); border: 1px solid var(--line);
  font: 600 22px var(--mono); cursor: pointer; }
.pinpad .pin-ok { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-family: var(--font); }

/* ---------- admin / automatización ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surf); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.kpi-v { font: 600 26px var(--mono); }
.kpi-l { font-size: 12px; color: var(--muted); }
.kpi-red .kpi-v { color: var(--red-tx); } .kpi-amb .kpi-v { color: var(--amb-tx); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 12px; }
.chart-box { position: relative; height: 300px; }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filtros .acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line2); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  background: var(--surf); padding: 10px 12px; position: sticky; top: 0; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-top: 1px solid var(--line2); vertical-align: top; }
.tbl tr:hover td { background: #141A21; }
.tbl .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.tbl a { text-decoration: none; }
.pag { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.dot-on { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dot-off { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #4A5563; margin-right: 6px; }
pre.json { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.4 var(--mono); color: var(--text2); }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form .input { min-height: 36px; padding: 6px 10px; width: auto; flex: 1 1 140px; }
.tag-off { color: var(--muted); text-decoration: line-through; }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
