:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --ink: #1b2420;
  --muted: #5b6861;
  --line: #dde4df;
  --side: #1b2420;
  --side-ink: #d4ded8;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fdebe1;
  --ok: #15803d; --ok-soft: #e3f4e8;
  --warn: #a15c07; --warn-soft: #fdf1dc;
  --bad: #b91c1c; --bad-soft: #fde4e4;
  --info: #1d4ed8; --info-soft: #e3eafc;
  --gray-soft: #eceff0;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--font); background: var(--bg); color: var(--ink); }
#app { display: flex; min-height: 100%; }
#lateral { width: 220px; flex: none; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; position: sticky; top: 0; height: 100vh; }
#lateral[hidden] { display: none; }
.marca { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.marca small { display: block; color: #9fb1a7; font-size: 12px; }
.marca b { color: #fff; font-size: 16px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--side-ink); text-decoration: none; padding: 9px 12px; border-radius: 8px; font-weight: 600; }
nav a:hover { background: rgba(255,255,255,.06); }
nav a.on { background: rgba(255,255,255,.12); color: #fff; }
.pie { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 0 8px; font-size: 13px; color: #9fb1a7; gap: 8px; }
.pie .link { color: #fff; }
main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 36px) 48px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.fila { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.entre { justify-content: space-between; }
.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; }
.dos { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: #b8c3bc; }
button.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.pri:hover { background: #a8380a; }
button.peligro { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, nav a:focus-visible { outline: 3px solid #f0a07a; outline-offset: 1px; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabla th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tabla tr.click { cursor: pointer; }
.tabla tr.click:hover td { background: #f8faf8; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.p-al_dia { background: var(--ok-soft); color: var(--ok); }
.p-por_vencer { background: var(--warn-soft); color: var(--warn); }
.p-en_gracia { background: var(--accent-soft); color: var(--accent); }
.p-vencido, .p-suspendido { background: var(--bad-soft); color: var(--bad); }
.p-sin_pago { background: var(--info-soft); color: var(--info); }
.p-baja { background: var(--gray-soft); color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.vacio { color: var(--muted); padding: 18px 0; }
.clave { font-family: Consolas, "Courier New", monospace; font-size: 18px; font-weight: 700; letter-spacing: .05em; background: var(--bg); padding: 6px 12px; border-radius: 8px; user-select: all; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }
.mini { font-size: 13px; }
.historial { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow: auto; }
.historial li { border-left: 3px solid var(--line); padding-left: 10px; }
.historial small { color: var(--muted); display: block; }
.modal { position: fixed; inset: 0; background: rgba(20, 28, 24, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal .caja { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal .acciones { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.aviso { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 30; max-width: calc(100vw - 32px); }
.aviso.mal { background: var(--bad); }
.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 16px; width: 100%; }
.entrada .tarjeta { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.cabeza { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.datos dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.datos dd { margin: 0 0 10px; }
@media (max-width: 760px) {
  .tabla .opt { display: none; }
  #app { flex-direction: column; }
  #lateral { width: auto; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  nav { flex-direction: row; }
  .pie { margin: 0 0 0 auto; }
}
