/* ============================================================
   RUY MAY — Design System CSS
   design-system/design-system.css
   Versión: 1.0.0 — RMC-8
   ============================================================ */

/* ============================================================
   SECCIÓN 1 — TOKENS FOUNDATION
   ============================================================ */

:root {
  /* ---- Colores de marca ---- */
  --brand-primary:   #3B8E91;
  --brand-secondary: #C9E8DA;
  --brand-dark:      #0D1F20;
  --brand-white:     #FFFFFF;
  --brand-text:      #2D2D2D;

  /* ---- Colores semánticos ---- */
  --color-success: #2E7D32;
  --color-warning: #F57C00;
  --color-danger:  #C62828;
  --color-info:    #3B8E91;

  /* ---- Status de cirugía (8 estados) ---- */
  --status-planning:     #92680A;  /* En Planeación — amber           */
  --status-pending:      #9E9E9E;  /* Pendiente     — gris neutro    */
  --status-confirmed:    #3B8E91;  /* Confirmada    — brand primary  */
  --status-in-transit:   #1565C0;  /* En Tránsito   — azul logístico */
  --status-rescheduled:  #6D28D9;  /* Reprogramada  — violeta        */
  --status-in-progress:  #F57C00;  /* En Curso      — naranja        */
  --status-completed:    #2E7D32;  /* Completada    — verde          */
  --status-cancelled:    #C62828;  /* Cancelada     — rojo           */

  /* Fondo de status (tint ~10%) */
  --status-planning-bg:    #FEFCE8;
  --status-pending-bg:     #F5F5F5;
  --status-confirmed-bg:   #D6ECED;
  --status-in-transit-bg:  #E3F2FD;
  --status-rescheduled-bg: #EDE9FE;
  --status-in-progress-bg: #FFF3E0;
  --status-completed-bg:   #E8F5E9;
  --status-cancelled-bg:   #FFEBEE;

  /* ---- Grises de UI ---- */
  --gray-50:  #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-400: #BDBDBD;
  --gray-500: #9E9E9E;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;

  /* ---- Escala de espaciado (base 4px) ---- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-9:  36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;

  /* ---- Escala tipográfica ---- */
  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */

  /* Line-heights */
  --lh-tight:  1.25;
  --lh-snug:   1.375;
  --lh-normal: 1.5;
  --lh-relaxed:1.625;
  --lh-loose:  2;

  /* ---- Familias tipográficas ---- */
  --font-heading: 'Poppins', sans-serif;
  --font-body:    'Inter', sans-serif;

  /* ---- Radio de borde ---- */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* ---- Sombras ---- */
  --shadow-sm:  0 1px 3px rgba(13,31,32,0.08), 0 1px 2px rgba(13,31,32,0.04);
  --shadow-md:  0 4px 6px rgba(13,31,32,0.07), 0 2px 4px rgba(13,31,32,0.06);
  --shadow-lg:  0 10px 15px rgba(13,31,32,0.08), 0 4px 6px rgba(13,31,32,0.05);
  --shadow-xl:  0 20px 25px rgba(13,31,32,0.10), 0 10px 10px rgba(13,31,32,0.04);

  /* ---- Z-index ---- */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-fixed:    300;
  --z-overlay:  400;
  --z-modal:    500;
  --z-toast:    600;
  --z-tooltip:  700;

  /* ---- Transiciones ---- */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow:   0.4s ease;
}

