/* Horario — hoja de estilos (extraída de index.html) */
/* ==========================================================================
   SISTEMA DE DISEÑO Y VARIABLES CSS (THEME TOKENS)
   ========================================================================== */
:root {
  --bg: #FFFFFF;
  --surface: #F9FAFB;
  --surface-elevated: #FFFFFF;
  --surface-secondary: #F3F4F6;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;
  --border: #E5E7EB;
  --border-focus: #3B82F6;
  --divider: #F1F5F9;

  /* Tipos de bloque */
  --type-turno: #2563EB;
  --type-turno-bg: #EFF6FF;
  --type-turno-border: #BFDBFE;
  --type-cap: #7C3AED;
  --type-cap-bg: #F5F3FF;
  --type-cap-border: #DDD6FE;
  /* Descanso: Gris suave limpio y elegante */
  --type-descanso: #64748B;
  --type-descanso-bg: #F1F5F9;
  --type-descanso-border: #CBD5E1;
  --type-permiso: #475569;
  --type-permiso-bg: #F8FAFC;
  --type-permiso-border: #CBD5E1;
  --type-incapacidad: #D97706;
  --type-incapacidad-bg: #FFFBEB;
  --type-incapacidad-border: #FDE68A;
  --type-vacaciones: #0D9488;
  --type-vacaciones-bg: #F0FDFA;
  --type-vacaciones-border: #99F6E4;

  /* Tags */
  --tag-desayuno: #EA580C;
  --tag-tp: #0891B2;
  --tag-montaje: #DB2777;
  --tag-encargado: #7C3AED;

  /* Alertas */
  --status-error: #DC2626;
  --status-error-bg: #FEF2F2;
  --status-warn: #D97706;
  --status-warn-bg: #FFFBEB;
  --status-info: #2563EB;
  --status-info-bg: #EFF6FF;
  --status-success: #16A34A;
  --status-success-bg: #F0FDF4;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 9999px;

  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface-elevated: #27354A;
  --surface-secondary: #334155;
  --text: #F8FAFC;
  --text-muted: #94A3B8;
  --text-subtle: #64748B;
  --border: #334155;
  --border-focus: #60A5FA;
  --divider: #1E293B;

  --type-turno-bg: #1E3A8A;
  --type-turno-border: #2563EB;
  --type-cap-bg: #4C1D95;
  --type-cap-border: #6D28D9;
  --type-descanso-bg: #334155;
  --type-descanso-border: #475569;
  --type-permiso-bg: #334155;
  --type-permiso-border: #475569;
  --type-incapacidad-bg: #78350F;
  --type-incapacidad-border: #B45309;
  --type-vacaciones-bg: #134E4A;
  --type-vacaciones-border: #0D9488;

  --status-error-bg: #450A0A;
  --status-warn-bg: #451A03;
  --status-info-bg: #172554;
  --status-success-bg: #052E16;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.55);
}

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

