:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1f2933;
  --ink-2: #4b5563;
  --muted: #6b7280;
  --line: #e3e6ea;
  --line-2: #d1d5db;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eef2ff;
  --ok: #15803d; --ok-soft: #ecfdf3;
  --warn: #b45309; --warn-soft: #fff7e6;
  --bad: #b91c1c; --bad-soft: #fef2f2;
  --info: #1e40af; --info-soft: #eff4ff;
  --input: #fffdf3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #16202a; color: #cbd2d9; display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 22px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 9px; height: 3px; border-radius: 2px; background: #fff; }
.brand-mark::before { top: 11px; width: 16px; box-shadow: 0 6px 0 #fff; }
.brand-mark::after { top: 23px; width: 10px; }
.brand-name { color: #fff; font-weight: 650; font-size: 15px; }
.brand-emp { font-size: 12px; color: #9aa5b1; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #cbd2d9; text-decoration: none; font-weight: 500; }
nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(255,255,255,.1); color: #fff; }
nav a.nav-cta { background: var(--accent); color: #fff; margin: 6px 0 10px; }
nav a.nav-cta:hover { background: #1e40af; }
.side-foot { margin-top: auto; font-size: 12px; color: #7b8794; padding: 0 8px; }

main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 2px 0 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.two { grid-template-columns: 1.35fr 1fr; align-items: start; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.quick button { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; box-shadow: var(--shadow); }
.quick button:hover { border-color: var(--accent); }
.quick .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.quick .ic svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.quick b { display: block; font-size: 15.5px; }
.quick span { color: var(--muted); font-size: 13px; }

.avisos { display: flex; flex-direction: column; gap: 10px; }
.aviso { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 11px 14px 11px 0; background: var(--surface); }
.aviso::before { content: ""; align-self: stretch; border-radius: 0 3px 3px 0; background: var(--info); }
.aviso.lv-alerta { background: var(--bad-soft); border-color: #f5c2c2; } .aviso.lv-alerta::before { background: var(--bad); }
.aviso.lv-aviso { background: var(--warn-soft); border-color: #f3dcae; } .aviso.lv-aviso::before { background: var(--warn); }
.aviso.lv-info::before { background: var(--info); }
.aviso.lv-ok { background: var(--ok-soft); border-color: #bfe8cd; } .aviso.lv-ok::before { background: var(--ok); }
.aviso .t { font-weight: 600; }
.aviso .d { color: var(--ink-2); font-size: 13.5px; margin-top: 1px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--bad); border-color: #f1b5b5; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.f { display: flex; flex-direction: column; gap: 5px; grid-column: span 3; min-width: 0; }
.f.s2 { grid-column: span 2; } .f.s4 { grid-column: span 4; } .f.s6 { grid-column: span 6; }
.f label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.f label .req { color: var(--bad); }
.f .hint { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--input); min-height: 40px;
}
select { background: #fff; }
textarea { min-height: 70px; resize: vertical; }
input.big { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; font-size: 13.5px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--ink); color: #fff; }
.calc { grid-column: span 6; display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 14px; background: var(--accent-soft); border-radius: 8px; font-variant-numeric: tabular-nums; }
.calc div span { display: block; font-size: 12px; color: var(--muted); }
.calc div b { font-size: 17px; }
.note-box { grid-column: span 6; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; }
.note-box.warn { background: var(--warn-soft); color: #7a3e06; }
.note-box.bad { background: var(--bad-soft); color: #7f1d1d; }
.drop { grid-column: span 6; border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfc; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop b { color: var(--ink); }
.drop.has { border-style: solid; border-color: #bfe8cd; background: var(--ok-soft); color: var(--ok); }
.actions { grid-column: span 6; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.actions .left { margin-right: auto; }
.tabs { display: inline-flex; gap: 4px; background: #e9ecf0; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; padding: 8px 16px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--ink-2); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-height: 36px; padding: 6px 10px; background: #fff; }
.filters input[type=search] { min-width: 220px; flex: 1; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f8fafc; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .sm { display: block; font-size: 12.5px; color: var(--muted); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tfoot td { font-weight: 650; border-top: 1.5px solid var(--ink); border-bottom: 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.pend { background: var(--warn-soft); color: var(--warn); }
.clip { color: var(--muted); }
.clip.yes { color: var(--ok); }
.clip svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; vertical-align: middle; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 96px; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.mini-bar { height: 7px; background: var(--accent); border-radius: 99px; min-width: 2px; }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 22px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.small { width: min(440px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 18px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }

.settings { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 13px; word-break: break-all; }

/* usuario en la barra lateral */
.side-user { margin-top: auto; display: flex; align-items: center; gap: 6px; border-top: 1px solid rgba(255,255,255,.08); padding: 14px 4px 0; }
.yo { display: flex; align-items: center; gap: 10px; color: #e4e7eb; text-decoration: none; flex: 1; min-width: 0; padding: 6px; border-radius: 8px; }
.yo:hover, .yo.active { background: rgba(255,255,255,.06); }
.yo > span:last-child { display: flex; flex-direction: column; min-width: 0; font-weight: 600; font-size: 14px; }
.yo small { color: #9aa5b1; font-weight: 400; font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2d3b4a; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.btn-salir { background: transparent; border: 0; color: #9aa5b1; padding: 8px; border-radius: 8px; cursor: pointer; }
.btn-salir:hover { background: rgba(255,255,255,.08); color: #fff; }
.btn-salir svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.solo-movil { display: none !important; }
.lbl-corto { display: none; }
main, .card, .modal, td, h1, h2, .aviso .t, .aviso .d { overflow-wrap: anywhere; }
.grid > *, .two > *, .settings > * { min-width: 0; }

/* login */
body.sin-sesion .side { display: none; }
body.sin-sesion .app { grid-template-columns: 1fr; }
body.sin-sesion main { max-width: none; }
.login-wrap { min-height: calc(100vh - 90px); display: grid; place-items: center; }
.login { width: min(400px, 100%); display: grid; gap: 14px; padding: 28px; }
.login .f { grid-column: auto; }
.login h1 { font-size: 22px; }
.login-brand { padding: 0; }
.login-brand .brand-name { color: var(--ink); }
.big-btn { padding: 12px 16px; font-size: 16px; width: 100%; }

.quien { margin: -6px 0 14px; font-size: 13px; color: var(--muted); }
.pasos { padding-left: 20px; margin: 0 0 12px; }
.pasos li { margin-bottom: 12px; }
.qr { margin: 10px 0; }
.qr svg { width: 200px; height: 200px; display: block; border: 1px solid var(--line); border-radius: 8px; }
.clave { background: #f3f4f6; padding: 8px 10px; border-radius: 6px; margin-top: 6px; display: inline-block; letter-spacing: .05em; }

/* móvil */
@media (max-width: 900px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; z-index: 40; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); flex-direction: row; background: #16202a; border-top: 1px solid rgba(255,255,255,.08); }
  .side .brand, .side-user { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); }
  main { min-width: 0; }
  .lbl-largo { display: none; }
  .lbl-corto { display: inline; }
  nav { flex-direction: row; justify-content: space-around; width: 100%; gap: 0; }
  nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; text-align: center; }
  nav a svg { width: 22px; height: 22px; }
  nav a.nav-cta { margin: 0; background: transparent; color: #fff; }
  nav a.nav-cta svg { background: var(--accent); border-radius: 50%; padding: 4px; width: 30px; height: 30px; margin-top: -4px; }
  .solo-escritorio { display: none !important; }
  .solo-movil { display: flex !important; }
  main { padding: 18px 14px calc(90px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 21px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .val { font-size: 19px; }
  .card { padding: 14px; }
  .two, .settings, .quick { grid-template-columns: 1fr; }
  .f, .f.s2, .f.s4 { grid-column: span 6; }
  .bar-row { grid-template-columns: 110px 1fr 84px; }
  .filters select, .filters input[type=search] { flex: 1 1 140px; min-width: 0; }
  td .sm { max-width: 180px; }
  input[type=text], input[type=date], input[type=password], select, textarea { font-size: 16px; } /* evita el zoom en iPhone */
  .modal { padding: 16px; border-radius: 12px; }
  .modal-bg { padding: 8px; align-items: end; }
  .actions .btn { flex: 1; }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.sin-sesion main { padding-bottom: 18px; }
}
input[type=password] { width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--input); min-height: 40px; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
