/* ============================================================
   Preinforme Analytics — sistema de diseño (Fase 1)
   Tokens claro/oscuro · Inter · acento teal clínico · Lucide
   ============================================================ */

:root {
  /* Acento clínico (teal/cyan) */
  --accent: #0e7490;
  --accent-2: #0891b2;
  --accent-soft: #ecfeff;
  --accent-ink: #155e75;

  /* Superficies y tinta (escala slate) */
  --bg: #f4f6f8;
  --card: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;

  /* Semánticos */
  --ok: #16a34a;       --ok-bg: #dcfce7;      --ok-ink: #166534;
  --warn: #d97706;     --warn-bg: #fef3c7;    --warn-ink: #92400e;
  --danger: #dc2626;   --danger-bg: #fee2e2;  --danger-ink: #991b1b;
  --info: #0284c7;     --info-bg: #e0f2fe;    --info-ink: #075985;

  /* Resaltados suaves (paneles comparativos, citas) */
  --hl-warn: #fff7ed;
  --hl-ok: #f0fdf4;
  --hl-danger: #fef2f2;

  /* Sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-ink: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-hover: #1e293b;
  --sidebar-active: #155e75;

  /* Forma y elevación */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
  --focus: 0 0 0 3px rgba(14, 116, 144, 0.25);

  /* Movimiento */
  --t-fast: 150ms ease;
  --t-med: 220ms ease;

  /* Compat: vistas antiguas usan var(--brand,…) */
  --brand: var(--accent);
}

[data-theme='dark'] {
  --accent: #22d3ee;
  --accent-2: #06b6d4;
  --accent-soft: #083344;
  --accent-ink: #67e8f9;

  --bg: #0b1220;
  --card: #111a2c;
  --surface-2: #16213a;
  --ink: #e2e8f0;
  --muted: #8aa0b8;
  --line: #243349;

  --ok: #4ade80;       --ok-bg: #14532d;      --ok-ink: #bbf7d0;
  --warn: #fbbf24;     --warn-bg: #57350b;    --warn-ink: #fde68a;
  --danger: #f87171;   --danger-bg: #5f1d1d;  --danger-ink: #fecaca;
  --info: #38bdf8;     --info-bg: #0c4a6e;    --info-ink: #bae6fd;

  --hl-warn: #2a2113;
  --hl-ok: #102418;
  --hl-danger: #2a1414;

  --sidebar-bg: #070d1a;
  --sidebar-ink: #b6c2d4;
  --sidebar-muted: #5b6b80;
  --sidebar-hover: #131e33;
  --sidebar-active: #0e4453;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.55);
  --focus: 0 0 0 3px rgba(34, 211, 238, 0.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  /* Render nítido y consistente en macOS (evita el texto "grueso/borroso"
     del subpixel-antialiasing por defecto). Práctica estándar en SaaS. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
  transition: background var(--t-med), color var(--t-med);
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
::selection { background: var(--accent); color: #fff; }

/* Scrollbars discretos */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

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

/* ── Íconos (Lucide) ─────────────────────────────────────── */
.icon, svg.lucide { width: 17px; height: 17px; stroke-width: 2; flex-shrink: 0; vertical-align: -3px; }
.nav svg.lucide { width: 17px; height: 17px; opacity: 0.85; }
.btn svg.lucide { width: 15px; height: 15px; vertical-align: -2px; }
/* Ícono que abre un título de sección: en color de acento, como Linear */
h2 > svg.lucide:first-child, h3 > svg.lucide:first-child { color: var(--accent); width: 16px; height: 16px; margin-right: 2px; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 232px; background: var(--sidebar-bg); color: var(--sidebar-ink); flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  transition: transform var(--t-med);
}
.brand { padding: 16px 14px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(148, 163, 184, 0.1); }
.brand .logo, .login-brand .logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #0891b2, #155e75);
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand .logo svg, .login-brand .logo svg { width: 19px; height: 19px; }
.brand-text { font-weight: 700; font-size: 13.5px; letter-spacing: -0.01em; color: #f1f5f9; line-height: 1.25; white-space: nowrap; }
.brand-text small { display: block; color: var(--sidebar-muted); font-weight: 500; font-size: 10.5px; letter-spacing: .4px; text-transform: uppercase; }
.login-brand { display: flex; justify-content: center; margin-bottom: 12px; }
.login-brand .logo { width: 44px; height: 44px; border-radius: 12px; }
.login-brand .logo svg { width: 24px; height: 24px; }
.login-card h1 { text-align: center; }
.login-card > .muted { text-align: center; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--sidebar-ink); margin-bottom: 1px; font-weight: 500; font-size: 13px;
  border-left: 2px solid transparent; transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--accent); }
.nav .nav-sec { color: var(--sidebar-muted); font-size: 10.5px; text-transform: uppercase; padding: 14px 10px 4px; letter-spacing: .8px; font-weight: 600; }
.sidebar .userbox { padding: 12px 16px; border-top: 1px solid rgba(148, 163, 184, 0.12); font-size: 12px; color: var(--sidebar-muted); }
.sidebar .userbox b { color: var(--sidebar-ink); display: block; }

/* Drawer móvil */
.nav-toggle { display: none; background: none; border: none; color: var(--ink); cursor: pointer; padding: 6px; border-radius: 8px; }
.nav-toggle:hover { background: var(--surface-2); }
.backdrop { display: none; }
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: inline-flex; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(2, 6, 23, 0.5); z-index: 50; }
}

