/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════════════ */
/*  🎨 TEMAS: Claro y Oscuro                     */
/* ══════════════════════════════════════════════ */

/* ── Tema Claro (por defecto) ── */
:root, [data-theme="light"] {
  --primary: #0f766e;
  --primary-light: #14b8a6;
  --primary-dark: #0d5c56;
  --primary-rgb: 15, 118, 110;
  --secondary: #1e40af;
  --secondary-rgb: 30, 64, 175;
  --accent: #f59e0b;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;

  --bg: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --input-focus: var(--primary);

  --header-bg: #ffffff;
  --header-border: #e2e8f0;
  --header-shadow: 0 1px 4px rgba(0,0,0,.04);

  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-hover: #f1f5f9;
  --sidebar-active-bg: var(--primary);
  --sidebar-active-text: #ffffff;

  --table-header-bg: #f8fafc;
  --table-row-hover: #f8fafc;
  --table-border: #e2e8f0;

  --modal-overlay: rgba(0,0,0,.5);
  --modal-bg: #ffffff;
  --modal-shadow: 0 25px 50px rgba(0,0,0,.25);

  --ticket-border: #e2e8f0;
  --ticket-area-bg: #f0fdf4;
  --ticket-area-text: var(--success);

  --badge-waiting-bg: #fef3c7;
  --badge-waiting-text: #92400e;
  --badge-calling-bg: #dbeafe;
  --badge-calling-text: #1e40af;
  --badge-recalling-bg: #e0e7ff;
  --badge-recalling-text: #3730a3;
  --badge-attending-bg: #dcfce7;
  --badge-attending-text: #166534;
  --badge-finished-bg: #f1f5f9;
  --badge-finished-text: #475569;
  --badge-cancelled-bg: #fee2e2;
  --badge-cancelled-text: #991b1b;

  --chart-track: #f1f5f9;
  --stat-card-bg: #ffffff;

  --notif-card-bg: #ffffff;
  --notif-card-shadow: 0 30px 60px rgba(0,0,0,.3);
  --notif-overlay: rgba(0,0,0,.8);

  --scrollbar-thumb: #cbd5e1;
  --scrollbar-hover: #94a3b8;

  --login-gradient: linear-gradient(135deg, #0f766e 0%, #1e40af 100%);
  --login-card-bg: #ffffff;
  --login-card-shadow: 0 25px 50px rgba(0,0,0,.2);

  --public-gradient: linear-gradient(135deg, #0c4a6e 0%, #0f766e 100%);
  --public-header-bg: rgba(0,0,0,.15);
  --public-card-bg: rgba(255,255,255,.1);
  --public-card-border: rgba(255,255,255,.15);
  --public-card-calling-bg: rgba(255,255,255,.18);
  --public-card-calling-border: rgba(255,255,255,.35);
  --public-waiting-item-bg: rgba(255,255,255,.08);
  --public-waiting-item-border: rgba(255,255,255,.08);

  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.12);
  --radius: 12px;

  --service-btn-bg: #ffffff;
  --service-btn-border: #e2e8f0;

  --theme-toggle-bg: #e2e8f0;
  --theme-toggle-knob: #ffffff;
  --theme-toggle-icon: '☀️';
}

/* ── Tema Oscuro ── */
[data-theme="dark"] {
  --primary: #14b8a6;
  --primary-light: #2dd4bf;
  --primary-dark: #0f766e;
  --primary-rgb: 20, 184, 166;
  --secondary: #3b82f6;
  --secondary-rgb: 59, 130, 246;
  --accent: #fbbf24;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #fbbf24;

  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --card: #1e293b;
  --card-hover: #334155;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --text-lighter: #64748b;
  --border: #334155;
  --border-light: #1e293b;

  --input-bg: #0f172a;
  --input-border: #334155;
  --input-focus: var(--primary);

  --header-bg: #1e293b;
  --header-border: #334155;
  --header-shadow: 0 1px 4px rgba(0,0,0,.3);

  --sidebar-bg: #1e293b;
  --sidebar-border: #334155;
  --sidebar-hover: #334155;
  --sidebar-active-bg: var(--primary);
  --sidebar-active-text: #0f172a;

  --table-header-bg: #1e293b;
  --table-row-hover: #334155;
  --table-border: #334155;

  --modal-overlay: rgba(0,0,0,.75);
  --modal-bg: #1e293b;
  --modal-shadow: 0 25px 50px rgba(0,0,0,.5);

  --ticket-border: #334155;
  --ticket-area-bg: rgba(22, 163, 74, .15);
  --ticket-area-text: var(--success);

  --badge-waiting-bg: rgba(245, 158, 11, .2);
  --badge-waiting-text: #fbbf24;
  --badge-calling-bg: rgba(59, 130, 246, .2);
  --badge-calling-text: #60a5fa;
  --badge-recalling-bg: rgba(99, 102, 241, .2);
  --badge-recalling-text: #818cf8;
  --badge-attending-bg: rgba(34, 197, 94, .2);
  --badge-attending-text: #4ade80;
  --badge-finished-bg: rgba(100, 116, 139, .15);
  --badge-finished-text: #94a3b8;
  --badge-cancelled-bg: rgba(239, 68, 68, .2);
  --badge-cancelled-text: #f87171;

  --chart-track: #334155;
  --stat-card-bg: #1e293b;

  --notif-card-bg: #1e293b;
  --notif-card-shadow: 0 30px 60px rgba(0,0,0,.6);
  --notif-overlay: rgba(0,0,0,.85);

  --scrollbar-thumb: #475569;
  --scrollbar-hover: #64748b;

  --login-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --login-card-bg: #1e293b;
  --login-card-shadow: 0 25px 50px rgba(0,0,0,.5);

  --public-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --public-header-bg: rgba(0,0,0,.3);
  --public-card-bg: rgba(255,255,255,.05);
  --public-card-border: rgba(255,255,255,.1);
  --public-card-calling-bg: rgba(20, 184, 166, .15);
  --public-card-calling-border: rgba(20, 184, 166, .4);
  --public-waiting-item-bg: rgba(255,255,255,.05);
  --public-waiting-item-border: rgba(255,255,255,.05);

  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.4);

  --service-btn-bg: #1e293b;
  --service-btn-border: #334155;

  --theme-toggle-bg: #334155;
  --theme-toggle-knob: #0f172a;
  --theme-toggle-icon: '🌙';
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color .3s ease, color .3s ease;
}
#app { min-height: 100vh; }

