/* ==========================================================================
   Sistema de Diseño v1.0 — implementación de sistema-de-diseno.md
   La fuente de verdad es el .md; este CSS lo implementa literalmente.
   ========================================================================== */

/* --------------------------------------------------------------------------
   §2 · Tokens de color  ·  §4 · Radios y sombras  ·  §5 · Movimiento
   -------------------------------------------------------------------------- */
:root {
  /* §2.1 Neutros */
  --bg-page: #F5F5F7;
  --bg-surface: #FFFFFF;
  --bg-surface-2: #FAFAFC;
  --bg-material: rgba(255, 255, 255, 0.72);
  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #AEAEB2;
  --border: #E5E5EA;
  --border-strong: #D2D2D7;

  /* §2.2 Acento y semánticos */
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-pressed: #006EDB;
  --accent-soft: #EAF3FE;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --danger-hover: #FF453A;
  --danger-pressed: #E0342B;
  --danger-soft: #FEECEB;

  /* §4.2 Radios */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* §4.3 Sombras */
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.14);

  /* §5 Movimiento */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 150ms;
  --dur-med: 250ms;
  --dur-slow: 350ms;

  /* Anillos de focus (§7.1, §8.1) */
  --ring-accent: 0 0 0 4px rgba(0, 113, 227, 0.25);
  --ring-accent-soft: 0 0 0 4px rgba(0, 113, 227, 0.15);
  --ring-danger: 0 0 0 4px rgba(255, 59, 48, 0.25);
  --ring-danger-soft: 0 0 0 4px rgba(255, 59, 48, 0.15);

  /* §3 Tipografía */
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text",
                "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }
button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon { flex: none; }
.ic-12 { width: 12px; height: 12px; }
.ic-16 { width: 16px; height: 16px; }
.ic-20 { width: 20px; height: 20px; }
.ic-24 { width: 24px; height: 24px; }

/* Focus visible por teclado en todo elemento interactivo (§13) */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring-accent); }

::selection { background: rgba(0, 113, 227, 0.2); }

/* §5 · prefers-reduced-motion: transiciones reducidas a cambios instantáneos */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* --------------------------------------------------------------------------
   §3 · Escala tipográfica
   -------------------------------------------------------------------------- */
.t-display     { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -0.02em; }
.t-title1      { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.015em; }
.t-title2      { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.t-title3      { font-size: 17px; line-height: 24px; font-weight: 600; }
.t-body        { font-size: 15px; line-height: 22px; font-weight: 400; }
.t-body-strong { font-size: 15px; line-height: 22px; font-weight: 600; }
.t-caption     { font-size: 13px; line-height: 18px; font-weight: 400; }
.t-micro       { font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.01em; }
.t-micro-caps  { font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }

.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }

