:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --border: #334155;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Modo claro (toggle en panel admin; persistido en localStorage) */
:root[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .alert-error {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}

:root[data-theme="light"] .alert-ok {
  color: #166534;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}

:root[data-theme="light"] .alert-warning {
  color: #92400e;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
}

:root[data-theme="light"] .badge-verde {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
  border-color: rgba(34, 197, 94, 0.35);
}

:root[data-theme="light"] .badge-amarillo {
  background: rgba(245, 158, 11, 0.2);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.4);
}

:root[data-theme="light"] .badge-rojo {
  background: rgba(239, 68, 68, 0.15);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.35);
}

:root[data-theme="light"] .page-spinner {
  background: rgba(241, 245, 249, 0.92);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
select,
textarea {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field {
  margin-bottom: 14px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.row > * {
  flex: 1;
}

.center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.muted {
  color: var(--muted);
}

.title {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  align-items: center;
}

.nav .spacer {
  flex: 1;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.nav-brand:hover {
  color: inherit;
  opacity: 0.92;
}

.site-logo {
  height: 36px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
}

.login-brand {
  text-align: center;
  margin-bottom: 16px;
}

.login-brand .site-logo {
  height: 56px;
  max-width: 160px;
  margin: 0 auto;
}

.landing-brand .site-logo {
  height: 72px;
  max-width: 200px;
  margin: 0 auto 12px;
}

.nav a {
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
}

.nav a:hover,
.nav a.active {
  background: var(--card);
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin: 12px 0;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.alert-ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.badge-verde {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
}

.badge-amarillo {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.4);
}

.badge-rojo {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.4);
}

.kiosk {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.kiosk-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.kiosk-display {
  font-size: 3rem;
  font-weight: 700;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 16px;
  letter-spacing: 0.2em;
  margin-bottom: 20px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kiosk-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kiosk-key {
  font-size: 2rem;
  padding: 18px 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.kiosk-key:hover {
  background: var(--card);
}

.kiosk-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kiosk-action {
  font-size: 1.4rem;
  padding: 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: white;
}

.kiosk-action.entrada {
  background: var(--primary);
}

.kiosk-action.salida {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
}

.kiosk-feedback {
  margin-top: 24px;
  padding: 24px;
  border-radius: 14px;
  font-size: 1.4rem;
  font-weight: 600;
  display: none;
}

.kiosk-feedback.show {
  display: block;
}

.kiosk-feedback.verde {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: #bbf7d0;
}

.kiosk-feedback.amarillo {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fcd34d;
}

.kiosk-feedback.rojo {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.kiosk-destacado {
  display: none;
  margin-top: 16px;
  padding: 20px 16px;
  border-radius: 14px;
  font-size: clamp(1.1rem, 3vw, 1.75rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.35;
  border: 2px solid rgba(245, 158, 11, 0.7);
  background: rgba(245, 158, 11, 0.25);
  color: #fef3c7;
}

.kiosk-destacado.show {
  display: block;
}

.rest-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 8px 0;
  color: var(--primary);
}

.bar {
  height: 14px;
  background: var(--bg-soft);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  background: var(--primary);
}

.bar-fill.verde {
  background: var(--success);
}

.bar-fill.amarillo {
  background: var(--warning);
}

.bar-fill.rojo {
  background: var(--danger);
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.landing-actions {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.landing-actions .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  text-align: center;
  white-space: nowrap;
  padding: 10px 14px;
}

@media (max-width: 640px) {
  .landing-actions {
    grid-template-columns: 1fr;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 0;
}

.modal-body {
  margin-top: 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

.page-spinner {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  flex-direction: column;
  gap: 12px;
  font-weight: 600;
  color: var(--text);
}

.page-spinner[hidden] {
  display: none !important;
}

.page-spinner::after {
  content: "";
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: gf-spin 0.75s linear infinite;
}

@keyframes gf-spin {
  to {
    transform: rotate(360deg);
  }
}

.gf-flash {
  margin-bottom: 12px;
}

.kiosk-photo {
  max-width: 160px;
  max-height: 160px;
  border-radius: 12px;
  object-fit: cover;
  margin: 0 auto 12px;
  display: block;
  border: 2px solid var(--border);
}

/* Panel admin — layout más profesional */
.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 640px;
  line-height: 1.45;
}

.tab-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 6px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tab-bar button {
  font: inherit;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.tab-bar button:hover {
  color: var(--text);
  background: var(--card);
}

.tab-bar button.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.toolbar .field {
  margin-bottom: 0;
  min-width: 160px;
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.table-wrap table {
  margin-top: 0;
}

.table-wrap th:first-child,
.table-wrap td:first-child {
  padding-left: 16px;
}

.table-wrap th:last-child,
.table-wrap td:last-child {
  padding-right: 16px;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.actions-cell .btn-sm {
  white-space: nowrap;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.split-panels {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
}

@media (max-width: 720px) {
  .page-header h1 {
    font-size: 1.45rem;
  }
}
