/* ==========================================================================
   Lensora — SISTEMA DE GESTIÓN ÓPTICA
   Licenciado bajo creación de KOERUS
   ========================================================================== */
.lensora-logo-light { display: inline-block; }
.lensora-logo-dark { display: none; }
[data-theme="dark"] .lensora-logo-light { display: none !important; }
[data-theme="dark"] .lensora-logo-dark { display: inline-block !important; }

:root {
  --app-base-font-size: 13.5px;

  /* Neutros Sólidos */
  --bg-app: #f9fafb;
  --bg-surface: #ffffff;
  --bg-subtle: #f3f4f6;
  --bg-sidebar: #090a0f;
  --bg-sidebar-hover: #12151e;
  --bg-sidebar-active: #171b26;

  /* Textos */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --text-on-dark: #f9fafb;
  --text-muted-dark: #6b7280;

  /* Acento Único (Precision Blue & Monocromo) */
  --brand-primary: #0f172a;
  --brand-accent: #2563eb;
  --brand-accent-subtle: #eff6ff;

  --clinical-od: #1d4ed8;
  --clinical-od-bg: #eff6ff;
  --clinical-oi: #4f46e5;
  --clinical-oi-bg: #eef2ff;

  --status-success: #166534;
  --status-success-bg: #f0fdf4;
  --status-warning: #92400e;
  --status-warning-bg: #fffbeb;
  --status-danger: #991b1b;
  --status-danger-bg: #fef2f2;

  /* Líneas Nítidas de 1px */
  --border: #e5e7eb;
  --border-subtle: #f3f4f6;
  --border-dark: rgba(255, 255, 255, 0.08);

  /* Radios Contenidos */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-overlay: 0 16px 36px -8px rgba(0, 0, 0, 0.12);

  --font-sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

/* ==========================================================================
   TEMA OSCURO (DARK MODE - LINEAR / RAYCAST PALETTE)
   ========================================================================== */
[data-theme="dark"] {
  --bg-app: #080c14;
  --bg-surface: #0f172a;
  --bg-subtle: #192338;
  --bg-sidebar: #05080f;
  --bg-sidebar-hover: #0d1424;
  --bg-sidebar-active: #141f36;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-on-dark: #f8fafc;
  --text-muted-dark: #475569;

  --brand-primary: #f8fafc;
  --brand-accent: #3b82f6;
  --brand-accent-subtle: rgba(59, 130, 246, 0.15);

  --clinical-od: #60a5fa;
  --clinical-od-bg: rgba(59, 130, 246, 0.14);
  --clinical-oi: #818cf8;
  --clinical-oi-bg: rgba(99, 102, 241, 0.14);

  --status-success: #34d399;
  --status-success-bg: rgba(16, 185, 129, 0.14);
  --status-warning: #fbbf24;
  --status-warning-bg: rgba(245, 158, 11, 0.14);
  --status-danger: #f87171;
  --status-danger-bg: rgba(239, 68, 68, 0.14);

  --border: #1e293b;
  --border-subtle: #192338;
  --border-dark: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-overlay: 0 16px 36px -8px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   ESCALAS TIPOGRÁFICAS (FONT SIZE HANDLER)
   ========================================================================== */
[data-font-size="normal"] {
  --app-base-font-size: 13.5px;
}
[data-font-size="medium"] {
  --app-base-font-size: 15.2px;
}
[data-font-size="large"] {
  --app-base-font-size: 17px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: var(--app-base-font-size, 13.5px);
  transition: background-color 0.22s ease, color 0.22s ease, font-size 0.18s ease;
}

/* ==========================================================================
   LAYOUT SHELL (ESPACIO Y ESTRUCTURA)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px 20px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-dark);
}

.brand-badge {
  width: 32px;
  height: 32px;
  background: #1e2536;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.brand-info h1 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand-info span {
  font-size: 10px;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-category {
  font-size: 10px;
  text-transform: uppercase;
  color: #4b5563;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 16px 12px 6px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #9ca3af;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 120ms ease;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background: var(--bg-sidebar-active);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-dark);
}

.tenant-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #11141d;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-xs);
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 8px;
}

.tenant-pill strong {
  color: #fff;
  letter-spacing: 0.04em;
}

.clinic-identity {
  font-size: 11.5px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   WORKSPACE & TOPBAR (LIMPIO, MINIMALISTA)
   ========================================================================== */

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-app);
}

