/**
 * Estilos canónicos para el Pastillero Virtual y Organizador de Medicamentos
 * Fijate Tools (fijate.com)
 */

/* ==========================================================================
   1. VARIABLES DE TEMA Y PALETA
   ========================================================================== */
:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-text: #ffffff;

  --success: #10b981;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;

  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;

  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --info: #06b6d4;
  --info-light: #ecfeff;
  --info-border: #a5f3fc;
  --info-text: #155e75;

  /* Colores de compartimentos */
  --comp-morning-bg: #fffbeb;
  --comp-morning-border: #fef3c7;
  --comp-morning-accent: #d97706;

  --comp-noon-bg: #eff6ff;
  --comp-noon-border: #dbeafe;
  --comp-noon-accent: #2563eb;

  --comp-evening-bg: #fff7ed;
  --comp-evening-border: #ffedd5;
  --comp-evening-accent: #ea580c;

  --comp-night-bg: #f5f3ff;
  --comp-night-border: #ede9fe;
  --comp-night-accent: #7c3aed;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-pill: 0 2px 8px rgba(0, 0, 0, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-card: #111827;
  --bg-card-subtle: #1e293b;
  --bg-card-hover: #263349;
  --border-color: #273549;
  --border-focus: #60a5fa;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #172554;
  --primary-text: #ffffff;

  --success: #10b981;
  --success-light: #064e3b;
  --success-border: #047857;
  --success-text: #6ee7b7;

  --warning: #f59e0b;
  --warning-light: #451a03;
  --warning-border: #78350f;
  --warning-text: #fcd34d;

  --danger: #f87171;
  --danger-light: #450a0a;
  --danger-border: #7f1d1d;
  --danger-text: #fca5a5;

  --info: #38bdf8;
  --info-light: #083344;
  --info-border: #0e7490;
  --info-text: #7dd3fc;

  /* Colores de compartimentos en modo oscuro */
  --comp-morning-bg: #1c1917;
  --comp-morning-border: #292524;
  --comp-morning-accent: #fbbf24;

  --comp-noon-bg: #0f172a;
  --comp-noon-border: #1e293b;
  --comp-noon-accent: #60a5fa;

  --comp-evening-bg: #1c1917;
  --comp-evening-border: #2c1a11;
  --comp-evening-accent: #fb923c;

  --comp-night-bg: #151128;
  --comp-night-border: #261f47;
  --comp-night-accent: #a78bfa;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
  --shadow-pill: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   2. ESTRUCTURA Y LAYOUT
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
  margin-top: 0;
  font-weight: 700;
  line-height: 1.25;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==========================================================================
   3. BOTONES Y CONTROLES GENERALES
   ========================================================================== */
button, input, select, textarea {
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-text);
  border: 1px solid transparent;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  min-height: 42px;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  min-height: 42px;
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  min-height: 34px;
}

.btn-icon-sm {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-sm:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

/* ==========================================================================
   4. NAVEGACIÓN POR PESTAÑAS (TABS)
   ========================================================================== */
.tool-nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  flex: 1 1 0%;
  min-width: 140px;
  padding: 0.7rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-content-panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-content-panel.active {
  display: flex;
}

/* ==========================================================================
   5. BARRA DE CONTROL DEL PASTILLERO (FECHA, STATS, ACCIONES)
   ========================================================================== */
.pillbox-topbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.date-navigator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-display-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  cursor: pointer;
  position: relative;
}