/* ── Contenido / topbar ──────────────────────────────────── */
.content { flex: 1; min-width: 0; }
.topbar {
  background: var(--card);
  background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 12px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
/* Centrado y con un ancho útil mayor: en monitores grandes el contenido usa
   más espacio (menos scroll horizontal en tablas anchas) y no se pega a la
   izquierda; en pantallas medianas/pequeñas se ajusta el padding. */
.container { padding: 24px 28px; max-width: 1440px; margin: 0 auto; width: 100%; }
/* Monitores muy anchos: aprovechar el espacio sin que las líneas se estiren
   en exceso en tablas y formularios. */
@media (min-width: 1700px) { .container { max-width: 1600px; } }
@media (max-width: 1000px) { .container { padding: 20px 20px; } }
@media (max-width: 768px)  { .container { padding: 16px 14px; } }
@media (max-width: 480px)  { .container { padding: 14px 11px; } }

/* ── Responsive: topbar compacta en móvil ────────────────── */
@media (max-width: 768px) {
  .topbar { padding: 10px 14px; gap: 8px; flex-wrap: nowrap; }
  .topbar h1 { font-size: 16px; min-width: 0; }
  /* el título puede truncar; nunca empuja la barra de acciones */
  .topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .toolbar { gap: 6px; flex-wrap: nowrap; flex-shrink: 0; }
  /* botones de la topbar = solo ícono (el texto queda como title/tooltip) */
  .topbar .toolbar .btn, .topbar .search-btn { padding: 8px; }
  .topbar .toolbar .btn-label, .topbar .search-btn .btn-label, .search-btn .kbd { display: none; }
  .topbar .toolbar .btn svg, .topbar .search-btn svg { vertical-align: middle; }
}

.theme-toggle { background: none; border: 1px solid var(--line); color: var(--muted); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all var(--t-fast); }
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }

/* ── Cards & grid ────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
/* Los items de grid traen min-width:auto: sin esto, una tabla/canvas ancho
   estira la columna (y rompe el scroll-horizontal contenido en móvil). */
.grid > * { min-width: 0; }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid.cols-5, .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid.cols-5, .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

/* ── Tablas: scroll horizontal contenido en móvil ────────── */
/* PA.wrapTables() envuelve cada <table> en .table-scroll para que las tablas
   anchas se desplacen dentro de su tarjeta en vez de romper el layout. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
/* En pantallas medianas y móviles compactamos las celdas para que quepan más
   columnas antes de necesitar scroll horizontal; el min-width solo se aplica
   en móvil real para no romper el layout de tablas muy anchas. */
@media (max-width: 1000px) {
  th, td { padding: 7px 8px; }
}
@media (max-width: 768px) {
  .table-scroll table { min-width: 520px; }
  .table-scroll { margin: 0 -2px; }
  table { font-size: 12.5px; }
  th, td { padding: 6px 7px; }
}