.code {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   §7 · Botones — altura 40 (compacto 32, grande 48), padding-x 20,
   radio --radius-md, tipografía 15/600, icono 20 px con gap 8.
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: relative;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:disabled, .btn.demo-disabled { cursor: default; pointer-events: none; }
.btn .icon { width: 20px; height: 20px; }
.btn--sm { height: 32px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--lg { height: 48px; padding: 0 24px; }

/* Efecto pressed universal (§5) */
.btn:active, .btn.demo-pressed { transform: scale(0.97); }

/* §7.1 Primario */
.btn--primary { background: var(--accent); color: #FFFFFF; }
.btn--primary:hover, .btn--primary.demo-hover { background: var(--accent-hover); }
.btn--primary:active, .btn--primary.demo-pressed { background: var(--accent-pressed); }
.btn--primary:focus-visible, .btn--primary.demo-focus { box-shadow: var(--ring-accent); }
.btn--primary:disabled, .btn--primary.demo-disabled { background: #D2D2D7; color: #FFFFFF; }

/* §7.2 Secundario — gris relleno, sin borde */
.btn--secondary { background: #F0F0F2; color: var(--text-primary); }
.btn--secondary:hover, .btn--secondary.demo-hover { background: #E8E8ED; }
.btn--secondary:active, .btn--secondary.demo-pressed { background: #E0E0E5; }
.btn--secondary:focus-visible, .btn--secondary.demo-focus { box-shadow: var(--ring-accent); }
.btn--secondary:disabled, .btn--secondary.demo-disabled { color: var(--text-tertiary); }

/* §7.3 Terciario / Ghost */
.btn--ghost { background: transparent; color: var(--accent); }
.btn--ghost:hover, .btn--ghost.demo-hover { background: var(--accent-soft); }
.btn--ghost:active, .btn--ghost.demo-pressed { background: #DCEBFD; }
.btn--ghost:focus-visible, .btn--ghost.demo-focus { box-shadow: var(--ring-accent); }
.btn--ghost:disabled, .btn--ghost.demo-disabled { color: var(--text-tertiary); }

/* §7.4 Destructivo */
.btn--danger { background: var(--danger); color: #FFFFFF; }
.btn--danger:hover, .btn--danger.demo-hover { background: var(--danger-hover); }
.btn--danger:active, .btn--danger.demo-pressed { background: var(--danger-pressed); }
.btn--danger:focus-visible, .btn--danger.demo-focus { box-shadow: var(--ring-danger); }
.btn--danger:disabled, .btn--danger.demo-disabled { background: #D2D2D7; color: #FFFFFF; }

/* §7.1 Cargando — acento al 80 %, spinner blanco 16 px, texto oculto, ancho fijo */
.btn.is-loading { pointer-events: none; }
.btn--primary.is-loading { background: rgba(0, 113, 227, 0.8); }
.btn--danger.is-loading { background: rgba(255, 59, 48, 0.8); }
.btn.is-loading > :not(.btn-spinner) { visibility: hidden; }
.btn-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.btn.is-loading .btn-spinner { display: flex; }
.btn-spinner::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: var(--radius-full);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   §6 · Botón de icono — área táctil mínima 40×40
   -------------------------------------------------------------------------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn:hover, .icon-btn.demo-hover { color: var(--text-primary); background: rgba(0, 0, 0, 0.05); }
.icon-btn:active, .icon-btn.demo-pressed { background: rgba(0, 0, 0, 0.09); transform: scale(0.94); }
.icon-btn.is-active, .icon-btn.demo-active { color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled, .icon-btn.demo-disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
  background: transparent;
  transform: none;
}

/* Variante ghost del botón de icono (§9: paginación con botones ghost) */
.icon-btn--ghost { color: var(--accent); }
.icon-btn--ghost:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn--ghost:active { background: #DCEBFD; }
.icon-btn--ghost:disabled { color: var(--text-tertiary); background: transparent; }

/* --------------------------------------------------------------------------
   §8.1 · Campo de texto
   -------------------------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; }
.form-label {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field {
  height: 44px;
  padding: 0 14px;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 22px;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.field::placeholder { color: var(--text-tertiary); }
.field:hover:not(:disabled):not(:focus):not(.is-error), .field.demo-hover { border-color: #B8B8BF; }
.field:focus, .field.demo-focus {
  border-color: var(--accent);
  box-shadow: var(--ring-accent-soft);
}
.field.is-error { border-color: var(--danger); box-shadow: var(--ring-danger-soft); }
.field.is-error:focus, .field.is-error.demo-focus { box-shadow: var(--ring-danger-soft); }
.field:disabled {
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
}
.form-error {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   §8.2 · Toggle — pista 51×31, bola 27 blanca, encendido --success
   -------------------------------------------------------------------------- */
.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: #E5E5EA;
  cursor: pointer;
  flex: none;
  transition: background-color var(--dur-med) var(--ease);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-med) var(--ease-spring);
}
.toggle[aria-checked="true"] { background: var(--success); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }
.toggle:disabled { opacity: 0.45; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   §8.3 · Checkbox y radio — 20×20
   -------------------------------------------------------------------------- */
.checkbox, .radio {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  background: #FFFFFF;
  cursor: pointer;
  flex: none;
  display: inline-grid;
  place-content: center;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.checkbox { border-radius: 6px; }
.radio { border-radius: var(--radius-full); }

.checkbox::after {
  content: "";
  width: 5px;
  height: 9px;
  margin-top: -2px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0.5);
  opacity: 0;
  transition: transform var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
.checkbox:checked, .checkbox:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox:checked::after { opacity: 1; transform: rotate(45deg) scale(1); }
.checkbox:indeterminate::after {
  opacity: 1;
  width: 10px;
  height: 0;
  margin-top: 0;
  border-width: 0 0 2px 0;
  transform: none;
}

.radio::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  transform: scale(0.5);
  opacity: 0;
  transition: transform var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
.radio:checked { background: var(--accent); border-color: var(--accent); }
.radio:checked::after { opacity: 1; transform: scale(1); }

.checkbox:disabled, .radio:disabled { opacity: 0.45; cursor: not-allowed; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px; /* área táctil §13 */
  cursor: pointer;
  font-size: 15px;
}
.check-row.is-disabled { color: var(--text-tertiary); cursor: not-allowed; }

/* --------------------------------------------------------------------------
   §8.4 · Select / Dropdown
   -------------------------------------------------------------------------- */
.select { position: relative; }
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.select-trigger:hover:not(:disabled) { border-color: #B8B8BF; }
.select-trigger:disabled {
  background: var(--bg-surface-2);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.select.is-error .select-trigger {
  border-color: var(--danger);
  box-shadow: var(--ring-danger-soft);
}
.select-trigger:focus-visible,
.select.is-open .select-trigger {
  border-color: var(--accent);
  box-shadow: var(--ring-accent-soft);
  outline: none;
}
.select-trigger .icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: transform var(--dur-med) var(--ease);
}
.select.is-open .select-trigger .icon { transform: rotate(180deg); }

.select-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  padding: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  visibility: hidden; /* fuera del orden de tabulación cuando está cerrado */
  transition: opacity var(--dur-med) var(--ease),
              transform var(--dur-med) var(--ease),
              visibility 0s linear var(--dur-med);
}
.select.is-open .select-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition: opacity var(--dur-med) var(--ease),
              transform var(--dur-med) var(--ease),
              visibility 0s;
}
.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.select-option:hover, .select-option.is-hl { background: #F0F0F2; }
.select-option .icon { width: 16px; height: 16px; color: var(--accent); opacity: 0; }
.select-option[aria-selected="true"] .icon { opacity: 1; }

/* --------------------------------------------------------------------------
   §8.5 · Segmented control
   -------------------------------------------------------------------------- */
.segmented {
  position: relative;
  display: inline-flex;
  height: 36px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: #EFEFF1;
}
.segmented-indicator {
  position: absolute;
  top: 2px;
  left: 0;
  height: calc(100% - 4px);
  border-radius: 6px;
  background: #FFFFFF;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-med) var(--ease);
  will-change: transform;
}
.segmented-btn {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  min-width: 88px;
  padding: 0 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.segmented-btn[aria-pressed="true"] { color: var(--text-primary); font-weight: 600; }

/* --------------------------------------------------------------------------
   §9 · Tabla
   -------------------------------------------------------------------------- */
.table-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.table thead th {
  height: 44px;
  padding: 0 16px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  border-radius: 4px;
}
.th-sort .icon {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.th-sort:hover .icon { opacity: 1; }
.th-sort.is-sorted { color: var(--accent); }
.th-sort.is-sorted .icon { opacity: 1; }
.th-sort.is-desc .icon { transform: rotate(180deg); }

.table tbody td {
  height: 52px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody tr {
  transition: background-color var(--dur-fast) var(--ease);
}
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr:hover { background: #F7F7F9; }
.table tbody tr.is-selected { background: var(--accent-soft); }
.td-check { width: 52px; }
.td-check .checkbox { vertical-align: middle; }

.row-actions {
  display: inline-flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  vertical-align: middle;
}
.table tbody tr:hover .row-actions,
.row-actions:focus-within { opacity: 1; }
/* área táctil 40×40 (§6/§13): los botones de fila no se reducen */

.row-chevron {
  color: var(--text-tertiary);
  vertical-align: middle;
  margin-left: 8px;
  transition: color var(--dur-fast) var(--ease);
}
.table tbody tr:hover .row-chevron { color: var(--text-secondary); }
.td-end { text-align: right; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
  border-top: 1px solid var(--border);
}
.table-empty .icon { color: var(--text-tertiary); }
.table-empty .btn { margin-top: 8px; }

/* --------------------------------------------------------------------------
   §10 · Sidebar — 260 px (colapsada 72), material + blur
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 260px;
  background: var(--bg-material);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
  transition: width var(--dur-slow) var(--ease),
              transform var(--dur-slow) var(--ease);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 12px 0 20px;
  flex: none;
  overflow: hidden;
}
.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #FFFFFF;
}
.brand-mark .icon { width: 16px; height: 16px; }
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 16px;
}
.nav-group-label {
  padding: 0 24px;
  margin: 24px 0 8px;
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.sidebar-nav > .nav-group-label:first-child { margin-top: 8px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  margin: 1px 12px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 22px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.nav-item:hover { background: rgba(0, 0, 0, 0.05); color: var(--text-primary); text-decoration: none; }
.nav-item:active { transform: scale(0.98); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 20px; height: 20px; }
.nav-item.is-hidden { display: none; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border);
  flex: none;
  overflow: hidden;
}
.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-content: center;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.sidebar-footer .name { flex: 1; font-size: 15px; white-space: nowrap; }

/* Colapsada: solo iconos centrados, nombre como tooltip */
body.sb-collapsed .sidebar { width: 72px; }
/* con la nav colapsada el tooltip debe salir del contenedor (sin recorte) */
body.sb-collapsed .sidebar-nav { overflow: visible; }
body.sb-collapsed .nav-item { justify-content: center; padding: 0; gap: 0; }
body.sb-collapsed .nav-item .nav-text { display: none; }
body.sb-collapsed .nav-group-label { visibility: hidden; margin: 12px 0 0; height: 0; padding: 0; }
body.sb-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.sb-collapsed .sidebar-brand .nav-text { display: none; }
body.sb-collapsed .sidebar-footer { justify-content: center; }
body.sb-collapsed .sidebar-footer .name,
body.sb-collapsed .sidebar-footer .icon-btn { display: none; }

/* Tooltip del ítem colapsado */
body.sb-collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  translate: 0 -50%;
  z-index: 60;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: #1D1D1F;
  color: #FFFFFF;
  font-size: 13px;
  line-height: 18px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
}
body.sb-collapsed .nav-item:hover::after { opacity: 1; transition-delay: 400ms; }

/* --------------------------------------------------------------------------
   §11 · Header — 56 px sticky, material + blur, borde solo con scroll
   -------------------------------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 24px;
  background: var(--bg-material);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--border);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.header.is-scrolled::after { opacity: 1; }
.header-title { margin-right: auto; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-search {
  width: 200px;
  height: 36px;
  padding: 0 14px 0 36px;
  border: none;
  border-radius: var(--radius-full);
  background: #EFEFF1 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21 21-4.34-4.34'/%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3C/svg%3E") no-repeat 12px center;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  transition: width var(--dur-med) var(--ease),
              box-shadow var(--dur-med) var(--ease);
}
.header-search::placeholder { color: var(--text-tertiary); }
.header-search:focus { width: 280px; box-shadow: var(--ring-accent-soft); }

/* --------------------------------------------------------------------------
   §12 · Componentes de apoyo
   -------------------------------------------------------------------------- */

/* Tarjeta */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 24px;
}
.card--clickable {
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.card--clickable:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
}
.modal.is-open { visibility: visible; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease);
}
.modal.is-open .modal-overlay { opacity: 1; }
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: 24px;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity var(--dur-slow) var(--ease),
              transform var(--dur-slow) var(--ease);
}
.modal.is-open .modal-panel { opacity: 1; transform: scale(1); }
.modal-body { margin: 16px 0 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* Toast */
.toast-region {
  position: fixed;
  bottom: 24px;
  left: 50%;
  translate: -50% 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  background: #1D1D1F;
  color: #FFFFFF;
  font-size: 15px;
  line-height: 22px;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--dur-med) var(--ease),
              transform var(--dur-med) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast .icon { width: 16px; height: 16px; }
.toast--success .icon { color: var(--success); }
.toast--error .icon { color: var(--danger); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge--success { background: #E8F8EC; color: #1F7A34; }
.badge--warning { background: #FFF4E5; color: #A05A00; }
.badge--danger  { background: var(--danger-soft); color: #C0281E; }
.badge--info    { background: var(--accent-soft); color: #0059B4; }
.badge--neutral { background: #F0F0F2; color: var(--text-secondary); }

/* Chip filtrable */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-full);
  background: #EFEFF1;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.chip:hover { background: #E8E8ED; color: var(--text-primary); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--accent); color: #FFFFFF; }
.chip .icon { width: 14px; height: 14px; }

/* Tooltip */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  translate: -50% 0;
  z-index: 60;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: #1D1D1F;
  color: #FFFFFF;
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease) 0ms;
}
.tip:hover::after, .tip:focus-visible::after {
  opacity: 1;
  transition-delay: 400ms;
}

/* Tabs */
.tabs {
  position: relative;
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}
.tab {
  position: relative;
  padding: 10px 2px 12px;
  border: none;
  background: none;
  font-size: 15px;
  line-height: 22px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { color: var(--text-primary); font-weight: 600; }
.tabs-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--accent);
  transition: transform var(--dur-med) var(--ease);
  will-change: transform;
}
.tab-panel[hidden] { display: none; }

/* ==========================================================================
   Estructura de la página UI Kit (usa los tokens de arriba)
   ========================================================================== */
.kit-main {
  margin-left: 260px;
  transition: margin-left var(--dur-slow) var(--ease);
  min-height: 100vh;
}
body.sb-collapsed .kit-main { margin-left: 72px; }

.kit-content {
  max-width: 1060px;
  margin: 0 auto;
  padding: 16px 32px 96px;
}

.kit-hero { padding: 48px 0 16px; }
.kit-hero .t-display { margin-top: 12px; }
.kit-hero p { max-width: 620px; margin-top: 12px; }

.kit-section { padding-top: 48px; scroll-margin-top: 72px; }
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
}
.kit-section > .t-title1 { margin-top: 8px; }
.section-desc { max-width: 640px; margin-top: 8px; }
.section-body { display: flex; flex-direction: column; gap: 24px; margin-top: 24px; }

.spec-card { padding: 24px; }
.spec-card > .t-title3 { margin-bottom: 4px; }
.spec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.spec-demo { margin-top: 20px; }

/* Chips de token (clic = copiar) */
.token-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.token-strip::before {
  content: "Tokens de este bloque · clic para copiar";
  flex-basis: 100%;
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.token-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: var(--bg-surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}
.token-chip:hover { background: var(--accent-soft); color: var(--accent); box-shadow: none; }

/* Swatches de color */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.swatch {
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-md);
}
.swatch-color {
  display: block;
  height: 64px;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: transform var(--dur-fast) var(--ease);
}
.swatch:hover .swatch-color { transform: translateY(-2px); }
.swatch:active .swatch-color { transform: scale(0.97); }
.swatch-name { display: block; margin-top: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.swatch-hex { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 12px; color: var(--text-tertiary); text-transform: uppercase; }

/* Tipografía */
.type-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.type-row:last-child { border-bottom: none; }
.type-meta { flex: none; text-align: right; }

/* Espaciado */
.space-scale { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.space-step { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.space-block { background: var(--accent-soft); border: 1px dashed rgba(0, 113, 227, 0.4); border-radius: 4px; }

/* Radios y sombras */
.demo-boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.radius-box {
  height: 96px;
  display: grid;
  place-content: center;
  background: var(--bg-surface);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.shadow-box {
  height: 96px;
  display: grid;
  place-content: center;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
}

/* Material / blur demo */
.material-demo {
  position: relative;
  height: 180px;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.material-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: linear-gradient(120deg, #DCEBFD, #FDE8DC 45%, #E5F8E9 80%);
}
/* §1.4: nada se mueve solo — el fondo solo se desplaza al interactuar (hover) */
.material-demo:hover .material-bg,
.material-demo:focus-within .material-bg {
  animation: material-drift 14s linear infinite alternate;
}
@keyframes material-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-60px); }
}
.material-bg span {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow-1);
}
.material-overlay {
  position: absolute;
  inset: auto 0 0 0;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg-material);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
}

/* Movimiento */
.motion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.motion-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 16px;
  border: none;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.motion-cell:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.motion-cell:active { transform: scale(0.99); }
.motion-track {
  display: block;
  position: relative;
  height: 40px;
  margin: 10px 0 6px;
}
/* raíl del recorrido */
.motion-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: var(--border);
}
.motion-dot {
  display: block;
  position: absolute;
  top: 4px;
  left: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-med) var(--ease);
}
.motion-track-label {
  position: absolute;
  right: 0;
  top: -4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}
/* el recorrido (--travel) lo calcula el JS según el ancho real de la pista */
.motion-cell.is-play .motion-dot { transform: translateX(var(--travel, 140px)); }
.motion-cell[data-dur="fast"] .motion-dot { transition-duration: var(--dur-fast); }
.motion-cell[data-dur="slow"] .motion-dot { transition-duration: var(--dur-slow); }
.motion-cell[data-ease="spring"] .motion-dot,
.motion-track[data-ease="spring"] .motion-dot { transition-timing-function: var(--ease-spring); }

.motion-rules { display: flex; flex-direction: column; gap: 10px; }
.motion-rules li { margin: 0; }

/* Grids de estados (botones / iconos / formularios) */
.state-grid { display: grid; gap: 12px 16px; align-items: center; }
.state-grid--buttons { grid-template-columns: 110px repeat(6, auto); overflow-x: auto; padding-bottom: 4px; }
.state-label { font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); }
.live-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.icon-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
}
.icon-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* Formularios: grid de dos columnas */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px 24px; }
.control-stack { display: flex; flex-direction: column; gap: 12px; }

/* Layout section: mini-esquema */
.layout-note {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  color: #0059B4;
  align-items: flex-start;
}
.layout-note .icon { flex: none; margin-top: 2px; }

/* Apoyo */
.support-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Fondo de página dentro de una tarjeta (para ver sombras) */
.on-page {
  background: var(--bg-page);
  border-radius: var(--radius-md);
  padding: 24px;
}

/* Solo lectores de pantalla */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Footer */
.kit-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   §12 · Alert inline (v1.3)
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 22px;
}
.alert .icon { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; }
.alert-close {
  flex: none;
  display: inline-grid;
  place-content: center;
  width: 40px; /* área táctil mínima §13 */
  height: 40px;
  margin: -9px -14px -9px 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.alert-close:hover { background: rgba(0, 0, 0, 0.06); }
.alert-close .icon { width: 16px; height: 16px; margin: 0; }
.alert--info    { background: var(--accent-soft); color: #0059B4; }
.alert--success { background: #E8F8EC; color: #1F7A34; }
.alert--warning { background: #FFF4E5; color: #A05A00; }
.alert--error   { background: var(--danger-soft); color: #C0281E; }

/* --------------------------------------------------------------------------
   §12 · Menú contextual (v1.3)
   -------------------------------------------------------------------------- */
.menu { position: relative; display: inline-block; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 180px;
  padding: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  visibility: hidden;
  transition: opacity var(--dur-med) var(--ease),
              transform var(--dur-med) var(--ease),
              visibility 0s linear var(--dur-med);
}
.menu.is-open .menu-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition: opacity var(--dur-med) var(--ease),
              transform var(--dur-med) var(--ease),
              visibility 0s;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.menu-item .icon { width: 16px; height: 16px; color: var(--text-secondary); }
.menu-item:hover { background: #F0F0F2; }
.menu-item--danger { color: var(--danger); }
.menu-item--danger .icon { color: var(--danger); }
.menu-item--danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* --------------------------------------------------------------------------
   §12 · Breadcrumbs (v1.3)
   -------------------------------------------------------------------------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 18px;
}
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
.breadcrumbs a:hover { color: var(--text-primary); text-decoration: none; }
.breadcrumbs .icon { width: 12px; height: 12px; color: var(--text-tertiary); }
.breadcrumbs .current { color: var(--text-primary); font-weight: 500; }

/* --------------------------------------------------------------------------
   §12 · Progreso (v1.3)
   -------------------------------------------------------------------------- */
.progress {
  height: 6px;
  border-radius: var(--radius-full);
  background: #E5E5EA;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform var(--dur-med) var(--ease);
}
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 113, 227, 0.2);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 700ms linear infinite;
}
.spinner--16 { width: 16px; height: 16px; }
.spinner--28 { width: 28px; height: 28px; }

/* --------------------------------------------------------------------------
   §12 · Skeleton (v1.3) — pulso solo durante la carga
   -------------------------------------------------------------------------- */
.sk-line, .sk-avatar, .sk-block, .sk-card {
  background: #EFEFF1;
}
.sk-line { height: 12px; border-radius: 6px; }
.sk-avatar { width: 32px; height: 32px; border-radius: var(--radius-full); flex: none; }
.sk-block { border-radius: var(--radius-sm); }
.sk-card { border-radius: var(--radius-lg); }
.is-loading-demo .sk-line,
.is-loading-demo .sk-avatar,
.is-loading-demo .sk-block,
.is-loading-demo .sk-card {
  animation: sk-pulse 1.2s var(--ease) infinite alternate;
}
@keyframes sk-pulse { to { opacity: 0.55; } }

/* --------------------------------------------------------------------------
   §12 · Tarjeta KPI y lista de actividad (v1.3)
   -------------------------------------------------------------------------- */
.kpi { position: relative; }
.kpi-label { font-size: 13px; line-height: 18px; color: var(--text-secondary); }
/* valor en Display por defecto; Título 1 en grids de 4+ (§12) */
.kpi-value { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.dash-kpis .kpi-value { font-size: 28px; line-height: 34px; letter-spacing: -0.015em; }
.kpi-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; line-height: 18px; color: var(--text-tertiary); }
.kpi-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; }
.kpi-delta .icon { width: 16px; height: 16px; }
.kpi-delta--up { color: var(--success); }
.kpi-delta--down { color: var(--danger); }
.kpi-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  display: grid;
  place-content: center;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
}
.kpi-icon .icon { width: 20px; height: 20px; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.activity li:first-child { border-top: none; }
.activity-icon {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-content: center;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
}
.activity-icon .icon { width: 16px; height: 16px; }
.activity-body { flex: 1; min-width: 0; font-size: 15px; line-height: 22px; }
.activity-time { display: block; margin-top: 1px; font-size: 13px; line-height: 18px; color: var(--text-tertiary); }

/* --------------------------------------------------------------------------
   §15 · Plantillas
   -------------------------------------------------------------------------- */
.tpl-back {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-full);
  background: var(--bg-material);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-2);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.tpl-back:hover { box-shadow: var(--shadow-3); transform: translateY(-2px); text-decoration: none; }
.tpl-back:active { transform: scale(0.97); }
.tpl-back .icon { width: 16px; height: 16px; color: var(--text-secondary); }

/* Login (§15.1) */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.login-brand {
  width: 40px;
  height: 40px;
  align-self: center;
  display: grid;
  place-content: center;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #FFFFFF;
}
.login-brand .icon { width: 22px; height: 22px; }
.login-head { text-align: center; }
.login-head .t-caption { margin-top: 4px; }
.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-wrap { position: relative; }
.field-wrap .field { padding-right: 46px; }
.field-eye {
  position: absolute;
  right: 3px;
  top: 50%;
  translate: 0 -50%;
}
@media (max-width: 480px) {
  .login-card { padding: 32px; }
}

/* Dashboard (§15.2) */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}
.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: stretch;
}
@media (max-width: 1000px) {
  .dash-row { grid-template-columns: 1fr; }
}
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 220px;
  margin-top: 20px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  height: 100%;
  min-width: 0;
}
.chart-bar-track {
  flex: 1;
  display: flex;
  align-items: flex-end;
}
.chart-bar {
  width: 100%;
  height: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  transform-origin: bottom;
  transform: scaleY(var(--h, 0.1));
  transition: transform var(--dur-med) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.chart-col:hover .chart-bar { background: var(--accent-hover); }
/* eje en Caption --text-tertiary (§15.2) */
.chart-label {
  text-align: center;
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  color: var(--text-tertiary);
}

/* Ajustes (§15.3) */
.settings-wrap { max-width: 720px; }
.settings-wrap .kit-section { padding-top: 24px; }
.settings-card { display: flex; flex-direction: column; gap: 20px; }
.settings-card .card-actions { display: flex; justify-content: flex-end; gap: 12px; }
.danger-card h3 { color: var(--danger); }

/* Error (§15.4) */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.error-badge {
  width: 56px;
  height: 56px;
  display: grid;
  place-content: center;
  border-radius: var(--radius-full);
  background: #EFEFF1;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.error-badge .icon { width: 24px; height: 24px; }
.error-code { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-tertiary); }
.error-page .btn { margin-top: 12px; }

/* Sección Plantillas del kit */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.tpl-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; }
.tpl-card:hover { text-decoration: none; }
.tpl-thumb {
  height: 120px;
  display: grid;
  place-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.tpl-thumb .icon { width: 28px; height: 28px; }
.tpl-card .go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}
.tpl-card .go .icon { width: 14px; height: 14px; transition: transform var(--dur-fast) var(--ease); }
.tpl-card:hover .go .icon { transform: translateX(2px); }

/* --------------------------------------------------------------------------
   Vista /sistema (documento renderizado)
   -------------------------------------------------------------------------- */
.doc-wrap { max-width: 780px; margin: 0 auto; padding: 40px 32px 96px; }
.doc { background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: 48px 56px; }
.doc h1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 16px; }
.doc h2 { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; margin: 40px 0 12px; }
.doc h3 { font-size: 17px; line-height: 24px; font-weight: 600; margin: 28px 0 8px; }
.doc p, .doc li { font-size: 15px; line-height: 24px; color: var(--text-primary); }
.doc blockquote { margin: 16px 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--bg-surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-secondary); }
.doc blockquote p { color: inherit; }
.doc table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; line-height: 18px; }
.doc th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); font-weight: 500; background: var(--bg-surface-2); padding: 10px 12px; }
.doc td { padding: 10px 12px; border-top: 1px solid var(--border); }
.doc code { font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-surface-2); box-shadow: inset 0 0 0 1px var(--border); border-radius: 6px; padding: 1px 6px; }
.doc pre { background: var(--bg-surface-2); box-shadow: inset 0 0 0 1px var(--border); border-radius: var(--radius-md); padding: 16px 20px; overflow-x: auto; }
.doc pre code { background: none; box-shadow: none; padding: 0; }
.doc hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.doc a { color: var(--accent); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  body.sb-open .sidebar { transform: translateX(0); width: 260px; }
  .kit-main, body.sb-collapsed .kit-main { margin-left: 0; }
  .kit-content { padding: 8px 16px 64px; }
  .header { padding: 0 16px; }
  .header-search { width: 140px; }
  .header-search:focus { width: 180px; }
  .doc { padding: 32px 24px; }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-med) var(--ease);
  }
  body.sb-open .scrim { opacity: 1; pointer-events: auto; }
}
@media (min-width: 901px) {
  .scrim { display: none; }
}