/* ============================================================
   BASE RESET & TIPOGRAFÍA GLOBAL
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  color: var(--brand-text);
  background-color: var(--brand-white);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   SECCIÓN 2 — TIPOGRAFÍA
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--lh-tight);
  color: var(--brand-text);
}

h1 { font-size: var(--text-4xl); font-weight: 700; }
h2 { font-size: var(--text-3xl); font-weight: 700; }
h3 { font-size: var(--text-2xl); font-weight: 600; }
h4 { font-size: var(--text-xl);  font-weight: 600; }
h5 { font-size: var(--text-lg);  font-weight: 600; }
h6 { font-size: var(--text-base); font-weight: 600; }

.body-lg  { font-family: var(--font-body); font-size: var(--text-lg);   line-height: var(--lh-relaxed); }
.body-md  { font-family: var(--font-body); font-size: var(--text-base); line-height: var(--lh-normal); }
.body-sm  { font-family: var(--font-body); font-size: var(--text-sm);   line-height: var(--lh-normal); }
.caption  { font-family: var(--font-body); font-size: var(--text-xs);   line-height: var(--lh-normal); color: var(--gray-600); }
.label    { font-family: var(--font-heading); font-size: var(--text-sm); font-weight: 500; line-height: var(--lh-snug); }
.overline { font-family: var(--font-heading); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-600); }

/* Color utilities */
.text-brand   { color: var(--brand-primary); }
.text-muted   { color: var(--gray-500); }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-dark    { color: var(--brand-dark); }
.text-white   { color: var(--brand-white); }

/* ============================================================
   SECCIÓN 3 — BOTONES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-weight: 500;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast),
              box-shadow var(--transition-fast),
              opacity var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* Tamaños */
.btn-sm  { font-size: var(--text-sm);   padding: var(--space-2) var(--space-3);  min-height: 32px; }
.btn-md,
.btn     { font-size: var(--text-sm);   padding: var(--space-2) var(--space-4); min-height: 40px; }
.btn-lg  { font-size: var(--text-base); padding: var(--space-3) var(--space-6);  min-height: 48px; }

/* Variantes */
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-white);
}
.btn-primary:hover  { background-color: #2f7275; border-color: #2f7275; }
.btn-primary:focus  { outline: none; box-shadow: 0 0 0 3px rgba(59,142,145,0.3); }
.btn-primary:active { background-color: #256163; }

.btn-secondary {
  background-color: transparent;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}
.btn-secondary:hover  { background-color: var(--brand-secondary); }
.btn-secondary:focus  { outline: none; box-shadow: 0 0 0 3px rgba(59,142,145,0.2); }

.btn-destructive {
  background-color: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--brand-white);
}
.btn-destructive:hover  { background-color: #a31f1f; border-color: #a31f1f; }
.btn-destructive:focus  { outline: none; box-shadow: 0 0 0 3px rgba(198,40,40,0.3); }

.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--brand-primary);
}
.btn-ghost:hover  { background-color: rgba(59,142,145,0.08); }
.btn-ghost:focus  { outline: none; box-shadow: 0 0 0 3px rgba(59,142,145,0.15); }

.btn-outline {
  background-color: transparent;
  border-color: var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover  { border-color: var(--gray-400); background-color: var(--gray-50); }
.btn-outline:focus  { outline: none; box-shadow: 0 0 0 3px rgba(0,0,0,0.08); }

/* Estado disabled */
.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Estado loading */
.btn-loading {
  pointer-events: none;
  color: transparent;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: var(--radius-full);
  animation: btn-spin 0.7s linear infinite;
  color: var(--brand-white);
}
.btn-primary.btn-loading::after   { border-top-color: var(--brand-white); }
.btn-secondary.btn-loading::after { border-top-color: var(--brand-primary); }
.btn-outline.btn-loading::after   { border-top-color: var(--gray-700); }
.btn-ghost.btn-loading::after     { border-top-color: var(--brand-primary); }

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Botón icono */
.btn-icon {
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--gray-600);
  background: transparent;
  border-color: transparent;
}
.btn-icon.btn-sm  { width: 32px; height: 32px; }
.btn-icon.btn-md,
.btn-icon         { width: 40px; height: 40px; }
.btn-icon.btn-lg  { width: 48px; height: 48px; }
.btn-icon:hover   { background-color: var(--gray-100); color: var(--brand-primary); }
.btn-icon:focus   { outline: none; box-shadow: 0 0 0 2px rgba(59,142,145,0.25); }
.btn-icon svg     { width: 18px; height: 18px; pointer-events: none; }

/* ============================================================
   SECCIÓN 4 — FORMULARIOS
   ============================================================ */

