:root {
  --bg-deep: #120c3a;
  --bg-mid: #1f1458;
  --bg-soft: #2f1d70;
  --card: rgba(255,255,255,.10);
  --card-strong: rgba(255,255,255,.16);
  --text: #fff8f0;
  --muted: #eadfcb;
  --gold: #c7b45d;
  --gold-soft: #e8dc9e;
  --red: #ef3c44;
  --red-dark: #c92735;
  --cream: #f6e7cf;
  --line: rgba(255,255,255,.11);
  --success: #5ed0ab;
  --danger: #ff8c88;
  --warning: #ffd37a;
  --shadow: 0 22px 50px rgba(0,0,0,.28);
  --radius-xl: 30px;
  --radius-lg: 24px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(239,60,68,.18), transparent 20%),
    radial-gradient(circle at top right, rgba(199,180,93,.16), transparent 24%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg-mid) 38%, var(--bg-deep) 100%);
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
.hidden { display: none !important; }
.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: .74rem;
  color: var(--gold-soft);
  margin-bottom: 8px;
  font-weight: 700;
}
.bg-totem, .bg-display, .bg-operator, .bg-login { min-height: 100vh; }

.totem-shell, .display-layout, .operator-shell, .login-shell {
  width: min(1440px, calc(100% - 38px));
  margin: 0 auto;
  padding: 24px 0 36px;
}
.brand-card, .display-header, .operator-header, .panel-card, .action-card, .stat-card, .login-card, .hero-call, .module-card, .empty-card, .active-item {
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.06));
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.brand-card, .display-header, .operator-header {
  padding: 28px 30px;
  border-radius: var(--radius-xl);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
.brand-card h1, .display-header h1, .operator-header h1, .login-card h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 3rem);
}
.brand-card p, .operator-header p, .login-card p { margin: 0; color: var(--muted); }

.brand-wrap, .display-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 24px;
  padding: 8px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.brand-accent {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--cream);
  font-size: .96rem;
}
.brand-accent::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-soft), var(--gold));
  box-shadow: 0 0 16px rgba(232,220,158,.45);
}
.clock-box, .display-clock {
  padding: 16px 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(0,0,0,.14));
  min-width: 290px;
  text-align: center;
  font-weight: 700;
  color: var(--cream);
  border: 1px solid rgba(255,255,255,.10);
}

