@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   DESIGN SYSTEM TOKENS — Formal & Institutional
   ============================================================ */
:root {
  --primary: #0b192c;
  /* Azul marino ejecutivo profundo */
  --primary-hover: #142844;
  --primary-light: #eef2f6;
  --primary-gradient: #0b192c;
  --accent: #0f4c5c;
  /* Acento clínico sobrio */
  --secondary: #334155;
  --secondary-gradient: #334155;

  --success: #065f46;
  --success-light: #ecfdf5;
  --success-gradient: #065f46;

  --warning: #92400e;
  --warning-light: #fffbeb;
  --danger: #991b1b;
  --danger-light: #fef2f2;

  --bg: #eef1f5;
  /* Fondo gris corporativo */
  --surface-solid: #ffffff;
  --text-dark: #0b1320;
  --text-body: #334155;
  --text-muted: #5a6678;
  --border: #d5dce4;
  --border-strong: #b8c4d0;

  --shadow-xs: 0 1px 2px rgba(11, 25, 44, 0.05);
  --shadow-sm: 0 1px 3px rgba(11, 25, 44, 0.07);
  --shadow-md: 0 3px 10px rgba(11, 25, 44, 0.08);
  --shadow-lg: 0 8px 24px rgba(11, 25, 44, 0.12);
  --shadow-primary: 0 1px 3px rgba(11, 25, 44, 0.22);
  --shadow-success: 0 1px 3px rgba(6, 95, 70, 0.2);

  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 6px;

  --transition: all 0.14s ease;
  --transition-bounce: all 0.14s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   MODAL DE LOGIN
   ============================================================ */
#overlay {
  position: fixed;
  inset: 0;
  background-color: #ffffff;
  z-index: 1000;
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  animation: fadeIn 0.3s ease;
}

.abstract-waves {
  display: none;
}

.circular-login {
  width: 100%;
  max-width: 400px;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 2.5rem 2.5rem !important;
  position: relative;
  text-align: left !important;
  animation: slideUp 0.3s ease;
}

.login-title {
  color: var(--text-dark) !important;
  font-size: 1.4rem !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  margin-bottom: 2rem !important;
  text-align: center;
}

.form-group-login {
  position: relative;
  margin-bottom: 1.25rem;
}

.form-group-login input,
.form-group-login select {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  color: var(--text-dark);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-group-login input:focus,
.form-group-login select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.form-group-login input::placeholder {
  color: #94a3b8;
  font-size: 0.9rem;
}

.login-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.2rem;
  height: 1.2rem;
  color: #64748b;
  pointer-events: none;
}

.login-btn-glass {
  width: 100%;
  margin: 1.5rem auto 0;
  display: block;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(26, 52, 97, 0.25);
  transition: all 0.18s ease;
}

.login-btn-glass:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(26, 52, 97, 0.32);
}

.login-btn-glass:active {
  opacity: 0.9;
  box-shadow: 0 1px 4px rgba(26, 52, 97, 0.2);
}

.login-btn-glass.loading-animation {
  animation: pulse-glow 1.5s infinite alternate ease-in-out;
  pointer-events: none;
  opacity: 0.8;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.1);
    transform: scale(0.98);
  }

  100% {
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
  }
}

.ekg-line {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: ekg-draw 1.5s linear infinite;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.8));
}

@keyframes ekg-draw {
  0% {
    stroke-dashoffset: 200;
  }

  50% {
    stroke-dashoffset: 0;
  }

  100% {
    stroke-dashoffset: -200;
  }
}

@keyframes pulse-text {
  0% {
    opacity: 0.6;
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.2);
  }

  100% {
    opacity: 1;
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.8);
  }
}

.login-footer-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.login-link {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}

.login-link:hover {
  color: var(--primary);
}

.btn-tv-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-tv-link:hover {
  color: var(--primary);
}

/* ============================================================
   ICONOGRAFÍA CORPORATIVA (SVG) & INDICADORES
   ============================================================ */
.ui-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 1.85;
  vertical-align: middle;
}

.ui-icon-lg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 1.85;
  color: var(--primary);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.status-dot-warning {
  background: var(--warning);
}

.status-dot-danger {
  background: var(--danger);
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  background: #ffffff;
  border-top: 3px solid var(--primary);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-xs);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo img {
  height: 38px;
  object-fit: contain;
  transition: opacity 0.16s ease;
}

.header-logo img:hover {
  opacity: 0.88;
}

.header-logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-dark);
  padding-left: 1rem;
  border-left: 1px solid var(--border);
  line-height: 1.2;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
}

#roleBadge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius-xs);
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--border-strong);
  line-height: 1.1;
}

#displayUserName {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-dark);
}