/* Base input */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="time"],
textarea,
select {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--lh-normal);
  color: var(--brand-text);
  background-color: var(--brand-white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  min-height: 40px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59,142,145,0.18);
}

/* Bloqueo visual unificado: :disabled, [readonly] y [aria-readonly="true"]
 * comparten tratamiento. <select> no admite el atributo readonly nativo en
 * HTML, por eso solo aparece con :disabled y [aria-readonly="true"]. */
.input:disabled,
input:disabled,
textarea:disabled,
select:disabled,
.input[readonly],
input[readonly],
textarea[readonly],
.input[aria-readonly="true"],
input[aria-readonly="true"],
textarea[aria-readonly="true"],
select[aria-readonly="true"] {
  background-color: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
  opacity: 0.7;
}

.input-error,
input.input-error,
textarea.input-error,
select.input-error {
  border-color: var(--color-danger);
}
.input-error:focus,
input.input-error:focus,
textarea.input-error:focus,
select.input-error:focus,
[aria-invalid="true"]:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(198,40,40,0.15);
}

.input-wrapper:focus-within .input-error,
.select-wrapper:focus-within select.input-error,
.form-group--error .input:focus,
.form-group--error select:focus,
.form-group--error textarea:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(198,40,40,0.15);
}

/* Input wrapper */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrapper .input-icon-left {
  position: absolute;
  left: var(--space-3);
  color: var(--gray-500);
  display: flex;
  align-items: center;
  pointer-events: none;
}
.input-wrapper .input-icon-left ~ .input,
.input-wrapper .input-icon-left ~ input {
  padding-left: var(--space-10);
}
.input-wrapper .input-icon-right {
  position: absolute;
  right: var(--space-3);
  color: var(--gray-500);
  display: flex;
  align-items: center;
}
.input-wrapper .input-icon-right ~ .input,
.input-wrapper .input-icon-right.btn-toggle ~ input {
  padding-right: var(--space-10);
}

/* Botón toggle password */
.btn-toggle {
  position: absolute;
  right: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}
.btn-toggle:hover { color: var(--brand-primary); }

/* Input search */
.input-search-wrapper .input-icon-left svg { width: 16px; height: 16px; }

/* Input number con +/- */
.input-number-wrapper {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.input-number-wrapper input[type="number"] {
  border: none;
  text-align: center;
  box-shadow: none;
  border-radius: 0;
  min-width: 60px;
}
.input-number-wrapper input[type="number"]:focus { box-shadow: none; }
.input-number-wrapper.input-error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(198,40,40,0.15);
}
.input-number-wrapper.input-error:focus-within {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(198,40,40,0.15);
}
.input-number-btn {
  background: var(--gray-50);
  border: none;
  padding: 0 var(--space-3);
  min-height: 40px;
  cursor: pointer;
  color: var(--gray-600);
  font-size: var(--text-lg);
  font-weight: 500;
  transition: background-color var(--transition-fast);
  display: flex;
  align-items: center;
}
.input-number-btn:hover { background: var(--gray-200); color: var(--brand-primary); }

/* Textarea */
textarea {
  min-height: 100px;
  resize: vertical;
  line-height: var(--lh-relaxed);
}

/* Select */
.select-wrapper {
  position: relative;
}
.select-wrapper select {
  appearance: none;
  padding-right: var(--space-10);
  cursor: pointer;
}
.select-wrapper::after {
  content: '';
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--gray-500);
  pointer-events: none;
}

/* Checkbox */
.checkbox-wrapper,
.radio-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.checkbox-wrapper input[type="checkbox"],
.radio-wrapper input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  background: var(--brand-white);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}
.checkbox-wrapper input[type="checkbox"]:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.checkbox-wrapper input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
.checkbox-wrapper input[type="checkbox"]:indeterminate {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.checkbox-wrapper input[type="checkbox"]:indeterminate::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 2px;
  background: white;
}
.checkbox-wrapper input[type="checkbox"]:focus,
.radio-wrapper input[type="radio"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,142,145,0.2);
}
.checkbox-wrapper input[type="checkbox"]:disabled,
.radio-wrapper input[type="radio"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox-wrapper label,
.radio-wrapper label {
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--brand-text);
}

