/* ==========================================================================
   ACP - SISTEMA CLÍNICO DE APOYO CONDUCTUAL POSITIVO (CHRYSLIS ECOSYSTEM)
   Estilos principales, componentes clínicos y reglas anti-desbordamiento PDF
   ========================================================================== */

:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --accent: #0d9488;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --purple: #7c3aed;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 10px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   BARRA SUPERIOR / HEADER
   ========================================================================== */
.app-header {
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Botones discretos y minimalistas */
.btn-discreet {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn-discreet:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-discreet:active {
  transform: translateY(1px);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-accent {
  background-color: var(--accent);
  color: #ffffff;
}
.btn-accent:hover {
  background-color: #0f766e;
}

.btn-outline-white {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
  border-color: rgba(255,255,255,0.3);
}
.btn-outline-white:hover {
  background: rgba(255,255,255,0.2);
  border-color: #ffffff;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

/* ==========================================================================
   ESTRUCTURA PRINCIPAL Y MENÚ LATERAL IZQUIERDO
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: calc(100vh - 55px);
  width: 100%;
}

.sidebar-nav {
  width: 260px;
  min-width: 260px;
  background: #ffffff;
  border-right: 1px solid var(--border-light);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 55px;
  height: calc(100vh - 55px);
  overflow-y: auto;
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.02);
}

.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  padding: 0.25rem 0.6rem;
  margin-bottom: 0.5rem;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-item,
.wizard-tab {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease-in-out;
}

.sidebar-item:hover,
.wizard-tab:hover {
  background-color: var(--bg-subtle);
  color: var(--primary-dark);
}

.sidebar-item.active,
.wizard-tab.active {
  background-color: #f0f9ff;
  color: var(--primary-dark);
  border-color: #bae6fd;
  font-weight: 700;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background-color: #e2e8f0;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-item.active .tab-badge,
.wizard-tab.active .tab-badge {
  background-color: var(--primary);
  color: #ffffff;
}

.tab-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-shortcut {
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  font-family: monospace;
  margin-left: auto;
}

.sidebar-item.active .tab-shortcut,
.wizard-tab.active .tab-shortcut {
  background: #e0f2fe;
  color: #0369a1;
}

.sidebar-status-box {
  margin-top: auto;
  padding: 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 0.75rem;
}

.sidebar-status-title {
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.68rem;
}

.sidebar-status-text {
  color: #64748b;
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL
   ========================================================================== */
.main-content-area,
.main-container {
  flex: 1;
  padding: 1.5rem 2rem 4rem 2rem;
  min-width: 0;
  max-width: 1250px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   TARJETAS Y SECCIONES
   ========================================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ==========================================================================
   FORMULARIOS Y CAMPOS
   ========================================================================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

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

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

textarea.form-control {
  min-height: 85px;
  resize: vertical;
}

/* Checkbox & Radio Groups */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.chip-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.825rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.chip-checkbox:hover {
  background: #e2e8f0;
}

.chip-checkbox input[type="checkbox"] {
  accent-color: var(--primary);
}

.chip-checkbox.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

/* ==========================================================================
   AUTOCOMPLETADO DE PACIENTES (CHRYSALIS BRIDGE INTEGRATION)
   ========================================================================== */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  display: none;
}

.autocomplete-item {
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
}

.autocomplete-item:hover, .autocomplete-item.selected {
  background-color: var(--primary-light);
}

/* ==========================================================================
   PANEL DE ANÁLISIS FUNCIONAL ABC Y GRÁFICOS
   ========================================================================== */
.abc-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.abc-column {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.abc-column-header {
  font-weight: 700;
  font-size: 0.95rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.8rem;
  border-bottom: 2px solid;
  display: flex;
  justify-content: space-between;
}

.abc-a { border-bottom-color: #0284c7; color: #0284c7; }
.abc-b { border-bottom-color: #ea580c; color: #ea580c; }
.abc-c { border-bottom-color: #16a34a; color: #16a34a; }

/* Functional Function Gauges */
.function-bars-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1rem;
}

.function-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.function-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.function-bar-track {
  width: 100%;
  height: 12px;
  background-color: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.function-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-escape { background: linear-gradient(90deg, #38bdf8, #0284c7); }
.fill-attention { background: linear-gradient(90deg, #fbbf24, #d97706); }
.fill-tangible { background: linear-gradient(90deg, #4ade80, #16a34a); }
.fill-sensory { background: linear-gradient(90deg, #c084fc, #7c3aed); }
.fill-pain { background: linear-gradient(90deg, #f87171, #dc2626); }

/* ==========================================================================
   CATÁLOGO DE LAS 121 TÉCNICAS (FILTRADO Y TARJETAS)
   ========================================================================== */
.techniques-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.filter-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.techniques-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.technique-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.technique-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.technique-card.recommended {
  border-left: 4px solid var(--success);
}

.technique-card.contraindicated {
  border-left: 4px solid var(--danger);
  opacity: 0.75;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.tech-id {
  font-size: 0.75rem;
  font-family: monospace;
  background: #f1f5f9;
  color: #475569;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
}

.match-score-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
}

.score-high { background-color: #dcfce7; color: #166534; }
.score-mid { background-color: #fef9c3; color: #854d0e; }
.score-low { background-color: #fee2e2; color: #991b1b; }

.tech-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.tech-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tech-phase-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.6rem;
}

.phase-1 { background-color: #e0f2fe; color: #0369a1; }
.phase-2 { background-color: #dcfce7; color: #15803d; }
.phase-3 { background-color: #ffedd5; color: #c2410c; }
.phase-4 { background-color: #fee2e2; color: #b91c1c; }
.phase-5 { background-color: #f3e8ff; color: #6b21a8; }

.tech-meta {
  font-size: 0.75rem;
  color: #64748b;
  border-top: 1px solid var(--border-light);
  padding-top: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   MODAL DE DETALLE DE TÉCNICA
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: #ffffff;
  border-radius: 12px;
  max-width: 750px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: var(--bg-subtle);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* ==========================================================================
   PANEL DE IA (GEMMA 2B IT & MOTOR DETERMINISTA)
   ========================================================================== */
.ai-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
}

.ai-status-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #94a3b8;
  margin-right: 0.5rem;
}

.ai-status-indicator.ready {
  background-color: #22c55e;
  box-shadow: 0 0 10px #22c55e;
}

.ai-status-indicator.loading {
  background-color: #f59e0b;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.6; }
}

.ai-output-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.65;
  color: #1e293b;
  min-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   REPORTE PACI Y REGLAS ANTI-DESBORDAMIENTO (PRINT & PDF)
   ========================================================================== */
.paci-report-container {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem;
  box-shadow: var(--shadow-sm);
  color: #0f172a;
}

.paci-header {
  border-bottom: 3px double var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.paci-institution {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.paci-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0.25rem 0;
}

.paci-subtitle {
  font-size: 0.95rem;
  color: var(--primary);
  font-weight: 600;
}

/* TABLAS CLÍNICAS CON ANCHO FIJO (ANTI-OVERFLOW FIX) */
.clinical-table {
  width: 100% !important;
  max-width: 100% !important;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  table-layout: fixed !important; /* Previene desbordamiento horizontal en PDF */
}

.clinical-table th,
.clinical-table td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  vertical-align: top;
  word-break: break-word !important; /* Rompe palabras largas sin salir del margen */
  overflow-wrap: anywhere !important;
}

.clinical-table th {
  background-color: var(--bg-subtle);
  font-weight: 700;
  color: #334155;
  text-align: left;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
}

.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ==========================================================================
   AUTOCOMPLETADO Y JALADO AUTOMÁTICO DE PACIENTES
   ========================================================================== */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  margin-top: 4px;
}

.autocomplete-item {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.autocomplete-item:hover {
  background: #f0f9ff;
  color: #0284c7;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.btn-link-action {
  background: none;
  border: none;
  color: #0284c7;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.btn-link-action:hover {
  color: #0369a1;
}

/* ==========================================================================
   MODAL DE HISTÓRICO DE EVALUACIONES Y COMPONENTES DE PERSISTENCIA
   ========================================================================== */
.history-modal-dialog {
  max-width: 980px !important;
  width: 95% !important;
}

.history-search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.history-search-input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

.history-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.history-table-wrapper {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th {
  background: #f8fafc;
  padding: 0.75rem 0.9rem;
  text-align: left;
  font-weight: 700;
  color: #334155;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.history-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.history-table tr:hover {
  background: #f8fafc;
}

.history-actions-cell {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

.btn-action-restore {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

.btn-action-restore:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.btn-action-view {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

.btn-action-view:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.btn-action-delete {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action-delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.history-badge-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  display: inline-block;
}

/* Sidebar History Trigger */
.sidebar-history-item {
  margin-top: 0.75rem;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.25);
  color: #0369a1;
  font-weight: 600;
}

.sidebar-history-item:hover {
  background: rgba(2, 132, 199, 0.15);
  border-color: rgba(2, 132, 199, 0.4);
}

.history-count-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  font-weight: 700;
  margin-left: auto;
}

/* Sistema de Notificaciones Toast Flotantes */
#acp-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.acp-toast {
  pointer-events: auto;
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--primary);
  animation: acpToastSlideIn 0.25s ease-out forwards;
  max-width: 420px;
  line-height: 1.4;
}

.acp-toast.success {
  border-left-color: #16a34a;
}

.acp-toast.warning {
  border-left-color: #ea580c;
}

.acp-toast.error {
  border-left-color: #dc2626;
}

@keyframes acpToastSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes acpToastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}


/* ==========================================================================
   ESTILOS ESPECÍFICOS PARA IMPRESIÓN Y PDF (@MEDIA PRINT)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 1.2cm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 9.5pt !important;
  }

  /* Ocultar elementos no imprimibles */
  .app-header,
  .sidebar-nav,
  .wizard-nav,
  .no-print,
  .btn,
  .btn-discreet,
  .techniques-filter-bar,
  .modal-overlay,
  .ai-status-card {
    display: none !important;
  }

  .app-layout {
    display: block !important;
  }

  .main-content-area,
  .main-container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .tab-pane {
    display: none !important;
  }

  /* Solo imprimir el reporte PACI */
  #tab-paci-report {
    display: block !important;
  }

  .paci-report-container {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .clinical-table {
    table-layout: fixed !important;
    width: 100% !important;
    font-size: 8.5pt !important;
  }

  .clinical-table th, 
  .clinical-table td {
    padding: 0.4rem 0.5rem !important;
    border: 1px solid #cbd5e1 !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .page-break {
    page-break-before: always;
  }

  .avoid-break {
    page-break-inside: avoid;
  }
}
