/* ─────────────────────────────────────────────────────────────
   Registro Anestésico Digital — Componentes de interfaz
   Equivalente estático de components/ui/* (shadcn/Radix)
   ───────────────────────────────────────────────────────────── */

/* ── Layout de la aplicación ──────────────────────────────── */
.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
}

.brand-logo {
  height: 96px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.vrule {
  height: 32px;
  width: 1px;
  background: var(--border);
}

.app-main { padding: 24px; }

.app-container {
  margin: 0 auto;
  max-width: 1600px;
}

.record-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  .record-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .record-grid .col-mid { grid-column: span 2; }
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header { padding: 16px 20px 12px; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.card-content { padding: 0 20px 20px; }
.card-content.pt { padding-top: 8px; }

/* ── Botones ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn:hover { background: #17458d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--primary); }

.btn-outline {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--muted); }
.btn-outline:disabled:hover { background: var(--card); }

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--muted); }
.btn-ghost:disabled:hover { background: transparent; }

.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: #e2e7ef; }

.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover { background: #b92e22; }

.btn-danger-outline {
  background: transparent;
  color: var(--destructive);
  border-color: rgba(207, 53, 39, 0.4);
}
.btn-danger-outline:hover { background: rgba(207, 53, 39, 0.08); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-icon { padding: 5px; width: 28px; height: 28px; }
.btn-icon-sm { padding: 3px; width: 22px; height: 22px; }
.btn-block { width: 100%; }
.btn-success-ghost { color: #16a34a; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  background: var(--primary);
  color: var(--primary-foreground);
  white-space: nowrap;
}

.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.badge-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.badge-success { background: var(--success); color: var(--success-foreground); }

.pulse-dot {
  height: 8px;
  width: 8px;
  border-radius: 999px;
  background: currentColor;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Controles de formulario ──────────────────────────────── */
.label { display: block; font-size: 13px; font-weight: 500; line-height: 1.4; }
.label-xs { font-size: 11px; color: var(--muted-foreground); font-weight: 500; }

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--input);
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--foreground);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(28, 80, 163, 0.18);
}

.input:read-only { background: var(--muted); }

.input-sm, .select-sm { padding: 4px 8px; font-size: 12px; }
.input-xs, .select-xs { padding: 3px 6px; font-size: 11px; }

.input-w-time { width: 130px; }
.input-w-sm { width: 96px; }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235c6675' stroke-width='1.6'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  padding-right: 28px;
}

.textarea { resize: vertical; min-height: 80px; }
.textarea-fixed { resize: none; }

.field { display: flex; flex-direction: column; gap: 4px; }

.checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.check-row { display: flex; align-items: center; gap: 8px; }
.check-row label { font-size: 13px; cursor: pointer; user-select: none; }

.radio-row { display: flex; align-items: center; gap: 6px; }
.radio { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.radio-row label { font-size: 13px; cursor: pointer; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--muted);
  border-radius: var(--radius-lg);
  padding: 3px;
  margin-bottom: 16px;
}

.tabs-list.full { display: flex; width: 100%; }
.tabs-list.full .tab-trigger { flex: 1; }

.tab-trigger {
  border-radius: var(--radius-md);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}

.tab-trigger:hover { color: var(--foreground); }