.logout-btn {
  background: transparent;
  color: var(--text-body);
  border: 1px solid var(--border-strong);
  padding: 0.42rem 0.9rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.logout-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* ============================================================
   NAVEGACIÓN PRINCIPAL
   ============================================================ */
.main-nav {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 66px;
  z-index: 90;
  box-shadow: var(--shadow-xs);
}

.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 0.5rem;
}

.nav-item {
  background: transparent;
  border: none;
  padding: 0.95rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.005em;
}

.nav-item:hover {
  color: var(--text-dark);
  border-bottom-color: var(--border-strong);
}

.nav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* ============================================================
   MAIN
   ============================================================ */
main {
  flex: 1;
  padding: 2rem;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

.view {
  display: none;
  animation: fadeInScale 0.22s ease;
}

.view.active {
  display: block;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  margin-bottom: 1.5rem;
}

.card:hover {
  border-color: var(--border-strong);
}

.card h2 {
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.card>p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Card header row (title + actions) */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-header h2 {
  margin-bottom: 0;
}

.card-header-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Sub-section box (e.g. create user form) */
.card-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: none;
}

.card-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}

.full-width {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-body);
  margin-bottom: 0.4rem;
  letter-spacing: 0.015em;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: #ffffff;
  color: var(--text-dark);
  transition: var(--transition);
  outline: none;
  width: 100%;
  box-shadow: var(--shadow-xs);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #94a3b8;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: #94a3b8;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 37, 68, 0.1);
  background: #ffffff;
}

/* Standalone search */
.search-input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 0.9rem center no-repeat;
  color: var(--text-dark);
  outline: none;
  transition: var(--transition);
  margin-bottom: 1.25rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-large {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  box-shadow: var(--shadow-primary);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-large:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(15, 37, 68, 0.25);
}

.btn-large:active {
  opacity: 0.92;
}

.btn-large:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none !important;
  filter: grayscale(0.4);
}

.btn-large.btn-secondary {
  background: var(--secondary);
  box-shadow: 0 2px 6px rgba(71, 85, 105, 0.2);
}

.btn-large.btn-secondary:hover {
  background: #334155;
  box-shadow: 0 4px 10px rgba(71, 85, 105, 0.25);
}

.btn-large.btn-success {
  background: var(--success);
  box-shadow: var(--shadow-success);
}

.btn-large.btn-success:hover {
  background: #065f46;
}

.btn-action {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.84rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}

.btn-action:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-action:active {
  opacity: 0.92;
}

.btn-action.btn-danger {
  background: var(--danger);
}

.btn-action.btn-danger:hover {
  background: #991b1b;
}

.btn-volver {
  display: block;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.85rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.93rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn-volver:hover {
  background: var(--bg);
  color: var(--text-dark);
  border-color: var(--primary);
}

/* ============================================================
   NEXT-PATIENT BANNER
   ============================================================ */
.next-patient {
  background: var(--primary);
  color: white;
  padding: 1.5rem 2rem;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 1.5rem;
  box-shadow: none;
  border: 1px solid var(--primary-hover);
  position: relative;
  overflow: hidden;
}

.next-patient.triaje-banner {
  background: var(--success);
  border-color: #047857;
  box-shadow: none;
}

.next-patient h3 {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
}

.next-patient .big-number {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0.25rem 0;
  text-shadow: none;
  position: relative;
}

.next-patient .patient-name-display {
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 500;
  position: relative;
}

/* ============================================================
   PATIENT LISTS
   ============================================================ */
.patient-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.patient-item {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.4rem 1.1rem 1.65rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.patient-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.patient-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  border-radius: 3px 0 0 3px;
}

.patient-item.en-consulta {
  background: rgba(236, 253, 245, 0.7);
  border-color: rgba(4, 120, 87, 0.25);
}

.patient-item.en-consulta::before {
  background: var(--success);
}

.patient-item.estado-espera::before {
  background: var(--warning);
}

.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
}

.patient-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
  line-height: 1.35;
}

.patient-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.patient-actions {
  display: flex;
  gap: 0.55rem;
  flex-shrink: 0;
  align-items: center;
}

/* Badges */
.badge-turno {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-status.espera {
  background: var(--warning-light);
  color: #92400e;
}

.badge-status.consulta {
  background: var(--success-light);
  color: #065f46;
}

.badge-status.pending {
  background: var(--primary-light);
  color: #3730a3;
}

/* Signos vitales grid */
.patient-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.data-item {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s ease, background 0.2s ease;
}

.data-item:hover {
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
}

.data-item .data-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.data-item .data-value {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--text-dark);
}

/* For backward compat (old span usage in data-item) */
.data-item span:first-child {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.data-item span:last-child {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--text-dark);
}

/* ============================================================
   ADMIN USER LIST
   ============================================================ */
.admin-user-item,
.patient-item[data-admin-row] {
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}

.admin-user-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.admin-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.admin-username {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
}