/* ══════════════════════════════════════════════ */
/*  🔘 Theme Toggle Switch                       */
/* ══════════════════════════════════════════════ */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  user-select: none;
}
.theme-toggle-track {
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: var(--theme-toggle-bg);
  position: relative;
  transition: background .3s ease;
  border: 2px solid var(--border);
}
.theme-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--theme-toggle-knob);
  transition: transform .3s ease, background .3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-theme="dark"] .theme-toggle-knob {
  transform: translateX(24px);
}
.theme-toggle-icon {
  font-size: .75rem;
  line-height: 1;
}
.theme-toggle-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-light);
}

/* ── Utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.text-center { text-align: center; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }
.text-5xl { font-size: 3rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-black { font-weight: 900; }
.text-muted { color: var(--text-light); }
.w-full { width: 100%; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.p-2 { padding: .5rem; }
.p-3 { padding: .75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.hidden { display: none !important; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
  transition: background .3s ease, border-color .3s ease;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
[data-theme="dark"] .btn-primary { color: #0f172a; }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #1e293b; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .375rem .75rem; font-size: .75rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-xl { padding: 1rem 2rem; font-size: 1.125rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-icon { padding: .5rem; min-width: 2.25rem; min-height: 2.25rem; }

/* ── Inputs ── */
.input, select, textarea {
  width: 100%;
  padding: .625rem .875rem;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: .875rem;
  color: var(--text);
  background: var(--input-bg);
  transition: border-color .15s, background .3s ease, color .3s ease;
  outline: none;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--input-focus);
}
.input::placeholder { color: var(--text-lighter); }
label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: .25rem;
}

/* ── Login ── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--login-gradient);
  padding: 1rem;
  position: relative;
}
.login-card {
  background: var(--login-card-bg);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--login-card-shadow);
  border: 1px solid var(--border);
  transition: background .3s ease, border-color .3s ease;
}
.login-card .logo { font-size: 3rem; text-align: center; margin-bottom: .5rem; }
.login-card h1 { text-align: center; font-size: 1.25rem; color: var(--primary); margin-bottom: .25rem; }
.login-card .subtitle { text-align: center; color: var(--text-light); font-size: .8125rem; margin-bottom: 1.5rem; }
.login-card .field { margin-bottom: 1rem; }
.login-error { color: var(--danger); font-size: .8125rem; text-align: center; margin-bottom: .75rem; font-weight: 500; }
.login-links { text-align: center; margin-top: 1rem; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.login-links a { color: var(--primary); font-size: .8125rem; text-decoration: none; font-weight: 500; cursor: pointer; }
.login-links a:hover { text-decoration: underline; }
.login-theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
}

/* ── Header ── */
.header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--header-shadow);
  transition: background .3s ease, border-color .3s ease;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-logo { font-size: 1.5rem; }