/* Radio */
.radio-wrapper input[type="radio"] {
  border-radius: var(--radius-full);
}
.radio-wrapper input[type="radio"]:checked {
  border-color: var(--brand-primary);
  background: var(--brand-white);
}
.radio-wrapper input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--brand-primary);
  border-radius: var(--radius-full);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Toggle / Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: var(--radius-full);
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--brand-primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}
.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}
.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(59,142,145,0.2);
}
.toggle-label {
  font-size: var(--text-sm);
  color: var(--brand-text);
  cursor: pointer;
}

/* Form group */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.form-group label,
.form-label {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}
.form-group label .required,
.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}
.form-helper {
  font-size: var(--text-xs);
  color: var(--gray-500);
  line-height: var(--lh-normal);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Input con prefijo / sufijo (moneda, unidades, etc.) */
.input-addon-wrapper {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-addon-wrapper:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59,142,145,0.18);
}
.input-addon-wrapper.input-error {
  border-color: var(--color-danger);
}
.input-addon-wrapper.input-error:focus-within {
  box-shadow: 0 0 0 3px rgba(198,40,40,0.15);
}
.input-addon {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: var(--gray-50);
  color: var(--gray-600);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.input-addon-left  { border-right: 1.5px solid var(--gray-200); }
.input-addon-right { border-left:  1.5px solid var(--gray-200); }
.input-addon-wrapper input {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  flex: 1;
  min-width: 0;
}
.input-addon-wrapper input:focus {
  border: none !important;
  box-shadow: none !important;
}
.input-currency { text-align: right; font-variant-numeric: tabular-nums; }

/* Datepicker custom */
.datepicker-wrapper {
  position: relative;
  width: 100%;
}
.datepicker-wrapper input[type="date"] {
  padding-right: var(--space-10);
}
.datepicker-icon {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  pointer-events: none;
}

/* Calendar popup */
.calendar-popup {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  z-index: var(--z-dropdown);
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  min-width: 280px;
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.calendar-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--brand-text);
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-day-header {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  text-align: center;
  padding: var(--space-1);
  text-transform: uppercase;
}
.calendar-day {
  font-size: var(--text-xs);
  text-align: center;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--brand-text);
  transition: background-color var(--transition-fast);
}
.calendar-day:hover { background: var(--brand-secondary); }
.calendar-day.today { font-weight: 700; color: var(--brand-primary); }
.calendar-day.selected {
  background: var(--brand-primary);
  color: white;
}
.calendar-day.other-month { color: var(--gray-400); }
.calendar-day.disabled { color: var(--gray-300); cursor: not-allowed; }

/* Timepicker */
.timepicker-wrapper {
  position: relative;
}
.timepicker-wrapper input[type="time"] {
  padding-right: var(--space-10);
}

/* Form grid — layout de 2 columnas para formularios */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-2);
}
.form-group--full {
  grid-column: 1 / -1;
}

/* Toggle field — label + toggle en fila horizontal */
.toggle-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.toggle-field label {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
}

/* ============================================================
   SECCIÓN 5 — BADGES Y ETIQUETAS
   ============================================================ */

/* Badge base */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.5;
}