/* Compuerta de autenticación: tapa la app hasta validar la sesión */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top, #1e3a8a 0, #0f172a 55%);
}
.auth-gate.hidden { display: none !important; }
.auth-gate-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  color: #0f172a;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, 0.45);
  text-align: center;
}
.auth-gate-brand { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.auth-gate-card #authGateMessage { color: #475569; font-size: 13px; line-height: 1.5; }
.auth-gate-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.auth-gate-actions.hidden { display: none !important; }

body {
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Layout general */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* Top Navigation Header */
header.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-secondary);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Week Navigator */
.week-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-elevated);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.week-label {
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  min-width: 190px;
  text-align: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dropdown Menus */
.export-dropdown-wrapper {
  position: relative;
  display: inline-block;
}
.export-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 230px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.export-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.export-menu-item:last-child {
  border-bottom: none;
}
.export-menu-item:hover {
  background: var(--surface-secondary);
}
.export-menu-item small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

/* Contingency Banner */
.contingency-banner {
  background: #FEF3C7;
  color: #92400E;
  border-bottom: 1px solid #FCD34D;
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Demo banner */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--status-warn-bg, #fef3c7);
  color: var(--status-warn, #92400e);
  border-bottom: 1px solid var(--status-warn, #f59e0b);
  font-size: 13px;
}
.demo-banner.hidden { display: none !important; }

/* Viewer (solo consulta) */
.viewer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #e0f2fe;
  color: #075985;
  border-bottom: 1px solid #38bdf8;
  font-size: 13px;
}
.viewer-banner.hidden { display: none !important; }
.viewer-notice {
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
  color: var(--text-muted);
  font-size: 13px;
}
.viewer-notice.hidden { display: none !important; }
body.viewer-mode .ideal-config-bar,
body.viewer-mode .cell-add-block,
body.viewer-mode .tab-add-block { display: none !important; }
body.viewer-mode .matrix-table .col-hours { display: none !important; }

@media (max-width: 640px) {
  .demo-banner,
  .viewer-banner { flex-direction: column; align-items: flex-start; }
}

[data-theme="dark"] .contingency-banner {
  background: #78350F;
  color: #FEF3C7;
  border-bottom-color: #B45309;
}
[data-theme="dark"] .viewer-banner {
  background: #0c4a6e;
  color: #e0f2fe;
  border-bottom-color: #0284c7;
}

/* Navigation Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
}

.tabs-group {
  display: flex;
  gap: 2px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--type-turno);
  border-bottom-color: var(--type-turno);
  font-weight: 600;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  min-height: 38px;
}

.status-counters {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, transform 0.1s;
}
.status-pill:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}
.status-pill.error {
  background: var(--status-error-bg);
  color: var(--status-error);
  border: 1px solid rgba(220, 38, 38, 0.3);
}
.status-pill.warn {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border: 1px solid rgba(217, 119, 6, 0.3);
}
.status-pill.info {
  background: var(--status-info-bg);
  color: var(--status-info);
  border: 1px solid rgba(37, 99, 235, 0.3);
}
.status-pill.neutral {
  background: var(--surface-secondary);
  color: var(--text);
}

.status-save {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

/* Expanded Alert Panel */
.alerts-dropdown {
  background: var(--surface-elevated);
  border-bottom: 2px solid var(--border);
  padding: 12px 18px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  display: none;
}
.alerts-dropdown.open {
  display: block;
}
.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px;
}
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s;
}
.alert-card.error {
  background: var(--status-error-bg);
  color: var(--status-error);
  border-color: rgba(220, 38, 38, 0.2);
}
.alert-card.warn {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border-color: rgba(217, 119, 6, 0.2);
}
.alert-card.info {
  background: var(--status-info-bg);
  color: var(--status-info);
  border-color: rgba(37, 99, 235, 0.2);
}

/* Main Content Container */
main.app-main {
  flex: 1;
  padding: 16px 18px 48px;
  max-width: 100%;
}

/* Common Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled) {
  background: var(--surface-secondary);
  border-color: var(--text-subtle);
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--type-turno);
  color: #FFFFFF;
  border-color: var(--type-turno);
}
.btn-primary:hover:not(:disabled) {
  background: #1D4ED8;
  border-color: #1D4ED8;
}
.btn-accent {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  color: #FFFFFF;
  border: 1px solid #4F46E5;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338CA 0%, #6D28D9 100%);
  border-color: #4338CA;
  color: #FFFFFF;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}
.btn-success {
  background: var(--status-success);
  color: #FFFFFF;
  border-color: var(--status-success);
}
.btn-success:hover:not(:disabled) {
  background: #15803D;
}
.btn-danger {
  background: var(--status-error);
  color: #FFFFFF;
  border-color: var(--status-error);
}
.btn-danger:hover:not(:disabled) {
  background: #B91C1C;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn-icon {
  padding: 5px;
  width: 28px;
  height: 28px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-draft {
  background: #FEF3C7;
  color: #92400E;
}
.badge-approved {
  background: #DCFCE7;
  color: #166534;
}
.badge-contingency {
  background: #FEE2E2;
  color: #991B1B;
}

/* MATRIZ SEMANAL */
.matrix-wrapper {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

table.matrix-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

/* Primera columna fija al desplazar la matriz en pantallas pequeñas */
.matrix-table th.col-staff,
.matrix-table td.col-staff {
  position: sticky;
  left: 0;
  z-index: 12;
  background: var(--surface-elevated);
}
.matrix-table th.col-staff {
  background: var(--surface);
  z-index: 13;
}
.matrix-table tr.row-boss > td.col-staff {
  background: var(--surface);
}

.matrix-table th,
.matrix-table td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  vertical-align: middle;
}

.matrix-table th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.col-staff {
  width: 175px;
  text-align: left !important;
  padding-left: 12px !important;
}

