/* RedactorApp - Premium Elegant Medical Theme */
/* Based on globals.css design system */

/* ============================================
   CSS VARIABLES - Design System
   ============================================ */
:root {
  /* Primary Colors - Deep Blue */
  --color-primary: #1B277A;
  --color-primary-hover: #141d5e;
  --color-primary-light: #e8eaf4;
  --color-primary-fg: #ffffff;

  /* Secondary Colors - Red */
  --color-secondary: #B9131E;
  --color-secondary-hover: #8f0f18;
  --color-secondary-light: #fce8e9;
  --color-secondary-fg: #ffffff;

  /* Accent Colors */
  --color-accent-purple: #8C05DB;
  --color-accent-green: #01FF79;

  /* Neutral Colors */
  --color-bg: linear-gradient(135deg, #e8eaf4 0%, #f0f1f8 100%);
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-text: #1a202c;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;

  /* Status */
  --color-success: #059669;
  --color-success-light: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;
  --color-error: #dc2626;
  --color-error-light: #fef2f2;
  --color-info: #0891b2;
  --color-info-light: #ecfeff;

  /* Typography */
  --font-heading: "DM Sans", sans-serif;
  --font-body: "Roboto", sans-serif;
  --font-accent: "Inter", sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(27, 39, 122, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  /* Radii — diseño de esquinas rectas en toda la app (pedido 2026-07-16) */
  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --radius-full: 0;

  /* Sombras del refresh */
  --shadow-card: 0 1px 3px rgba(27, 39, 122, 0.06), 0 4px 14px rgba(27, 39, 122, 0.04);
  --shadow-card-hover: 0 2px 6px rgba(27, 39, 122, 0.08), 0 8px 24px rgba(27, 39, 122, 0.07);
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--color-bg) !important;
  color: var(--color-text);
  font-size: 0.9375rem;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

/* ============================================
   NAVBAR
   ============================================ */











/* ============================================
   ALERTS / MESSAGES
   ============================================ */
.alert {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 400;
  border-left: 4px solid;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.alert-success {
  border-color: var(--color-success);
  background: var(--color-success-light);
  color: #065f46;
}

.alert-error {
  border-color: var(--color-error);
  background: var(--color-error-light);
  color: #991b1b;
}

.alert-warning {
  border-color: var(--color-warning);
  background: var(--color-warning-light);
  color: #92400e;
}

.alert-info {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ============================================
   AUTH CARDS (login, register, reset)
   ============================================ */
.auth-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}


.auth-subtitle {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  padding: 2.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}











/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
  letter-spacing: 0.01em;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 39, 122, 0.1);
}

.form-input::placeholder {
  color: #94a3b8;
}

.form-select {
  display: block;
  width: 100%;
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  transition: all var(--transition-fast);
}

.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 39, 122, 0.1);
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-error);
  margin-top: 0.25rem;
}

.form-checkbox {
  accent-color: var(--color-primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-accent);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  outline: none;
  letter-spacing: 0.015em;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Button - Deep Blue with gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #3040b0);
  color: var(--color-primary-fg) !important;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(27, 39, 122, 0.22);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left var(--transition-slow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-primary-hover), var(--color-primary));
  box-shadow: 0 2px 8px rgba(27, 39, 122, 0.22);
}

.btn-primary:hover:not(:disabled)::before {
  left: 100%;
}

/* Secondary/Outline Button */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-secondary) !important;
  border: 1px solid var(--color-secondary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary);
  color: var(--color-primary-fg) !important;
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Danger Button */
.btn-danger {
  background: var(--color-secondary-light);
  color: var(--color-secondary) !important;
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-secondary);
  color: var(--color-secondary-fg) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted) !important;
  border: 1px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-primary-light);
  color: var(--color-primary) !important;
  border-color: var(--color-primary);
}

.btn-ghost.btn-active {
  background: var(--color-primary-light);
  color: var(--color-primary) !important;
  border-color: var(--color-primary);
}

