:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273549;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
}

/* ── Light mode overrides ── */
html.light-mode {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #cbd5e1;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}
html.light-mode body { background: var(--bg) !important; color: var(--text) !important; }
html.light-mode tbody tr:hover { background: #e2e8f0; }
html.light-mode thead tr { background: #e2e8f0; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Button reset — elimina estilos default del browser ── */
button {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
  line-height: inherit;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

/* ── Layout ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.card--sm { max-width: 420px; width: 100%; }
.card__title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; }
.card__subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.5rem; }

/* ── Form ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .375rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--danger:hover  { background: #b91c1c; }
.btn--ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--ghost:hover { background: var(--bg); }
.btn--full    { width: 100%; }
.btn--sm      { padding: .375rem .75rem; font-size: .875rem; }

/* ── Flash messages ── */
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.flash--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash--success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash--warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead tr { background: var(--bg); }
th, td { padding: .625rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--surface-2); }

/* ── Branding ── */
.brand { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: -.02em; }

/* ── Stat grid (cierre report) ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat { background: var(--bg); padding: 1rem; border-radius: var(--radius); }
.stat__label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat__value { font-size: 1.375rem; font-weight: 700; margin-top: .25rem; }
.stat--danger .stat__value { color: var(--danger); }
.stat--success .stat__value { color: var(--success); }

/* ── Nav ── */
.nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.nav__brand { font-weight: 800; color: var(--primary); font-size: 1.5rem; letter-spacing: -.02em; line-height: 1; }
.nav__logo  { height: 48px; max-width: 160px; object-fit: contain; border-radius: 6px; }
.nav__user  { margin-left: auto; font-size: .875rem; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-wrap { padding: 1rem .75rem; }
  .card { padding: 1.25rem; }
  .nav { padding: .5rem .75rem; gap: .75rem; flex-wrap: wrap; }
  .nav__user { margin-left: auto; }
  .card__title { font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .app-wrap { padding: .75rem .5rem; }
  .card { padding: 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .btn { font-size: .875rem; padding: .5rem 1rem; }
}

/* Prevent horizontal overflow globally */
img, table { max-width: 100%; }
.nav { overflow-x: auto; }

/* Utility — stack flex on small screens */
@media (max-width: 600px) {
  .flex-stack { flex-direction: column !important; }
  .flex-stack > * { width: 100%; }
}

/* ── Global Pager ─────────────────────────────────────────── */
.pager {
  display: flex; gap: .3rem; padding: .75rem 1rem;
  justify-content: center; align-items: center;
  flex-wrap: wrap;
}
.pager a {
  min-width: 2rem; height: 2rem; padding: 0 .5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: .8rem; font-weight: 600;
  text-decoration: none;
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--surface);
  transition: all .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  cursor: pointer;
  user-select: none;
}
.pager a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  transform: translateY(-1px);
}
.pager a:active { transform: translateY(0); }
.pager a.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent);
  pointer-events: none;
}
.pager-sep  { font-size: .85rem; color: var(--text-muted); padding: 0 .15rem; }
.pager-info { font-size: .75rem; color: var(--text-muted); margin-left: .5rem; font-weight: 500; }