.admin-user-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.role-badge.admin {
  background: #1e293b;
  color: #f8fafc;
}

.role-badge.doctor {
  background: #dbeafe;
  color: #1d4ed8;
}

.role-badge.enfermera {
  background: #ccfbf1;
  color: #0f766e;
}

.role-badge.turnero {
  background: #fef3c7;
  color: #92400e;
}

.area-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */
.state-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  text-align: center;
  gap: 0.75rem;
}

.state-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.85;
}

.state-empty-icon svg {
  width: 20px;
  height: 20px;
}

.state-empty-text {
  font-weight: 600;
  font-size: 0.97rem;
}

.state-empty-sub {
  font-size: 0.85rem;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.7rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--surface-solid);
  color: var(--text-dark);
  padding: 0.9rem 1.4rem 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.93rem;
  animation: slideInRight 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  border-left: 4px solid var(--primary);
  pointer-events: all;
  min-width: 260px;
  max-width: 380px;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(36px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.04);
    opacity: 0.85;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(48px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1.25rem;
  }

  .user-info {
    width: 100%;
    justify-content: space-between;
  }

  main {
    padding: 1.25rem 0.9rem;
  }

  .card {
    padding: 1.4rem 1.25rem;
  }

  .next-patient {
    padding: 1.5rem 1.25rem;
  }

  .next-patient .big-number {
    font-size: 3rem;
  }

  .patient-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
  }

  .patient-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .btn-action {
    flex: 1;
    justify-content: center;
  }

  .admin-user-item {
    flex-direction: column !important;
    align-items: flex-start;
  }

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

/* ============================================================
   MODAL EXPORTAR EXCEL
   ============================================================ */
#modalExcelExport {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.22s ease;
}

.modal-excel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.modal-excel-box {
  position: relative;
  z-index: 1;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: min(540px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px -10px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(79, 70, 229, 0.08);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* Barra de color superior */
.modal-excel-box::before {
  content: '';
  display: block;
  height: 5px;
  background: var(--success-gradient);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-excel-inner {
  padding: 2rem 2.25rem 2.25rem;
  max-height: calc(88vh - 5px);
  overflow-y: auto;
}

.modal-excel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-excel-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--success-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-success);
  flex-shrink: 0;
}

.modal-excel-titles {
  flex: 1;
  margin-left: 1rem;
}

.modal-excel-titles h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: -0.03em;
  margin-bottom: 0.2rem;
}

.modal-excel-titles p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-excel-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  font-family: inherit;
}

.modal-excel-close:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
  transform: rotate(90deg);
}

/* Secciones del modal */
.modal-excel-section {
  margin-bottom: 1.25rem;
}

.modal-excel-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.modal-excel-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Lista de especialidades */
.excel-esp-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 210px;
  overflow-y: auto;
  padding: 0.4rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.excel-esp-list::-webkit-scrollbar {
  width: 4px;
}

.excel-esp-list::-webkit-scrollbar-track {
  background: transparent;
}

.admin-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.admin-user-item:hover {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
  border-color: var(--border-strong);
}

.admin-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.admin-username {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-dark);
}

.admin-user-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.excel-esp-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

/* Opciones radio estilizadas */
.excel-radio-opt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border: 1.5px solid transparent;
  user-select: none;
}

.excel-radio-opt:hover {
  background: var(--primary-light);
  border-color: rgba(26, 52, 97, 0.2);
}

.excel-radio-opt input[type="radio"] {
  display: none;
}

/* Custom radio bullet */
.excel-radio-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.excel-radio-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0;
  transform: scale(0);
  transition: var(--transition);
}

.excel-radio-opt input[type="radio"]:checked~.excel-radio-dot {
  border-color: var(--primary);
  background: var(--primary-light);
}

.excel-radio-opt input[type="radio"]:checked~.excel-radio-dot::after {
  opacity: 1;
  transform: scale(1);
}

.excel-radio-opt:has(input:checked) {
  background: var(--primary-light);
  border-color: rgba(26, 52, 97, 0.25);
}

.excel-radio-opt:has(input:checked) .excel-radio-label {
  color: var(--primary);
  font-weight: 600;
}

.excel-radio-label {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-body);
  transition: color 0.15s;
  line-height: 1.3;
}

/* Opciones de filtro — chips horizontales */
.excel-filtro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.excel-chip-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface-solid);
  transition: var(--transition);
  text-align: center;
  user-select: none;
}

.excel-chip-opt:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.excel-chip-opt input[type="radio"] {
  display: none;
}

.excel-chip-opt:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(26, 52, 97, 0.15);
}

.excel-chip-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.excel-chip-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
}

.excel-chip-opt:has(input:checked) .excel-chip-label {
  color: var(--primary);
  font-weight: 700;
}

/* Botones del footer del modal */
.modal-excel-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.modal-excel-footer .btn-large {
  margin: 0;
}