.col-day {
  min-width: 135px;
}

.col-today {
  background-color: rgba(59, 130, 246, 0.05) !important;
  border-top: 2px solid var(--type-turno) !important;
}

.col-weekend {
  background-color: rgba(248, 250, 252, 0.5);
}
[data-theme="dark"] .col-weekend {
  background-color: rgba(30, 41, 59, 0.3);
}

.col-hours {
  width: 70px;
  text-align: right !important;
  padding-right: 10px !important;
}

/* Botón "+" para añadir otro bloque en una celda ocupada */
.cell-add-block {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
  z-index: 3;
}
.day-cell:hover .cell-add-block,
.cell-add-block:focus {
  opacity: 1;
}
.cell-add-block:hover {
  background: var(--type-turno);
  color: #FFFFFF;
  border-color: transparent;
}
@media (hover: none) {
  .cell-add-block { opacity: 0.8; }
}

/* Filas de staff */
.row-boss {
  background: var(--surface) !important;
}
.row-boss .staff-name {
  color: var(--text-muted);
}

.staff-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.staff-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.staff-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.staff-badges {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.tag-chip-mini {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

/* Celda de día: ajustada al espacio total, bloques centrados */
.day-cell {
  height: 52px;
  padding: 4px !important;
  position: relative;
  cursor: pointer;
  transition: background-color 0.1s;
}
.day-cell:hover {
  background-color: var(--surface-secondary);
}
.day-cell.selected {
  outline: 2px solid var(--type-turno);
  outline-offset: -2px;
}

.empty-cell-btn {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.01);
  transition: all 0.15s;
}
.day-cell:hover .empty-cell-btn {
  opacity: 1;
  background: var(--surface-secondary);
  border-color: var(--border-focus);
  color: var(--type-turno);
}

/* Contenedor que ocupa la totalidad de la celda de manera limpia */
.cell-blocks-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 3px;
}

/* Bloque dentro de la celda: Centrado, ocupa el ancho completo, sin proporción horizontal */
.time-block-bar {
  width: 100% !important;
  min-height: 26px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 2px 6px;
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(0,0,0,0.16);
  cursor: pointer;
  transition: filter 0.15s;
  text-align: center;
  line-height: 1.2;
}
.time-block-bar:hover {
  filter: brightness(1.1);
}
.time-block-bar.type-TURNO {
  background: var(--type-turno);
}
.time-block-bar.type-CAPACITACION {
  background: var(--type-cap);
}
.time-block-bar.type-DESCANSO {
  background: var(--type-descanso) !important;
  color: #FFFFFF !important;
}
.time-block-bar.type-PERMISO {
  background: var(--type-permiso);
}
.time-block-bar.type-INCAPACIDAD {
  background: var(--type-incapacidad);
}
.time-block-bar.type-VACACIONES {
  background: var(--type-vacaciones);
}