.header-title { font-size: 1rem; font-weight: 700; color: var(--primary); }
.header-user { display: flex; align-items: center; gap: .75rem; }
.header-profile-badge {
  background: var(--primary);
  color: white;
  padding: .25rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
[data-theme="dark"] .header-profile-badge { color: #0f172a; }
.header-window {
  background: var(--accent);
  color: #1e293b;
  padding: .25rem .75rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

/* ── Layout ── */
.main-layout {
  display: flex;
  min-height: calc(100vh - 57px);
}
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  transition: background .3s ease, border-color .3s ease;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .875rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-link:hover { background: var(--sidebar-hover); }
.sidebar-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-section {
  font-size: .6875rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .75rem .875rem .25rem;
}
.content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* ── Service Grid ── */
.service-category { margin-bottom: 1.5rem; }
.service-category h3 {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
}
.service-btn {
  background: var(--service-btn-bg);
  border: 2px solid var(--service-btn-border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  font-family: inherit;
}
.service-btn:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.service-btn .prefix {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: .125rem .5rem;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 700;
  margin-bottom: .375rem;
}
[data-theme="dark"] .service-btn .prefix { color: #0f172a; }
.service-btn .label { font-size: .875rem; font-weight: 600; color: var(--text); }
.service-btn .area { font-size: .6875rem; color: var(--text-light); margin-top: .25rem; }

/* Category colors */
.cat-consultas .prefix { background: #0f766e; }
.cat-estudios .prefix { background: #7c3aed; }
.cat-administrativos .prefix { background: #0369a1; }
.cat-donativos .prefix { background: #b45309; }
.cat-otros .prefix { background: #be185d; }

[data-theme="dark"] .cat-consultas .prefix { background: #14b8a6; color: #0f172a; }
[data-theme="dark"] .cat-estudios .prefix { background: #a78bfa; color: #0f172a; }
[data-theme="dark"] .cat-administrativos .prefix { background: #38bdf8; color: #0f172a; }
[data-theme="dark"] .cat-donativos .prefix { background: #fbbf24; color: #0f172a; }
[data-theme="dark"] .cat-otros .prefix { background: #f472b6; color: #0f172a; }

/* ── Ticket Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--modal-bg);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--modal-shadow);
  border: 1px solid var(--border);
  transition: background .3s ease, border-color .3s ease;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.125rem; color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}
.close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-light);
  padding: .25rem;
}
.close-btn:hover { color: var(--text); }

/* Ticket */
.ticket {
  border: 2px dashed var(--ticket-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.ticket-turn {
  font-size: 3rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: .05em;
}
.ticket-service { font-size: 1.125rem; font-weight: 600; margin: .25rem 0; color: var(--text); }
.ticket-info { font-size: .8125rem; color: var(--text-light); margin: .25rem 0; }
.ticket-area {
  margin-top: .75rem;
  padding: .5rem .75rem;
  background: var(--ticket-area-bg);
  border-radius: 8px;
  color: var(--ticket-area-text);
  font-weight: 600;
  font-size: .875rem;
}

/* ── Queue Table ── */
.queue-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.queue-table th {
  background: var(--table-header-bg);
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  border-bottom: 2px solid var(--table-border);
}
.queue-table td {
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--table-border);
  font-size: .875rem;
  color: var(--text);
}
.queue-table tr:hover td { background: var(--table-row-hover); }
.turn-code {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
}
.queue-actions { display: flex; gap: .375rem; flex-wrap: wrap; }

/* Status badges */
.badge {
  display: inline-block;
  padding: .125rem .625rem;
  border-radius: 20px;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-waiting { background: var(--badge-waiting-bg); color: var(--badge-waiting-text); }
.badge-calling { background: var(--badge-calling-bg); color: var(--badge-calling-text); animation: pulse-badge 1s infinite; }
.badge-recalling { background: var(--badge-recalling-bg); color: var(--badge-recalling-text); animation: pulse-badge .7s infinite; }
.badge-attending { background: var(--badge-attending-bg); color: var(--badge-attending-text); }
.badge-finished { background: var(--badge-finished-bg); color: var(--badge-finished-text); }
.badge-cancelled { background: var(--badge-cancelled-bg); color: var(--badge-cancelled-text); }

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

/* ══════════════════════════════════════════════ */
/*  🖥️ KIOSCO                                   */
/* ══════════════════════════════════════════════ */
.kiosco-screen {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* Header */
.kiosco-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #0f766e 0%, #1e40af 100%);
  color: white;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.kiosco-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.kiosco-logo {
  font-size: 2.5rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.2));
}
.kiosco-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.kiosco-subtitle {
  font-size: .875rem;
  opacity: .85;
  font-weight: 400;
}
.kiosco-header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.kiosco-clock {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.15);
  padding: .4rem 1rem;
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

/* Body */
.kiosco-body {
  flex: 1;
  padding: 2rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.kiosco-welcome {
  text-align: center;
  margin-bottom: 1.5rem;
}
.kiosco-welcome h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: .25rem;
}
.kiosco-welcome p {
  font-size: 1rem;
  color: var(--text-light);
}

/* Patient Input */
.kiosco-patient-row {
  max-width: 500px;
  margin: 0 auto 2rem;
}
.kiosco-patient-field label {
  display: block;
  font-weight: 600;
  margin-bottom: .5rem;
  color: var(--text);
  font-size: .95rem;
}
.kiosco-input {
  width: 100%;
  padding: .875rem 1rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
  border: 2px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  text-align: center;
  transition: border-color .2s;
}
.kiosco-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15);
}

/* Services */
.kiosco-services {
  margin-top: 1rem;
}
.kiosco-loading, .kiosco-error {
  text-align: center;
  padding: 3rem;
  font-size: 1.1rem;
  color: var(--text-light);
}
.kiosco-error {
  color: var(--danger);
}
.kiosco-category {
  margin-bottom: 2rem;
}
.kiosco-category-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}
.kiosco-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* Service Buttons */
.kiosco-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kiosco-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
  transition: height .2s;
}
.kiosco-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.kiosco-btn:hover::before {
  height: 6px;
}
.kiosco-btn:active {
  transform: translateY(0);
}
.kiosco-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}
.kiosco-btn-loading {
  opacity: .6;
  pointer-events: none;
}
.kiosco-btn-prefix {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: .05em;
}
.kiosco-btn-label {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}
.kiosco-btn-area {
  font-size: .75rem;
  color: var(--text-light);
}

/* Category Colors */
.kiosco-cat-donativos::before { background: #f59e0b; }
.kiosco-cat-donativos .kiosco-btn-prefix { color: #f59e0b; }
.kiosco-cat-donativos:hover { border-color: #f59e0b; }

.kiosco-cat-otros::before { background: #8b5cf6; }
.kiosco-cat-otros .kiosco-btn-prefix { color: #8b5cf6; }
.kiosco-cat-otros:hover { border-color: #8b5cf6; }

/* Ticket Overlay */
.kiosco-ticket-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn .3s ease;
}
.kiosco-ticket-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(0,0,0,.3);
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  animation: slideUp .4s ease;
}
.kiosco-ticket-header {
  background: linear-gradient(135deg, #0f766e, #16a34a);
  color: white;
  text-align: center;
  padding: 1.5rem;
}
.kiosco-ticket-check {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .5rem;
}
.kiosco-ticket-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
}
.kiosco-ticket-body {
  padding: 2rem;
  text-align: center;
}
.kiosco-ticket-clinic {
  font-size: .8rem;
  color: var(--text-light);
  margin-bottom: .5rem;
}
.kiosco-ticket-code {
  font-size: 4rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: .05em;
  line-height: 1;
  margin-bottom: .5rem;
}
.kiosco-ticket-service {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .5rem;
}
.kiosco-ticket-patient {
  font-size: .95rem;
  color: var(--text-light);
  margin-bottom: .5rem;
}
.kiosco-ticket-divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
  position: relative;
}
.kiosco-ticket-divider::before,
.kiosco-ticket-divider::after {
  content: '';
  position: absolute;
  top: -8px;
  width: 16px;
  height: 16px;
  background: var(--card);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--border);
}
.kiosco-ticket-divider::before { left: -2rem; }
.kiosco-ticket-divider::after { right: -2rem; }
.kiosco-ticket-info {
  font-size: 1rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.kiosco-ticket-info strong {
  color: var(--primary);
}
.kiosco-ticket-time {
  font-size: .8rem;
  color: var(--text-lighter);
  margin-top: 1rem;
}
.kiosco-ticket-actions {
  padding: 0 2rem 1.5rem;
  display: flex;
  gap: .75rem;
}
.kiosco-ticket-print {
  flex: 1;
}
.kiosco-ticket-close {
  flex: 1;
}
.kiosco-ticket-countdown {
  text-align: center;
  padding: 0 2rem 1.5rem;
  font-size: .8rem;
  color: var(--text-lighter);
}

/* Animations */
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive Kiosco */
@media (max-width: 768px) {
  .kiosco-header {
    flex-direction: column;
    gap: .75rem;
    padding: 1rem;
  }
  .kiosco-body {
    padding: 1rem;
  }
  .kiosco-welcome h2 {
    font-size: 1.25rem;
  }
  .kiosco-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
  }
  .kiosco-btn {
    padding: 1rem .75rem;
  }
  .kiosco-btn-prefix {
    font-size: 1.25rem;
  }
  .kiosco-ticket-code {
    font-size: 3rem;
  }
}

/* Print for Kiosco Ticket */
@media print {
  body * { visibility: hidden !important; }
  #kiosco-printable-ticket,
  #kiosco-printable-ticket *,
  #printable-ticket,
  #printable-ticket * {
    visibility: visible !important;
  }
  #kiosco-printable-ticket,
  #printable-ticket {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 80mm !important;
    padding: 5mm !important;
    background: white !important;
    color: black !important;
  }
  .kiosco-ticket-code {
    font-size: 2.5rem !important;
    color: black !important;
  }
}

/* ── Public Screen ── */
.public-screen {
  min-height: 100vh;
  background: var(--public-gradient);
  color: white;
  overflow: hidden;
}
.public-header {
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--public-header-bg);
}
.public-header h1 { font-size: 1.5rem; font-weight: 800; }
.public-header-right { display: flex; align-items: center; gap: 1.5rem; }
.public-clock {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.public-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2rem;
  min-height: calc(100vh - 100px);
}
.public-current {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.public-current-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .7;
}
.public-card {
  background: var(--public-card-bg);
  border: 1px solid var(--public-card-border);
  border-radius: 16px;
  padding: 2rem;
  backdrop-filter: blur(10px);
  transition: all .3s ease;
}
.public-card.calling {
  background: var(--public-card-calling-bg);
  border-color: var(--public-card-calling-border);
  animation: glow 2s infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(var(--primary-rgb), .2); }
  50% { box-shadow: 0 0 40px rgba(var(--primary-rgb), .4); }
}
.public-turn-code {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: .05em;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.public-turn-service { font-size: 1.5rem; font-weight: 600; margin-top: .5rem; }
.public-turn-window {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: .5rem;
  color: var(--accent);
}
.public-turn-area { font-size: 1rem; opacity: .7; margin-top: .25rem; }
.public-waiting { display: flex; flex-direction: column; gap: .75rem; }
.public-waiting-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .7;
}
.public-waiting-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.public-waiting-item {
  background: var(--public-waiting-item-bg);
  border-radius: 10px;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--public-waiting-item-border);
}
.public-waiting-item .code { font-weight: 800; font-size: 1.25rem; }
.public-waiting-item .svc { font-size: .875rem; opacity: .7; }
.public-no-turns {
  text-align: center;
  padding: 3rem;
  opacity: .4;
  font-size: 1.125rem;
}
.public-theme-toggle {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: .375rem .75rem;
  color: white;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  transition: background .2s;
  font-family: inherit;
}
.public-theme-toggle:hover { background: rgba(255,255,255,.25); }

/* ── Sound Toggle Button ── */
.sound-toggle-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: .375rem .75rem;
  color: white;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  transition: all .3s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: .375rem;
}
.sound-toggle-btn:hover {
  background: rgba(255,255,255,.25);
  transform: translateY(-1px);
}
.sound-toggle-btn.sound-active {
  background: rgba(34, 197, 94, .35);
  border-color: rgba(34, 197, 94, .6);
  box-shadow: 0 0 12px rgba(34, 197, 94, .3);
  animation: soundPulse 2s ease-in-out infinite;
}
@keyframes soundPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(34, 197, 94, .3); }
  50% { box-shadow: 0 0 20px rgba(34, 197, 94, .5); }
}

/* Voice name indicator inside sound button */
.voice-name {
  font-size: .7rem;
  font-weight: 400;
  opacity: .8;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

/* Voice settings button */
.voice-settings-btn {
  background: rgba(255,255,255,.1) !important;
  font-size: .8rem !important;
  padding: .25rem .5rem !important;
}
.voice-settings-btn:hover {
  background: rgba(255,255,255,.2) !important;
}

/* ── Voice Settings Panel ── */
.voice-settings-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn .2s ease;
}
.voice-settings-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.5);
  width: 90%;
  max-width: 480px;
  overflow: hidden;
}
.voice-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-alt, var(--card));
}
.voice-settings-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.voice-settings-body {
  padding: 1.25rem;
}
.voice-settings-body .field {
  margin-bottom: 1rem;
}
.voice-settings-body label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .375rem;
}
.voice-settings-body select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: .8rem;
  font-family: inherit;
}