.btn-excel-download {
  flex: 1;
  background: var(--success-gradient) !important;
  box-shadow: var(--shadow-success) !important;
}

.btn-excel-download:hover {
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.4) !important;
}

.btn-excel-cancel {
  flex: 0 0 auto;
  background: var(--bg) !important;
  color: var(--text-muted) !important;
  border: 1.5px solid var(--border) !important;
  box-shadow: none !important;
  background-image: none !important;
}

.btn-excel-cancel:hover {
  background: var(--surface-solid) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-dark) !important;
  box-shadow: var(--shadow-xs) !important;
  transform: none !important;
}

@media (max-width: 480px) {
  .modal-excel-inner {
    padding: 1.5rem 1.25rem 1.75rem;
  }

  .excel-filtro-grid {
    grid-template-columns: 1fr;
  }

  .modal-excel-footer {
    flex-direction: column-reverse;
  }

  .btn-excel-cancel {
    width: 100%;
  }
}

/* ============================================================
   IMPRESIÓN (TICKET TÉRMICO)
   ============================================================ */
@media print {
  body * {
    visibility: hidden;
  }

  #printArea,
  #printArea * {
    visibility: visible;
  }

  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    /* Formato ticketera térmica */
    padding: 0;
    margin: 0;
    color: #000 !important;
  }

  /* Ticket Styles */
  .ticket-print {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    color: #000;
  }

  .ticket-print h1 {
    font-size: 16px;
    font-weight: bold;
    margin: 5px 0;
  }

  .ticket-print h2 {
    font-size: 24px;
    font-weight: bold;
    margin: 10px 0;
  }

  .ticket-print .line {
    border-top: 1px dashed #000;
    margin: 10px 0;
  }

  .ticket-print p {
    margin: 4px 0;
  }
}

/* ============================================================
   ANIMACIONES GLOBALES
   ============================================================ */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-5px);
  }

  80% {
    transform: translateX(5px);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* ============================================================
   RESPONSIVIDAD MÓVIL
   ============================================================ */
@media (max-width: 650px) {
  .circular-login {
    width: 92% !important;
    height: auto !important;
    min-height: 480px !important;
    border-radius: 32px !important;
    padding: 3rem 1.5rem 2.5rem 1.5rem !important;
  }

  .login-footer-links {
    margin-top: 1.5rem !important;
  }

  .login-link {
    font-size: 0.7rem !important;
    width: 100% !important;
  }

  .form-group-login input {
    font-size: 0.95rem;
  }
}

/* ============================================================
   BOTÓN MODO OSCURO
   ============================================================ */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  transition: var(--transition);
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

html[data-theme="dark"] .card-section {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] #roleBadge {
  background: rgba(126, 168, 212, 0.14);
  color: #93c5fd;
  border-color: rgba(126, 168, 212, 0.25);
}

/* ============================================================
   MODO OSCURO — NEGRO MATE
   ============================================================ */
html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #7ea8d4;
  /* Azul acero claro para dark mode */
  --primary-hover: #93bcdf;
  --primary-light: rgba(100, 150, 200, 0.12);
  --primary-gradient: #5b84b1;
  --secondary-gradient: #4b6080;
  --success-light: rgba(16, 185, 129, 0.14);
  --warning-light: rgba(180, 83, 9, 0.14);
  --danger-light: rgba(185, 28, 28, 0.14);
  --bg: #0f1117;
  --surface-solid: #181c24;
  --text-dark: #e8eaf0;
  --text-body: #b8bdc9;
  --text-muted: #7a8090;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.65);
  --shadow-primary: 0 6px 18px rgba(94, 130, 170, 0.22);
}

html[data-theme="dark"] body {
  background-color: #0d1117;
  background-attachment: fixed;
}

html[data-theme="dark"] header,
html[data-theme="dark"] .main-nav {
  background: rgba(18, 22, 32, 0.97);
  border-color: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-excel-box {
  background: #141416;
  border-color: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background-color: #1b1b1e;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-dark);
}

html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group select:focus,
html[data-theme="dark"] .search-input:focus {
  background-color: #222226;
}

html[data-theme="dark"] .form-group input::placeholder,
html[data-theme="dark"] .form-group textarea::placeholder {
  color: #6b6b73;
}

html[data-theme="dark"] select option {
  background: #1b1b1e;
  color: var(--text-dark);
}

html[data-theme="dark"] .patient-item,
html[data-theme="dark"] .admin-user-item,
html[data-theme="dark"] .data-item {
  background: #1a1a1d;
  border-color: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .patient-item:hover,
html[data-theme="dark"] .admin-user-item:hover,
html[data-theme="dark"] .data-item:hover {
  background: #222226;
}

html[data-theme="dark"] .user-info {
  background: #1a1a1d;
}

html[data-theme="dark"] .logout-btn {
  color: #fca5a5;
}

html[data-theme="dark"] table,
html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-body);
}

