/* ============================================================
   Clinímetrica · Estilos v2.0 — Moderno y accesible
============================================================ */

/* ---------- Variables y temas ---------- */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.10);
  --shadow-primary: 0 8px 24px rgba(30, 58, 77, 0.18);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);

  /* Light theme */
  --bg: #f4f6fb;
  --bg-gradient: linear-gradient(135deg, #eef2f9 0%, #f8f5ff 100%);
  --surface: #ffffff;
  --surface-hover: #f7f9fc;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --ink: #0f172a;
  --ink-secondary: #64748b;
  --ink-tertiary: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #1e3a5f;
  --primary-light: #2d5580;
  --primary-bg: #e8f0f8;
  --primary-gradient: linear-gradient(135deg, #1e3a5f 0%, #2d5580 100%);
  --accent: #a9927d;
  --warn: #c53030;
  --warn-bg: #fef2f2;
  --warn-border: #fecaca;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --libre: #047857;
  --restringida: #c53030;
  --focus: 0 0 0 3px rgba(30, 58, 95, 0.22);
  --glow: radial-gradient(circle at 50% 0%, rgba(30, 58, 95, 0.12), transparent 60%);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg-gradient: linear-gradient(135deg, #0b1220 0%, #111a2e 100%);
  --surface: #151d2e;
  --surface-hover: #1c2640;
  --surface-glass: rgba(21, 29, 46, 0.72);
  --ink: #e6edf7;
  --ink-secondary: #94a3b8;
  --ink-tertiary: #64748b;
  --border: #1f2a44;
  --border-strong: #2a3a5c;
  --primary: #7ab0e0;
  --primary-light: #9ac5ec;
  --primary-bg: #17243a;
  --primary-gradient: linear-gradient(135deg, #4a7fb8 0%, #7ab0e0 100%);
  --warn: #f87171;
  --warn-bg: #3a1a1a;
  --warn-border: #7f1d1d;
  --ok: #34d399;
  --ok-bg: #0f2e22;
  --ok-border: #065f46;
  --focus: 0 0 0 3px rgba(122, 176, 224, 0.32);
  --glow: radial-gradient(circle at 50% 0%, rgba(122, 176, 224, 0.15), transparent 60%);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  font-size: 1rem;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 5rem;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -1000px;
  left: 10px;
  background: var(--primary);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 8px;
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  font-family: inherit;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn:hover::after { opacity: 0.06; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.btn.primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-primary);
}
.btn.primary:hover { box-shadow: 0 10px 28px rgba(30, 58, 95, 0.25); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(1px); }

.btn.secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border-strong);
}
.btn.secondary:hover { background: var(--surface-hover); border-color: var(--primary); }

.btn.warn {
  background: var(--warn);
  color: white;
}
.btn.warn:hover { filter: brightness(1.1); }

.btn.small { padding: 0.45rem 0.85rem; font-size: 0.78rem; }

/* ---------- Header ---------- */
header {
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--ink);
  padding: 0.9rem 1.2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
  letter-spacing: -0.01em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
header .back {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
header .back svg { width: 18px; height: 18px; }
header .back:hover { background: var(--surface-hover); transform: translateX(-2px); }
header .back:focus-visible { outline: none; box-shadow: var(--focus); }

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle:hover { background: var(--surface-hover); transform: rotate(15deg); }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Main ---------- */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
}

/* ---------- Hero ---------- */
.hero {
  margin-bottom: 2rem;
  text-align: left;
}
.hero.oculto { display: none; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.3rem 0.8rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}
.hero-title {
  font-size: 1.8rem;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--ink);
}
.hero-sub {
  color: var(--ink-secondary);
  font-size: 0.95rem;
}

/* ---------- Filtros ---------- */
.filtros {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--ink-tertiary);
  pointer-events: none;
}
.filtros input[type="text"] {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.filtros input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
  outline: none;
}