/* Record Button */
.btn-record {
  background: var(--color-secondary);
  color: white !important;
  box-shadow: 0 4px 15px rgba(185, 19, 30, 0.3);
}

.btn-record:hover:not(:disabled) {
  background: var(--color-secondary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(185, 19, 30, 0.4);
}

/* Stop Button */
.btn-stop {
  background: #374151;
  color: white !important;
}

.btn-stop:hover:not(:disabled) {
  background: #1f2937;
}

/* QR Button - Purple accent */
.btn-qr {
  background: linear-gradient(135deg, rgba(140, 5, 219, 0.1) 0%, rgba(27, 39, 122, 0.1) 100%);
  color: var(--color-accent-purple) !important;
  border: 1px solid rgba(140, 5, 219, 0.2);
}

.btn-qr:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-accent-purple) 0%, var(--color-primary) 100%);
  color: white !important;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(140, 5, 219, 0.3);
}

/* Upload Button */
.btn-upload {
  background: var(--color-surface-alt);
  color: var(--color-text) !important;
  border: 1px solid var(--color-border);
  cursor: pointer;
}

.btn-upload:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary) !important;
}

/* Small action buttons (copy, clear) */
.btn-action {
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  font-weight: 500;
}

/* Full-width button */
.btn-block {
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ============================================
   WORKSPACE - AUDIO CONTROLS PANEL
   ============================================ */
.audio-panel {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  /* backdrop-filter crea un stacking context que atrapa dropdowns (ej. picker "Subir PDF");
     elevamos el panel para que su dropdown se pinte por encima de las cards siguientes */
  position: relative;
  z-index: 5;
}

/* ============================================
   MODE SELECTOR
   ============================================ */
.mode-selector {
  display: flex;
  background: var(--color-primary-light);
  padding: 3px;
}

.mode-btn {
  padding: 0.4rem 1rem;
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.mode-btn:not(.active):hover {
  color: var(--color-primary);
}

/* ============================================
   SECTION CARDS (medical-card style)
   ============================================ */
.section-card {
  background: var(--color-surface);
  border: 1px solid #eaeef7;
  /* Acento izquierdo: los paneles especiales lo recolorean con
     border-left-color inline (aclaracion, especialista, etc.). */
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-normal);
  padding: 1.25rem;
  margin-bottom: 1rem;
  position: relative;
}

.section-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
}

.section-content {
  min-height: 60px;
  padding: 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text);
  white-space: pre-wrap;
  line-height: 1.6;
}