html[data-theme="dark"] th {
  background: #1b1b1e;
}

html[data-theme="dark"] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #0e0e10;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #2a2a2e;
  border-radius: 10px;
}

/* ============================================================
   RESPONSIVE DESIGN (MOBILE)
   ============================================================ */
@media (max-width: 768px) {

  /* === LOGIN SPLIT-SCREEN -> STACKED === */
  #overlay {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
  }

  /* Blue left panel shrinks to a top banner */
  #overlay>div:first-child {
    flex: 0 0 auto !important;
    width: 100% !important;
    padding: 3.5rem 1.5rem 2rem !important;
    justify-content: flex-start !important;
  }

  #overlay>div:first-child h1 {
    font-size: 2rem !important;
  }

  #overlay>div:first-child p {
    font-size: 0.95rem !important;
    margin-bottom: 1rem !important;
  }

  .absolute-footer {
    position: relative !important;
    left: 0 !important;
    bottom: 0 !important;
    margin-top: 1.5rem;
    font-size: 0.78rem !important;
    opacity: 0.7;
  }

  /* White right panel fills the rest */
  #overlay>div:last-child {
    flex: 1 1 auto !important;
    width: 100% !important;
    padding: 2.5rem 1.5rem 3rem !important;
    justify-content: flex-start !important;
    box-shadow: none !important;
  }

  /* === HEADER === */
  header {
    padding: 0.75rem 1rem !important;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  header .logo-area {
    gap: 0.5rem;
  }

  header .logo-area img {
    max-height: 32px !important;
  }

  header .logo-area span {
    font-size: 0.9rem !important;
  }

  .user-info {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  #roleBadge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .logout-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
  }

  /* === NAVIGATION === */
  .main-nav {
    top: auto !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-container {
    padding: 0 0.5rem;
    gap: 0;
    min-width: max-content;
  }

  .nav-item {
    padding: 0.9rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* === MAIN CONTENT === */
  main {
    padding: 1rem;
  }

  .card {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-sm);
  }

  .card h2 {
    font-size: 1.2rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .card-header-actions {
    width: 100%;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .card-header-actions .btn-action {
    flex: 1;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
  }

  /* === FORM GRIDS === */
  .form-grid {
    grid-template-columns: 1fr;
  }

  .full-width {
    grid-column: 1;
  }

  /* === BUTTONS SIDE BY SIDE === */
  .btn-large {
    font-size: 0.95rem;
    padding: 0.9rem 1rem;
  }

  /* Pair of buttons next to each other */
  div[style*="display:flex"][style*="gap:1rem"],
  div[style*="display: flex"][style*="gap: 1rem"] {
    flex-direction: column !important;
    gap: 0.6rem !important;
  }

  /* === PATIENT ITEMS === */
  .patient-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .patient-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* === NEXT PATIENT BANNER === */
  .next-patient {
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
  }

  .next-patient .big-number {
    font-size: 2rem;
  }

  .next-patient .patient-name-display {
    font-size: 0.9rem;
  }

  /* === TABLE OVERFLOW === */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.82rem;
  }
}


/* ============================================================
   EXECUTIVE ENTERPRISE THEME — ENSING CORPORATE (ULTRA-FORMAL)
   ============================================================ */
:root {
  --primary: #111827;
  --primary-hover: #1f2937;
  --primary-light: #f3f4f6;
  --primary-gradient: #111827;
  --accent: #0f4c5c;
  --secondary: #374151;
  --bg: #f5f6f8;
  --surface-solid: #ffffff;
  --text-dark: #111827;
  --text-body: #374151;
  --text-muted: #6b7280;
  --border: #dfe3e8;
  --border-strong: #c4cbd4;
}

body {
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-variant-numeric: tabular-nums;
  background-color: var(--bg);
}

/* Ultra-Formal Light Executive Header */
header {
  background: #ffffff;
  border-top: none;
  border-bottom: 1px solid var(--border);
  padding: 0 2.5rem;
  height: 62px;
  box-shadow: none;
}

.header-logo {
  gap: 1.15rem;
}

.header-logo img {
  height: 38px;
  filter: none;
}

.header-logo h1 {
  color: #111827;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-left: 1px solid var(--border);
  padding-left: 1.15rem;
}

.user-info {
  gap: 0.75rem;
}

#roleBadge {
  background: transparent;
  color: #6b7280;
  border: none;
  border-radius: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 0;
  text-transform: uppercase;
}

#displayUserName {
  color: #111827;
  font-size: 0.85rem;
  font-weight: 600;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

header .theme-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: #6b7280;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  margin-right: 0.9rem;
}

header .theme-toggle:hover {
  background: #f3f4f6;
  border-color: var(--border);
  color: #111827;
}