/* ---------- Cuadrícula de categorías ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}
.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: all var(--transition);
  font-family: inherit;
}
.cat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}
.cat-card:active { transform: translateY(0) scale(0.98); }
.cat-card:focus-visible { outline: none; box-shadow: var(--focus); }
.cat-emoji { font-size: 1.5rem; line-height: 1; }
.cat-nombre { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.cat-n { font-size: 0.78rem; color: var(--ink-secondary); }

.volver-categorias {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 99px;
  padding: 0.45rem 1rem 0.45rem 0.75rem;
  cursor: pointer;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  font-family: inherit;
}
.volver-categorias:hover { background: var(--surface-hover); transform: translateX(-2px); }
.volver-categorias:focus-visible { outline: none; box-shadow: var(--focus); }
.volver-categorias svg { width: 14px; height: 14px; }

/* ---------- Categorías y tarjetas ---------- */
.categoria-grupo { margin-bottom: 2rem; }
.categoria-grupo h2 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}
.cat-count {
  font-size: 0.75rem;
  background: var(--border);
  color: var(--ink-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  margin-left: 0.25rem;
}

.escala-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.escala-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}
.escala-card:focus-visible { outline: none; box-shadow: var(--focus); }
.card-body { flex: 1; }
.card-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.3rem; color: var(--ink); }
.card-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.meta-chip {
  font-size: 0.75rem;
  color: var(--ink-secondary);
  background: var(--bg);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}
.meta-chip.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.card-arrow {
  width: 20px;
  height: 20px;
  color: var(--ink-tertiary);
  transition: transform var(--transition);
}
.escala-card:hover .card-arrow { transform: translateX(3px); color: var(--primary); }

.tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
  font-weight: 700;
  white-space: nowrap;
}
.tag.dominio_publico, .tag.libre_con_citacion, .tag.libre_con_registro {
  background: var(--ok-bg);
  color: var(--ok);
}
.tag.restringida {
  background: var(--warn-bg);
  color: var(--warn);
}
.tag.personalizada {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ---------- Formulario y progreso ---------- */
.item-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.item-block:focus-within {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
}
.item-text {
  display: flex;
  gap: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  font-size: 1.05rem;
  line-height: 1.4;
}
.item-number {
  background: var(--primary-bg);
  color: var(--primary);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.opciones {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.opcion-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.opcion-label:hover { background: var(--surface-hover); }
.opcion-label input[type="radio"] { display: none; }
.opcion-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: inline-block;
  flex-shrink: 0;
  position: relative;
  transition: all var(--transition-fast);
}
.opcion-label input[type="radio"]:checked + .opcion-radio {
  border-color: var(--primary);
  background: var(--primary);
}
.opcion-label input[type="radio"]:checked + .opcion-radio::after {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.opcion-label:has(input:checked) {
  background: var(--primary-bg);
  border-color: var(--border);
}

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.progress-ring-wrap {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.progress-ring { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 4; }
.ring-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s;
}
.ring-text {
  position: absolute;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}
.progress-info { flex: 1; }
.progress-label { font-size: 0.85rem; font-weight: 700; color: var(--ink-secondary); margin-bottom: 0.3rem; }
.barra-progreso {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.barra-progreso > div {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 99px;
  transition: width 0.35s ease;
}

/* ---------- Resultado ---------- */
.resultado-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.resultado-glow {
  position: absolute;
  inset: 0;
  background: var(--glow);
  pointer-events: none;
}
.resultado-card .puntaje {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -0.04em;
}
.resultado-card .etiqueta {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
}

.subescalas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.subescala-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.subescala-nombre { font-size: 0.8rem; font-weight: 700; color: var(--ink-secondary); text-transform: uppercase; }
.subescala-puntaje { font-size: 1.8rem; font-weight: 800; color: var(--primary); margin: 0.2rem 0; }
.subescala-rango { font-size: 0.75rem; color: var(--ink-tertiary); }

.alerta-riesgo {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  color: var(--warn);
  font-weight: 600;
}
.alerta-riesgo svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }

/* ---------- Resumen respuestas ---------- */
.resumen-respuestas {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}
.resumen-respuestas summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.resumen-respuestas summary svg { width: 16px; height: 16px; transition: transform var(--transition); }
.resumen-respuestas[open] summary svg { transform: rotate(90deg); }
.resumen-respuestas table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.resumen-respuestas th, .resumen-respuestas td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.resumen-respuestas th { color: var(--ink-secondary); font-weight: 700; }

/* ---------- Disclaimers y avisos ---------- */
.disclaimer {
  background: var(--primary-bg);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
  color: var(--primary);
}
.disclaimer strong { display: block; margin-bottom: 0.25rem; }
.disclaimer.restricted { background: var(--warn-bg); border-left-color: var(--warn); color: var(--warn); }
.disclaimer.warn { background: var(--warn-bg); border-left-color: var(--warn); color: var(--warn); }

/* ---------- Registro ---------- */
.registro-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.registro-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.registro-item .fila-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.25rem;
}
.reg-nombre { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.reg-puntaje {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.95rem;
}
.registro-item .fecha {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.4rem;
}
.reg-etiqueta { font-size: 0.9rem; color: var(--ink-secondary); margin-bottom: 0.8rem; }

/* ---------- Agregar escala ---------- */
.card-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.card-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
}
.card-section h2 svg { width: 20px; height: 20px; color: var(--primary); }
textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }

/* ---------- Guía JSON ---------- */
.guia-json {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.9rem 1.1rem;
}
.guia-json summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}
.guia-json summary svg { width: 16px; height: 16px; transition: transform var(--transition); flex-shrink: 0; }
.guia-json[open] summary svg { transform: rotate(90deg); }
.guia-body { margin-top: 0.9rem; font-size: 0.88rem; color: var(--ink-secondary); }
.guia-body h3 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 1rem 0 0.4rem;
}
.guia-body p { margin-bottom: 0.5rem; }
.guia-body ul { padding-left: 1.2rem; margin-bottom: 0.5rem; }
.guia-body li { margin-bottom: 0.35rem; }
.guia-body code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05rem 0.35rem;
  font-size: 0.82em;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.guia-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  margin: 0.5rem 0 0.75rem;
}
.guia-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--ink);
  white-space: pre;
}