textarea.section-editable {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  outline: none;
  overflow: hidden;
  border-radius: 0 0 0.5rem 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea.section-editable:focus {
  border-color: var(--color-primary, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

textarea.section-editable::placeholder {
  color: var(--color-text-muted, #9ca3af);
  font-style: italic;
}

.section-content[contenteditable="true"] {
  border-radius: 0 0 0.5rem 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.section-content[contenteditable="true"]:focus {
  border-color: var(--color-primary, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.section-content[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted, #9ca3af);
  font-style: italic;
  pointer-events: none;
}

.section-footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* ============================================
   PROCESSING INDICATORS
   ============================================ */
.processing-bar {
  background: var(--color-surface);
  border: 1px solid #c7d2fe;
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0.5rem;
  z-index: 40;
}

.processing-bar .spinner {
  border-color: rgba(27, 39, 122, 0.2);
  border-top-color: var(--color-primary);
}

.processing-bar .text {
  font-family: var(--font-accent);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-primary);
}

.processing-body { flex: 1; min-width: 0; }

.processing-progress {
  height: 5px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.45rem;
}

.processing-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #4f46e5);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.processing-step-label {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
}

.error-bar {
  background: var(--color-error-light);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-left: 4px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.error-bar .text {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: #991b1b;
  flex: 1;
}

.error-dismiss {
  background: none;
  border: none;
  color: #991b1b;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

/* ============================================
   SPINNER
   ============================================ */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(27, 39, 122, 0.2);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
}

/* ============================================
   QR MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-xl);
  padding: 2rem;
  max-width: 24rem;
  width: 100%;
  margin: 1rem;
  animation: fadeInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-text);
}

/* ============================================
   BMI WIDGET
   ============================================ */
.bmi-input {
  width: 5.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  transition: all var(--transition-fast);
}

.bmi-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(27, 39, 122, 0.08);
  outline: none;
}

.bmi-result {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* ============================================
   STANDARD PARAGRAPHS
   ============================================ */
.paragraph-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.paragraph-label:hover {
  color: var(--color-primary);
}

/* ============================================
   BOTTOM ACTIONS
   ============================================ */
.bottom-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.75rem;
}

/* ============================================
   LINK STYLES
   ============================================ */
.link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ============================================
   RECORDING INDICATOR
   ============================================ */
.recording-dot {
  width: 0.75rem;
  height: 0.75rem;
  background: white;
  display: inline-block;
}

.recording-pulse {
  color: var(--color-secondary);
  font-family: var(--font-accent);
  font-size: 0.875rem;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   MOBILE CAPTURE PAGE
   ============================================ */
.mobile-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: white;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(27, 39, 122, 0.3);
}

.mobile-header h1 {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
}

.mobile-header .timer {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

.record-circle {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  background: var(--color-secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(185, 19, 30, 0.4);
  transition: all var(--transition-normal);
}

.record-circle:hover {
  background: var(--color-secondary-hover);
  transform: scale(1.05);
  box-shadow: 0 8px 30px rgba(185, 19, 30, 0.5);
}

.animate-pulse-red {
  animation: pulseRed 1.5s infinite;
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 19, 30, 0.4); }
  50% { box-shadow: 0 0 0 14px rgba(185, 19, 30, 0); }
}

/* ============================================
   EXPIRED PAGE
   ============================================ */
.expired-container {
  text-align: center;
  padding: 2rem;
}

.expired-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.expired-title {
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.expired-text {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ============================================
   ANIMATIONS
   ============================================ */
.animate-fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

.section-content-arrived {
  animation: contentArrive 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes contentArrive {
  from { opacity: 0.3; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Seccion en proceso de generacion IA */
.section-loading {
  position: relative;
  pointer-events: none;
}
.section-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg,
    rgba(226, 232, 240, 0.0) 25%,
    rgba(199, 210, 254, 0.35) 50%,
    rgba(226, 232, 240, 0.0) 75%);
  background-size: 400px 100%;
  animation: skeleton-shimmer 1.4s infinite linear;
}
@keyframes skeleton-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .section-loading::after { animation: none; }
}

/* ============================================
   PAGE WRAPPER
   ============================================ */
.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   WORKSPACE HEADER
   ============================================ */
.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.workspace-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

/* ============================================
   DIVIDER
   ============================================ */
.divider {
  color: var(--color-border-strong);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(27, 39, 122, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(27, 39, 122, 0.3);
}

/* ============================================
   SELECTION
   ============================================ */
::selection {
  background: rgba(27, 39, 122, 0.15);
  color: var(--color-primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .workspace-header {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-actions {
    flex-direction: column;
  }

  .bottom-actions .btn {
    width: 100%;
  }

  
  .auth-card {
    padding: 1.75rem;
  }
}

@media (max-width: 480px) {
  .page-content {
    padding: 1rem 0.75rem;
  }

  .audio-panel {
    padding: 1rem;
  }

  .section-card {
    padding: 1rem;
  }
}

/* ============================================
   TAILWIND UTILITY REPLACEMENTS
   ============================================ */

/* Display */
.hidden { display: none !important; }
.flex { display: flex; }

/* Flex Direction & Wrap */
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }

/* Alignment */
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Gap */
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* Margin */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-auto { margin-top: auto; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* Sizing */
.w-full { width: 100%; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.min-h-screen { min-height: 100vh; }
.max-w-5xl { max-width: 64rem; }

/* Typography */
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.whitespace-pre-wrap { white-space: pre-wrap; }

/* Colors */
.text-white { color: #ffffff; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }

/* Borders */
.border { border: 1px solid #e5e7eb; }
.border-t { border-top: 1px solid #e5e7eb; }
.border-gray-200 { border-color: #e5e7eb; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-md { border-radius: 0.375rem; }

/* Spacing between children */
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* ============================================
   PANEL ADMIN
   ============================================ */

/* Navbar admin button */


/* Panel header with breadcrumbs */
.panel-header {
  margin-bottom: 1.5rem;
}

.panel-breadcrumb {
  font-family: var(--font-accent);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Stats grid */
.panel-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Consumo por Usuario: controles en linea y separacion del grafico */
.consumption-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.consumption-toggle {
  display: inline-flex;
  gap: 0.25rem;
}

#consumption-user {
  max-width: 22rem;
}

.consumption-summary {
  margin-bottom: 1rem;
}

/* Dashboard: cards en 2 columnas en desktop, 1 en movil */
.panel-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

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

  .panel-grid-span-2 {
    grid-column: span 2;
  }
}

/* Charts (Chart.js necesita un wrapper con altura fija para responsive) */
.chart-container {
  position: relative;
  height: 260px;
}

.chart-container--tall {
  height: 300px;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 120px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.panel-stat-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}

.panel-stat-label {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.panel-stat-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* Tables */
.panel-table-wrapper {
  overflow-x: auto;
}

.panel-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.panel-table th {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  background: var(--color-surface-alt);
}

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

.panel-table tbody tr:hover {
  background: var(--color-primary-light);
}

.panel-table-total td {
  background: var(--color-surface-alt);
  border-top: 2px solid var(--color-border-strong);
  font-weight: 600;
}

/* Badges */
.badge {
  display: inline-block;
  font-family: var(--font-accent);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-danger {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge-info {
  background: var(--color-info-light);
  color: var(--color-info);
  border: 1px solid rgba(8, 145, 178, 0.2);
}

.badge-purple {
  background: rgba(140, 5, 219, 0.08);
  color: var(--color-accent-purple);
  border: 1px solid rgba(140, 5, 219, 0.2);
}

.badge-neutral {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* Status Chip */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  padding: 0.15rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-accent);
}

/* Info grid (user detail) */
.panel-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.panel-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.panel-info-label {
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-info-value {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--color-text);
}

/* ============================================
   CUPS SELECTOR (Descripciones Quirurgicas)
   ============================================ */

.cups-dropdown {
  position: relative;
  background: var(--panel2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.cups-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

.cups-item:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
}

.cups-item.cups-selected {
  background: var(--color-primary-light);
  opacity: 0.6;
  pointer-events: none;
}

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

.cups-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover, #141e66) 100%);
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-body);
  line-height: 1.3;
}

.cups-chip strong {
  font-weight: 700;
}

.cups-chip-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  transition: color 0.15s;
}

.cups-chip-remove:hover {
  color: #fff;
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  body {
    background: white !important;
  }

  .audio-panel, .bottom-actions, .btn-action {
    display: none !important;
  }

  .section-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* ============================================
   DATOS PREVIOS (cards estilo seccion)
   ============================================ */
.previous-card .section-title .badge {
  color: var(--color-text-muted);
  margin-left: 0.4rem;
  font-weight: 400;
  font-size: 0.85em;
}

.previous-items-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  min-height: 60px;
  box-sizing: border-box;
}

/* Empty states de paneles de datos previos */
.empty-state {
  display: none;
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--color-text-muted);
}
.empty-state.visible { display: block; }
.empty-state-icon { font-size: 1.75rem; opacity: 0.5; }
.empty-state-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.4rem 0 0.2rem;
  color: var(--color-text);
}
.empty-state-hint { font-size: 0.8rem; margin: 0; }

/* Help tip (?) icon + tooltip on hover/focus */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #6b7280;
  color: white;
  font-size: 10px;
  font-weight: bold;
  margin-left: 6px;
  cursor: help;
  user-select: none;
  position: relative;
  vertical-align: middle;
}
.help-tip:focus { outline: 2px solid var(--color-primary, #3b82f6); }
.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: normal;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  width: 240px;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.help-tip:hover::after,
.help-tip:focus::after {
  opacity: 1;
  visibility: visible;
}

.previous-item-card {
  padding: 8px;
  margin-bottom: 6px;
  background: var(--panel2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.previous-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.previous-item-fecha {
  font-weight: 600;
  font-size: 12px;
}

.previous-item-titulo {
  flex-grow: 1;
  color: var(--color-text-muted, #6b7280);
}

.previous-item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
}

.previous-item-actions button:hover {
  opacity: 1;
}

.previous-toggle {
  cursor: pointer;
  user-select: none;
}

.previous-caret {
  display: inline-block;
  font-size: 0.85em;
  margin-right: 0.25rem;
  transition: transform 0.15s ease;
}

.previous-card.previous-open .previous-caret {
  transform: rotate(90deg);
}

.previous-item-to-resultados {
  color: var(--color-secondary, #2563eb);
  font-size: 12px;
  white-space: nowrap;
}

.previous-item-to-resultados:disabled {
  color: var(--color-success, #10b981);
  cursor: default;
}

/* Touch targets: minimo 44px en dispositivos tactiles (WCAG 2.5.5) */
.btn-action,
.previous-item-delete,
.previous-item-to-resultados,
.error-dismiss {
  min-height: 44px;
  min-width: 44px;
}
@media (pointer: fine) {
  /* En desktop con mouse mantener compactos */
  .btn-action, .previous-item-delete, .previous-item-to-resultados, .error-dismiss {
    min-height: 32px;
    min-width: auto;
  }
}

.previous-item-body {
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text, #374151);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  color: white;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  font-family: var(--font-accent);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toast-slide-in 0.2s ease-out;
}

.toast-success {
  background: var(--color-success);
}

.toast-error {
  background: var(--color-error);
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Banners de estado de suscripcion (base.html) */
.banner-info {
  background: var(--color-info-light);
  color: #075985;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  text-align: center;
}
.banner-warning {
  background: var(--color-warning-light);
  color: #92400e;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  text-align: center;
}
.banner-info a, .banner-warning a {
  text-decoration: underline;
  color: inherit;
}

/* Barra de reintento de uploads pendientes (audio_recorder.js) */
.retry-bar {
  background: var(--color-warning-light);
  border-color: rgba(217, 119, 6, 0.25);
  border-left-color: var(--color-warning);
}
.retry-bar .text { color: #92400e; }

/* Hint de primer uso */
.first-use-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-info-light);
  border: 1px solid rgba(8, 145, 178, 0.2);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--color-text);
}

/* ============================================
   ESQUINAS RECTAS GLOBALES (pedido 2026-07-16)
   Anula todo border-radius, incluidos estilos inline
   de templates y elementos creados por JS.
   Única excepción: el spinner debe seguir siendo
   circular para leerse como indicador giratorio.
   ============================================ */
* {
  border-radius: 0 !important;
}
.spinner {
  border-radius: 50% !important;
}

/* ============================================
   ZONA DE PEGADO DEL DOCUMENTO DEL PACIENTE
   ============================================ */
/* La zona necesita el foco para recibir Ctrl+V, asi que tiene que verse cuando
   lo tiene: sin senal visible, el medico clickea, pega y no sabe si fallo el
   pegado o si nunca tuvo el foco. */
#paste-zone:focus,
#paste-zone:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-color: var(--color-primary);
}
