/* =====================================================================
   PRODE AFA 2027 — Design System
   ===================================================================== */

/* ---- Color tokens: dark (default) ---- */
:root {
  --bg:          #0f1420;
  --bg-soft:     #151b2b;
  --card:        #1a2233;
  --card-hover:  #1e2840;
  --ink:         #e8ecf3;
  --muted:       #94a1b5;
  --line:        #2a3450;
  --accent:      #4da3ff;
  --accent-dark: #2e88e8;
  --accent-ink:  #07142b;
  --ok:          #34d399;
  --ok-ink:      #06281c;
  --bad:         #f87171;
  --warn:        #fbbf24;
  --tab-bg:      #232c44;
  --thead:       #202a42;
  --badge-bg:    #2a3450;
  --code-bg:     #232c44;
  --hover:       #1f2a42;
  --nav-bg:      rgba(10, 15, 28, 0.94);
  --nav-ink:     #d7dee9;
  --shadow:      0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-sm:   0 2px 8px  rgba(0, 0, 0, 0.25);
  --radius:      12px;
  --radius-sm:   8px;
  color-scheme: dark;
}

/* ---- Color tokens: light ---- */
[data-theme="claro"] {
  --bg:          #f0f2f5;
  --bg-soft:     #e8ebf0;
  --card:        #ffffff;
  --card-hover:  #f7f8fa;
  --ink:         #1c2230;
  --muted:       #5d6b80;
  --line:        #d8dce4;
  --accent:      #0b66c3;
  --accent-dark: #0952a0;
  --accent-ink:  #ffffff;
  --ok:          #0e8a5f;
  --ok-ink:      #ffffff;
  --bad:         #c0392b;
  --warn:        #d97706;
  --tab-bg:      #e4e7ed;
  --thead:       #edf0f4;
  --badge-bg:    #e4e7ed;
  --code-bg:     #eceef2;
  --hover:       #eef1f6;
  --nav-bg:      rgba(255, 255, 255, 0.95);
  --nav-ink:     #1c2230;
  --shadow:      0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-sm:   0 2px 8px  rgba(0, 0, 0, 0.07);
  color-scheme: light;
}

/* =====================================================================
   RESET & BASE
   ===================================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.25s ease, color 0.25s ease;
  min-height: 100dvh;
}

h1 { font-size: 1.5rem;  font-weight: 800; letter-spacing: -0.02em; margin: 0 0 16px; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 28px 0 10px; }
h3 { font-size: 1rem;    font-weight: 600; margin: 20px 0 8px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

p { margin: 0 0 12px; }

/* =====================================================================
   NAVBAR
   ===================================================================== */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: background 0.25s ease;
}

.navbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover { text-decoration: none; }

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  color: var(--nav-ink);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Nav links container */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: flex-end;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--hover);
  color: var(--nav-ink);
  text-decoration: none;
}

.nav-link-staff {
  font-size: 0.82rem;
  opacity: 0.75;
}

/* Vertical separator */
.nav-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 6px;
  flex-shrink: 0;
}

/* Theme toggle */
.tema-toggle {
  background: var(--tab-bg);
  color: var(--nav-ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.tema-toggle:hover {
  background: var(--hover);
  transform: scale(1.07);
}

/* User dropdown */
.nav-user { position: relative; flex-shrink: 0; }

.nav-avatar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tab-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 6px;
  cursor: pointer;
  color: var(--nav-ink);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-avatar:hover {
  background: var(--hover);
  border-color: var(--accent);
}

.avatar-initials {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.nav-username {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-avatar[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

/* Dropdown menu */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 190px;
  overflow: hidden;
  display: none;
  z-index: 200;
  animation: dropIn 0.15s ease;
}

.dropdown-menu.open { display: block; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line);
}

.dropdown-item,
a.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none !important;
  transition: background 0.12s ease;
}

.dropdown-item:hover,
.dropdown-item:focus,
a.dropdown-item:hover,
a.dropdown-item:focus {
  background: var(--hover);
  color: var(--ink);
  text-decoration: none !important;
}
.danger-item { color: var(--bad); }
.danger-item:hover { background: rgba(248, 113, 113, 0.1); }

/* Btn inside navbar */
.btn-nav {
  padding: 7px 16px;
  font-size: 0.88rem;
  margin-left: 4px;
  margin-top: 0;
  font-weight: 700;
  border-radius: 999px;
}

/* Hamburger (mobile) */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--nav-ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* =====================================================================
   LAYOUT
   ===================================================================== */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* =====================================================================
   CARDS
   ===================================================================== */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover { box-shadow: var(--shadow); }
.card.danger { border-color: var(--bad); }
.card.accent-border { border-color: var(--accent); }

/* =====================================================================
   GRUPOS HOME — card grid
   ===================================================================== */

.grupos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.grupo-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.grupo-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.grupo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
  text-decoration: none;
  color: inherit;
}

.grupo-card:hover::before { opacity: 1; }

.grupo-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.grupo-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.3;
}