header .logout-btn {
  background: transparent;
  border: 1px solid transparent;
  border-left: 1px solid var(--border);
  border-radius: 0;
  color: #4b5563;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  margin-left: 0.25rem;
}

header .logout-btn:hover {
  background: transparent;
  border-color: transparent;
  border-left-color: var(--border);
  color: #991b1b;
}

/* Quiet Architectural Sub-Navigation Bar */
.main-nav {
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  top: 62px;
  box-shadow: none;
}

.nav-container {
  padding: 0 2.5rem;
  gap: 0.25rem;
}

.nav-item {
  padding: 0.8rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.005em;
  color: #6b7280;
  border-bottom: 2px solid transparent;
}

.nav-item:hover {
  color: #111827;
  background: transparent;
  border-bottom-color: #d1d5db;
}

.nav-item.active {
  color: #111827;
  border-bottom-color: #111827;
  background: transparent;
  font-weight: 700;
}

/* Tailored Formal Select Controls */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem !important;
}

/* Structured Quiet Cards */
.card {
  border: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.75rem 2.25rem;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.03);
}

.card:hover {
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
  border-color: var(--border-strong);
  border-top-color: var(--border-strong);
}

.card h2 {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111827;
}

.card-header {
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-section {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem 1.75rem;
}

.card-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #374151;
  padding-bottom: 0.65rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

/* Formal Micro-Label Forms */
.form-group label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.62rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.875rem;
  background-color: #ffffff;
  color: #111827;
  box-shadow: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.09);
}

/* Crisp Restrained Buttons */
.btn-action {
  background: #111827;
  color: #ffffff;
  border: 1px solid #111827;
  border-radius: 4px;
  padding: 0.48rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: none;
}

.btn-action:hover {
  background: #1f2937;
  border-color: #1f2937;
  box-shadow: none;
}

.btn-action.btn-outline {
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--border-strong);
}

.btn-action.btn-outline:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.btn-action.btn-danger-outline {
  background: #ffffff;
  color: #991b1b;
  border: 1px solid #e5b8b8;
}

.btn-action.btn-danger-outline:hover {
  background: #991b1b;
  border-color: #991b1b;
  color: #ffffff;
}

.btn-large {
  border-radius: 4px;
  padding: 0.8rem 1.35rem;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  box-shadow: none;
}

.btn-volver {
  border-radius: 4px;
  font-size: 0.82rem;
  padding: 0.65rem 1rem;
  border-width: 1px;
}

/* Rectangular Enterprise Badges */
.badge-turno,
.badge-status,
.role-badge {
  border-radius: 3px;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
}

.badge-status.espera {
  border: 1px solid #fde68a;
}

.badge-status.consulta {
  border: 1px solid #a7f3d0;
}

.badge-status.pending {
  border: 1px solid #d1d5db;
  color: #374151;
  background: #f3f4f6;
}

/* Table-Row Style Lists */
.patient-list {
  gap: 0.5rem;
}

.patient-item,
.admin-user-item,
.patient-item[data-admin-row] {
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: none;
  padding: 0.88rem 1.25rem 0.88rem 1.4rem;
}

.patient-item:hover,
.admin-user-item:hover {
  background: #fafbfc;
  box-shadow: none;
  border-color: var(--border-strong);
}

.patient-item::before {
  width: 3px;
  border-radius: 0;
}