/* Formularios y barras de acción apilan en móvil */
@media (max-width: 640px) {
  .row { gap: 8px; }
  .row > * { min-width: 100%; flex-basis: 100%; }
  .toolbar { gap: 8px; }
  .toolbar .btn, .toolbar .btn.secondary, .toolbar a.btn { flex: 1 1 auto; justify-content: center; }
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
  transition: background var(--t-med), border-color var(--t-med);
}
.card h2, .card h3 { margin: 0 0 12px; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi .value { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* ── Tablas ──────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-danger { background: var(--danger-bg); color: var(--danger-ink); }
.badge-info { background: var(--info-bg); color: var(--info-ink); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

/* ── Formularios y botones ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  padding: 8px 15px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; font-size: 13px;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--accent-2); text-decoration: none; box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--muted); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
[data-theme='dark'] .btn { color: #03222b; }
[data-theme='dark'] .btn.secondary { color: var(--ink); }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--focus); }
input::placeholder { color: var(--muted); opacity: .7; }
label { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 120px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.muted { color: var(--muted); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 26px 0 10px; font-weight: 700; }
.chart-wrap { position: relative; height: 280px; }
.report-vs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .report-vs { grid-template-columns: 1fr; } }
.report-box { white-space: pre-wrap; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; max-height: 520px; overflow: auto; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Markdown (feedback) ─────────────────────────────────── */
.markdown { font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.markdown h2 { font-size: 16px; margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 2px solid var(--accent); color: var(--accent-ink); }
.markdown h3 { font-size: 14px; margin: 14px 0 6px; }
.markdown p { margin: 8px 0; }
.markdown ul { margin: 8px 0; padding-left: 20px; }
.markdown li { margin: 3px 0; }
.markdown a { color: var(--accent-2); text-decoration: underline; word-break: break-word; }
.markdown table { margin: 12px 0; width: 100%; border-collapse: collapse; font-size: 12.5px; }
.markdown table td { border: 1px solid var(--line); padding: 6px 10px; }
.markdown table tr:first-child td { background: var(--surface-2); font-weight: 600; }
.markdown blockquote { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.markdown blockquote p { margin: 4px 0; font-size: 13px; }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.markdown code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--hl-warn); border: 1px solid var(--warn); color: var(--warn-ink); margin-bottom: 16px; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(1200px 600px at 70% -10%, #134e5e33, transparent), var(--sidebar-bg); }
.login-card { background: var(--card); padding: 32px; border-radius: 16px; width: min(360px, calc(100vw - 28px)); box-shadow: var(--shadow-lg); }
@media (max-width: 480px) { .login-card { padding: 24px 20px; } }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Command palette (⌘K) ────────────────────────────────── */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(2, 6, 23, 0.45);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh;
  backdrop-filter: blur(2px);
}
.cmdk {
  width: min(560px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: cmdk-in 140ms ease;
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.cmdk input {
  border: none; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 14px 16px; font-size: 15px; background: transparent;
}
.cmdk input:focus { box-shadow: none; border-color: var(--line); }
.cmdk-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; color: var(--ink);
}
.cmdk-item svg { width: 16px; height: 16px; color: var(--muted); }
.cmdk-item.sel { background: var(--accent); color: #fff; }
.cmdk-item.sel svg { color: #fff; }
[data-theme='dark'] .cmdk-item.sel { color: #03222b; }
[data-theme='dark'] .cmdk-item.sel svg { color: #03222b; }
.cmdk-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.cmdk-hint { padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; display: flex; gap: 14px; }
.kbd {
  font-family: inherit; font-size: 10.5px; color: var(--muted); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; background: var(--surface-2);
}
.search-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); border-radius: 8px; padding: 6px 10px;
  font-size: 12.5px; cursor: pointer; transition: border-color var(--t-fast), color var(--t-fast);
}
.search-btn:hover { border-color: var(--muted); color: var(--ink); }
.search-btn svg { width: 14px; height: 14px; }
@media (max-width: 768px) { .search-btn .kbd { display: none; } }

/* ── Delta de KPI (▲/▼ vs semana anterior) ───────────────── */
.kpi .delta { font-size: 11.5px; font-weight: 600; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }
.kpi .delta.flat { color: var(--muted); }

/* ── Ayuda contextual (globos «¿qué es esto?») ───────────── */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0; margin-left: 4px; vertical-align: -2px;
  border: none; background: none; color: var(--muted); cursor: help; border-radius: 50%;
  opacity: 0.6; transition: opacity var(--t-fast), color var(--t-fast);
}
.help-btn:hover, .help-btn:focus-visible, .help-btn.active { opacity: 1; color: var(--accent); }
.help-btn svg { width: 14px; height: 14px; }
/* en encabezados de tabla, el ícono no debe heredar el uppercase/bold */
th .help-btn { vertical-align: middle; }

.help-pop {
  position: fixed; z-index: 120; width: min(300px, calc(100vw - 24px));
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 14px;
  font-size: 12.5px; line-height: 1.5; font-weight: 400; text-transform: none; letter-spacing: normal;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.help-pop.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.help-pop .help-title { display: block; font-weight: 700; font-size: 13px; color: var(--accent-ink); margin-bottom: 5px; }
[data-theme='dark'] .help-pop .help-title { color: var(--accent); }
.help-pop .help-what { display: block; color: var(--ink); }
.help-pop .help-how { display: block; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); color: var(--muted); }
.help-pop .help-how b { color: var(--ink); font-weight: 600; }

/* ── Tour de bienvenida (walkthrough) ────────────────────── */
/* 4 paneles oscuros alrededor del foco: el elemento resaltado queda al
   descubierto Y clickeable (los paneles bloquean el resto de la página). */
.tour-dim { position: fixed; z-index: 130; background: rgba(2, 6, 23, 0.62); transition: all 180ms ease; }
.tour-ring {
  position: fixed; z-index: 131; pointer-events: none; border-radius: 10px;
  border: 2px solid var(--accent-2);
  box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.35), 0 0 22px rgba(8, 145, 178, 0.45);
  transition: all 180ms ease;
}
.tour-tip {
  position: fixed; z-index: 132; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 14px 16px; animation: tour-in 180ms ease;
}
@keyframes tour-in { from { opacity: 0; transform: translateY(6px); } }
.tour-tip-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; color: var(--accent-ink); }
[data-theme='dark'] .tour-tip-title { color: var(--accent); }
.tour-tip-text { font-size: 13px; line-height: 1.5; }
.tour-tip-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tour-tip-row .btn { padding: 6px 12px; font-size: 12.5px; }
.tour-count { margin-left: auto; margin-right: 2px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tour-skip { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px 0; }
.tour-skip:hover { color: var(--ink); text-decoration: underline; }

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── Impresión: solo el área marcada con .print-area ─────── */
.print-only { display: none; }
@media print {
  /* Siempre en claro al imprimir, aunque la app esté en oscuro */
  :root, [data-theme='dark'] {
    --bg: #fff; --card: #fff; --surface-2: #f8fafc; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
    --accent: #0e7490; --accent-ink: #155e75;
  }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-only { display: block; }
  .print-area {
    position: absolute; left: 0; top: 0; width: 100%;
    margin: 0; padding: 0; border: none; box-shadow: none; background: #fff;
  }
  .print-header { border-bottom: 2px solid var(--accent); padding-bottom: 10px; margin-bottom: 8px; }
  .print-header h2 { font-size: 18px; color: var(--accent-ink); }
  .sidebar, .topbar, .toolbar, .nav { display: none !important; }
  .no-print { display: none !important; }
  .markdown a { color: #0369a1; text-decoration: underline; }
  .markdown table { width: 100%; }
  .markdown table, .markdown blockquote { page-break-inside: avoid; }
  .markdown h2, .markdown h3 { page-break-after: avoid; }
  @page { margin: 1.4cm; }
}

/* ── Mi Colección + Buscar (Fase 1) ─────────────────────── */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--line); text-decoration: none; cursor: pointer;
}
.tag-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag-chip .x { opacity: .6; font-weight: 400; }
mark { background: var(--warn-bg); color: var(--warn-ink); padding: 0 2px; border-radius: 3px; }
.sc-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 90;
}
.sc-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(440px, 92vw); z-index: 91; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.sc-modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.sc-modal input, .sc-modal textarea { width: 100%; }
.star-btn { background: none; border: none; cursor: pointer; padding: 2px; color: var(--muted); }
.star-btn.saved { color: #f59e0b; }
.star-btn.saved svg { fill: #f59e0b; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; box-shadow: 0 2px 8px rgba(220, 38, 38, .25); }

/* ── Panel de administración: secciones colapsables ──────────────── */
/* <details class="card adm-sec"> con <summary> = título clicable. El estado
   abierto/cerrado se persiste por sección en localStorage (ver admin.ejs). */
details.adm-sec { margin-bottom: 14px; }
details.adm-sec > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: -4px 0;
}
details.adm-sec > summary::-webkit-details-marker { display: none; }
details.adm-sec > summary .chev {
  flex: none; color: var(--muted); transition: transform .15s ease;
  display: inline-flex; font-size: 12px;
}
details.adm-sec[open] > summary .chev { transform: rotate(90deg); }
details.adm-sec > summary h3 { margin: 0; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
details.adm-sec > summary .sum-note { color: var(--muted); font-weight: 400; font-size: 12px; }
details.adm-sec > summary:hover h3 { color: var(--accent); }
details.adm-sec[open] > summary { margin-bottom: 12px; }

/* Índice de salto del panel (chips) */
.adm-index {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 8px 2px; margin: 0 0 12px; background: var(--bg);
}
.adm-index a {
  font-size: 11.5px; padding: 3px 10px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); background: var(--card);
  text-decoration: none; white-space: nowrap;
}
.adm-index a:hover { color: var(--accent); border-color: var(--accent-2); }

/* Grupos de rotaciones por becado */
details.rot-group { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
details.rot-group > summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.rot-group > summary::-webkit-details-marker { display: none; }
details.rot-group[open] { padding-bottom: 4px; }
details.rot-group[open] > summary { margin-bottom: 6px; }

/* Buscador de filas dentro de una sección */
.adm-filter { max-width: 280px; padding: 6px 10px; font-size: 12.5px; }

/* ── Login: mostrar/ocultar contraseña + recordar correo ─────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 5px; display: inline-flex; border-radius: 6px; line-height: 0;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.login-remember {
  display: flex; align-items: center; gap: 7px; margin: 2px 0 14px;
  font-size: 12.5px; color: var(--muted); font-weight: 400; cursor: pointer;
}
.login-remember input { width: auto; margin: 0; }
.caps-warn { font-size: 11.5px; color: var(--warn-ink, #92400e); margin-top: 5px; }