/* ---------- Sticky actions y tabbar ---------- */
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.sticky-actions {
  position: sticky;
  bottom: 4.8rem;
  left: 0;
  right: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  justify-content: flex-end;
}

footer.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4.5rem;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
footer.tabbar button {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: var(--ink-secondary);
  font-weight: 600;
  transition: all var(--transition);
  position: relative;
  font-family: inherit;
}
footer.tabbar button .icon svg { width: 22px; height: 22px; transition: transform var(--transition); }
footer.tabbar button .label { font-size: 0.75rem; }
footer.tabbar button.active { color: var(--primary); }
footer.tabbar button.active .icon svg { transform: translateY(-2px); }
footer.tabbar button .indicator {
  position: absolute;
  top: 0;
  width: 24px;
  height: 3px;
  background: var(--primary-gradient);
  border-radius: 0 0 4px 4px;
}
footer.tabbar button:focus-visible { outline: none; background: var(--surface-hover); }

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-icon { font-size: 1.2rem; }
.toast-msg { font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.toast-ok { border-left: 4px solid var(--ok); }
.toast-error { border-left: 4px solid var(--warn); }
.toast-warn { border-left: 4px solid var(--accent); }

/* ---------- Modal ---------- */
#modal-disclaimer {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 480px;
  padding: 2.2rem;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-content h2 { margin-top: 0; color: var(--primary); font-weight: 800; font-size: 1.4rem; margin-bottom: 0.8rem; }
.modal-content p { color: var(--ink-secondary); margin-bottom: 1rem; font-size: 0.95rem; }
.modal-content .badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-right: 0.4rem;
  margin-bottom: 0.4rem;
}

/* ---------- Skeleton Loader ---------- */
.skeleton-main { padding: 1.5rem 1rem; }
.skel-bar { background: var(--border); border-radius: 6px; animation: pulse 1.5s infinite; }
.skel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  height: 80px;
  border-radius: var(--radius);
  margin-top: 0.75rem;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

/* ---------- Animaciones ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.22s cubic-bezier(0.4, 0, 0.2, 1); }

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ink-secondary);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; color: var(--ink-tertiary); }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; color: var(--ink); }
.empty-state.big { padding: 5rem 1.5rem; }
.empty-state.big .btn { margin-top: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .escala-card { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .card-arrow { display: none; }
  .sticky-actions { bottom: 4.6rem; left: 0; right: 0; width: 100%; border-radius: 0; border-left: none; border-right: none; }
}

/* ---------- Print ---------- */
@media print {
  header, footer.tabbar, .actions, .skip-link, .filtros, .sticky-actions { display: none !important; }
  body { background: white; color: black; padding-bottom: 0; }
  .resultado-card { border: 1px solid #000; box-shadow: none; }
}
