:root {
  --bg: #f4f1ea; --surface: #ffffff; --ink: #1f2a24; --muted: #6b766f; --line: #e3ded2;
  --brand: #2f5d3a; --brand-2: #1f4228; --accent: #b8782f; --ok: #2f7d4a; --warn: #c58a12; --bad: #b3372f;
  --radius: 12px; --shadow: 0 1px 2px rgba(30,40,30,.06), 0 4px 14px rgba(30,40,30,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151b17; --surface: #1d2520; --ink: #e8ece7; --muted: #94a099; --line: #2c3730;
          --brand: #5fa271; --brand-2: #3f7a50; --accent: #d9a05a; --ok: #62b57d; --warn: #e0b04a; --bad: #e0675e; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; } h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

/* Layout */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--brand-2); color: #e9efe9; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.logo .mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; font-size: 20px; }
.logo b { display: block; line-height: 1.1; } .logo small { opacity: .7; font-size: .72rem; }
.grupo { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; opacity: .55; padding: 14px 10px 4px; }
.side a.nav { display: flex; gap: 10px; align-items: center; color: #dfe8df; padding: 8px 10px; border-radius: 8px; font-size: .92rem; }
.side a.nav:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side a.nav.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.main { padding: 22px 28px 48px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); font-size: .9rem; }
.user { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .88rem; }
.burger { display: none; }

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; } .g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: repeat(2, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.kpi strong { display: block; font-size: 1.55rem; margin-top: 4px; }
.kpi small { color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 9px; font: inherit; cursor: pointer; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--bg); }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.badge.muted { color: var(--muted); }

/* Tablas */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.vacio { text-align: center; color: var(--muted); padding: 30px; }

/* Formularios */
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
.check { width: 18px; height: 18px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.campo label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.campo.chk label { display: flex; gap: 8px; align-items: center; margin-top: 24px; color: var(--ink); }
.ayuda { font-size: .76rem; color: var(--muted); margin-top: 3px; }
.error, .errorlist { color: var(--bad); font-size: .82rem; list-style: none; padding: 0; margin: 3px 0 0; }
.alerta-form { background: color-mix(in srgb, var(--bad) 10%, transparent); border: 1px solid var(--bad); color: var(--bad); border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filtros .input { width: auto; min-width: 150px; }
.filtros label { font-size: .75rem; color: var(--muted); display: block; font-weight: 600; }

/* Mensajes */
.msg { padding: 10px 14px; border-radius: 9px; margin-bottom: 10px; border: 1px solid var(--line); background: var(--surface); }
.msg.success { border-color: var(--ok); color: var(--ok); } .msg.error { border-color: var(--bad); color: var(--bad); }

/* Gráfico de barras */
.barras { display: flex; gap: 10px; align-items: flex-end; height: 160px; padding-top: 10px; }
.barra { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: .72rem; color: var(--muted); }
.barra i { display: block; width: 100%; max-width: 46px; background: var(--brand); border-radius: 6px 6px 0 0; min-height: 3px; }
.barra em { font-style: normal; color: var(--ink); font-weight: 600; margin-bottom: 3px; }

/* Asistencia */
.cel { width: 26px; text-align: center; padding: 4px 0; font-size: .72rem; font-weight: 700; }
.cel.A { color: var(--ok); } .cel.T { color: var(--warn); } .cel.F { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.cel.J, .cel.V, .cel.L { color: var(--accent); } .cel.D { color: var(--muted); }
.reloj { max-width: 460px; margin: 20px auto; text-align: center; }
.reloj .hora { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.reloj input { font-size: 1.8rem; text-align: center; letter-spacing: .3em; padding: 14px; }
.resultado { border-radius: var(--radius); padding: 18px; margin: 16px 0; background: color-mix(in srgb, var(--ok) 14%, transparent); border: 1px solid var(--ok); }

/* Documento imprimible */
.doc { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 32px; border: 1px solid #ccc; }
.doc table th { color: #333; border-bottom: 1px solid #999; } .doc td { border-bottom: 1px solid #e5e5e5; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #2f5d3a; padding-bottom: 14px; margin-bottom: 14px; }
.doc-caja { border: 2px solid #2f5d3a; padding: 10px 18px; text-align: center; border-radius: 6px; min-width: 220px; }
.totales { margin-left: auto; width: 280px; } .totales td { border: 0; padding: 3px 8px; } .totales tr:last-child td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid #111; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--brand-2), var(--brand)); }
.login .box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 30px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }

.pag { display: flex; gap: 8px; justify-content: center; margin-top: 14px; align-items: center; color: var(--muted); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; width: 260px; left: -270px; transition: left .2s; }
  .side.open { left: 0; }
  .burger { display: inline-flex; }
  .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
@media print {
  .side, .topbar, .no-print, .msg { display: none !important; }
  .app { display: block; } .main { padding: 0; } body { background: #fff; }
  .doc { border: 0; padding: 0; max-width: none; }
}
