:root {
  --ink: #0f172a;
  --muted: #64748b;
  --navy: #0f172a;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --paper: #f3f6fb;
  --card: #ffffff;
  --line: #e2e8f0;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --err: #be123c;
  --err-bg: #fff1f2;
  --warn: #b45309;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --sans: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(37, 99, 235, 0.08), transparent 55%),
    var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(700px 380px at 15% -10%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(600px 320px at 100% 100%, rgba(14, 165, 233, 0.14), transparent 55%),
    #f3f6fb;
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: 2rem 1.5rem 1.3rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--sans); font-weight: 720; letter-spacing: -0.03em; line-height: 1.15; }
h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.35rem); }
h2 { margin: 0 0 0.8rem; font-size: 1.35rem; }
h3 { margin: 0 0 0.7rem; font-size: 1.05rem; }

.sub { margin: 0.45rem 0 1.3rem; color: var(--muted); }

.hint-box, .msg, .note {
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin: 0 0 1rem;
}

.hint-box {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1e3a8a;
  font-size: 0.92rem;
}

.hint-box strong { display: block; margin-bottom: 0.25rem; }
.hint-box p { margin: 0.15rem 0; }

.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--err-bg); color: var(--err); }
.note { background: #eff6ff; color: #1e3a8a; border: 1px solid #dbeafe; }

.field { margin-bottom: 0.95rem; }
.field label, .lbl {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  font-weight: 650;
}
.req { color: var(--err); }
.help { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.85rem; font-weight: 400; }

input:not([type="checkbox"]):not([type="file"]), select, textarea {
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: white;
  font-weight: 650;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: var(--accent-dark); }
.btn.full { width: 100%; }
.btn.gold { background: var(--accent); }
.btn.ghost {
  background: transparent;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn.line {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.line:hover { background: #f8fafc; }
.btn.danger { background: #e11d48; }
.btn.danger:hover { background: #be123c; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 1.35rem 1rem 1.15rem;
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.brand-kicker {
  margin: 0;
  color: #93c5fd;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
}

.brand-title {
  margin: 0.4rem 0 0.25rem;
  font-size: 1.55rem;
  font-weight: 740;
  letter-spacing: -0.04em;
  line-height: 1;
  color: white;
}

.brand-sub { margin: 0 0 1.1rem; color: #94a3b8; font-size: 0.86rem; }

.who {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 0.8rem 0.85rem;
  margin-bottom: 0.85rem;
}
.who strong { display: block; color: white; }
.who span { color: #94a3b8; font-size: 0.86rem; }

.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #cbd5e1;
  border: 0;
  border-radius: 10px;
  padding: 0.68rem 0.75rem;
  font-weight: 600;
}
.nav-btn.active, .nav-btn:hover {
  background: rgba(37, 99, 235, 0.22);
  color: white;
}

.side-spacer { flex: 1; }
.side .btn { margin-top: 0.45rem; }

.main { min-width: 0; padding: 1.4rem clamp(1rem, 2vw, 2.2rem) 3rem; }

.topbar { display: none; }
.menu-btn { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  border: 0;
  z-index: 15;
}

.counter {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid #dbe7f5;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.3rem 1.15rem;
  margin-bottom: 1rem;
}

.counter-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

.counter-num {
  margin: 0.2rem 0 0.1rem;
  font-family: var(--sans);
  font-weight: 760;
  font-size: clamp(3.4rem, 8vw, 5.6rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.06em;
  line-height: 0.9;
  color: #0f172a;
}
.counter-num span { font-size: 0.42em; color: #94a3b8; font-weight: 650; }
.counter.low .counter-num { color: var(--warn); }
.counter.done .counter-num { color: var(--err); }
.counter.ok .counter-num { color: #1d4ed8; }

.bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.9rem 0 0.45rem;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
}
.counter.low .bar > span { background: #f59e0b; }
.counter.done .bar > span { background: #e11d48; }

.quiet { color: var(--muted); margin: 0.2rem 0 0; }

.stack { display: grid; gap: 1rem; min-width: 0; }
.form-card { max-width: 760px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

.drop {
  position: relative;
  border: 1.5px dashed #93c5fd;
  border-radius: 14px;
  padding: 1.1rem;
  background: #f8fbff;
  text-align: center;
  margin-bottom: 1rem;
}
.drop.over { border-color: var(--accent); background: #eff6ff; }
.drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop strong { display: block; }
.preview {
  display: block;
  margin: 0.6rem auto 0;
  max-height: 140px;
  border-radius: 10px;
}

.cards-3, .cards-4 {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.7rem;
  font-weight: 740;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stat span { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 650; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  max-height: 640px;
  max-width: 100%;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef2f7;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.frac { font-variant-numeric: tabular-nums; font-weight: 740; white-space: nowrap; color: var(--accent-dark); }
.frac.low { color: var(--warn); }
.frac.done { color: var(--err); }

.celda-estado { white-space: normal; min-width: 11rem; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}
.badge.pendiente { background: #fff7ed; color: #c2410c; }
.badge.aprobada { background: var(--ok-bg); color: var(--ok); }
.badge.realizada { background: #f1f5f9; color: #334155; }
.motivo {
  display: block;
  margin-top: 0.35rem;
  color: var(--err);
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: normal;
}
.stat-btn {
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
.stat-btn:hover { border-color: #bfdbfe; }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; white-space: normal; min-width: 11rem; }
.mini {
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

.filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.filters input, .filters select { width: auto; min-width: 180px; flex: 1; }

.inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.inline input { width: 110px; }

dialog {
  border: 0;
  border-radius: 18px;
  padding: 1.25rem;
  width: min(440px, calc(100% - 2rem));
  background: var(--card);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.5); }

.foot {
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 980px) {
  .grid-2, .cards-4, .cards-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; align-items: center; margin-bottom: 1rem; }
  .menu-btn { display: inline-flex; }
  .side {
    position: fixed;
    z-index: 20;
    width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .side.open { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .side, .btn, input, select, textarea { transition: none; }
}

@media print {
  .side, .scrim, .menu-btn, .no-print, .drop, form, dialog { display: none !important; }
  .shell { display: block; }
  body { background: white; }
  .card, .counter, .stat { box-shadow: none; }
}
