:root {
  --bg: #0f1720; --panel: #17212b; --panel2: #1e2b38; --line: #2a3a4a;
  --txt: #e6edf3; --muted: #8aa0b2; --brand: #2dd4bf; --brand2: #14b8a6;
  --danger: #f87171; --warn: #fbbf24; --ok: #34d399; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 15px; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 9px 14px;
  background: var(--brand); color: #04201c; font-weight: 600; }
button.ghost { background: transparent; color: var(--txt); border: 1px solid var(--line); }
button.sm { padding: 5px 10px; font-size: 13px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
input, select, textarea { font: inherit; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 340px; }
.brandmark { font-size: 22px; font-weight: 800; letter-spacing: .3px; }
.brandmark span { color: var(--brand); }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; }
.side .nav a { display: flex; gap: 9px; align-items: center; padding: 10px 12px; border-radius: 8px;
  color: var(--muted); margin-bottom: 2px; font-weight: 500; }
.side .nav a.active, .side .nav a:hover { background: var(--panel2); color: var(--txt); }
.main { padding: 26px 30px; max-width: 1100px; }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 17px; margin: 26px 0 12px; }
.sub { color: var(--muted); font-size: 13px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi.red .v { color: var(--danger); } .kpi.ok .v { color: var(--ok); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--panel2); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.BORRADOR { background: #3a3320; color: var(--warn); }
.pill.EMITIDO, .pill.EN_CURSO { background: #123a33; color: var(--ok); }
.pill.CERRADO, .pill.RESUELTO { background: #1e2b38; color: var(--muted); }
.pill.SOLICITADO { background: #2a2140; color: #c4b5fd; }
.pill.RECHAZADO { background: #3a1f20; color: var(--danger); }
.pill.deuda { background: #3a1f20; color: var(--danger); }
.pill.aldia { background: #123a33; color: var(--ok); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1; min-width: 130px; }
.bar { height: 10px; background: var(--panel2); border-radius: 999px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; }
.modal { width: 460px; max-width: 92vw; max-height: 90vh; overflow: auto; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--line);
  padding: 12px 16px; border-radius: 8px; z-index: 100; }
.toast.err { border-color: var(--danger); color: var(--danger); }
@media (max-width: 780px) { .shell { grid-template-columns: 1fr; } .side { display: none; } .kpis { grid-template-columns: repeat(2,1fr); } }