.date-display-btn input[type="date"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.date-badge-today {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.pillbox-adherence-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 220px;
}

.adherence-bar-wrapper {
  flex: 1;
}

.adherence-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.adherence-progress-track {
  height: 8px;
  background: var(--bg-card-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.adherence-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

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

/* ==========================================================================
   6. CAJITA VIRTUAL (PASTILLERO CON 4 COMPARTIMENTOS)
   ========================================================================== */
.virtual-pillbox {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

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

@media (max-width: 1024px) {
  .pillbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .pillbox-grid {
    grid-template-columns: 1fr;
  }
}

.compartment-card {
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 280px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  background: var(--bg-card);
}

.compartment-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.compartment-morning {
  border-color: var(--comp-morning-border);
}
.compartment-morning .compartment-header {
  background: var(--comp-morning-bg);
  border-bottom: 1.5px solid var(--comp-morning-border);
}
.compartment-morning .comp-icon-box {
  color: var(--comp-morning-accent);
}

.compartment-noon {
  border-color: var(--comp-noon-border);
}
.compartment-noon .compartment-header {
  background: var(--comp-noon-bg);
  border-bottom: 1.5px solid var(--comp-noon-border);
}
.compartment-noon .comp-icon-box {
  color: var(--comp-noon-accent);
}

.compartment-evening {
  border-color: var(--comp-evening-border);
}
.compartment-evening .compartment-header {
  background: var(--comp-evening-bg);
  border-bottom: 1.5px solid var(--comp-evening-border);
}
.compartment-evening .comp-icon-box {
  color: var(--comp-evening-accent);
}

.compartment-night {
  border-color: var(--comp-night-border);
}
.compartment-night .compartment-header {
  background: var(--comp-night-bg);
  border-bottom: 1.5px solid var(--comp-night-border);
}
.compartment-night .comp-icon-box {
  color: var(--comp-night-accent);
}

.compartment-header {
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.comp-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.comp-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
}

.comp-title-group h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.comp-time-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.comp-badge-count {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.compartment-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.compartment-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 1.5rem 0.5rem;
}

.compartment-empty svg {
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

/* ==========================================================================
   7. TARJETA DE MEDICAMENTO EN COMPARTIMENTO (TOMA DIARIA)
   ========================================================================== */
.med-pill-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.med-pill-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: var(--med-accent-color, #3b82f6);
}

.med-pill-card.estado-tomado {
  background: var(--success-light);
  border-color: var(--success-border);
}

.med-pill-card.estado-tomado::before {
  background-color: var(--success);
}

.med-pill-card.estado-omitido {
  opacity: 0.6;
  background: var(--bg-card-subtle);
}

.med-pill-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.med-pill-info {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.med-shape-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background-color: var(--med-accent-color, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.med-pill-text {
  flex: 1;
  min-width: 0;
}

.med-pill-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.med-pill-dose {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.med-pill-instructions {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 0.15rem;
  font-style: italic;
}

.med-pill-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.btn-take-pill {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
  min-height: 38px;
}

.btn-take-pill:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.taken-status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.taken-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--success-text);
  font-weight: 700;
  font-size: 0.82rem;
}

.btn-undo-take {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.btn-undo-take:hover {
  color: var(--danger);
}

/* ==========================================================================
   8. ALERTA DE STOCK DE FARMACIA
   ========================================================================== */
.pharmacy-alert-banner {
  background: var(--warning-light);
  border: 1.5px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pharmacy-alert-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--warning-text);
}

.pharmacy-alert-left strong {
  display: block;
  font-size: 0.95rem;
}

.pharmacy-alert-left span {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* ==========================================================================
   9. PESTAÑA: MI BOTIQUÍN (CATÁLOGO DE MEDICAMENTOS)
   ========================================================================== */
.botiquin-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

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

.botiquin-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.botiquin-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.botiquin-card.inactivo {
  opacity: 0.55;
  filter: grayscale(0.6);
}

.botiquin-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.botiquin-meta-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.botiquin-shape-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--med-accent-color, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.botiquin-title h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.botiquin-details {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.botiquin-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stock-meter-box {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
}

.stock-meter-box.alerta-baja {
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.stock-meter-box.alerta-agotado {
  background: var(--danger-light);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

.botiquin-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 0.85rem;
}

/* ==========================================================================
   10. PESTAÑA: VISTA SEMANAL
   ========================================================================== */
.week-grid-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.75rem;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .week-grid-container {
    grid-template-columns: repeat(7, minmax(130px, 1fr));
  }
}

.week-day-col {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 260px;
}

.week-day-col.dia-actual {
  border-color: var(--primary);
  background: var(--primary-light);
}

.week-day-header {
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.week-day-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.week-day-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.week-pills-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.week-pill-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--bg-card-subtle);
  border-left: 3px solid var(--med-accent-color, #3b82f6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.week-pill-tag.tomado {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success-text);
}

/* ==========================================================================
   11. PESTAÑA: HISTORIAL Y ESTADÍSTICAS
   ========================================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kpi-card span {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-card strong {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
}

.history-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.history-table th {
  background: var(--bg-card-subtle);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.history-table tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   12. MODALES ACCESIBLES Y CANÓNICOS (SIN ALERTS)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
  min-height: 42px;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
}

select.form-control {
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

/* Chips selectores de forma farmacéutica */
.shape-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
}

.shape-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 0.4rem;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.shape-chip:hover {
  border-color: var(--border-focus);
  color: var(--text-main);
}

.shape-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Chips selectores de color */
.color-picker-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.color-dot-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.color-dot-btn:hover {
  transform: scale(1.15);
}

.color-dot-btn.active {
  border-color: var(--text-main);
  box-shadow: 0 0 0 2px var(--bg-card);
}

/* Selector de momentos del día en formulario */
.momentos-checkbox-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

@media (max-width: 500px) {
  .momentos-checkbox-group {
    grid-template-columns: repeat(2, 1fr);
  }
}

.momento-checkbox-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.momento-checkbox-card.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Selector de días de la semana */
.dias-semana-chips-grid {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.dia-chip {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.dia-chip:hover {
  border-color: var(--border-focus);
  color: var(--text-main);
}

.dia-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* ==========================================================================
   13. ESTILOS DE IMPRESIÓN OFICIAL (A4 PARA EL MÉDICO / CENTRO DE SALUD)
   ========================================================================== */
@media print {
  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .tool-nav-tabs,
  .pillbox-actions-quick,
  .btn-take-pill,
  .modal-overlay {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .virtual-pillbox {
    border: 1px solid #000 !important;
    box-shadow: none !important;
  }

  .print-header-report {
    display: block !important;
    margin-bottom: 2rem;
    border-bottom: 2px solid #000;
    padding-bottom: 1rem;
  }
}

.print-header-report {
  display: none;
}

/* ==========================================================================
   14. PASTILLERO FÍSICO SEMANAL REALISTA (ESTUCHE ACRÍLICO 28 COMPARTIMENTOS)
   ========================================================================== */

/* Barra de leyenda del pastillero físico */
.physical-pillbox-legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.dot-pending {
  background: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.legend-dot.dot-taken {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.legend-dot.dot-empty {
  background: var(--text-dim);
  opacity: 0.5;
}

.legend-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Estuche acrílico exterior completo */
.physical-case-wrapper {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(241, 245, 249, 0.75) 100%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 1.25rem 1rem 1.5rem;
  box-shadow:
    0 25px 50px -12px rgba(15, 23, 42, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.05),
    inset 0 2px 4px rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-top: 0.5rem;
}

[data-theme="dark"] .physical-case-wrapper {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

/* Tapa transparente superior del estuche (abierta hacia arriba) */
.case-lid {
  position: relative;
  height: 38px;
  margin: -0.75rem -0.5rem 0.75rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.25) 100%);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border-top: 2px solid rgba(255, 255, 255, 0.95);
  border-left: 1.5px solid rgba(255, 255, 255, 0.7);
  border-right: 1.5px solid rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .case-lid {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.03) 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.case-lid-reflection {
  position: absolute;
  top: 0;
  left: 5%;
  right: 5%;
  height: 40%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.8) 50%, transparent 100%);
  border-radius: 8px;
  pointer-events: none;
}

[data-theme="dark"] .case-lid-reflection {
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%);
}

.case-hinges {
  display: flex;
  width: 60%;
  justify-content: space-around;
  z-index: 2;
}

.case-hinge {
  width: 54px;
  height: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), inset 0 1px 1px #ffffff;
}

[data-theme="dark"] .case-hinge {
  background: linear-gradient(180deg, #64748b 0%, #334155 100%);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

/* Bandeja y scroll horizontal para móvil */
.case-body {
  position: relative;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  padding: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .case-body {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.case-scroll-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

/* Cuadrícula de 7 columnas de días */
.case-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 8px;
  min-width: 1000px;
}

/* Columna de día (estuche individual) */
.case-day-column {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--col-bg, #ffffff);
  border: 1.5px solid var(--col-border, #cbd5e1);
  border-radius: 12px;
  padding: 7px;
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.04),
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.case-day-column:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.case-day-column.is-today-column {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}

/* Encabezado superior de cada columna de día */
.case-day-head {
  text-align: center;
  padding: 6px 4px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .case-day-head {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.08);
}

.case-day-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: #0f172a;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
}

[data-theme="dark"] .case-day-title {
  color: #f8fafc;
}

.case-day-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* PALETA EXACTA DE PLÁSTICO TRANSLÚCIDO SEGÚN LA FOTOGRAFÍA */
/* 1. Lunes - Rosa / Magenta translúcido */
.case-col-lun {
  --col-bg: linear-gradient(180deg, rgba(255, 64, 129, 0.16) 0%, rgba(255, 64, 129, 0.07) 100%);
  --col-border: #f06292;
  --slot-head-bg: rgba(255, 64, 129, 0.22);
}

/* 2. Martes - Naranja translúcido */
.case-col-mar {
  --col-bg: linear-gradient(180deg, rgba(255, 152, 0, 0.18) 0%, rgba(255, 152, 0, 0.07) 100%);
  --col-border: #ffb74d;
  --slot-head-bg: rgba(255, 152, 0, 0.24);
}

/* 3. Miércoles - Amarillo translúcido */
.case-col-mie {
  --col-bg: linear-gradient(180deg, rgba(255, 235, 59, 0.24) 0%, rgba(255, 235, 59, 0.09) 100%);
  --col-border: #fdd835;
  --slot-head-bg: rgba(255, 235, 59, 0.32);
}

/* 4. Jueves - Verde claro / Lima translúcido */
.case-col-jue {
  --col-bg: linear-gradient(180deg, rgba(139, 195, 74, 0.2) 0%, rgba(139, 195, 74, 0.08) 100%);
  --col-border: #9ccc65;
  --slot-head-bg: rgba(139, 195, 74, 0.26);
}

/* 5. Viernes - Azul cielo translúcido */
.case-col-vie {
  --col-bg: linear-gradient(180deg, rgba(3, 169, 244, 0.18) 0%, rgba(3, 169, 244, 0.07) 100%);
  --col-border: #4fc3f7;
  --slot-head-bg: rgba(3, 169, 244, 0.24);
}

/* 6. Sábado - Cian / Turquesa brillante translúcido */
.case-col-sab {
  --col-bg: linear-gradient(180deg, rgba(0, 229, 255, 0.2) 0%, rgba(0, 229, 255, 0.08) 100%);
  --col-border: #26c6da;
  --slot-head-bg: rgba(0, 229, 255, 0.28);
}

/* 7. Domingo - Púrpura / Violeta translúcido */
.case-col-dom {
  --col-bg: linear-gradient(180deg, rgba(171, 71, 188, 0.18) 0%, rgba(171, 71, 188, 0.07) 100%);
  --col-border: #ba68c8;
  --slot-head-bg: rgba(171, 71, 188, 0.25);
}

/* CASILLERO INDIVIDUAL DE TOMA (MAÑ, M.DÍA, TARDE, NOCHE) */
.physical-slot {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(0, 0, 0, 0.09);
  border-radius: 9px;
  padding: 6px 7px 8px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.95),
    inset 0 -2px 3px rgba(0, 0, 0, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

[data-theme="dark"] .physical-slot {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.12),
    inset 0 -2px 3px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.physical-slot:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.09),
    inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

/* Estado: Tomado */
.physical-slot.is-taken {
  background: rgba(236, 253, 245, 0.75);
  border-color: rgba(16, 185, 129, 0.45);
}

[data-theme="dark"] .physical-slot.is-taken {
  background: rgba(6, 95, 70, 0.25);
  border-color: rgba(16, 185, 129, 0.35);
}

/* Estado: Vacío (sin tomas programadas) */
.physical-slot.is-empty {
  opacity: 0.65;
  background: rgba(255, 255, 255, 0.45);
  cursor: default;
}

[data-theme="dark"] .physical-slot.is-empty {
  background: rgba(15, 23, 42, 0.35);
  opacity: 0.5;
}

/* Rótulo serigrafiado superior del casillero (igual al pastillero físico real) */
.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--slot-head-bg, rgba(0, 0, 0, 0.05));
  margin-bottom: 6px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.slot-header-title {
  display: flex;
  align-items: center;
  gap: 4px;
}

.slot-day-abbrev {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  color: #0f172a;
  letter-spacing: 0.03em;
}

[data-theme="dark"] .slot-day-abbrev {
  color: #f8fafc;
}

.slot-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
}

[data-theme="dark"] .slot-icon-box {
  color: #f8fafc;
}

.slot-time-abbrev {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 0.72rem;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .slot-time-abbrev {
  color: #f8fafc;
}

/* Cámara interior de pastillas 3D */
.slot-pills-chamber {
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
  margin-bottom: 6px;
}

[data-theme="dark"] .slot-pills-chamber {
  background: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chamber-empty-sign {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
}

.chamber-taken-sign {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success);
}

/* ==========================================================================
   PASTILLAS REALISTAS EN 3D (CSS PURO)
   ========================================================================== */

/* 1. Cápsula bicolor en 3D */
.pill-3d-capsule {
  position: relative;
  width: 32px;
  height: 14px;
  border-radius: 12px;
  display: flex;
  overflow: hidden;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.22),
    inset 0 2px 3px rgba(255, 255, 255, 0.8),
    inset 0 -1px 2px rgba(0, 0, 0, 0.2);
  transform: rotate(-12deg);
  transition: transform 0.2s ease;
}

.pill-3d-capsule:hover {
  transform: rotate(0deg) scale(1.1);
}

.capsule-half-left {
  flex: 1;
  background: var(--pill-color, #3b82f6);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.5);
}

.capsule-half-right {
  flex: 1;
  background: #ffffff;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.9);
}

.capsule-sheen {
  position: absolute;
  top: 1px;
  left: 3px;
  right: 3px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, transparent 100%);
  pointer-events: none;
}

/* 2. Comprimido circular con hendidura en 3D */
.pill-3d-round {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pill-color, #f8fafc);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 3px 5px rgba(0, 0, 0, 0.2),
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -2px 3px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(20deg);
  transition: transform 0.2s ease;
}

.pill-3d-round:hover {
  transform: rotate(0deg) scale(1.1);
}

.round-groove {
  width: 70%;
  height: 1.5px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

/* 3. Comprimido oblongo / caplet en 3D */
.pill-3d-oval {
  position: relative;
  width: 30px;
  height: 13px;
  border-radius: 8px;
  background: var(--pill-color, #e2e8f0);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 3px 5px rgba(0, 0, 0, 0.18),
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -2px 3px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-5deg);
  transition: transform 0.2s ease;
}

.pill-3d-oval:hover {
  transform: rotate(0deg) scale(1.1);
}

/* Desglose de medicamentos dentro de cada casillero */
.slot-meds-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: auto;
}

.slot-med-pill-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="dark"] .slot-med-pill-item {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.slot-med-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.slot-med-name-text {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.slot-med-dose-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Pie del casillero: estado de la toma */
.slot-footer-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .slot-footer-status {
  border-color: rgba(255, 255, 255, 0.08);
}

.slot-status-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.slot-status-pill.status-pending {
  background: var(--primary-light);
  color: var(--primary);
}

.slot-status-pill.status-taken {
  background: var(--success-light);
  color: var(--success);
}

.slot-status-pill.status-none {
  background: var(--bg-card-subtle);
  color: var(--text-dim);
}

/* ==========================================================================
   15. INTEGRACIÓN DE PROSPECTOS CIMA (AEMPS) Y AUTOCOMPLETADO OFICIAL
   ========================================================================== */

/* Desplegable de autocompletado de medicamentos */
.cima-autocomplete-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1050;
}

[data-theme="dark"] .cima-autocomplete-box {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}

.cima-autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

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

[data-theme="dark"] .cima-autocomplete-item:hover,
[data-theme="dark"] .cima-autocomplete-item.active {
  background-color: rgba(37, 99, 235, 0.2);
}

.cima-auto-nombre {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.25;
}

.cima-auto-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.cima-auto-badge {
  background: var(--bg-card-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Insignia oficial CIMA / AEMPS */
.cima-badge-official {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.25);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

[data-theme="dark"] .cima-badge-official {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
}

/* Modal del Visor de Prospecto */
.modal-prospecto-card {
  max-width: 840px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-prospecto-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  min-height: 320px;
}

/* Spinner de carga */
.prospecto-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: 3px solid rgba(37, 99, 235, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Formato y lectura del prospecto oficial AEMPS */
.prospecto-html-content {
  color: var(--text-main);
  font-size: 0.94rem;
  line-height: 1.68;
}

.prospecto-html-content h1,
.prospecto-html-content .prospecto-h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.prospecto-html-content h2,
.prospecto-html-content .prospecto-h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

[data-theme="dark"] .prospecto-html-content h2,
[data-theme="dark"] .prospecto-html-content .prospecto-h2 {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
}

.prospecto-html-content h3,
.prospecto-html-content .prospecto-h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.prospecto-html-content p {
  margin: 0.5rem 0 0.75rem;
}

.prospecto-html-content ul,
.prospecto-html-content ol {
  padding-left: 1.4rem;
  margin: 0.5rem 0 0.85rem;
}

.prospecto-html-content li {
  margin-bottom: 0.35rem;
}

.prospecto-html-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
}

.prospecto-html-content th,
.prospecto-html-content td {
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.prospecto-html-content th {
  background: var(--bg-card-subtle);
  font-weight: 700;
}

.prospecto-html-content img,
.prospecto-html-content .prospecto-img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  vertical-align: middle;
  margin: 0.25rem;
}

/* Selector de presentación CIMA en modal 5 */
.cima-match-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  gap: 0.75rem;
}

.cima-match-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

[data-theme="dark"] .cima-match-item:hover {
  background: rgba(37, 99, 235, 0.2);
}

.cima-match-info {
  min-width: 0;
  flex: 1;
}

.cima-match-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 2px;
}

.cima-match-lab {
  font-size: 0.78rem;
  color: var(--text-muted);
}