/* Variantes semánticas */
.badge-success  { background: #E8F5E9; color: var(--color-success); }
.badge-warning  { background: #FFF3E0; color: var(--color-warning); }
.badge-danger   { background: #FFEBEE; color: var(--color-danger); }
.badge-info     { background: #E3F2FD; color: #1565C0; }
.badge-neutral  { background: var(--gray-100); color: var(--gray-700); }

/* Badge status de cirugía */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

.badge-status-planning    { background: var(--status-planning-bg);    color: var(--status-planning); }
.badge-status-pending     { background: var(--status-pending-bg);     color: var(--status-pending); }
.badge-status-confirmed   { background: var(--status-confirmed-bg);   color: var(--status-confirmed); }
.badge-status-in-transit  { background: var(--status-in-transit-bg);  color: var(--status-in-transit); }
.badge-status-rescheduled { background: var(--status-rescheduled-bg); color: var(--status-rescheduled); }
.badge-status-in-progress { background: var(--status-in-progress-bg); color: var(--status-in-progress); }
.badge-status-completed   { background: var(--status-completed-bg);   color: var(--status-completed); }
.badge-status-cancelled   { background: var(--status-cancelled-bg);   color: var(--status-cancelled); }

/* Surgery card stickers — Marca / Distribuidor / Asistencia */
.list-stickers { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.sticker {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 3px; text-transform: uppercase; line-height: 1.4;
}
.sticker svg { width: 9px; height: 9px; flex-shrink: 0; }
.sticker-brand       { background: #E3F2FD; color: #1565C0; }
.sticker-distributor { background: #F3E5F5; color: #6A1B9A; }
.sticker-assist-yes  { background: #E8F5E9; color: #2E7D32; }
.sticker-assist-no   { background: #F5F5F5; color: #9E9E9E; }

/* Tag / Chip removible */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 4px var(--space-2) 4px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--brand-secondary);
  color: var(--brand-dark);
  border: 1px solid rgba(59,142,145,0.2);
}
.tag-remove {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--gray-600);
  border-radius: var(--radius-full);
  padding: 1px;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.tag-remove:hover { color: var(--color-danger); background: rgba(198,40,40,0.1); }
.tag-remove svg   { width: 12px; height: 12px; }

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--brand-primary);
  color: var(--brand-white);
  font-family: var(--font-heading);
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-sm  { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-md  { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-lg  { width: 56px; height: 56px; font-size: var(--text-base); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   SECCIÓN 6 — NAVEGACIÓN
   ============================================================ */

/* ---- Sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 240px;
  min-height: 100vh;
  background: var(--brand-dark);
  color: var(--brand-white);
  transition: width var(--transition-normal);
  overflow: hidden;
}
.sidebar.collapsed {
  width: 64px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: 64px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow: hidden;
}
.sidebar-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--brand-white);
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-normal);
}
.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.sidebar-toggle:hover { color: var(--brand-white); background: rgba(255,255,255,0.1); }
.sidebar-toggle svg   { width: 20px; height: 20px; }

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: var(--space-3) var(--space-4) var(--space-1);
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-normal);
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  color: var(--gray-400);
  text-decoration: none;
  border-radius: 0;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
  position: relative;
  white-space: nowrap;
  min-height: 44px;
  font-size: var(--text-sm);
}
.nav-item:hover {
  color: var(--brand-white);
  background: rgba(255,255,255,0.06);
}
.nav-item.active {
  color: var(--brand-white);
  background: rgba(59,142,145,0.25);
  border-right: 3px solid var(--brand-primary);
}
.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.nav-item-label {
  opacity: 1;
  transition: opacity var(--transition-normal);
}
.sidebar.collapsed .nav-item-label { opacity: 0; width: 0; overflow: hidden; }

/* Badge numérico en nav-item */
.nav-badge {
  margin-left: auto;
  background: var(--brand-primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--transition-normal);
}
.sidebar.collapsed .nav-badge { opacity: 0; }

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  height: 64px;
  background: var(--brand-white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.topbar-left  { display: flex; align-items: center; gap: var(--space-4); }
.topbar-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--brand-text);
}
.topbar-right { display: flex; align-items: center; gap: var(--space-2); }

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  list-style: none;
}
.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--gray-500);
}
.breadcrumb-item a {
  color: var(--gray-500);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.breadcrumb-item a:hover { color: var(--brand-primary); }
.breadcrumb-item.active  { color: var(--brand-text); font-weight: 500; }
.breadcrumb-separator    { color: var(--gray-400); font-size: var(--text-xs); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  border-bottom: 1.5px solid var(--gray-200);
  gap: 0;
}
.tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover  { color: var(--brand-primary); }
.tab.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.pagination-info {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-right: var(--space-2);
}
.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  color: var(--gray-700);
  background: var(--brand-white);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.page-btn:hover   { border-color: var(--brand-primary); color: var(--brand-primary); }
.page-btn.active  { background: var(--brand-primary); border-color: var(--brand-primary); color: white; }
.page-btn:disabled{ opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.page-ellipsis    { color: var(--gray-400); padding: 0 var(--space-1); display: flex; align-items: center; }

/* ---- Dropdown menu ---- */
.dropdown {
  position: relative;
  display: inline-flex;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: var(--z-dropdown);
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: var(--space-1) 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}
.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--gray-700);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover       { background: var(--gray-50); color: var(--brand-primary); }
.dropdown-item.destructive { color: var(--color-danger); }
.dropdown-item.destructive:hover { background: #FFEBEE; }
.dropdown-item svg         { width: 16px; height: 16px; flex-shrink: 0; }
.dropdown-divider          { height: 1px; background: var(--gray-200); margin: var(--space-1) 0; }
.dropdown-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-2) var(--space-4) var(--space-1);
}

/* ============================================================
   SECCIÓN 7 — CARDS
   ============================================================ */

/* Card base */
.card {
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--brand-text);
}
.card-body  { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Card variantes */
.card-highlighted {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 1px var(--brand-primary), var(--shadow-sm);
}
.card-dark {
  background: var(--brand-dark);
  border-color: transparent;
  color: var(--brand-white);
}
.card-dark .card-title { color: var(--brand-white); }
.card-dark .card-header { border-color: rgba(255,255,255,0.1); }
.card-dark .card-footer { background: rgba(0,0,0,0.2); border-color: rgba(255,255,255,0.1); }

/* KPI Card */
.kpi-card {
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--brand-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
}
.kpi-icon svg { width: 24px; height: 24px; }
.kpi-value {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--brand-text);
  line-height: 1;
}
.kpi-label {
  font-size: var(--text-sm);
  color: var(--gray-500);
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
}
.kpi-delta-up   { color: var(--color-success); }
.kpi-delta-down { color: var(--color-danger); }

/* Surgery Card */
.surgery-card {
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: box-shadow var(--transition-fast);
  border-left: 4px solid var(--brand-primary);
}
.surgery-card:hover { box-shadow: var(--shadow-md); }
.surgery-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.surgery-card-date {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.surgery-card-procedure {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--brand-text);
}
.surgery-card-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.surgery-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--gray-600);
}
.surgery-meta-item svg { width: 14px; height: 14px; color: var(--gray-400); flex-shrink: 0; }
.surgery-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--gray-100);
}

