:root {
  --brand: #12306e; --brand-2: #1d4596; --brand-soft: #e8eef9; --ink: #1b2333; --muted: #5c677d; --line: #dfe4ee;
  --bg: #f4f6fa; --card: #fff; --ok: #1d7a46; --warn: #a15c00; --err: #b3261e; --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; color: var(--brand); }
h2 { font-size: 17px; margin: 22px 0 10px; color: var(--brand); }
h3 { font-size: 15px; margin: 16px 0 8px; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #fff; padding: 16px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { background: #fff; margin: 0 14px 18px; border-radius: 8px; padding: 10px; text-align: center; }
.side .logo img { max-width: 100%; height: 54px; object-fit: contain; }
.side .logo div { color: var(--brand); font-weight: 700; font-size: 15px; margin-top: 4px; letter-spacing: .3px; }
.side nav a { display: block; color: #dfe7f8; padding: 9px 20px; font-size: 14px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side nav a.active { background: rgba(255,255,255,.14); border-left-color: #fff; color: #fff; font-weight: 600; }
.side nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #9fb3dc; padding: 14px 20px 4px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .grow { flex: 1; }
.top select { min-width: 260px; }
.content { padding: 22px 24px 60px; max-width: 1400px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.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)); }
.stat { font-size: 26px; font-weight: 700; color: var(--brand); } .stat-l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c9d1e0; border-radius: 6px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9db6ea; border-color: var(--brand-2); }
textarea { min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
button, .btn { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none !important; white-space: nowrap; }
button:hover, .btn:hover { background: var(--brand-2); }
button.sec, .btn.sec { background: #fff; color: var(--brand); }
button.sec:hover, .btn.sec:hover { background: var(--brand-soft); }
button.danger { background: var(--err); border-color: var(--err); }
button.sm, .btn.sm { padding: 3px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f0f3f9; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click:hover td { background: #f6f8fd; cursor: pointer; }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); max-height: 70vh; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eef1f6; color: var(--muted); }
.badge.ok { background: #e3f4ea; color: var(--ok); } .badge.warn { background: #fff1dc; color: var(--warn); } .badge.err { background: #fde7e6; color: var(--err); }
.badge.REM { background: #e3f4ea; color: var(--ok); } .badge.NOREM { background: #e6eefc; color: var(--brand-2); } .badge.DESC { background: #fde7e6; color: var(--err); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.alert { padding: 10px 14px; border-radius: 6px; background: #fff6e5; border: 1px solid #f3d49b; color: #6b4300; margin-bottom: 12px; }
.alert.info { background: var(--brand-soft); border-color: #c4d3f2; color: var(--brand); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 16px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); text-decoration: none; }
.modal { position: fixed; inset: 0; background: rgba(15, 25, 50, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 10px; width: min(900px, 100%); padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.hidden { display: none !important; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; z-index: 60; max-width: 420px; }
.toast.err { background: var(--err); }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #12306e, #2a58b3); padding: 16px; }
.login .box { background: #fff; padding: 30px 32px; border-radius: 12px; width: 380px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login img { width: 100%; max-width: 260px; display: block; margin: 0 auto 6px; }
.login h1 { text-align: center; margin-bottom: 20px; }
.nov input { width: 82px; padding: 4px 6px; text-align: right; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 11px; color: var(--muted); }
.chart .b span { display: block; width: 100%; max-width: 46px; background: var(--brand-2); border-radius: 4px 4px 0 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--brand); color: #fff; border-radius: 10px; padding: 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-weight: 600; }
.tile:nth-child(4n+2), .tile:nth-child(4n+4) { background: #c0562b; }
.tile:hover { text-decoration: none; filter: brightness(1.1); } .tile span { font-size: 28px; }
th a { color: inherit; text-decoration: underline dotted; }
.vars { columns: 3; font-size: 12.5px; } .vars div { break-inside: avoid; margin-bottom: 4px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; }
  .side nav { display: flex; flex-wrap: wrap; } .side nav .sep { display: none; } .side .logo { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .top { flex-wrap: wrap; padding: 10px 16px; } .top select { min-width: 0; width: 100%; }
  .content { padding: 16px; } .vars { columns: 1; }
}

/* ---------- impresión ---------- */
.print-bar { padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; position: sticky; top: 0; }
.sheet { background: #fff; width: 210mm; margin: 14px auto; padding: 8mm 10mm; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.recibo { border: 1px solid #333; padding: 0; margin-bottom: 6mm; font-size: 10.5px; page-break-inside: avoid; color: #000; }
.recibo .hd { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid #333; padding: 6px 8px; gap: 8px; }
.recibo .hd b { font-size: 12px; }
.recibo .copy { font-weight: 700; text-align: right; font-size: 10px; }
.recibo .dat { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid #333; }
.recibo .dat div { padding: 3px 6px; border-right: 1px solid #ccc; } .recibo .dat div:nth-child(4n) { border-right: 0; }
.recibo .dat small { display: block; color: #555; font-size: 8.5px; text-transform: uppercase; }
.recibo table { font-size: 10.5px; } .recibo th { background: #eee; color: #000; font-size: 9px; padding: 3px 6px; position: static; border-bottom: 1px solid #333; }
.recibo td { padding: 2px 6px; border-bottom: 0; }
.recibo .items { min-height: 160px; border-bottom: 1px solid #333; }
.recibo .tot td { border-top: 1px solid #333; font-weight: 700; }
.recibo .ft { display: grid; grid-template-columns: 1.4fr 1fr; }
.recibo .ft > div { padding: 5px 8px; } .recibo .ft > div + div { border-left: 1px solid #333; }
.recibo .firma { margin-top: 26px; border-top: 1px solid #000; text-align: center; padding-top: 2px; font-size: 9px; }
.rep { font-size: 11.5px; color: #000; } .rep table th { position: static; }
@media print {
  body { background: #fff; } .no-print, .print-bar { display: none !important; }
  .sheet { box-shadow: none; margin: 0; width: auto; padding: 0; }
  @page { size: A4; margin: 8mm; }
}