/* Voice slider (range input) */
.voice-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  margin-top: .25rem;
}
.voice-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.voice-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.voice-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* ── Dashboard ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--stat-card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border);
  transition: background .3s ease, border-color .3s ease;
}
.stat-number { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: .75rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .05em; }
.stat-card.waiting .stat-number { color: var(--warning); }
.stat-card.calling .stat-number { color: var(--secondary); }
.stat-card.attending .stat-number { color: var(--primary); }
.stat-card.finished .stat-number { color: var(--success); }
.stat-card.cancelled .stat-number { color: var(--danger); }

.chart-bar-container { display: flex; flex-direction: column; gap: .5rem; }
.chart-bar-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.chart-bar-label { width: 160px; font-size: .8125rem; font-weight: 500; text-align: right; flex-shrink: 0; color: var(--text); }
.chart-bar-track { flex: 1; height: 28px; background: var(--chart-track); border-radius: 6px; overflow: hidden; }
.chart-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 .5rem;
  font-size: .75rem;
  font-weight: 700;
  color: white;
  transition: width .5s ease;
  min-width: fit-content;
}
[data-theme="dark"] .chart-bar-fill { color: #0f172a; }

/* ── Admin ── */
.admin-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1.5rem;
  background: var(--card);
  padding: .25rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.admin-tab {
  padding: .5rem 1rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text-light);
  transition: all .15s;
}
.admin-tab:hover { color: var(--text); background: var(--card-hover); }
.admin-tab.active { background: var(--primary); color: white; }
[data-theme="dark"] .admin-tab.active { color: #0f172a; }

/* ── Tabs filter ── */
.filter-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-tab {
  padding: .375rem .875rem;
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  color: var(--text-light);
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { border-color: var(--primary); background: var(--primary); color: white; }
[data-theme="dark"] .filter-tab.active { color: #0f172a; }

/* ── Patient Name Input ── */
.patient-input-row {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: end;
}
.patient-input-row .field { flex: 1; }

/* ── Notification Overlay ── */
.notification-overlay {
  position: fixed;
  inset: 0;
  background: var(--notif-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn .3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.notification-card {
  background: var(--notif-card-bg);
  border-radius: 24px;
  padding: 3rem;
  text-align: center;
  box-shadow: var(--notif-card-shadow);
  animation: scaleIn .4s ease;
  max-width: 500px;
  width: 90%;
  border: 1px solid var(--border);
}
@keyframes scaleIn { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.notification-code {
  font-size: 5rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: .05em;
  line-height: 1;
}
.notification-service { font-size: 1.5rem; font-weight: 600; margin: .5rem 0; color: var(--text); }
.notification-window {
  font-size: 2rem;
  font-weight: 800;
  color: var(--secondary);
  margin: .5rem 0;
}
.notification-area { font-size: 1rem; color: var(--text-light); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .public-body { grid-template-columns: 1fr; }
  .public-turn-code { font-size: 3.5rem; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .header { padding: .5rem 1rem; }
  .content { padding: 1rem; }
  .service-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .public-header { padding: 1rem; }
  .public-header h1 { font-size: 1rem; }
  .public-body { padding: 1rem; }
  .public-turn-code { font-size: 2.5rem; }
  .header-user { gap: .375rem; }
  .header-user .font-medium { display: none; }
}

/* print ticket */
@media print {
  body * { visibility: hidden; }
  .ticket-print, .ticket-print * { visibility: visible; }
  .ticket-print { position: absolute; left: 0; top: 0; width: 80mm; background: white !important; color: #000 !important; }
  .ticket-print .ticket-turn { color: #000 !important; }
}

/* ── Smooth transitions for theme changes ── */
.header, .sidebar, .card, .modal, .stat-card, .service-btn, .admin-tabs, .filter-tab, .input, select, textarea {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .3s ease;
}