/* Stat item */
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--brand-text);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
}
.empty-state-icon svg { width: 32px; height: 32px; }
.empty-state-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--brand-text);
}
.empty-state-description {
  font-size: var(--text-sm);
  color: var(--gray-500);
  max-width: 360px;
  line-height: var(--lh-relaxed);
}

/* ============================================================
   SECCIÓN 8 — TABLAS
   ============================================================ */

/* Data table wrapper */
.data-table-wrapper {
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.data-table-toolbar-left  { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 200px; }
.data-table-toolbar-right { display: flex; align-items: center; gap: var(--space-2); }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead {
  background: var(--gray-50);
  border-bottom: 1.5px solid var(--gray-200);
}
.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--gray-50);
}
.th-sortable {
  cursor: pointer;
  user-select: none;
}
.th-sortable:hover { color: var(--brand-primary); }
.sort-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  margin-left: var(--space-1);
  vertical-align: middle;
}
.sort-icon svg { width: 10px; height: 10px; opacity: 0.4; }
.sort-icon svg.active { opacity: 1; color: var(--brand-primary); }

.data-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--brand-text);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.selected { background: #E3F2FD; }

/* Date cell — Fechas en tabla con iconos y monospace */
.date-cell {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.5;
}
.date-cell-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-cell-row svg {
  flex-shrink: 0;
  color: var(--gray-600);
}
.date-monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
  font-size: 0.65rem;
  line-height: var(--lh-normal);
  color: var(--gray-600);
}

.data-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---- Filter panel (colapsable, entre toolbar y tabla) ---- */
.filter-panel {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding: var(--space-4) var(--space-5);
  display: none;
  flex-direction: column;
  gap: var(--space-4);
  animation: filter-panel-in 0.2s ease;
}
.filter-panel.open { display: flex; }