.tab-trigger[data-state="active"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.tab-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.tab-panel[data-state="inactive"] { display: none; }

/* ── Diálogos (modal) ─────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.dialog {
  position: relative;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.22);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
}

.dialog-lg { max-width: 560px; }
.dialog-header { margin-bottom: 4px; padding-right: 24px; }
.dialog-title { font-size: 17px; font-weight: 600; }
.dialog-description { font-size: 13px; color: var(--muted-foreground); margin-top: 4px; }

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--muted-foreground);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.dialog-close:hover { background: var(--muted); }

/* ── Menú desplegable ─────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.16);
  padding: 4px;
  z-index: 40;
}

.dropdown-menu.left { right: auto; left: 0; }
.dropdown-menu.scroll { max-height: 224px; overflow-y: auto; min-width: 90px; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 13px;
}

.dropdown-item:hover { background: var(--muted); }

/* ── Cajas contenedoras / secciones internas ──────────────── */
.panel {
  border: 1px solid var(--border);
  background: rgba(233, 237, 243, 0.45);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.panel-primary {
  border: 1px solid rgba(28, 80, 163, 0.2);
  background: rgba(28, 80, 163, 0.05);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.panel-plain {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.panel-dashed {
  border: 1px dashed rgba(28, 80, 163, 0.3);
  background: rgba(28, 80, 163, 0.05);
  border-radius: var(--radius-md);
  padding: 8px;
}

.panel-dashed-blue { border: 1px dashed rgba(96, 165, 250, 0.6); background: rgba(239, 246, 255, 0.7); border-radius: var(--radius-md); padding: 8px; }
.panel-dashed-green { border: 1px dashed rgba(74, 222, 128, 0.6); background: rgba(240, 253, 244, 0.7); border-radius: var(--radius-md); padding: 8px; }
.panel-dashed-violet { border: 1px dashed rgba(167, 139, 250, 0.6); background: rgba(245, 243, 255, 0.7); border-radius: var(--radius-md); padding: 8px; }
.panel-dashed-amber { border: 1px dashed rgba(251, 191, 36, 0.5); background: rgba(255, 251, 235, 0.6); border-radius: var(--radius-md); padding: 8px; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}

/* ── Píldoras ─────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-lg);
  background: var(--muted);
  padding: 5px 11px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.pill strong { color: var(--foreground); font-weight: 600; font-size: 13px; }

.time-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-lg);
  background: var(--muted);
  padding: 7px 12px;
  transition: background 0.15s;
}

.time-pill:hover { background: #dfe4ec; }

.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: 0 -4px;
  transition: background 0.15s;
}

.inline-edit:hover { background: rgba(233, 237, 243, 0.75); }
.inline-edit .pencil { opacity: 0; transition: opacity 0.15s; color: var(--muted-foreground); }
.inline-edit:hover .pencil { opacity: 1; }

.placeholder-text { color: var(--muted-foreground); font-style: italic; }

/* ── Tablas de datos ──────────────────────────────────────── */
.data-table { width: 100%; font-size: 13px; }

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  text-align: left;
  font-weight: 500;
  color: var(--muted-foreground);
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.data-table tbody tr { border-bottom: 1px solid rgba(213, 218, 226, 0.55); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td { padding: 7px 4px; }
.data-table tbody tr .row-actions { opacity: 0; transition: opacity 0.15s; }
.data-table tbody tr:hover .row-actions { opacity: 1; }
.data-table tbody tr:hover { background: rgba(233, 237, 243, 0.4); }

.scroll-box { max-height: 300px; overflow: auto; }
.scroll-box-lg { max-height: 400px; overflow: auto; }

.border-l-4 { border-left: 4px solid transparent; }
.bl-blue-500 { border-left-color: #3b82f6; }
.bl-indigo-500 { border-left-color: #6366f1; }
.bl-cyan-500 { border-left-color: #06b6d4; }
.bl-lime-500 { border-left-color: #84cc16; }
.bl-amber-500 { border-left-color: #f59e0b; }
.bl-sky-400 { border-left-color: #38bdf8; }
.bl-orange-400 { border-left-color: #fb923c; }
.bl-green-500 { border-left-color: #22c55e; }
.bl-violet-500 { border-left-color: #8b5cf6; }
.bl-teal-500 { border-left-color: #14b8a6; }
.bl-pink-400 { border-left-color: #f472b6; }
.bl-gray-400 { border-left-color: #9ca3af; }
.bl-yellow-500 { border-left-color: #eab308; }
.bl-red-500 { border-left-color: #ef4444; }

/* ── Líquidos ─────────────────────────────────────────────── */
.fluid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: var(--radius-lg);
  border-left: 4px solid transparent;
  background: rgba(233, 237, 243, 0.5);
  padding: 8px 12px;
}

.chip {
  border-radius: var(--radius-sm);
  border: 1px solid;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
}

.chip-blue { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.chip-yellow { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.chip-red { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.chip-gray { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }

/* ── Línea de tiempo ──────────────────────────────────────── */
.timeline { position: relative; }

.timeline-rail {
  position: absolute;
  left: 52px;
  top: 0;
  height: 100%;
  width: 1px;
  background: var(--border);
}

.timeline-item { position: relative; display: flex; gap: 16px; }
.timeline-time { width: 48px; flex-shrink: 0; font-size: 13px; font-weight: 500; color: var(--muted-foreground); }

.timeline-dot {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  height: 10px;
  width: 10px;
  flex-shrink: 0;
  border-radius: 999px;
  box-shadow: 0 0 0 4px var(--card);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  padding: 1px 6px;
  font-size: 11px;
}

.tag-red { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.tag-yellow { background: #fefce8; border-color: #fde68a; color: #a16207; }

.badge-cat-hemorragia { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.badge-cat-broncoespasmo { background: #fef9c3; color: #a16207; border-color: #fde047; }
.badge-cat-anafilaxia { background: #ffedd5; color: #c2410c; border-color: #fdba74; }
.badge-cat-paro_cardiaco { background: #fee2e2; color: #991b1b; border-color: #f87171; font-weight: 700; }
.badge-cat-inicio_rcp { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.badge-cat-complicacion_otro { background: #ffedd5; color: #ea580c; border-color: #fed7aa; }

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
}

/* ── Firma ────────────────────────────────────────────────── */
.signature-box {
  position: relative;
  border: 2px dashed var(--border);
  background: rgba(233, 237, 243, 0.35);
  border-radius: var(--radius-lg);
}

.signature-box.signed {
  border-color: var(--success);
  background: rgba(14, 138, 99, 0.06);
}

.signature-box canvas { width: 100%; height: 120px; touch-action: none; cursor: crosshair; }
.signature-box.signed canvas { cursor: not-allowed; }

.signature-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted-foreground);
  pointer-events: none;
}

.upload-drop {
  display: flex;
  height: 120px;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--border);
  background: rgba(233, 237, 243, 0.35);
  border-radius: var(--radius-lg);
  color: var(--muted-foreground);
  transition: border-color 0.15s, background 0.15s;
}

.upload-drop:hover { border-color: var(--primary); }

.upload-preview {
  display: flex;
  height: 120px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px dashed var(--border);
  background: rgba(233, 237, 243, 0.35);
  border-radius: var(--radius-lg);
}

.upload-preview img { max-height: 100%; max-width: 100%; object-fit: contain; padding: 8px; }

/* ── Selector de categorías de anestesia ──────────────────── */
.cat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-lg);
  border: 2px solid;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.cat-general { border-color: #bfdbfe; color: #1d4ed8; background: transparent; }
.cat-general:hover { background: #eff6ff; }
.cat-general.on { background: #2563eb; color: #fff; border-color: #2563eb; }
.cat-regional { border-color: #bbf7d0; color: #15803d; background: transparent; }
.cat-regional:hover { background: #f0fdf4; }
.cat-regional.on { background: #16a34a; color: #fff; border-color: #16a34a; }
.cat-sedacion { border-color: #ddd6fe; color: #6d28d9; background: transparent; }
.cat-sedacion:hover { background: #f5f3ff; }
.cat-sedacion.on { background: #7c3aed; color: #fff; border-color: #7c3aed; }

/* ── Resumen de anestesia ─────────────────────────────────── */
.summary-box { border-radius: var(--radius-md); border: 1px solid; padding: 10px; }
.summary-blue { border-color: #bfdbfe; background: #eff6ff; }
.summary-green { border-color: #bbf7d0; background: #f0fdf4; }
.summary-violet { border-color: #ddd6fe; background: #f5f3ff; }

.summary-blue .s-title { color: #1d4ed8; }
.summary-green .s-title { color: #15803d; }
.summary-violet .s-title { color: #6d28d9; }
.summary-blue .s-line { color: #1e40af; }
.summary-green .s-line { color: #166534; }
.summary-violet .s-line { color: #5b21b6; }

.s-title { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 12px; font-weight: 600; }
.s-line { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: 12px; }
.s-tag { border-radius: var(--radius-sm); padding: 1px 6px; font-weight: 500; }
.summary-blue .s-tag { background: #dbeafe; }
.summary-green .s-tag { background: #dcfce7; }
.summary-violet .s-tag { background: #ede9fe; }

.mini-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
}

.mini-add-green { color: #15803d; background: #dcfce7; }
.mini-add-green:hover { background: #bbf7d0; }
.mini-add-violet { color: #6d28d9; background: #ede9fe; }
.mini-add-violet:hover { background: #ddd6fe; }

.dose-grid { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px; align-items: end; }

/* ── Gráficos ─────────────────────────────────────────────── */
.chart-wrapper { position: relative; width: 100%; }
.chart-wrapper svg { width: 100%; height: auto; display: block; }

.chart-grid-line { stroke: var(--border); stroke-dasharray: 3 3; stroke-width: 1; }
.chart-axis-text { fill: var(--muted-foreground); font-size: 10px; }
.chart-axis-title { fill: #64748b; font-size: 9px; }
.chart-event-line { stroke: #f59e0b; stroke-dasharray: 4 3; stroke-width: 1.5; }
.chart-event-label { fill: #f59e0b; font-size: 9px; font-weight: 600; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  padding-top: 8px;
  font-size: 11px;
  color: var(--foreground);
}

.chart-legend .item { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .swatch { width: 14px; height: 3px; border-radius: 2px; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  padding: 6px 9px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.14);
  z-index: 5;
  white-space: nowrap;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.axis-legend { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 8px; padding: 0 4px; font-size: 10px; color: var(--muted-foreground); }
.axis-legend .line { display: inline-block; width: 24px; height: 2px; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--foreground);
  color: var(--background);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  font-size: 13px;
  z-index: 80;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.25);
}

/* ── Navegación principal ─────────────────────────────────── */
.main-nav {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.main-nav-item {
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

/* Pestañas que el administrador no habilitó para este usuario.
   La regla es explícita porque .main-nav es flex y ganaría al
   display:none del atributo hidden. */
.main-nav[hidden],
.main-nav-item[hidden] { display: none; }

.main-nav-item:hover { color: var(--foreground); }

.main-nav-item[data-active="true"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.view-panel { display: none; }
.view-panel[data-active="true"] { display: block; }

/* ── Menú de usuario ──────────────────────────────────────── */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  background: var(--card);
  transition: background 0.15s;
}

.user-chip:hover { background: var(--muted); }

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.user-name { font-size: 13px; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Estado de conexión ───────────────────────────────────── */
.conn-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  border: 1px solid;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

.conn-offline {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

.conn-offline:hover { background: #e2e8f0; }

.conn-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #a16207;
}

.conn-warn:hover { background: #fef3c7; }

/* ── Diálogo de guardado ──────────────────────────────────── */
.export-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.export-option:hover { border-color: var(--primary); }

.export-option.on {
  border-color: var(--primary);
  background: rgba(28, 80, 163, 0.05);
}

.export-option.off {
  opacity: 0.55;
  cursor: not-allowed;
}

.export-option.off:hover { border-color: var(--border); }

.export-option input { margin-top: 2px; flex-shrink: 0; }

.export-option-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

/* ── Pantalla de acceso ───────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(28, 80, 163, 0.12), transparent 60%),
    var(--background);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 44px rgba(16, 24, 40, 0.12);
  padding: 26px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.login-brand img {
  height: 58px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-error {
  border-radius: var(--radius-md);
  background: rgba(207, 53, 39, 0.08);
  border: 1px solid rgba(207, 53, 39, 0.25);
  color: var(--destructive);
  font-size: 12px;
  padding: 7px 10px;
}

.form-ok {
  border-radius: var(--radius-md);
  background: rgba(14, 138, 99, 0.08);
  border: 1px solid rgba(14, 138, 99, 0.25);
  color: var(--success);
  font-size: 12px;
  padding: 7px 10px;
}

.login-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted-foreground);
}

.login-note svg { display: inline; vertical-align: -2px; margin-right: 2px; }

/* ── Acceso: roles y permisos ─────────────────────────────── */

/* Aviso dentro de una tarjeta (por ejemplo, el orden de los tiempos) */
.alert-warn {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  line-height: 1.45;
  background: rgba(180, 120, 10, 0.08);
  border: 1px solid rgba(180, 120, 10, 0.25);
  color: var(--warning);
}

.alert-warn svg { flex-shrink: 0; margin-top: 2px; }

/* Ficha de usuario en la administración */
.user-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--muted);
}

.user-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.role-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  white-space: nowrap;
}

.role-badge.is-admin {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--primary);
}

/* Casillas de pestañas habilitadas */
.perm-tabs {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.perm-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  cursor: pointer;
}

/* ── Tiempos, constancias y post anestesia ────────────────── */

/* Los seis tiempos del acto, en columnas que se acomodan solas */
.time-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

/* Tablas anchas: se desplazan solas sin arrastrar la página */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.recovery-table { min-width: 900px; }

.recovery-table th { white-space: nowrap; }

.recovery-table .th-unit {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted-foreground);
}

.recovery-table td { padding: 4px 3px; }
.recovery-table .input { min-width: 62px; }

/* Escalas por ítems (Aldrete, Steward) */
.score-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--muted);
}

.score-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.score-total {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  white-space: nowrap;
}

.score-total.is-ok {
  background: rgba(14, 138, 99, 0.1);
  border-color: rgba(14, 138, 99, 0.3);
  color: var(--success);
}

.score-total.is-warn {
  background: rgba(180, 120, 10, 0.1);
  border-color: rgba(180, 120, 10, 0.3);
  color: var(--warning);
}

.score-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.score-label { font-size: 12.5px; color: var(--muted-foreground); }

@media (max-width: 520px) {
  .score-row { grid-template-columns: 1fr; gap: 3px; }
  .score-label { font-size: 12px; }
}

/* Título del registro, dentro de la pestaña (antes iba en el encabezado) */
.record-title {
  margin-bottom: 14px;
}

.record-title h1 { line-height: 1.25; }
.record-title p { margin-top: 1px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .main-nav { padding: 0 12px; }
  .user-name { display: none; }
  .login-card { padding: 20px; }
  .app-main { padding: 12px; }
  .app-header-inner { padding: 12px; }
  .brand-logo { height: 64px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dose-grid { grid-template-columns: 1fr 1fr auto; }
}