.topbar {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.role-switcher-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.role-switcher-box label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.role-switcher-box select {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-initials {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
}

.user-profile-info .u-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}

.user-profile-info .u-role {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.content-body {
  padding: 36px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.content-body.module-exit {
  opacity: 0;
  transform: translateY(-8px) scale(0.997);
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
}

[data-motion="reduced"] .content-body {
  animation: none !important;
  transform: none !important;
}

/* ==========================================================================
   CARDS & SUPERFICIES (BORDES NÍTIDOS 1PX, ESPACIO NEGATIVO)
   ========================================================================== */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

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

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Fila de Métricas (Contraste drástico y limpio) */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.metric-number {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   BOTONES (DIRECTOS, ESTILO LINEAR)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 120ms ease;
  white-space: nowrap;
  font-family: inherit;
  outline: none;
}

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

.btn-primary {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.btn-primary:hover {
  background: #1e293b;
}

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

.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: #d1d5db;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-success {
  background: #15803d;
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

/* ==========================================================================
   FORMULARIOS (LIMPIOS, SIN DISTRACCIONES)
   ========================================================================== */

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color 120ms ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px var(--brand-accent-subtle);
}

/* ==========================================================================
   TABLAS Y MATRIZ OD/OI (ALTA DENSIDAD, NÚMEROS MONOSPACE)
   ========================================================================== */

.rx-matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 12.5px;
}

.rx-matrix-table th {
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: transparent;
}

.rx-matrix-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.rx-matrix-table tr:hover td {
  background: var(--bg-subtle);
}

.rx-eye-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.rx-eye-od { background: var(--clinical-od-bg); color: var(--clinical-od); }
.rx-eye-oi { background: var(--clinical-oi-bg); color: var(--clinical-oi); }

.rx-input {
  width: 85px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  padding: 6px;
}

/* Alerta Médica Nítida */
.clinical-alert-banner {
  background: var(--status-danger-bg);
  border: 1px solid #fecaca;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--status-danger);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
}

.badge-emerald { background: var(--status-success-bg); color: var(--status-success); }
.badge-blue    { background: var(--brand-accent-subtle); color: var(--brand-accent); }
.badge-amber   { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-purple  { background: #eef2ff; color: #4338ca; }
.badge-rose    { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-slate   { background: var(--bg-subtle); color: var(--text-secondary); }

/* ==========================================================================
   KANBAN WORKSHOP (LINEAL Y ELEGANTE)
   ========================================================================== */

.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-column {
  flex: 0 0 270px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.kanban-column-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.kanban-cards-container {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
}

.kanban-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: border-color 100ms ease;
}

.kanban-card:hover {
  border-color: #9ca3af;
}

.signature-box {
  border: 1px dashed #d1d5db;
  border-radius: var(--radius-sm);
  background: #fafafa;
  width: 100%;
  height: 120px;
  cursor: crosshair;
}

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand-info, .menu-category, .nav-link span, .sidebar-footer { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .content-body { padding: 20px 16px; }
}

/* ==========================================================================
   INTERACTIVE DASHBOARD ANIMATIONS & MICRO-INTERACTIONS
   ========================================================================== */

/* Píldoras de filtro instantáneo */
.filter-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filter-pill {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.filter-pill:hover {
  color: var(--text-primary);
}

.filter-pill.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Barra de progreso de laboratorio animada */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  background-size: 20px 20px;
}

/* Pipeline visual en miniatura */
.pipeline-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

/* ==========================================================================
   SETTINGS MENU & THEME / FONT SIZE CONTROLS
   ========================================================================== */

/* Botón rápido de Tema y Ajustes en el Topbar */
.topbar-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.topbar-tool-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.topbar-tool-btn svg {
  width: 16px;
  height: 16px;
}

/* Modal / Cajón Flotante de Ajustes */
.settings-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);


  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal-card {
  width: 92%;
  max-width: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.25);
  padding: 24px;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.settings-modal-backdrop.open .settings-modal-card {
  transform: scale(1) translateY(0);
}

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

.settings-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-section:last-of-type {
  border-bottom: none;
  margin-bottom: 12px;
  padding-bottom: 0;
}

.settings-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Selector Segmentado de Tema */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 4px;
}

.segmented-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

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

.segmented-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Selector de Tamaño de Fuentes */
.font-scale-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 4px;
}

.font-scale-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.font-scale-btn .f-icon {
  font-weight: 700;
  line-height: 1;
  margin-bottom: 2px;
}

.font-scale-btn .f-label {
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.85;
}

.font-scale-btn:hover {
  color: var(--text-primary);
}

.font-scale-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Previsualización en vivo del tamaño */
.font-preview-box {
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: var(--app-base-font-size, 13.5px);
  color: var(--text-primary);
  line-height: 1.4;
  transition: font-size 0.15s ease;
}

/* Switch de Animación entre Módulos */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--brand-accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* ==========================================================================
   PALETAS DE COLOR DE MARCA (SETTINGS MODAL)
   ========================================================================== */
.brand-color-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.swatch-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

.swatch-btn.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2.5px var(--c), 0 2px 6px rgba(0, 0, 0, 0.25);
  transform: scale(1.08);
}

.swatch-btn.active::after {
  content: "✓";
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* ==========================================================================
   MODAL DE INFORME CLÍNICO DE PROYECCIÓN DE MIOPÍA (ESTILO PROFESIONAL SINTETIZADO)
   ========================================================================== */
.report-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);


  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}