/* Iniciales de Tags en cuadros nítidos de colores */
.block-tags-inline {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
.tag-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 3px;
  min-width: 15px;
  height: 15px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  color: #FFFFFF !important;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.tag-icon-DESAYUNO { background: #EA580C !important; }
.tag-icon-TP { background: #0891B2 !important; }
.tag-icon-MONTAJE { background: #DB2777 !important; }
.tag-icon-ENCARGADO { background: #7C3AED !important; }

/* Cobertura rows at matrix bottom */
.row-coverage-header {
  background: var(--surface) !important;
  font-weight: 700;
  font-size: 12px;
}
.coverage-cell {
  font-size: 11px;
  text-align: center;
  padding: 6px 4px !important;
}
.cov-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  background: var(--surface-secondary);
  font-size: 11px;
}
.cov-band.ok {
  border-left: 3px solid var(--status-success);
}
.cov-band.gap {
  border-left: 3px solid var(--status-error);
  background: var(--status-error-bg);
  color: var(--status-error);
  font-weight: 600;
}

/* Barra de configuración de Ideales */
.ideal-config-bar {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
}

/* Cuadro sutil de convención de letras y colores */
.matrix-legend-card {
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.legend-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.legend-header {
  font-weight: 700;
  color: var(--text);
}
.legend-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
}

/* Hourly breakdown panel */
.hourly-breakdown-panel {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* DRAWER LATERAL DE EDICIÓN (SLIDE-OVER) */
.drawer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 90;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}
.drawer-overlay.open {
  display: block;
  opacity: 1;
}

.edit-drawer {
  position: fixed;
  top: 0;
  right: -460px;
  width: 440px;
  max-width: 95vw;
  height: 100vh;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid var(--border);
}
.edit-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-title {
  font-size: 16px;
  font-weight: 700;
}
.drawer-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
}

/* Segmented block types in drawer */
.type-segments {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.type-segment-btn {
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.type-segment-btn:hover {
  border-color: var(--text-subtle);
}
.type-segment-btn.active {
  color: #FFFFFF !important;
  border-color: transparent !important;
}
.type-segment-btn.active[data-type="TURNO"] { background: var(--type-turno); }
.type-segment-btn.active[data-type="CAPACITACION"] { background: var(--type-cap); }
.type-segment-btn.active[data-type="DESCANSO"] { background: var(--type-descanso); }
.type-segment-btn.active[data-type="PERMISO"] { background: var(--type-permiso); }
.type-segment-btn.active[data-type="INCAPACIDAD"] { background: var(--type-incapacidad); }
.type-segment-btn.active[data-type="VACACIONES"] { background: var(--type-vacaciones); }

/* Form controls in drawer */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Tag chips toggle */
.tag-chips-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.tag-chip-toggle.active {
  color: #FFFFFF;
  border-color: transparent;
}
.tag-chip-toggle.active[data-tag="DESAYUNO"] { background: var(--tag-desayuno); }
.tag-chip-toggle.active[data-tag="TP"] { background: var(--tag-tp); }
.tag-chip-toggle.active[data-tag="MONTAJE"] { background: var(--tag-montaje); }
.tag-chip-toggle.active[data-tag="ENCARGADO"] { background: var(--tag-encargado); }

/* Live preview inside drawer */
.drawer-preview {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.drawer-preview-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.drawer-preview-error {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--status-error-bg);
  color: var(--status-error);
  font-size: 12px;
  font-weight: 500;
  display: none;
}
.drawer-preview-warn {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--status-warn-bg);
  color: var(--status-warn);
  font-size: 12px;
  font-weight: 500;
  display: none;
}

/* Modal dialogs */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 520px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Generic data table (Reportes, Colaboradores, etc.) */
.data-table-container {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th {
  background: var(--surface);
  padding: 8px 12px;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
table.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
table.data-table tr:hover {
  background: var(--surface-secondary);
}

/* Configuración: tarjetas por sección */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}
.config-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.config-card-full { grid-column: 1 / -1; }
.config-card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.config-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}
.config-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.config-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 6px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}
.ideal-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  gap: 10px;
  align-items: center;
}
@media (max-width: 640px) {
  .ideal-row { grid-template-columns: 70px 1fr 1fr; gap: 6px; }
}

.config-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
}

