:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #18212b;
  --ink-2: #4a5765;
  --ink-3: #7b8794;
  --line: #e3e8ee;
  --line-2: #cfd7e0;
  --brand: #1d4e89;
  --brand-2: #163c6a;
  --brand-soft: #e8f0fa;
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf3e1;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --input: #f7fbff;
  --input-line: #b9cde4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
small { color: var(--ink-3); }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- estructura ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; background: #0f2a4a; color: #dbe6f3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: .98rem; }
.brand small { color: #9fb6d0; font-size: .78rem; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: #fff; color: var(--brand); font-weight: 800; display: grid; place-items: center; letter-spacing: -.5px; }
.side nav { flex: 1; overflow-y: auto; padding: 4px 8px; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: #cfdcec; font-size: .93rem; }
.side nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.side nav a.on { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; }
.nav-sep { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #86a0bd; padding: 16px 10px 6px; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding: 10px 8px; display: flex; align-items: center; gap: 6px; }
.me { display: flex; gap: 8px; align-items: center; color: #e7eef7; flex: 1; min-width: 0; padding: 4px; border-radius: 8px; font-size: .88rem; }
.me:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.me small { display: block; color: #93abc6; font-size: .74rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2f6db3; color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.btn-ghost { background: none; border: 0; color: #cfdcec; display: flex; gap: 6px; align-items: center; cursor: pointer; padding: 8px; border-radius: 8px; font: inherit; font-size: .85rem; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.top h1 { font-size: 1.45rem; margin: 0; }
.menu-btn { display: none; border: 1px solid var(--line-2); background: var(--card); border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }
.content { padding: 12px 28px 40px; max-width: 1280px; }
.main.wide .content { max-width: none; }
.flash { margin: 8px 28px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); border: 1px solid #b8e0c9; max-width: 1224px; }
.flash.err { background: var(--bad-soft); color: var(--bad); border-color: #f5c2bd; }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: #f3d9a6; }

@media (max-width: 900px) {
  .side { position: fixed; left: -260px; z-index: 50; transition: left .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .side.open { left: 0; }
  .menu-btn { display: inline-block; }
  .top { padding: 14px 16px 4px; }
  .content { padding: 10px 16px 32px; }
  .flash { margin: 8px 16px 0; }
}

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card > .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card.flush > .card-head { padding: 14px 18px 0; }
.card-head h2 { margin: 0; }
.muted { color: var(--ink-3); }
.lead { color: var(--ink-2); margin: 0 0 16px; max-width: 760px; }
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .lbl { font-size: .82rem; color: var(--ink-3); }
.kpi .val { font-size: 1.45rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn.sec { background: var(--card); color: var(--brand); border-color: var(--line-2); }
.btn.sec:hover { background: var(--brand-soft); }
.btn.danger { background: var(--card); color: var(--bad); border-color: #f0b8b2; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: .84rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--bad); font: inherit; font-size: .84rem; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
td form { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gray { background: #eef1f4; color: var(--ink-2); }

/* ---------- tablas ---------- */
.tbl-wrap { overflow: auto; max-width: 100%; }
.tbl-wrap.tall { max-height: calc(100vh - 230px); }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t thead th { position: sticky; top: 0; background: #f8fafc; z-index: 2; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); font-weight: 650; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t thead tr.grp th { background: #eef3f9; color: var(--brand-2); text-align: center; border-bottom: 1px solid var(--line); top: 0; }
table.t thead tr.grp + tr th { top: 31px; }
table.t tbody tr:hover td { background: #fafcff; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td.c, table.t th.c { text-align: center; }
table.t tfoot td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line-2); position: sticky; bottom: 0; }
table.t td.calc { background: #fbfbfc; color: var(--ink-2); }
table.t td.strong { font-weight: 700; color: var(--ink); }
table.t .sticky-col { position: sticky; left: 0; background: var(--card); z-index: 1; box-shadow: 1px 0 0 var(--line); min-width: 220px; }
table.att .sticky-col { min-width: 210px; text-align: left; padding-left: 10px; }
table.t thead .sticky-col { z-index: 3; background: #f8fafc; }
table.t tfoot .sticky-col { z-index: 3; background: #f8fafc; }
table.t tr.dim td { color: var(--ink-3); }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty h2 { color: var(--ink); }

/* inputs dentro de tablas */
.cell-in { width: 100%; min-width: 86px; border: 1px solid transparent; background: var(--input); border-radius: 6px; padding: 5px 7px; font: inherit; font-size: .9rem; text-align: right; color: #0d3b78; font-variant-numeric: tabular-nums; }
.cell-in.txt { text-align: left; min-width: 140px; }
.cell-in.sm { min-width: 58px; }
.cell-in:hover { border-color: var(--input-line); }
.cell-in:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(29, 78, 137, .15); }
.cell-in.saving { background: #fff8e1; }
.cell-in.saved { background: var(--ok-soft); transition: background .6s; }
.cell-in.error { background: var(--bad-soft); border-color: var(--bad); }
select.cell-in { text-align: left; padding-right: 4px; }

/* ---------- formularios ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .hint { font-size: .78rem; color: var(--ink-3); margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=month], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 137, .15); }
textarea { min-height: 70px; resize: vertical; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.inline { display: inline-flex; gap: 8px; align-items: center; }

/* ---------- login ---------- */
body.bare { background: linear-gradient(160deg, #0f2a4a 0%, #1d4e89 60%, #2f6db3 100%); min-height: 100vh; }
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px 26px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login .brand-l { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.login .logo { background: var(--brand); color: #fff; }
.login .field { margin-bottom: 14px; }
.login .btn { width: 100%; justify-content: center; padding: 10px; }

/* ---------- asistencia ---------- */
table.att td, table.att th { padding: 3px 2px; text-align: center; }
table.att th.day { min-width: 30px; font-size: .72rem; }
table.att th.day.we, table.att td.we { background: #f3f4f6; }
table.att th.day.fe, table.att td.fe { background: #fdecea; }
.mk { width: 30px; height: 28px; border: 1px solid transparent; border-radius: 5px; text-align: center; font: inherit; font-size: .82rem; font-weight: 700; background: transparent; text-transform: uppercase; padding: 0; }
.mk:hover { border-color: var(--input-line); background: var(--input); }
.mk:focus { outline: none; border-color: var(--brand); background: #fff; }
.mk.F { background: #fde2df; color: #a1271c; }
.mk.L { background: #e3ecfb; color: #1b4f9c; }
.mk.V { background: #e2f4e9; color: #19693f; }
.mk.R { background: #f1e8fb; color: #6c3aa8; }
.mk.H { background: #fff1d6; color: #8a5300; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .84rem; color: var(--ink-2); margin-bottom: 10px; }
.legend span b { display: inline-block; min-width: 22px; text-align: center; border-radius: 4px; margin-right: 4px; padding: 0 4px; }

/* ---------- alertas ---------- */
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.alerts li:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--brand); }
.dot.bad { background: var(--bad); }
.dot.warn { background: #e09400; }
.dot.ok { background: var(--ok); }

.perm-grid select { min-width: 140px; }
.qr { display: grid; place-items: center; padding: 18px; background: #fff; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.qr img { width: 260px; height: 260px; image-rendering: pixelated; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .86em; background: #f1f4f8; padding: 1px 5px; border-radius: 4px; }
pre.cmd { background: #0f2a4a; color: #e7eef7; padding: 12px 14px; border-radius: 8px; overflow: auto; font-size: .86rem; line-height: 1.6; }

/* ---------- comprobante ---------- */
.voucher { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 36px; box-shadow: var(--shadow); }
.voucher header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--brand); padding-bottom: 12px; margin-bottom: 18px; }
.voucher h2 { font-size: 1.3rem; color: var(--brand); margin: 0; }
.voucher table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.voucher td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.voucher td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.voucher tr.total td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 0; font-size: 1.05rem; }
.voucher h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); margin: 18px 0 6px; }
.voucher .note { color: var(--ink-3); font-size: .85rem; }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; text-align: center; font-size: .88rem; }
.sign div { border-top: 1px solid var(--ink); padding-top: 6px; }
.receive { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.receive div { background: var(--brand-soft); border-radius: 8px; padding: 12px 14px; }
.receive b { display: block; font-size: 1.3rem; }

@media print {
  .side, .top, .no-print, .flash { display: none !important; }
  body, .main, .content { background: #fff; padding: 0; margin: 0; }
  .voucher { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
}