/* Executive Next-Patient Banner */
.next-patient {
  background: #111827;
  border: 1px solid #1f2937;
  border-left: 3px solid #0f4c5c;
  border-radius: 4px;
  padding: 1.35rem 1.75rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.next-patient.triaje-banner {
  background: #111827;
  border-color: #1f2937;
  border-left-color: #059669;
}

.next-patient h3 {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #9ca3af;
  opacity: 1;
}

.next-patient .big-number {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.next-patient .patient-name-display {
  font-size: 0.92rem;
  color: #d1d5db;
  opacity: 1;
}

/* KPI Cards (Dashboard) */
.kpi-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-top: 2px solid #111827;
  padding: 1.25rem 1.5rem;
  border-radius: 4px;
  text-align: left;
}

.kpi-card.kpi-success {
  border-top-color: var(--success);
}

.kpi-card.kpi-warning {
  border-top-color: var(--warning);
}

.kpi-card h3 {
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.kpi-card .kpi-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* Dark Mode Executive Alignment */
html[data-theme="dark"] header {
  background: #11141b;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .header-logo img {
  filter: brightness(0) invert(1);
}

html[data-theme="dark"] .header-logo h1,
html[data-theme="dark"] #displayUserName {
  color: #f3f4f6;
}

html[data-theme="dark"] .header-logo h1,
html[data-theme="dark"] #displayUserName,
html[data-theme="dark"] header .logout-btn {
  border-color: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .main-nav {
  background: #0d1016;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .nav-item.active {
  color: #f3f4f6;
  border-bottom-color: #f3f4f6;
}

html[data-theme="dark"] .card {
  background: #151922;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .card h2 {
  color: #f3f4f6;
}

html[data-theme="dark"] .card-section {
  background: #10131a;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .card-section h3 {
  color: #d1d5db;
}

html[data-theme="dark"] .btn-action.btn-outline {
  background: #1a1f2b;
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.14);
}

html[data-theme="dark"] .btn-action.btn-danger-outline {
  background: transparent;
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

html[data-theme="dark"] .kpi-card {
  background: #10131a;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .patient-item:hover,
html[data-theme="dark"] .admin-user-item:hover {
  background: #1b202c;
}


/* ============================================================
   INSTITUTIONAL PRECISION LAYER — ULTRA-FORMAL
   ============================================================ */
:root {
  --primary: #18181b;
  --primary-hover: #27272a;
  --primary-light: #f4f4f5;
  --primary-gradient: #18181b;
  --secondary: #3f3f46;
  --success: #14532d;
  --success-light: #f0fdf4;
  --warning: #78350f;
  --warning-light: #fefce8;
  --danger: #7f1d1d;
  --danger-light: #fef2f2;
  --bg: #f4f4f5;
  --surface-solid: #ffffff;
  --text-dark: #09090b;
  --text-body: #27272a;
  --text-muted: #52525b;
  --border: #d4d4d8;
  --border-strong: #a1a1aa;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: 0 4px 16px rgba(9, 9, 11, 0.10);
  --shadow-primary: none;
  --shadow-success: none;
  --radius-xs: 2px;
  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 2px;
  --radius-xl: 3px;
  --transition: color 0.12s linear, background-color 0.12s linear, border-color 0.12s linear;
}

body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-body);
  background-color: var(--bg);
}

/* Precision Hairline Header & Sub-Nav */
header {
  height: 76px;
  padding: 0 2.5rem;
  border-bottom: 1px solid var(--border);
}

.header-logo img {
  height: 62px;
}

.header-logo h1 {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--text-dark);
}

.main-nav {
  top: 76px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.nav-item {
  padding: 0.72rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}

.nav-item:hover {
  color: var(--text-dark);
  border-bottom-color: var(--border-strong);
}

.nav-item.active {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark);
  font-weight: 700;
}

/* Zero-Shadow Architectural Cards & Sections */
main {
  padding: 1.75rem 2.5rem 2.5rem;
}

.view {
  animation: none;
}

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.6rem 2rem;
  box-shadow: none;
}

.card:hover {
  box-shadow: none;
  border-color: var(--border);
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dark);
}

.card > p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.card-header {
  padding-bottom: 0.9rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}

.card-section {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.35rem 1.5rem;
}

.card-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dark);
  padding-bottom: 0.55rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

/* Precision Compact Forms */
.form-grid {
  gap: 0.95rem 1.1rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.32rem;
}

.form-group input,
.form-group select,
.form-group textarea,
.search-input {
  padding: 0.54rem 0.78rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 0.85rem;
  background-color: #ffffff;
  color: var(--text-dark);
  box-shadow: none;
}