.totem-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 26px;
}
.ticket-btn {
  min-height: 350px;
  border: 0;
  border-radius: 34px;
  padding: 34px;
  color: white;
  cursor: pointer;
  background: linear-gradient(145deg, #ef4b4f 0%, #cb2436 100%);
  box-shadow: 0 28px 50px rgba(124,18,31,.34);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.ticket-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,.22), transparent 35%);
  pointer-events: none;
}
.ticket-btn.priority {
  background: linear-gradient(145deg, #c8b65f 0%, #a28c33 100%);
  color: #2a1c03;
  box-shadow: 0 28px 50px rgba(101,83,14,.34);
}
.ticket-btn:hover { transform: translateY(-4px) scale(1.008); filter: brightness(1.03); }
.ticket-btn:active { transform: translateY(0) scale(.995); }
.ticket-btn .icon { font-size: 4.4rem; line-height: 1; }
.ticket-btn strong { font-size: clamp(2rem, 3.2vw, 3rem); }
.ticket-btn small { font-size: 1.12rem; opacity: .96; max-width: 90%; }
.ticket-chip {
  position: absolute;
  top: 22px;
  right: 22px;
  padding: 8px 12px;
  font-size: .85rem;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
}
.ticket-btn.priority .ticket-chip { background: rgba(42,28,3,.12); border-color: rgba(42,28,3,.18); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}
.stats-row.larger { margin-top: 20px; }
.stat-card {
  border-radius: 24px;
  padding: 20px 24px;
}
.stat-card span { color: var(--muted); display: block; margin-bottom: 10px; }
.stat-card strong { font-size: 2.2rem; color: var(--gold-soft); }

.modal {
  position: fixed; inset: 0; background: rgba(10,5,26,.50); display: grid; place-items: center; z-index: 50;
}
.modal-card.compact {
  background: #20134e; border-radius: 24px; padding: 28px; width: min(420px, calc(100% - 32px)); text-align: center; border: 1px solid rgba(255,255,255,.12);
}
.spinner {
  width: 58px; height: 58px; border-radius: 50%; border: 5px solid rgba(255,255,255,.15); border-top-color: var(--gold-soft); margin: 0 auto 16px; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.display-layout { padding-top: 24px; }
.hero-call {
  border-radius: 38px; padding: 40px 36px; margin-top: 24px; text-align: center; position: relative; overflow: hidden;
}
.hero-call::after {
  content: ''; position: absolute; inset: auto -10% -46% -10%; height: 220px; background: radial-gradient(circle, rgba(199,180,93,.28), transparent 65%);
}
.hero-label { color: var(--gold-soft); letter-spacing: .16em; text-transform: uppercase; font-weight: 700; }
.hero-number { font-size: clamp(4.5rem, 11vw, 8.5rem); font-weight: 800; margin-top: 8px; color: #fff; }
.hero-module { font-size: clamp(1.8rem, 4vw, 3rem); color: var(--cream); }
.hero-subtext { margin-top: 10px; color: var(--muted); font-size: 1.05rem; }
.flash { animation: flash 1s ease; }
@keyframes flash { 0%{transform:scale(1)} 35%{transform:scale(1.02)} 100%{transform:scale(1)} }

.module-board { margin-top: 26px; }
.section-title-row {
  display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px;
}
.section-title-row h2 { margin: 0; }
.section-title-row span { color: var(--muted); }
.module-grid, .operator-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.module-card, .empty-card, .panel-card, .action-card, .active-item {
  border-radius: 24px;
  padding: 22px;
}
.module-card strong { display: block; font-size: 2.9rem; margin: 12px 0 6px; color: #fff; }
.module-tag {
  display: inline-block; padding: 8px 14px; border-radius: 999px; background: rgba(199,180,93,.16); color: var(--gold-soft); font-size: .92rem; border: 1px solid rgba(199,180,93,.22);
}
.module-card small, .active-item small { color: var(--muted); }
.empty-card { color: var(--muted); }
.pulse { animation: pulse 1.1s ease; }
@keyframes pulse { 0%{transform:scale(1)} 50%{transform:scale(1.03)} 100%{transform:scale(1)} }

.operator-actions { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; margin-top: 24px; }
.btn-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-top: 18px; }
.btn-grid.single-col { grid-template-columns: 1fr; }
.primary-btn, .secondary-btn, .danger-btn, .ghost-btn {
  border: 0; border-radius: 18px; padding: 15px 18px; cursor: pointer; font-weight: 700; transition: transform .12s ease, opacity .12s ease;
}
.primary-btn:hover, .secondary-btn:hover, .danger-btn:hover, .ghost-btn:hover { transform: translateY(-2px); }
.primary-btn { color: white; background: linear-gradient(145deg, #ef4b4f, #cb2436); }
.secondary-btn { color: white; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.12); }
.danger-btn { color: #2e050a; background: linear-gradient(145deg, #ffd37a, #c7b45d); }
.ghost-btn { color: white; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); display: inline-flex; align-items: center; }
.action-btn { min-height: 58px; }
.highlight { outline: 1px solid rgba(199,180,93,.34); }
.hint { color: var(--muted); margin-top: 14px; }
.full { width: 100%; }

.operator-columns { margin-top: 20px; grid-template-columns: 1.35fr 1fr; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08); }
th { color: var(--gold-soft); font-size: .92rem; }
.status.waiting { display: inline-block; padding: 6px 10px; border-radius: 999px; background: rgba(255,211,122,.16); color: #ffe7aa; }
.empty-row { color: var(--muted); text-align: center; }
.active-list { display: grid; gap: 12px; }
.active-item { display: grid; gap: 4px; }
.active-item.mine { outline: 1px solid rgba(94,208,171,.35); background: linear-gradient(180deg, rgba(94,208,171,.12), rgba(255,255,255,.06)); }

.login-shell { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(460px, calc(100% - 30px)); border-radius: 30px; padding: 30px; }
.login-card label { display: block; margin: 16px 0 8px; color: #f6efe5; }
.login-card input {
  width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: white; padding: 14px 16px; border-radius: 16px;
}
.alert-error {
  padding: 12px 14px; border-radius: 16px; background: rgba(255,107,107,.15); color: #ffc4c4; margin: 14px 0;
}
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 360px; padding: 16px 18px; border-radius: 18px; background: rgba(94,208,171,.95); color: #032619; font-weight: 700; box-shadow: var(--shadow);
}
.toast.error { background: rgba(255,107,107,.95); color: white; }
.print-frame {
  position: fixed;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.totem-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: .95rem;
}
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.live-dot::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5ed0ab;
  box-shadow: 0 0 12px rgba(94,208,171,.8);
}

@media (max-width: 1100px) {
  .totem-grid, .module-grid, .operator-actions, .operator-columns { grid-template-columns: 1fr; }
  .btn-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .brand-card, .display-header, .operator-header { flex-direction: column; align-items: flex-start; }
  .stats-row { grid-template-columns: 1fr; }
  .clock-box, .display-clock { min-width: 0; width: 100%; }
  .ticket-btn { min-height: 250px; }
  .brand-wrap, .display-brand { align-items: flex-start; }
  .brand-logo { width: 78px; height: 78px; }
}
/* FIX HISTORIAL RECIENTE - SOLO ESTO */

.history-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.history-item {
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: 0.3s;
}

.history-item:hover {
    transform: translateY(-3px);
    background: rgba(255,255,255,0.12);
}

.history-code {
    font-size: 32px;
    font-weight: bold;
    text-align: center;
}

.history-meta strong {
    display: block;
    text-align: center;
    margin-top: 5px;
    font-size: 14px;
}

.history-type {
    text-align: center;
    font-size: 12px;
    margin-top: 3px;
}

.history-item time {
    text-align: center;
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.8;
}

@media (max-width: 900px) {
    .history-list {
        grid-template-columns: 1fr;
    }
}