.filter-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3) var(--space-4);
  align-items: start;
}
.filter-panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--gray-200);
}

/* Barra de filtros activos */
.filter-active-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--status-confirmed-bg);
  border-bottom: 1px solid rgba(59,142,145,0.2);
}
.filter-active-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--brand-primary);
  margin-right: var(--space-1);
}
.filter-active-bar .tag {
  background: var(--brand-white);
  border-color: rgba(59,142,145,0.3);
}

@keyframes filter-panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Badge activo en el botón de filtros */
.btn-filter-active {
  position: relative;
}
.btn-filter-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  background: var(--brand-primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Table actions bar (aparece al seleccionar filas) */
.table-actions-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--brand-dark);
  color: var(--brand-white);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: slide-in-top 0.2s ease;
}
.table-actions-bar-count {
  background: var(--brand-primary);
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}
.table-actions-bar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
}

@keyframes slide-in-top {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Skeleton rows */
.skeleton-row td { border-bottom: 1px solid var(--gray-100); padding: var(--space-3) var(--space-4); }

/* Permissions matrix */
.permissions-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.permissions-matrix th {
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--gray-600);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1.5px solid var(--gray-200);
  position: sticky;
  top: 0;
}
.permissions-matrix th:first-child { text-align: left; }
.permissions-matrix td {
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--brand-text);
  border-bottom: 1px solid var(--gray-100);
  text-align: center;
  vertical-align: middle;
}
.permissions-matrix td:first-child { text-align: left; font-weight: 500; color: var(--brand-text); }
.permissions-matrix tbody tr:hover td { background: var(--gray-50); }

/* Checkboxes en tablas (data-table + permissions-matrix) — mismo estilo teal */
.permissions-matrix input[type="checkbox"],
.data-table input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  background: var(--brand-white);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  display: inline-block;
  vertical-align: middle;
}
.permissions-matrix input[type="checkbox"]:checked,
.data-table input[type="checkbox"]:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.permissions-matrix input[type="checkbox"]:checked::after,
.data-table input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
.permissions-matrix input[type="checkbox"]:focus,
.data-table input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,142,145,0.2);
}
.permissions-matrix input[type="checkbox"]:disabled,
.data-table input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   SECCIÓN 9 — OVERLAYS Y FEEDBACK
   ============================================================ */

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,31,32,0.55);
  backdrop-filter: blur(3px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--brand-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  width: 100%;
  overflow: hidden;
  transform: scale(0.95) translateY(16px);
  transition: transform var(--transition-normal);
}
.modal-backdrop.open .modal {
  transform: scale(1) translateY(0);
}
.modal-sm { max-width: 400px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 800px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--brand-text);
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-500);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.modal-close:hover { color: var(--brand-text); background: var(--gray-100); }
.modal-close svg   { width: 20px; height: 20px; }
.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
  background: var(--gray-50);
}

