:root {
  --bg: #111010;
  --surface: #1a1918;
  --surface-2: #232120;
  --glass: rgba(26, 25, 24, .76);
  --glass-strong: rgba(35, 33, 32, .82);
  --border: #2e2b2a;
  --border-soft: rgba(240, 237, 232, .08);
  --text: #f0ede8;
  --muted: #9a9490;
  --primary: #b21917;
  --primary-hover: #d63230;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 8px;
  --sidebar: 250px;
  --sidebar-collapsed: 74px;
  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --glass: #ffffff;
  --glass-strong: #ffffff;
  --border: #ddd8d3;
  --border-soft: #e7e2df;
  --text: #1a1110;
  --muted: #716b66;
}
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(255, 255, 255, .78);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(178, 25, 23, .16), transparent 32%),
    linear-gradient(180deg, var(--bg), #151211 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
[data-theme="light"] body {
  background: #ffffff;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(35, 33, 32, .72);
  color: var(--text);
  padding: 10px 12px;
  min-height: 42px;
  display: block;
}
textarea {
  min-height: 120px;
  resize: vertical;
}
label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--surface-2); font-size: 11px; text-transform: uppercase; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(178, 25, 23, .08); }
td small { display: block; color: var(--muted); margin-top: 4px; }

.guest-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(178, 25, 23, .18), transparent 34%),
    linear-gradient(180deg, #111010 0%, #171313 100%);
}
.auth-shell { width: min(420px, 100%); }
.auth-brand-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  min-height: 590px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .38);
}
.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(17, 16, 16, .92), rgba(17, 16, 16, .98)),
    #111010;
}
.auth-brand-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
}
.auth-brand-logo {
  width: 118px;
  height: auto;
  object-fit: contain;
}
.auth-kicker {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 14px;
  padding: 6px 10px;
  border: 1px solid rgba(178, 25, 23, .5);
  border-radius: 999px;
  color: #f0ede8;
  background: rgba(178, 25, 23, .18);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.auth-brand-panel h1 {
  max-width: 420px;
  margin: 0 0 12px;
  color: #f0ede8;
  font-size: 34px;
  line-height: 1.06;
}
.auth-brand-panel p {
  max-width: 390px;
  margin: 0;
  color: #b8b1ac;
  line-height: 1.65;
}
.auth-brand-foot {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  color: #5f5a56;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.auth-form-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 34px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 0;
  padding: 34px;
  box-shadow: none;
}
.auth-form-card {
  align-self: center;
  width: min(100%, 390px);
  padding: 0;
}
.auth-logo {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 20px;
}
.auth-logo img {
  height: 56px;
  width: auto;
  object-fit: contain;
}
.auth-form-kicker {
  display: block;
  margin-bottom: 14px;
  color: var(--primary-hover);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.auth-card h1, .auth-card h2, .page-head h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card p, .page-head p, .hint { margin: 0 0 18px; color: var(--muted); }
.resend-form { margin-top: 12px; text-align: center; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: linear-gradient(180deg, rgba(26, 25, 24, .88), rgba(17, 16, 16, .94));
  border-right: 1px solid var(--border-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
[data-theme="light"] .sidebar {
  background: #171514;
  border-right-color: #2e2b2a;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-logo {
  width: 108px;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-logo-collapsed {
  display: none;
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.sidebar-toggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(35, 33, 32, .62);
  color: var(--text);
  cursor: pointer;
}
[data-theme="light"] .sidebar-toggle {
  border-color: rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .08);
  color: #f0ede8;
}
.brand span, .topbar span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.sidebar nav { display: grid; gap: 4px; align-content: start; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 600;
}
[data-theme="light"] .sidebar nav a {
  color: #bdb7b3;
}
.sidebar nav a i {
  width: 18px;
  color: var(--primary-hover);
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(178, 25, 23, .14);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(178, 25, 23, .16);
}
[data-theme="light"] .sidebar nav a:hover,
[data-theme="light"] .sidebar nav a.active {
  color: #ffffff;
  background: rgba(178, 25, 23, .22);
}
.sidebar-system {
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(35, 33, 32, .46);
}
.sidebar-system span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .05em;
}
.sidebar-system strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
}
[data-theme="light"] .sidebar-system {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .1);
}
[data-theme="light"] .sidebar-system strong {
  color: #f0ede8;
}
.logout-form { margin-top: 0; }

.sidebar,
.main {
  transition: width .2s ease, margin-left .2s ease;
}
.main { margin-left: var(--sidebar); min-height: 100vh; padding: 22px; display: flex; flex-direction: column; }
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
  padding-inline: 10px;
}
body.sidebar-collapsed .main {
  margin-left: var(--sidebar-collapsed);
}
body.sidebar-collapsed .brand {
  justify-content: center;
  padding-inline: 0;
}
body.sidebar-collapsed .brand-logo {
  display: none;
}
body.sidebar-collapsed .brand-logo-collapsed {
  display: block;
}
body.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  margin-left: 0;
  width: 38px;
}
body.sidebar-collapsed .sidebar nav {
  margin-top: 44px;
}
body.sidebar-collapsed .sidebar nav a,
body.sidebar-collapsed .logout-form .btn {
  justify-content: center;
  padding-inline: 0;
}
body.sidebar-collapsed .sidebar nav a span,
body.sidebar-collapsed .logout-form .btn span,
body.sidebar-collapsed .sidebar-system {
  display: none;
}
body.sidebar-collapsed .sidebar nav a i {
  width: auto;
  font-size: 17px;
}
.topbar {
  min-height: 58px;
  margin: -22px -22px 22px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
[data-theme="light"] .topbar {
  background: #ffffff;
  border-bottom-color: #ece8e5;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-avatar {
  width: 36px;
  height: 36px;
  display: grid !important;
  place-items: center;
  border-radius: 50%;
  background: rgba(178, 25, 23, .18);
  color: var(--primary-hover) !important;
  border: 1px solid rgba(178, 25, 23, .25);
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  min-height: 38px;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { width: 100%; margin-top: 18px; }
.theme-btn { width: auto; border: 1px solid var(--border-soft); background: rgba(35, 33, 32, .62); color: var(--text); border-radius: var(--radius); padding: 8px 12px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
[data-theme="light"] .theme-btn {
  background: #f2f0ef;
  color: var(--text);
  border-color: #d8d3cf;
}

.flash {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 20;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.22);
}
.flash-success { background: #14532d; color: #dcfce7; }
.flash-error { background: #7f1d1d; color: #fee2e2; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card, .panel, .table-card, .filters, .danger-zone {
  background: var(--glass);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .18);
}
[data-theme="light"] .kpi-card,
[data-theme="light"] .panel,
[data-theme="light"] .table-card,
[data-theme="light"] .filters,
[data-theme="light"] .danger-zone,
[data-theme="light"] .app-footer {
  box-shadow: 0 10px 28px rgba(26, 17, 16, .08);
}
.kpi-card { padding: 18px; position: relative; overflow: hidden; }
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), transparent);
}
.kpi-card span { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 700; }
.kpi-card strong { display: block; color: var(--primary-hover); font-size: 28px; margin-top: 8px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.panel { padding: 18px; overflow: auto; }
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.metric-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); }
.metric-row strong { text-align: right; word-break: break-word; }
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
}
.table-card { overflow: auto; }
.pagination { display: flex; justify-content: center; gap: 6px; margin: 18px 0; }
.pagination a { padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border-soft); background: var(--glass); }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.badge-pendiente { background: rgba(154,148,144,.18); color: var(--muted); }
.badge-contactado { background: rgba(59,130,246,.18); color: var(--blue); }
.badge-interesado { background: rgba(245,158,11,.18); color: var(--yellow); }
.badge-inscrito { background: rgba(34,197,94,.18); color: var(--green); }
.badge-no_interesa { background: rgba(239,68,68,.18); color: var(--red); }
.form-panel {
  max-width: 980px;
}
.form-panel > .btn,
.form-panel > button.btn,
.import-box > .btn,
.import-box > button.btn,
.panel form > .btn,
.panel form > button.btn {
  margin-top: 18px;
}
.form-panel .actions {
  margin-top: 18px;
}
.form-panel .actions + .hint {
  margin-top: 12px;
}
.stacked-form {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.form-panel label:first-child,
.form-panel h2 + label,
.panel form label:first-child,
.panel form h2 + label {
  margin-top: 0;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.form-grid label {
  margin-top: 0;
}
.table-card input,
.table-card select {
  min-width: 150px;
}
.table-card form {
  margin: 0;
}
.table-card .btn {
  white-space: nowrap;
}
.danger-zone { padding: 14px; display: flex; align-items: end; gap: 10px; max-width: 620px; margin-top: 22px; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 14px;
  margin-bottom: 8px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 10px 0;
  color: var(--text);
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0;
}
.check-row input[type="checkbox"] {
  width: auto;
  min-height: 0;
  display: inline-block;
}
.metadata {
  max-width: 360px;
  max-height: 180px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
}
.mini-form {
  margin-top: 8px;
}
.import-box { max-width: 720px; margin-bottom: 18px; }
.import-box .hint {
  margin-top: 10px;
}
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding: 16px 18px;
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(26, 25, 24, .52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
[data-theme="light"] .app-footer {
  background: #ffffff;
  border-color: #e5ded9;
  color: #5d5651;
}
.app-footer strong {
  display: block;
  color: var(--text);
}
[data-theme="light"] .app-footer strong {
  color: #1a1110;
}
.app-footer span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}
[data-theme="light"] .app-footer span {
  color: #6d625c;
}
.app-footer a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
[data-theme="light"] .app-footer a {
  color: #4f4742;
}
.app-footer img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; min-height: auto; }
  .sidebar-system { margin-top: 0; }
  .main { margin-left: 0; }
  body.sidebar-collapsed .sidebar {
    width: auto;
    padding-inline: 14px;
  }
  body.sidebar-collapsed .main {
    margin-left: 0;
  }
  body.sidebar-collapsed .brand {
    justify-content: flex-start;
    padding: 4px 6px 18px;
  }
  body.sidebar-collapsed .brand-logo {
    display: block;
  }
  body.sidebar-collapsed .brand-logo-collapsed {
    display: none;
  }
  body.sidebar-collapsed .sidebar-toggle {
    position: static;
    transform: none;
    margin-left: auto;
  }
  body.sidebar-collapsed .sidebar nav {
    margin-top: 0;
  }
  body.sidebar-collapsed .sidebar nav a,
  body.sidebar-collapsed .logout-form .btn {
    justify-content: flex-start;
    padding-inline: 12px;
  }
  body.sidebar-collapsed .sidebar nav a span,
  body.sidebar-collapsed .logout-form .btn span {
    display: initial;
  }
  body.sidebar-collapsed .sidebar-system {
    display: block;
  }
  .topbar { margin-top: 0; }
  .page-head, .grid-two, .form-grid { grid-template-columns: 1fr; display: grid; }
  .filters { grid-template-columns: 1fr; }
  .danger-zone { display: grid; max-width: none; }
  .auth-brand-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .auth-brand-panel {
    min-height: 260px;
    padding: 28px;
    background:
      linear-gradient(180deg, rgba(17, 16, 16, .9), rgba(17, 16, 16, .97)),
      #111010;
  }
  .auth-brand-panel h1 { font-size: 26px; }
  .auth-form-stack,
  .auth-card { padding: 28px; }
  .auth-form-card { padding: 0; }
  .app-footer {
    display: grid;
  }
}