.grupo-card-rol {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--tab-bg);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.grupo-card-rol.admin { background: rgba(77, 163, 255, 0.15); color: var(--accent); }

.grupo-card-stats {
  display: flex;
  gap: 16px;
}

.grupo-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.grupo-stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ok);
  line-height: 1;
}

.grupo-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.grupo-card-code {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.grupo-card-code code {
  background: var(--tab-bg);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

.grupo-card-img {
  display: block;
  width: calc(100% + 40px);
  height: 120px;
  object-fit: contain;
  padding: 8px;
  background: radial-gradient(circle at center, var(--card-hover), var(--bg));
  margin: -18px -20px 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.grupo-card-img-vacio {
  object-fit: fill;
  padding: 0;
}

.grupo-banner {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: contain;
  padding: 8px;
  background: radial-gradient(circle at center, var(--card-hover), var(--bg));
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.grupo-card-img-vacio,
.grupo-banner-vacio {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--tab-bg), var(--card));
  color: var(--muted);
}

.grupo-card-img-vacio { height: 120px; }
.grupo-banner-vacio { height: 140px; }

.grupo-thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.grupo-thumb-vacio {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: var(--tab-bg);
}

/* =====================================================================
   HOME PAGE HERO (unauthenticated)
   ===================================================================== */

.pronto-wrap { text-align: center; padding: 40px 10px 70px; }

.pronto-hero {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.pronto-media {
  width: 100%;
  display: block;
  background: #000;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

iframe.pronto-media { border: none; }

.pronto-titulo {
  margin-top: 24px;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.pronto-msj {
  color: var(--muted);
  max-width: 560px;
  margin: 10px auto 0;
  font-size: 1.05rem;
}

.pronto-login {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.pronto-login .btn {
  font-size: 1rem;
  padding: 12px 32px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* =====================================================================
   PAGE HEADER UTILITY
   ===================================================================== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.page-header h1 { margin: 0; }

/* =====================================================================
   TABLES
   ===================================================================== */

.tabla {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tabla th, .tabla td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.tabla tbody tr:last-child td { border-bottom: none; }

.tabla tbody tr { transition: background 0.12s ease; }
.tabla tbody tr:hover { background: var(--hover); }

.tabla thead th {
  background: var(--thead);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.num { text-align: center; }
.ptos { font-weight: 800; color: var(--ok); }

/* =====================================================================
   FORMS
   ===================================================================== */

.form label, .grid-premios label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin: 12px 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-soft);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.18);
}

[data-theme="claro"] input:focus,
[data-theme="claro"] select:focus,
[data-theme="claro"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(11, 102, 195, 0.14);
}

/* =====================================================================
   BUTTONS
   ===================================================================== */

.btn {
  background: var(--accent);
  border: none;
  color: var(--accent-ink);
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.93rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  transition: filter 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: scale(0.97); }

.btn-mini { padding: 6px 13px; font-size: 0.82rem; margin-top: 0; }
.btn.ok   { background: var(--ok);  color: var(--ok-ink); }
.btn.danger { background: var(--bad); color: #fff; }

.linklike {
  background: none;
  border: none;
  color: var(--nav-ink);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.93rem;
  text-decoration: underline;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.linklike:hover { color: var(--accent); background: var(--hover); }

/* =====================================================================
   TABS
   ===================================================================== */

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 14px 0 2px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.tab {
  padding: 9px 16px;
  border-radius: 9px 9px 0 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab:hover { background: var(--hover); color: var(--ink); text-decoration: none; }

.tab.active {
  color: var(--accent);
  font-weight: 700;
  border-bottom-color: var(--accent);
  background: transparent;
}

/* =====================================================================
   FECHITAS (round selector)
   ===================================================================== */

.fechitas {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 0;
}

.fechita {
  width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tab-bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.fechita:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.fechita.activa { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.fechita.small { width: 28px; height: 26px; font-size: 0.76rem; }

/* =====================================================================
   MESSAGES / ALERTS
   ===================================================================== */

.messages { margin-bottom: 16px; }

.msg {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 6px 0;
  font-weight: 600;
  font-size: 0.93rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg.error   { background: rgba(248, 113, 113, 0.12); color: var(--bad); border: 1px solid rgba(248, 113, 113, 0.3); }
.msg.success { background: rgba(52, 211, 153, 0.1);  color: var(--ok);  border: 1px solid rgba(52, 211, 153, 0.3); }
.msg.warning { background: rgba(251, 191, 36, 0.1);  color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.3); }
.msg.info    { background: rgba(77, 163, 255, 0.1);  color: var(--accent); border: 1px solid rgba(77, 163, 255, 0.3); }

/* =====================================================================
   BADGES & MISC
   ===================================================================== */

.badge {
  font-size: 0.74rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--muted);
  font-weight: 600;
}

.badge.ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.badge.bad { background: rgba(248, 113, 113, 0.14); color: var(--bad); }

.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.big-num { font-size: 1.6rem; font-weight: 800; color: var(--ok); }
.editable { background: rgba(77, 163, 255, 0.07); }

code {
  background: var(--code-bg);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: ui-monospace, "Cascadia Code", Menlo, monospace;
}

.grid-premios {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.inline-form, form.inline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* =====================================================================
   SECTION HEADERS (for forms sections on home)
   ===================================================================== */

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 32px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* =====================================================================
   EMPTY STATE
   ===================================================================== */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 14px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

/* =====================================================================
   SCROLLBAR
   ===================================================================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   MODALES
   ===================================================================== */

.acciones-home {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  flex-shrink: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 18px;
}

.modal {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 { margin: 0; font-size: 1.15rem; color: var(--ink); }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.modal-close:hover { color: var(--ink); background: var(--hover); }

.modal-body { padding: 18px 20px 22px; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 680px) {
  .navbar { padding: 0 14px; }

  .nav-hamburger { display: flex; }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    position: absolute;
    top: 61px;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px 16px;
    box-shadow: var(--shadow);
  }

  .nav-links.open { display: flex; }

  .nav-link, .linklike { width: 100%; }

  .nav-sep { width: 100%; height: 1px; margin: 4px 0; }

  .nav-user { width: 100%; }
  .nav-avatar { width: 100%; border-radius: var(--radius-sm); }

  .btn-nav { width: 100%; justify-content: center; border-radius: var(--radius-sm); }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    animation: none;
  }

  .grupos-grid { grid-template-columns: 1fr; }

  h1 { font-size: 1.3rem; }
  .pronto-titulo { font-size: 1.5rem; }
}

@media (max-width: 420px) {
  .container { padding: 20px 14px 60px; }
  .tabla th, .tabla td { padding: 8px 10px; font-size: 0.88rem; }
}

/* =====================================================================
   TOGGLE SWITCH — reemplaza todos los checkboxes del sitio
   ===================================================================== */

/* Ocultar el checkbox nativo */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--line);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  vertical-align: middle;
  border: none;
  padding: 0;
}

/* El círculo */
input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* Estado ON */
input[type="checkbox"]:checked {
  background: var(--accent);
}

input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

/* Focus accesible */
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.35);
}

[data-theme="claro"] input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(11, 102, 195, 0.25);
}

/* Wrapper para alinear label + toggle en la misma línea */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.toggle-row label {
  margin: 0;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: normal;
}

/* Django as_p wraps: <p><label><input type=checkbox ...></label></p>  */
/* Detecta el patrón y lo estiliza como toggle row */
p:has(> label > input[type="checkbox"]),
p:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  margin: 4px 0;
  border-bottom: 1px solid var(--line);
}

p:has(> label > input[type="checkbox"]) label,
p:has(> input[type="checkbox"]) label {
  order: 2;
  margin: 0;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

p:has(> label > input[type="checkbox"]) input[type="checkbox"],
p:has(> input[type="checkbox"]) input[type="checkbox"] {
  order: 1;
}

/* =====================================================================
   PANEL ADMIN STYLES
   ===================================================================== */

.btn-panel-volver {
  background: var(--card);
  color: var(--ink) !important;
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
  margin-top: 0;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.btn-panel-volver:hover {
  background: var(--hover);
  border-color: var(--accent);
  color: var(--accent) !important;
  text-decoration: none !important;
  transform: translateX(-2px);
}

.btn-panel-volver svg {
  transition: transform 0.15s ease;
}

.btn-panel-volver:hover svg {
  transform: translateX(-3px);
}

.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.breadcrumb-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb-link:hover {
  color: var(--accent);
}

.breadcrumb-sep {
  color: var(--muted);
  opacity: 0.6;
}

.breadcrumb-current {
  color: var(--ink);
  font-weight: 600;
}

.panel-title {
  margin: 0 0 20px 0;
  font-size: 1.8rem;
  font-weight: 800;
}

.panel-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.form-actions {
  margin-top: 18px;
}

.config-resumen {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--tab-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 0.88rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-item {
  background: var(--tab-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.estado-legend {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.legend-title {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:hover {
  background: var(--hover);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.metric-num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}

.metric-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Badges for roles & status */
.badge-super { background: rgba(168, 85, 247, 0.18); color: #a855f7; font-weight: 700; }
.badge-staff { background: rgba(59, 130, 246, 0.18); color: #3b82f6; font-weight: 700; }
.badge-user { background: var(--tab-bg); color: var(--muted); }
.badge-active { background: rgba(16, 185, 129, 0.18); color: #10b981; font-weight: 700; }
.badge-pending { background: rgba(245, 158, 11, 0.18); color: #f59e0b; font-weight: 700; }
.badge-done { background: rgba(16, 185, 129, 0.18); color: #10b981; }
.badge-cancel { background: rgba(239, 68, 68, 0.18); color: #ef4444; }
.badge-reject { background: rgba(107, 114, 128, 0.18); color: #6b7280; }

.badge-estado-desafio_pendiente { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }
.badge-estado-en_curso { background: rgba(59, 130, 246, 0.18); color: #3b82f6; }
.badge-estado-terminada { background: rgba(16, 185, 129, 0.18); color: #10b981; }
.badge-estado-suspendida { background: rgba(239, 68, 68, 0.18); color: #ef4444; }
.badge-estado-abandonada { background: rgba(239, 68, 68, 0.18); color: #ef4444; }
.badge-estado-desafio_rechazado { background: rgba(107, 114, 128, 0.18); color: #6b7280; }

/* =====================================================================
   CODIGO REGISTRO FORM ALIGNMENT
   ===================================================================== */

.codigo-form-card {
  margin-bottom: 24px;
}

.codigo-form-grid {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) minmax(180px, 2fr) minmax(120px, 1fr) auto auto;
  gap: 16px;
  align-items: end;
}

@media (max-width: 1024px) {
  .codigo-form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .codigo-form-grid {
    grid-template-columns: 1fr;
  }
}

.codigo-field-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.codigo-field-group label.field-label {
  display: block;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  color: var(--muted) !important;
  margin: 0 0 8px 0 !important;
  min-height: 32px;
  line-height: 16px;
  white-space: normal;
  display: flex;
  align-items: flex-end;
}

.codigo-field-group input.input {
  height: 42px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

.codigo-field-group .toggle-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  box-sizing: border-box;
}

.codigo-field-group .toggle-box input[type="checkbox"] {
  margin: 0 !important;
}

.codigo-field-group .toggle-box label {
  margin: 0 !important;
  cursor: pointer;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}

.codigo-field-group .btn-crear {
  height: 42px !important;
  margin: 0 !important;
  padding: 0 20px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
  width: 100%;
}

.codigo-field-group .field-hint {
  font-size: 0.76rem !important;
  color: var(--muted) !important;
  margin-top: 6px !important;
  min-height: 16px;
  line-height: 16px;
}