/* ---- Confirm dialog ---- */
.confirm-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  padding: var(--space-2);
}
.confirm-dialog-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: #FFEBEE;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-danger);
}
.confirm-dialog-icon svg { width: 28px; height: 28px; }
.confirm-dialog-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-xl);
  color: var(--brand-text);
}
.confirm-dialog-body { font-size: var(--text-sm); color: var(--gray-500); line-height: var(--lh-relaxed); }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--brand-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  pointer-events: all;
  animation: toast-in 0.3s ease forwards;
  border-left: 4px solid var(--gray-300);
}
.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-error   { border-left-color: var(--color-danger); }
.toast.toast-warning { border-left-color: var(--color-warning); }
.toast.toast-info    { border-left-color: var(--brand-primary); }
.toast.toast-out     { animation: toast-out 0.3s ease forwards; }

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}
.toast-success .toast-icon { color: var(--color-success); }
.toast-error   .toast-icon { color: var(--color-danger); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info    .toast-icon { color: var(--brand-primary); }

.toast-content { flex: 1; }
.toast-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--brand-text);
  margin-bottom: 2px;
}
.toast-message { font-size: var(--text-xs); color: var(--gray-600); line-height: var(--lh-relaxed); }
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}
.toast-close:hover { color: var(--gray-700); }
.toast-close svg   { width: 16px; height: 16px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ---- Alert ---- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}
.alert-success { background: #E8F5E9; border-color: #A5D6A7; color: #1B5E20; }
.alert-error   { background: #FFEBEE; border-color: #EF9A9A; color: #7F0000; }
.alert-warning { background: #FFF3E0; border-color: #FFCC80; color: #E65100; }
.alert-info    { background: #E3F2FD; border-color: #90CAF9; color: #0D47A1; }

.alert-icon { flex-shrink: 0; }
.alert-icon svg { width: 20px; height: 20px; }
.alert-content  { flex: 1; }
.alert-title    { font-weight: 600; margin-bottom: 2px; }
.alert-dismiss  {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition-fast);
}
.alert-dismiss:hover { opacity: 1; }
.alert-dismiss svg   { width: 16px; height: 16px; }

/* ---- Tooltip ---- */
.tooltip-wrapper {
  position: relative;
  display: inline-flex;
}
.tooltip-bubble {
  position: absolute;
  z-index: var(--z-tooltip);
  background: var(--brand-dark);
  color: var(--brand-white);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-md);
}
.tooltip-wrapper:hover .tooltip-bubble { opacity: 1; }

/* Posiciones */
.tooltip-bubble.tooltip-top    { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
.tooltip-bubble.tooltip-bottom { top: calc(100% + 8px);    left: 50%; transform: translateX(-50%); }
.tooltip-bubble.tooltip-left   { right: calc(100% + 8px);  top: 50%;  transform: translateY(-50%); }
.tooltip-bubble.tooltip-right  { left: calc(100% + 8px);   top: 50%;  transform: translateY(-50%); }

/* Flecha */
.tooltip-bubble::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
}
.tooltip-bubble.tooltip-top::after {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--brand-dark);
  top: 100%; left: 50%; transform: translateX(-50%);
}
.tooltip-bubble.tooltip-bottom::after {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--brand-dark);
  bottom: 100%; left: 50%; transform: translateX(-50%);
}
.tooltip-bubble.tooltip-right::after {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 5px solid var(--brand-dark);
  right: 100%; top: 50%; transform: translateY(-50%);
}
.tooltip-bubble.tooltip-left::after {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 5px solid var(--brand-dark);
  left: 100%; top: 50%; transform: translateY(-50%);
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  border-radius: var(--radius-full);
  border: 2px solid var(--gray-200);
  border-top-color: var(--brand-primary);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm  { width: 16px; height: 16px; }
.spinner-md  { width: 32px; height: 32px; border-width: 3px; }
.spinner-lg  { width: 48px; height: 48px; border-width: 4px; }
.spinner-white { border-color: rgba(255,255,255,0.3); border-top-color: white; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Skeleton ---- */
.skeleton {
  background: var(--gray-200);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-text { height: 14px; border-radius: var(--radius-sm); }
.skeleton-title { height: 20px; border-radius: var(--radius-sm); }
.skeleton-circle { border-radius: var(--radius-full); }
.skeleton-card {
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ============================================================
   SECCIÓN 10 — PAGE LAYOUT
   ============================================================ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  margin: 0;
  color: var(--brand-text);
}

.page-subtitle {
  margin: var(--space-2) 0 0 0;
  color: var(--gray-500);
  font-size: var(--text-sm);
}

.page-actions {
  display: flex;
  gap: var(--space-2);
}

/* ============================================================
   UTILIDADES GENERALES
   ============================================================ */

/* Spacing utilities */
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

/* Divider */
.divider { height: 1px; background: var(--gray-200); }
.divider-vertical { width: 1px; background: var(--gray-200); align-self: stretch; }

/* Scrollbar personalizada */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* Focus visible global */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Helpers de layout */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: var(--space-2); }
.gap-3       { gap: var(--space-3); }
.gap-4       { gap: var(--space-4); }
.w-full      { width: 100%; }
