/* Panel admin — Concurso provincial */
:root {
  --bg: #0f1419;
  --bg-elevated: #1a222d;
  --surface: #232d3b;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8edf4;
  --muted: #8b9aaf;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --sidebar-w: 260px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body.admin-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.admin-shell { min-height: 100vh; display: flex; flex-direction: column; }

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; letter-spacing: -0.02em; }
.brand-mark {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.5);
}
.brand-mark.lg { width: 14px; height: 14px; }

.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.nav-toggle::before,
.nav-toggle::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}
.nav-toggle::before { top: 14px; box-shadow: 0 6px 0 var(--text); }
.nav-toggle::after { top: 26px; }

.topbar-user {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.user-pill {
  padding: 0.25rem 0.65rem;
  background: var(--surface);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.role-pill {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-size: 0.75rem;
  text-transform: capitalize;
}

.admin-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
}

.admin-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
}

.side-nav { display: flex; flex-direction: column; gap: 0.25rem; padding: 0 0.75rem; }

.side-link {
  display: block;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: background 0.15s, color 0.15s;
}
.side-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.side-link.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
  border-left: 3px solid var(--accent);
  margin-left: -3px;
  padding-left: calc(1rem + 3px);
}
.side-link.muted { margin-top: 1rem; font-size: 0.8125rem; opacity: 0.8; }

.admin-main {
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 2.5rem;
  max-width: 1400px;
  width: 100%;
}

.page-head { margin-bottom: 1.5rem; }
.page-head.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.page-title {
  margin: 0 0 0.25rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.page-sub { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.page-sub a { color: var(--accent); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.stat-card.subtle { opacity: 0.95; }
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-top: 0.35rem; letter-spacing: -0.02em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 1.5rem; }
.card.pad.narrow { max-width: 520px; }
.card.mt { margin-top: 1.25rem; }

.h3 { margin: 0 0 1rem; font-size: 1.1rem; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background: rgba(255,255,255,0.1); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn.ghost:hover { color: var(--text); }
.btn.sm { padding: 0.4rem 0.85rem; font-size: 0.8125rem; }
.btn.full { width: 100%; }
.btn.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}
.btn.danger:hover { background: rgba(239, 68, 68, 0.25); }

.filter-bar { margin-bottom: 1rem; }
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}
.lbl-inline { font-size: 0.75rem; color: var(--muted); display: block; margin-bottom: 0.25rem; }

.export-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.data-table .nowrap { white-space: nowrap; }
.data-table .actions { white-space: nowrap; }
.data-table .link { color: var(--accent); text-decoration: none; }
.data-table .link:hover { text-decoration: underline; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-size: 0.8125rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1rem;
}
.pg {
  min-width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
}
.pg:hover { color: var(--text); border-color: var(--accent); }
.pg.current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}
.alert.ok { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.35); color: #86efac; }
.alert.err { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); color: #fecaca; }
.alert.warn { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); color: #fcd34d; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.lbl { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.lbl.inline-check { display: flex; align-items: flex-start; gap: 0.5rem; font-weight: 400; cursor: pointer; }
.inp {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
.inp:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.inp.sm { max-width: 220px; padding: 0.45rem 0.65rem; font-size: 0.875rem; }

.hint { margin: 0; font-size: 0.8125rem; color: var(--muted); }
.small { font-size: 0.8125rem; }

.form-actions { margin-top: 0.5rem; }

.danger-zone { border-color: rgba(239, 68, 68, 0.25); }

/* Login standalone */
body.login-only {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(59, 130, 246, 0.25), transparent),
    var(--bg);
}
.login-card-wrap { width: 100%; max-width: 420px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-brand h1 { margin: 0.5rem 0 0.25rem; font-size: 1.5rem; letter-spacing: -0.03em; }
.login-brand .muted { color: var(--muted); margin: 0; font-size: 0.9rem; }

.muted { color: var(--muted); }
.muted a { color: var(--accent); }

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: fixed;
    left: 0; top: 56px; bottom: 0;
    width: min(var(--sidebar-w), 88vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .admin-main { padding-top: 1rem; }
  .topbar-user .user-pill { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (min-width: 901px) {
  .admin-sidebar { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); }
}