/* Revisión de propuesta generada automáticamente */
.pending-proposal-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 10px;
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border: 1px solid var(--status-warn);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
}
.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.review-table th, .review-table td {
  border-bottom: 1px solid var(--border);
  padding: 4px 6px;
  text-align: center;
}
.review-table th {
  background: var(--surface-secondary);
  position: sticky;
  top: 0;
  font-size: 10px;
  z-index: 1;
}
.review-table td.review-name {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.review-cell-block {
  display: inline-block;
  padding: 1px 5px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
}
.review-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.review-summary-item {
  background: var(--surface-secondary);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.review-summary-item strong {
  display: block;
  font-size: 16px;
  color: var(--text);
}
.review-alert-box {
  font-size: 12px;
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

/* Utilities */
.hidden { display: none !important; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.font-semibold { font-weight: 600; }
.mt-4 { margin-top: 16px; }

/* ESTILOS DE IMPRESIÓN CON RESPETO RIGUROSO DE COLORES */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  header.app-header, .tabs-bar, .status-bar, .header-actions, .empty-cell-btn, .btn, .ideal-config-bar, #reportTagFilterBar {
    display: none !important;
  }
  main.app-main {
    padding: 0 !important;
    margin: 0 !important;
  }
  .matrix-wrapper {
    border: 1px solid #334155 !important;
    box-shadow: none !important;
  }
  .matrix-table th {
    background: #F1F5F9 !important;
    color: #0F172A !important;
    border: 1px solid #94A3B8 !important;
  }
  .matrix-table td {
    border: 1px solid #CBD5E1 !important;
  }
  .time-block-bar.type-TURNO { background: #2563EB !important; color: #FFFFFF !important; }
  .time-block-bar.type-CAPACITACION { background: #7C3AED !important; color: #FFFFFF !important; }
  .time-block-bar.type-DESCANSO { background: #64748B !important; color: #FFFFFF !important; }
  .time-block-bar.type-PERMISO { background: #475569 !important; color: #FFFFFF !important; }
  .time-block-bar.type-INCAPACIDAD { background: #D97706 !important; color: #FFFFFF !important; }
  .time-block-bar.type-VACACIONES { background: #0D9488 !important; color: #FFFFFF !important; }

  .tag-icon-DESAYUNO { background: #EA580C !important; color: #FFFFFF !important; }
  .tag-icon-TP { background: #0891B2 !important; color: #FFFFFF !important; }
  .tag-icon-MONTAJE { background: #DB2777 !important; color: #FFFFFF !important; }
  .tag-icon-ENCARGADO { background: #7C3AED !important; color: #FFFFFF !important; }

  @page {
    size: landscape;
    margin: 10mm;
  }
}

/* ==========================================================================
   RESPONSIVE (móvil, tablet, escritorio)
   ========================================================================== */
@media (max-width: 1200px) {
  .config-grid { grid-template-columns: 1fr; }
  .week-label { min-width: 150px; }
}

@media (max-width: 900px) {
  .header-top {
    flex-wrap: wrap;
    align-items: stretch;
    padding: 8px 10px;
    gap: 8px;
  }
  .brand-section {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }
  .week-nav { flex-wrap: nowrap; }
  .tabs-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 6px 10px;
  }
  .tabs-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .tab-btn { white-space: nowrap; flex: 0 0 auto; }
  .status-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 10px;
  }
  .status-counters { flex-wrap: wrap; gap: 6px; }
  .status-pill { font-size: 11px; }
  .ideal-config-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .matrix-wrapper { -webkit-overflow-scrolling: touch; }
  table.matrix-table { min-width: 900px; }
  .col-staff { width: 150px; }
  .col-day { min-width: 120px; }
  .edit-drawer { width: min(480px, 100vw); right: -100%; }
  main.app-main { padding: 12px 10px 40px; }
  .modal-overlay { padding: 10px; }
  .modal-card { width: 100%; max-width: 100%; }
  .config-grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }
  .brand-title { font-size: 16px; }
  .brand-badge { font-size: 9px; }
  .week-label { min-width: 0; flex: 1; font-size: 12px; padding: 2px 4px; }
  .week-nav { width: 100%; justify-content: space-between; }
  main.app-main { padding: 8px 8px 36px; }
  .matrix-table { min-width: 820px; font-size: 11px; }
  .matrix-table th, .matrix-table td { padding: 3px 4px; }
  .col-staff { width: 128px; padding-left: 8px !important; }
  .col-hours { width: 56px; padding-right: 6px !important; }
  .day-cell { height: 46px; }
  .staff-name { font-size: 12px; }
  .time-block-bar { font-size: 10px; padding: 1px 4px; }
  .status-save { font-size: 11px; }
  .flex-row { flex-wrap: wrap; }
  .modal-overlay { padding: 6px; }
  .modal-card { max-height: 94vh; border-radius: var(--radius-lg); }
  .modal-header, .modal-body, .modal-footer { padding: 12px 14px; }
  .modal-footer { flex-wrap: wrap; gap: 8px; }
  .drawer-body { padding: 12px; gap: 12px; }
  .drawer-footer { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .config-grid { gap: 12px; }
  .config-card { padding: 14px; }
  .config-grid-2 { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
  .review-summary-grid { grid-template-columns: repeat(2, 1fr); }
  table.data-table th, table.data-table td { padding: 6px 8px; white-space: nowrap; }
  .toast-container { left: 10px; right: 10px; bottom: 12px; }
  .toast { font-size: 12px; }
  .pending-proposal-banner { flex-direction: column; align-items: stretch; gap: 6px; }
}

@media (max-width: 400px) {
  .matrix-table { min-width: 760px; }
  .col-staff { width: 112px; }
  .header-actions .btn { font-size: 11px; padding: 4px 7px; }
  .review-summary-grid { grid-template-columns: 1fr 1fr; }
}