.search-input {
  padding-left: 2.3rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.search-input:focus {
  border-color: var(--text-dark);
  box-shadow: none;
  outline: 1px solid var(--text-dark);
  outline-offset: -1px;
}

/* Restrained Precision Buttons */
.btn-action,
.btn-large,
.btn-volver {
  border-radius: 2px;
  box-shadow: none !important;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  font-weight: 600;
}

.btn-action {
  padding: 0.46rem 0.9rem;
  font-size: 0.72rem;
}

.btn-large {
  padding: 0.74rem 1.25rem;
  font-size: 0.78rem;
}

.btn-volver {
  padding: 0.6rem 0.95rem;
  font-size: 0.74rem;
}

/* Monochrome Precision Badges & Lists */
.badge-turno,
.badge-status,
.role-badge {
  border-radius: 2px;
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  padding: 2px 7px;
}

.role-badge.admin {
  background: #18181b;
  color: #ffffff;
}

.role-badge.doctor {
  background: #f4f4f5;
  color: #18181b;
  border: 1px solid #d4d4d8;
}

.role-badge.enfermera {
  background: #f0fdf4;
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.role-badge.turnero {
  background: #fafafa;
  color: #3f3f46;
  border: 1px solid #d4d4d8;
}

.patient-item,
.admin-user-item,
.patient-item[data-admin-row] {
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.78rem 1.15rem 0.78rem 1.3rem;
}

.patient-item::before {
  width: 2px;
}

.next-patient,
.next-patient.triaje-banner {
  background: #18181b;
  border: 1px solid #27272a;
  border-left: 3px solid #71717a;
  border-radius: 2px;
  padding: 1.2rem 1.5rem;
}

.kpi-card {
  border-radius: 2px;
  border-top: 2px solid #18181b;
  padding: 1.15rem 1.35rem;
}

.institutional-footer {
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 2.5rem 1.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Dark Mode Precision Alignment */
html[data-theme="dark"] {
  --primary: #e4e4e7;
  --primary-hover: #ffffff;
  --bg: #0c0c0e;
  --surface-solid: #141417;
  --text-dark: #f4f4f5;
  --text-body: #d4d4d8;
  --text-muted: #a1a1aa;
  --border: #27272a;
  --border-strong: #3f3f46;
}

html[data-theme="dark"] header,
html[data-theme="dark"] .main-nav,
html[data-theme="dark"] .card {
  background: #141417;
  border-color: #27272a;
}

html[data-theme="dark"] .card-section {
  background: #0f0f12;
  border-color: #27272a;
}

html[data-theme="dark"] .btn-action {
  background: #f4f4f5;
  color: #09090b;
  border-color: #f4f4f5;
}

html[data-theme="dark"] .btn-action:hover {
  background: #ffffff;
}

html[data-theme="dark"] .btn-action.btn-outline {
  background: transparent;
  color: #e4e4e7;
  border-color: #3f3f46;
}

html[data-theme="dark"] .institutional-footer {
  border-top-color: #27272a;
}

/* ============================================================
   PANTALLA PÚBLICA (TV) — CORPORATIVA
   ============================================================ */
.tv-screen {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: #f4f4f5;
  color: #18181b;
}

/* Encabezado */
.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d4d4d8;
  padding: 0.6rem 2rem;
  min-height: 92px;
  gap: 1.5rem;
}

.tv-header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}

.tv-header-brand {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.tv-header-brand img {
  height: 66px;
  object-fit: contain;
}

.tv-header-titles {
  border-left: 1px solid #d4d4d8;
  padding-left: 1.5rem;
}

.tv-header-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #18181b;
}

.tv-header-sub {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 0.3rem;
}

.tv-header-sub-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #71717a;
}

.tv-sede {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3f3f46;
}

.tv-header-time {
  text-align: right;
}

.tv-date {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #71717a;
}

.tv-clock {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #18181b;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

/* Cuerpo */
.tv-main {
  flex: 1;
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 2rem;
  overflow: hidden;
  min-height: 0;
}

.tv-panel {
  background: #ffffff;
  border: 1px solid #d4d4d8;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tv-panel-head {
  padding: 0.7rem 1.1rem;
  background: #fafafa;
  border-bottom: 1px solid #d4d4d8;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #3f3f46;
  flex-shrink: 0;
}

.tv-col-history { width: 25%; }
.tv-video-wrap { width: 35%; }
.tv-col-call { width: 40%; }

/* Últimos llamados */
.tv-history-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tv-hist-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid #e4e4e7;
  background: #ffffff;
  flex-shrink: 0;
}

.tv-hist-turn {
  min-width: 92px;
  padding-right: 0.9rem;
  border-right: 1px solid #d4d4d8;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #18181b;
}

.tv-hist-info {
  flex: 1;
  min-width: 0;
}

.tv-hist-area {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #71717a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-hist-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: #27272a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Video */
.tv-video-body {
  flex: 1;
  background: #09090b;
  min-height: 0;
}

/* Turno en atención */
.tv-call-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn 0.4s ease;
}

.tv-field-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #71717a;
  margin-bottom: 0.4rem;
}

.tv-call-field {
  padding: 1.25rem 1.75rem;
  text-align: center;
}

.tv-call-area {
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #18181b;
}

.tv-call-turn-wrap {
  background: #18181b;
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
}

.tv-call-turn-wrap .tv-field-label {
  color: #a1a1aa;
}

.tv-call-turn {
  font-size: 5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffffff;
  line-height: 1.05;
}

.tv-call-name {
  font-size: 1.75rem;
  font-weight: 600;
  color: #27272a;
}

.tv-call-waiting {
  text-align: center;
  padding: 2rem;
}

.tv-call-waiting-title {
  font-size: 1.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #52525b;
}

.tv-call-waiting-sub {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  color: #71717a;
  letter-spacing: 0.02em;
}

/* Pie */
.tv-footer {
  height: 46px;
  background: #18181b;
  color: #e4e4e7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.tv-footer-right {
  color: #a1a1aa;
  letter-spacing: 0.08em;
  text-transform: none;
  font-weight: 500;
  font-size: 0.85rem;
}

.tv-close-btn {
  background: #ffffff;
  color: #3f3f46;
  border: 1px solid #a1a1aa;
  padding: 0.45rem 0.95rem;
  border-radius: 2px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.tv-close-btn:hover {
  background: #18181b;
  border-color: #18181b;
  color: #ffffff;
}