.report-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.report-modal-container {
  width: 100%;
  max-width: 860px;
  max-height: 92vh;
  background: var(--bg-surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97) translateY(10px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.report-modal-backdrop.open .report-modal-container {
  transform: scale(1) translateY(0);
}

.report-modal-toolbar {
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.report-modal-body {
  padding: 24px;
  overflow-y: auto;
  background: #f1f5f9;
}

/* Hoja Clínica del Informe en Formato A4 Ejecutivo */
.myopia-report-sheet {
  background: #ffffff;
  color: #0f172a;
  max-width: 800px;
  margin: 0 auto;
  padding: 36px 42px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  position: relative;
  font-family: var(--font-sans);
  box-sizing: border-box;
}

.myopia-report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 2.5px solid var(--brand-accent);
  margin-bottom: 20px;
  gap: 16px;
}

.myopia-report-clinic-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.myopia-report-logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--brand-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.myopia-report-clinic-name {
  font-size: 19px;
  font-weight: 800;
  color: var(--brand-accent);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

.myopia-report-clinic-subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #64748b;
  margin-top: 3px;
}

.myopia-report-meta-box {
  text-align: right;
  font-size: 11.5px;
  color: #475569;
}

.myopia-report-meta-box strong {
  color: #0f172a;
}

/* Ficha del Paciente Sintetizada */
.myopia-patient-summary-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 12px;
}

.myopia-patient-summary-grid .item strong {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 3px;
}

.myopia-patient-summary-grid .item span {
  font-weight: 700;
  color: #0f172a;
}

/* Métricas Clave Sintetizadas a los 18 años */
.myopia-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.myopia-kpi-card {
  padding: 14px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.myopia-kpi-card.unmanaged {
  background: #fff5f5;
  border-color: #fecaca;
}

.myopia-kpi-card.managed {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.myopia-kpi-card.benefit {
  background: var(--brand-accent-subtle);
  border-color: var(--brand-accent);
}

.myopia-kpi-card .kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.myopia-kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  margin-bottom: 4px;
}

.myopia-kpi-card.unmanaged .kpi-label { color: #991b1b; }
.myopia-kpi-card.unmanaged .kpi-value { color: #dc2626; }

.myopia-kpi-card.managed .kpi-label { color: #166534; }
.myopia-kpi-card.managed .kpi-value { color: #059669; }

.myopia-kpi-card.benefit .kpi-label { color: var(--brand-accent); }
.myopia-kpi-card.benefit .kpi-value { color: var(--brand-accent); }

.myopia-kpi-card .kpi-desc {
  font-size: 10.5px;
  color: #64748b;
}

/* Gráfico Sintetizado en el Reporte */
.myopia-report-chart-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 18px 10px 18px;
  margin-bottom: 20px;
}

.myopia-report-chart-title {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* Tabla Resumen de Hitos Médicos */
.myopia-milestone-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-bottom: 20px;
}

.myopia-milestone-table th {
  background: #f1f5f9;
  color: #334155;
  padding: 8px 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  border: 1px solid #e2e8f0;
  text-align: center;
}

.myopia-milestone-table td {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Plan de Acción y Firma */
.myopia-plan-box {
  background: #f8fafc;
  border-left: 3.5px solid var(--brand-accent);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 24px;
  font-size: 11.5px;
  color: #334155;
  line-height: 1.5;
}

.myopia-plan-box strong {
  color: #0f172a;
}

.myopia-signatures-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px dashed #cbd5e1;
}

.myopia-signature-block {
  text-align: center;
  width: 240px;
}

.myopia-signature-line {
  border-top: 1px solid #0f172a;
  margin-bottom: 6px;
}

/* ==========================================================================
   REGLAS EXCLUSIVAS DE IMPRESIÓN (@media print)
   Garantiza que el reporte salga como un documento A4 limpio, sin interfaz
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 15mm;
  }

  /* Ocultar toda la interfaz web */
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 11.5pt !important;
  }

  .sidebar,
  .topbar,
  .content-body > *:not(#myopiaReportModal),
  .report-modal-toolbar,
  .settings-modal-backdrop,
  #settingsModal,
  .no-print {
    display: none !important;
  }

  .report-modal-backdrop {
    position: static !important;
    background: transparent !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    opacity: 1 !important;
  }

  .report-modal-container {
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    background: #ffffff !important;
  }

  .report-modal-body {
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  .myopia-report-sheet {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    page-break-after: avoid;
    page-break-inside: avoid;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .myopia-report-header {
    border-bottom: 2.5pt solid var(--brand-accent) !important;
  }

  .myopia-report-logo-badge {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .myopia-kpi-card {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}




/* Shared operational surfaces */
:root {
  --font-sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, Consolas, monospace;
  --app-base-font-size: 14px;
  --bg-app: #f5f7f7; --bg-surface: #fff; --bg-subtle: #edf1f2;
  --bg-sidebar: #eef2f2; --bg-sidebar-hover: #e2e9e9; --bg-sidebar-active: #dce7e9;
  --text-primary: #202e33; --text-secondary: #53636b; --text-tertiary: #5c6c74;
  --brand-accent: #245a67; --brand-accent-subtle: #e6eff1;
  --border: #d8e0e2; --border-subtle: #e5eaec; --border-dark: #d8e0e2;
  --radius-md: 12px; --shadow-card: none; --shadow-sm: none;
  --bg-card: var(--bg-surface); --border-hairline: var(--border);
  --shadow-hover: none; --shadow-subtle: none; --rose: var(--status-danger);
  --emerald: var(--status-success); --amber: var(--status-warning);
  --blue: var(--brand-accent); --purple: #65587b; --indigo: #485b7c;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg-app: #151c20; --bg-surface: #1d272c; --bg-subtle: #26333a;
  --bg-sidebar: #182125; --bg-sidebar-hover: #29373d; --bg-sidebar-active: #31464e;
  --text-primary: #e4ecef; --text-secondary: #b0c0c7; --text-tertiary: #a5b8c0;
  --border: #3a4a51; --border-subtle: #304047; --border-dark: #3a4a51;
  --brand-accent-subtle: #29434c; color-scheme: dark;
}
[data-font-size="normal"] { --app-base-font-size: 14px; }
body { transition: background-color 220ms ease, color 220ms ease; }
a { color: var(--brand-accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
input, textarea { caret-color: var(--brand-accent); }
::selection { background: #c4dde3; color: #173b45; }
:focus-visible { outline: 2px solid #36788b !important; outline-offset: 3px; }
button:disabled, .btn:disabled, [aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 10000; padding: 12px 20px; background: var(--bg-surface); }
.skip-link:focus { top: 12px; }
.sidebar { width: 232px; color: var(--text-primary); height: 100dvh; }
.sidebar-header { min-height: 76px; padding: 20px; gap: 10px; }
.brand-info h1 { color: var(--text-primary); letter-spacing: .04em; }
.brand-info span { color: var(--text-secondary); text-transform: none; letter-spacing: 0; font-size: 11px; }
.brand-badge { border: none; border-radius: 6px; }
.sidebar-menu { padding: 8px 12px 20px; gap: 2px; }
.menu-category { color: var(--text-secondary); font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 18px 10px 7px; }
.nav-link { color: var(--text-secondary); min-height: 38px; padding: 9px 10px; font-size: 13px; }
.nav-link:hover, .nav-link.active { color: var(--text-primary); }
.nav-link.active { background: var(--bg-sidebar-active); }
.nav-icon { flex-shrink: 0; opacity: 1; }
.sidebar-footer { padding: 16px 20px; }
.tenant-pill { background: transparent; color: var(--text-secondary); border: none; padding: 0; }
.tenant-pill strong, .clinic-identity { color: var(--text-primary); }
.clinic-identity { white-space: normal; }
.topbar { min-height: 68px; height: auto; padding: 14px 32px; gap: 16px; }
.topbar-title { min-width: 0; }
.topbar-title h2 { font-size: 16px; font-weight: 600; line-height: 1.35; }
.topbar-actions { gap: 12px; flex-shrink: 0; }
.topbar-tool-btn { width: 36px; height: 36px; background: transparent; }
.topbar-tool-btn:hover { transform: none; background: var(--bg-subtle); }
.logout-form { margin: 0; }
.content-body { padding: 32px; max-width: 1480px; animation: none; overflow-wrap: anywhere; }
.card { box-shadow: none; padding: 24px; min-width: 0; }
.card-header { gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; }
.card .card { border: 0; border-radius: 0; box-shadow: none; padding: 16px 0; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.page-heading h1 { font-size: 26px; line-height: 1.25; letter-spacing: -.025em; font-weight: 600; margin-bottom: 8px; }
.page-heading p { color: var(--text-secondary); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 36px; font-size: 13px; font-weight: 600; box-shadow: none !important; transition: background-color 150ms ease, border-color 150ms ease; }
.btn-primary { background: var(--brand-accent); border-color: var(--brand-accent); color: white; }
.btn-primary:hover { background: #1b4853; border-color: #1b4853; }
.btn-outline { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.btn-sm { min-height: 32px; }
.btn:active { transform: none; }
.form-label { color: var(--text-primary); font-size: 13px; font-weight: 500; }
.form-control { min-height: 40px; font-size: 14px; border-color: #b7c4ca; border-radius: 6px; }
.form-control::placeholder { color: var(--text-secondary); opacity: 1; }
.form-control:focus { border-color: var(--brand-accent); box-shadow: none; outline: 2px solid #c2d9df; outline-offset: 1px; }
.form-group { margin-bottom: 20px; }
textarea.form-control { resize: vertical; }
.field-hint { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-accent); width: 16px; height: 16px; }
.table-scroll { overflow-x: auto; max-width: 100%; border-radius: 4px; }
.table-scroll:focus { outline-offset: 1px; }
.rx-matrix-table { margin-bottom: 0; min-width: 580px; }
.rx-matrix-table th { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--text-secondary); background: var(--bg-subtle); }
.rx-matrix-table td { font-size: 13px; padding: 13px 12px; }
.rx-input { width: 82px; }
.rx-eye-oi { color: #514b72; background: #efedf5; }
.badge-indigo, .badge-purple { color: #514b72; background: #efedf5; }
.badge { line-height: 1.45; font-size: 11px; }
.metrics-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-block: 1px solid var(--border); padding-block: 20px; margin-bottom: 28px; }
.metric-tile, .metric-tile-interactive { padding: 0 20px; background: transparent; border: none; border-right: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.metric-tile:first-child { padding-left: 0; }
.metric-tile:last-child { border-right: none; }
.metric-label { text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.metric-number { font-size: 28px; line-height: 1.3; font-weight: 600; color: var(--text-primary); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 24px; }
.dashboard-grid > .card { margin-bottom: 0; }
.dashboard-section { margin-bottom: 24px; }
.chart-container { position: relative; height: 250px; margin-top: 16px; }
.section-description { font-size: 12px; color: var(--text-secondary); margin-top: 6px; max-width: 70ch; }
.stage-list { list-style: none; }
.stage-list li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.stage-list strong { font-variant-numeric: tabular-nums; }
.empty-state { padding: 28px 0; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.order-row { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border-subtle); text-decoration: none; }
.order-row strong { display: block; color: var(--text-primary); }
.order-row small { color: var(--text-secondary); }
.filter-tabs { flex-wrap: wrap; }
.filter-pill { min-height: 32px; font-family: inherit; }
.filter-pill.active { background: var(--bg-surface); box-shadow: none; }
.kanban-board { max-width: 100%; align-items: stretch; gap: 12px; }
.kanban-column { flex-basis: 280px; padding: 12px; }
.kanban-column-title { text-transform: none; letter-spacing: 0; font-size: 12px; }
.kanban-card { background: var(--bg-surface); box-shadow: none; }
.kanban-card.dragging { opacity: .6; }
.kanban-card[aria-busy="true"] { opacity: .65; cursor: wait; }
.kanban-empty { color: var(--text-secondary); font-size: 12px; padding: 20px 4px; }
.kanban-cards-container:has(.kanban-card) .kanban-empty { display: none; }
.kanban-cards-container.is-drag-over { outline: 2px dashed var(--brand-accent); outline-offset: 3px; }
.kanban-status-select { margin-top: 12px; min-height: 36px; width: 100%; font-size: 12px; }
.notice { border: 1px solid var(--border); background: var(--bg-surface); padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; line-height: 1.5; }
.notice-error { color: var(--status-danger); background: var(--status-danger-bg); }
.notice-success { color: var(--status-success); background: var(--status-success-bg); }
.settings-modal-backdrop, .report-modal-backdrop { backdrop-filter: none; visibility: hidden; }
.settings-modal-backdrop.open, .report-modal-backdrop.open { visibility: visible; }
.settings-modal-card { max-height: calc(100dvh - 40px); overflow-y: auto; }
.settings-section-label { text-transform: none; letter-spacing: 0; font-size: 12px; }
.swatch-btn, .swatch-btn:hover, .swatch-btn.active { transform: none; box-shadow: none; border-radius: 6px; }
.swatch-btn.active { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.swatch-btn.active::after { content: none; }
.signature-box { background: #fff; touch-action: none; }
.myopia-plan-box { border-left-width: 1px; }
.progress-bar-fill { background-image: none; transform-origin: left; transition: width 500ms cubic-bezier(.16,1,.3,1); }

.mobile-menu-toggle, .navigation-backdrop { display: none; }
.error-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.error-panel { max-width: 640px; }
.error-panel h1 { font-size: 26px; margin-bottom: 16px; }
.error-panel p { margin-bottom: 20px; color: var(--text-secondary); }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 32px 24px; background: #f1f4f4; color-scheme: light; }
.login-layout { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 1040px); background: #fff; border: 1px solid #d8e0e2; border-radius: 12px; overflow: hidden; }
.login-intro { position: relative; min-height: 620px; overflow: hidden; background: #e5f1f5; color: #234751; }
.login-artwork { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.login-brand { position: absolute; top: 32px; left: 32px; display: flex; align-items: center; gap: 12px; font-size: 16px; letter-spacing: .06em; }
.login-form-panel { padding: 56px 48px; align-self: center; min-width: 0; }
.login-form-panel h1 { font-size: 28px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; margin-bottom: 10px; }
.login-description { color: #53636b; margin-bottom: 32px; }
.password-field { position: relative; }
.password-field input { padding-right: 80px; }
.password-field button { position: absolute; right: 8px; top: 4px; height: 32px; border: none; color: #245a67; background: transparent; padding: 0 8px; font-size: 12px; cursor: pointer; }
.login-submit { width: 100%; margin-top: 8px; min-height: 42px; }
.login-help { font-size: 12px; color: #53636b; margin-top: 28px; line-height: 1.7; }
@media (max-width: 1150px) {
  .content-body { padding: 24px; }
  .grid-12 > [style*="grid-column"] { grid-column: span 12 !important; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding-inline: 24px; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); visibility: hidden; z-index: 100; transition: transform 180ms ease; }
  .brand-info, .menu-category, .nav-link span, .sidebar-footer { display: block; }
  .mobile-menu-toggle { display: inline-flex; flex-shrink: 0; }
  .sidebar-open .sidebar { transform: none; visibility: visible; }
  .sidebar-open .navigation-backdrop { display: block; position: fixed; inset: 0; background: rgb(15 30 36 / .35); border: none; z-index: 90; }
  .topbar-title { flex: 1; }
  .topbar { gap: 12px; padding: 12px 16px; }
  .topbar-actions { gap: 8px; }
  .content-body { padding: 24px 16px; }
  .metrics-row { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px 0; }
  .metric-tile:nth-child(3) { padding-left: 0; }
  .metric-tile:nth-child(2) { border-right: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0,1fr); }
  .content-body [style*="grid-template-columns"]:not(.myopia-patient-summary-grid) { grid-template-columns: minmax(0,1fr) !important; }
  .content-body .grid-12 { grid-template-columns: minmax(0,1fr); }
  .grid-12 > [style*="grid-column"] { grid-column: auto !important; }
  .card { padding: 20px; }
  .login-layout { grid-template-columns: .9fr 1fr; }
  .login-form-panel { padding: 40px 32px; }
}
@media (max-width: 600px) {
  .user-profile-info { display: none !important; }
  .topbar-title h2 { font-size: 14px; }
  .topbar-actions { gap: 6px; }
  #btnQuickSettings { display: none; }
  .topbar-tool-btn { width: 34px; height: 36px; }
  .page-heading h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .card { padding: 16px; }
  .card-title { font-size: 14px; }
  .content-body [style*="display:flex"], .content-body [style*="display: flex"] { flex-wrap: wrap; }
  .btn { white-space: normal; text-align: center; }
  .myopia-patient-summary-grid, .myopia-kpi-grid { grid-template-columns: minmax(0,1fr); }
  .myopia-report-sheet { padding: 20px; }
  .myopia-report-header, .myopia-signatures-row { flex-wrap: wrap; }
  .report-modal-body { padding: 12px; }
  .report-modal-toolbar { padding: 12px; flex-wrap: wrap; }
  .login-page { padding: 20px 16px; }
  .login-layout { display: block; }
  .login-intro { min-height: 0; height: 208px; }
  .login-artwork { object-position: 50% 30%; }
  .login-brand { top: 16px; left: 20px; gap: 10px; padding: 8px 10px; border-radius: 6px; background: #f5fafc; font-size: 15px; }
  .login-form-panel { padding: 32px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .app-layout, .main-wrapper, .content-body { display: block !important; padding: 0 !important; margin: 0 !important; width: 100% !important; }
  .sidebar, .topbar, .skip-link, .navigation-backdrop { display: none !important; }
  .report-modal-backdrop { visibility: visible !important; }
  .myopia-plan-box { border-left-width: 1px; }
}
.btn-primary, .brand-badge { color: var(--brand-button-text, #fff); }
[data-theme="dark"] .btn-outline, [data-theme="dark"] .filter-pill.active, [data-theme="dark"] .kanban-card { background: var(--bg-surface); }
[data-theme="dark"] .badge-blue { color: #acd7e3; }
[data-theme="dark"] .badge-purple, [data-theme="dark"] .badge-indigo { background: #343342; color: #c7c0e2; }
:root { --shadow-elevated: 0 12px 32px rgb(20 40 48 / .15); --brand-primary-border: var(--border); --brand-button-text: #fff; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 24px; padding-block: 16px; border-block: 1px solid var(--border); }
.metric-card { min-width: 0; }
.metric-icon { display: none; }
.metric-value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.command-banner { background: var(--bg-subtle); padding: 16px; border-radius: 6px; }
.hover-underline:hover { text-decoration: underline !important; }
[id^="modal"] { padding: 20px; overflow-y: auto; }
[id^="modal"] > div { max-height: calc(100dvh - 40px); overflow-y: auto; margin: auto; }
@media(max-width:600px) {
  .metrics-grid { gap: 12px; }
  .metric-value { font-size: 24px; }
  [style*="grid-column: span 3"] { grid-column: auto !important; }
  [style*="grid-column: span 2"] { grid-column: auto !important; }
}
.rx-matrix-table th, .rx-matrix-table td { overflow-wrap: normal; word-break: normal; }
.rx-matrix-table th { min-width: 86px; }
.rx-matrix-table td { max-width: 360px; }
.rx-matrix-table.table-empty { min-width: 0; width: 100%; }
.table-empty thead { display: none; }
.table-empty td { max-width: none; }
.content-body :where([style*="color:#10b981"],[style*="color: #10b981"]) { color: var(--status-success) !important; }

/* Motion: preserve the interface's expressive transitions and feedback. */
@keyframes opticFadeInUp { from {opacity:.55;transform:translateY(14px);} to {opacity:1;transform:translateY(0);} }
:root:not([data-motion="reduced"]) .animate-fade-in-up {animation:opticFadeInUp 450ms cubic-bezier(.16,1,.3,1);}
:root:not([data-motion="reduced"]) .stagger-1 {animation-delay:40ms;}
:root:not([data-motion="reduced"]) .stagger-2 {animation-delay:80ms;}
:root:not([data-motion="reduced"]) .stagger-3 {animation-delay:120ms;}
:root:not([data-motion="reduced"]) .stagger-4 {animation-delay:160ms;}
.card, .metric-tile, .metric-card, .kanban-card {transition:transform 220ms cubic-bezier(.16,1,.3,1),box-shadow 220ms ease,border-color 150ms ease;}
.btn, .topbar-tool-btn {transition:transform 160ms ease,background-color 150ms ease,border-color 150ms ease;}
@media (hover:hover) and (prefers-reduced-motion:no-preference) {
  :root:not([data-motion="reduced"]) .content-body .card:hover {transform:translateY(-2px);box-shadow:0 10px 24px -16px rgb(25 50 60 / .28);}
  :root:not([data-motion="reduced"]) :is(.metric-tile,.metric-card):hover {transform:translateY(-3px);}
  :root:not([data-motion="reduced"]) .kanban-card:hover {transform:translateY(-2px);}
  :root:not([data-motion="reduced"]) :is(.btn,.topbar-tool-btn):hover {transform:translateY(-1px);}
}
:root:not([data-motion="reduced"]) .btn:active {transform:translateY(1px);}
.settings-modal-backdrop, .report-modal-backdrop {transition:opacity 200ms ease,visibility 0s linear 200ms;}
.settings-modal-backdrop.open, .report-modal-backdrop.open {transition-delay:0s;}
[data-motion="reduced"] :is(.content-body,.card,.metric-tile,.metric-card,.kanban-card,.btn,.settings-modal-card,.report-modal-container) {animation:none!important;transform:none!important;transition-duration:0.01ms!important;}
@media (prefers-reduced-motion:reduce) {
  :is(.card,.metric-tile,.metric-card,.kanban-card,.btn,.settings-modal-card,.report-modal-container) {animation:none!important;transform:none!important;}
}
@media print { * {animation:none!important;transition:none!important;} .card {transform:none!important;} }
/* Clinical document capture uses the existing type, color and motion system. */
.signature-settings { max-width: 760px; }
.signature-settings p { max-width: 65ch; }
.signature-preview { display: grid; place-items: center; min-height: 160px; padding: 24px; margin: 24px 0; background: #fff; border: 1px solid var(--border-color, #d7dddc); border-radius: 12px; color: #566562; }
.signature-preview img { display: block; max-width: 100%; max-height: 180px; object-fit: contain; }
.signature-remove { margin-top: 16px; }
.ocr-panel { margin-top: 24px; border-top: 1px solid var(--border-color, #d7dddc); padding-top: 20px; }
.ocr-panel summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.ocr-panel .form-help { max-width: 70ch; margin: 12px 0; }
.ocr-panel > .btn { margin-top: 12px; }
.ocr-panel progress { width: 100%; accent-color: var(--brand-accent); }
.ocr-review-layout { display: grid; grid-template-columns: minmax(160px, .65fr) minmax(0, 1.35fr); gap: 24px; margin: 24px 0; align-items: start; }
.ocr-review-layout img { display: block; max-width: 100%; max-height: 480px; object-fit: contain; background: white; }
.ocr-review-layout > * { min-width: 0; }
.ocr-review-layout h3 { margin: 0 0 12px; }
.ocr-review-layout .rx-matrix-table { min-width: 360px; }
.ocr-review-layout .rx-input { min-width: 76px; }
.ocr-review-layout input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.ocr-review-layout input[type="number"]::-webkit-inner-spin-button, .ocr-review-layout input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ocr-confirm { display: flex; align-items: start; gap: 10px; margin: 16px 0; cursor: pointer; }
.ocr-confirm input { margin-top: 3px; accent-color: var(--brand-accent); }
.ocr-raw { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; padding: 16px; background: var(--bg-subtle); font-size: 13px; }
.myopia-signatures-row { break-inside: avoid; }
@media (max-width: 760px) {
  .ocr-review-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .ocr-review-layout img { max-height: 260px; margin: auto; }
  .ocr-review-layout .rx-matrix-table { min-width: 280px; }
  .ocr-review-layout .rx-input { min-width: 0; width: 64px; padding: 6px; }
  .ocr-review-layout .rx-matrix-table th, .ocr-review-layout .rx-matrix-table td { padding: 8px; }
}

/* Intrinsic sizing also exists in markup; these bounds cover future shared icons. */
svg { flex-shrink:0; }
.metric-icon { width:40px; height:40px; overflow:hidden; }
.metric-icon > svg { width:24px; height:24px; max-width:100%; max-height:100%; }
/* Operación comercial: acciones, historial y recuperación de formularios. */
.page-actions { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px; margin-bottom:24px; }
.page-actions p { margin:0; max-width:65ch; }
.page-actions > .btn { flex:0 0 auto; max-width:100%; white-space:normal; overflow-wrap:normal; text-align:center; }
.page-actions > h2 { flex:1 1 280px; min-width:0; }
.commercial-tabs { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:24px; }
.commercial-summary { display:flex; flex-wrap:wrap; gap:24px; padding:20px 0; margin-bottom:24px; border-block:1px solid var(--border); }
.commercial-summary span { display:grid; gap:6px; }
.commercial-form { margin-top:24px; padding-top:24px; border-top:1px solid var(--border); }
.commercial-form .form-label { margin-top:12px; }
.commercial-log { padding:16px 0; border-bottom:1px solid var(--border); overflow-wrap:anywhere; }
.commercial-log p { margin:6px 0; }
.commercial-log form { max-width:480px; }
.commercial-log summary { cursor:pointer; margin-top:12px; }
.commercial-price { font-size:32px; font-weight:600; }
.commercial-price span { font-size:14px; font-weight:400; }
.payment-address { overflow-wrap:anywhere; }
.clinical-conditional[hidden] { display:none!important; }
.draft-notice { display:flex; flex-wrap:wrap; align-items:center; gap:12px; padding:12px 16px; margin-bottom:20px; background:var(--bg-subtle); border:1px solid var(--border); border-radius:8px; font-size:13px; }
@media(max-width:760px) { .commercial-summary { gap:16px; }.page-actions h1 { font-size:22px; }.commercial-tabs .btn { flex:1 1 auto; }.card form input[type="file"] { max-width:100%; } }
