/*
 * Panel — sistema de diseño del área de administración (propuesta).
 * Capa 1: primitivas (rampas). Capa 2: tokens semánticos (lo único que usan los componentes).
 * El admin tiene su propio tema: de la tienda solo hereda --brand (color de marca), nunca la paleta completa.
 */

/* ───────────── 1. Tokens ───────────── */
:root {
  color-scheme: light;
  --font-sans: "Inter", "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Marca: el único valor que viene de la tienda */
  --brand: #2266b8;
  --brand-hover: color-mix(in oklab, var(--brand) 88%, black);
  --brand-soft: color-mix(in oklab, var(--brand) 9%, white);
  --brand-soft-2: color-mix(in oklab, var(--brand) 16%, white);
  --brand-text: color-mix(in oklab, var(--brand) 82%, black);
  --on-brand: #ffffff;

  /* Superficies */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --sunken: #f0f2f5;
  --overlay: rgba(12, 18, 28, 0.42);
  --sidebar: #fbfcfd;

  /* Bordes */
  --border: #e4e7ec;
  --border-strong: #cdd3dc;
  --divider: #eef0f3;

  /* Texto */
  --text: #0f1729;
  --text-2: #475467;
  --text-3: #667085;
  --text-disabled: #98a2b3;
  --text-inverse: #ffffff;

  /* Estados (fg = texto/icono AA sobre bg, bg = fondo suave, bd = borde, solid = punto/acento) */
  --neutral-fg: #475467; --neutral-bg: #f0f2f5; --neutral-bd: #dde1e7; --neutral-solid: #98a2b3;
  --info-fg: var(--brand-text); --info-bg: var(--brand-soft); --info-bd: color-mix(in oklab, var(--brand) 28%, white); --info-solid: var(--brand);
  --success-fg: #0f6b3a; --success-bg: #e8f6ee; --success-bd: #b5e2c8; --success-solid: #16a05a;
  --warning-fg: #8a4b00; --warning-bg: #fff5e1; --warning-bd: #f5d7a1; --warning-solid: #f2a20c;
  --danger-fg: #b42318; --danger-bg: #fdeeec; --danger-bd: #f5c2bc; --danger-solid: #d92d20;
  --violet-fg: #5b3fc4; --violet-bg: #f1edfd; --violet-bd: #d8cdf8; --violet-solid: #7a5af8;

  /* Datos (gráficos) */
  --chart-1: var(--brand);
  --chart-compare: #98a2b3;
  --chart-grid: #eceef2;
  --chart-axis: #cdd3dc;

  /* Elevación */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 32px -8px rgba(16, 24, 40, 0.16), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
  --ring: 0 0 0 3px color-mix(in oklab, var(--brand) 28%, transparent);

  /* Forma */
  --r-xs: 4px;   /* chips de tabla, kbd */
  --r-sm: 6px;   /* controles: botón, input, select */
  --r-md: 8px;   /* menús, popovers, toasts */
  --r-lg: 12px;  /* tarjetas, paneles, diálogos */
  --r-full: 999px;

  /* Espacio (base 4) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Tipografía */
  --t-xs: 12px; --t-sm: 13px; --t-base: 14px; --t-md: 16px; --t-lg: 18px; --t-xl: 20px; --t-2xl: 24px; --t-3xl: 30px;

  /* Densidad (cómoda por defecto) */
  --ctl-h: 36px; --ctl-h-sm: 30px; --ctl-h-lg: 40px;
  --row-h: 48px;
  --card-pad: 20px;
  --page-pad: 32px;

  /* Movimiento */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 260ms;

  --sidebar-w: 248px;
  --topbar-h: 56px;
}

:root[data-density="compact"] {
  --ctl-h: 32px; --ctl-h-sm: 26px; --ctl-h-lg: 36px;
  --row-h: 38px;
  --card-pad: 16px;
  --page-pad: 24px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-hover: color-mix(in oklab, var(--brand) 85%, white);
  --brand-soft: color-mix(in oklab, var(--brand) 16%, #121823);
  --brand-soft-2: color-mix(in oklab, var(--brand) 26%, #121823);
  --brand-text: color-mix(in oklab, var(--brand) 55%, white);

  --bg: #0b0f16;
  --surface: #121821;
  --surface-2: #151c26;
  --sunken: #0e131b;
  --overlay: rgba(0, 0, 0, 0.6);
  --sidebar: #0e131b;

  --border: #232c3a;
  --border-strong: #334055;
  --divider: #1b2330;

  --text: #e8edf4;
  --text-2: #aab4c3;
  --text-3: #8592a6;
  --text-disabled: #556073;

  --neutral-fg: #b7c0cd; --neutral-bg: #1b2330; --neutral-bd: #2a3444; --neutral-solid: #6b778a;
  --info-bd: color-mix(in oklab, var(--brand) 40%, #121823);
  --success-fg: #5ed39a; --success-bg: #0f2a1d; --success-bd: #1d4a33; --success-solid: #2fb871;
  --warning-fg: #f5bd57; --warning-bg: #2c2110; --warning-bd: #4d3814; --warning-solid: #f2a20c;
  --danger-fg: #f6877e; --danger-bg: #2f1514; --danger-bd: #57221f; --danger-solid: #f04438;
  --violet-fg: #b3a2fb; --violet-bg: #1f1938; --violet-bd: #392d6b; --violet-solid: #9b87f5;

  --chart-compare: #5d6a7e;
  --chart-grid: #1c2431;
  --chart-axis: #2f3a4c;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 12px -4px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.7);
}

/* ───────────── 2. Base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.i-lg { width: 20px; height: 20px; }
svg.i-sm { width: 14px; height: 14px; }

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

/* Tipografía por rol */
.t-display { font-size: var(--t-3xl); font-weight: 650; line-height: 1.15; letter-spacing: -0.025em; }
.t-title { font-size: var(--t-2xl); font-weight: 650; line-height: 1.2; letter-spacing: -0.02em; }
.t-heading { font-size: var(--t-md); font-weight: 600; line-height: 1.35; }
.t-subheading { font-size: var(--t-base); font-weight: 600; }
.t-body { font-size: var(--t-base); }
.t-small { font-size: var(--t-sm); }
.t-caption { font-size: var(--t-xs); color: var(--text-3); }
.t-overline { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.t-metric { font-size: 28px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* ───────────── 3. Componentes ───────────── */

/* Botón */
.btn {
  --_bg: var(--surface); --_fg: var(--text); --_bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl-h); padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--_bd); background: var(--_bg); color: var(--_fg);
  font-size: var(--t-sm); font-weight: 550; white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-disabled); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-primary { --_bg: var(--brand); --_fg: var(--on-brand); --_bd: transparent; }
.btn-primary:hover { background: var(--brand-hover); border-color: transparent; }
.btn-ghost { --_bg: transparent; --_bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--sunken); border-color: transparent; color: var(--text); }
.btn-danger { --_bg: var(--danger-solid); --_fg: #fff; --_bd: transparent; }
.btn-danger:hover { background: color-mix(in oklab, var(--danger-solid) 88%, black); border-color: transparent; }
.btn-danger-soft { --_bg: var(--surface); --_fg: var(--danger-fg); --_bd: var(--danger-bd); }
.btn-danger-soft:hover { background: var(--danger-bg); border-color: var(--danger-bd); }
.btn-link { --_bg: transparent; --_bd: transparent; box-shadow: none; color: var(--brand-text); padding: 0; height: auto; }
.btn-link:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn-sm { height: var(--ctl-h-sm); padding: 0 10px; font-size: var(--t-xs); gap: 4px; }
.btn-lg { height: var(--ctl-h-lg); padding: 0 18px; font-size: var(--t-base); }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-sm.btn-icon { width: var(--ctl-h-sm); }
.btn .spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* Campos */
.field { display: grid; gap: 6px; }
.label { font-size: var(--t-sm); font-weight: 550; color: var(--text); }
.label .opt { font-weight: 400; color: var(--text-3); }
.hint { font-size: var(--t-xs); color: var(--text-3); }
.error-text { font-size: var(--t-xs); color: var(--danger-fg); display: flex; gap: 4px; align-items: center; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl-h); padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: var(--t-sm); box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-disabled); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-disabled); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--ring); outline: none; }
.input[aria-invalid="true"] { border-color: var(--danger-solid); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger-solid) 25%, transparent); }
.input[disabled] { background: var(--sunken); color: var(--text-disabled); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-group > .affix { position: absolute; right: 10px; color: var(--text-3); font-size: var(--t-sm); pointer-events: none; }
.input-addon { display: flex; }
.input-addon > .addon { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: var(--sunken); color: var(--text-3); font-size: var(--t-sm); }
.input-addon > .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* Checkbox, radio, switch */
.check { display: inline-flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: var(--t-sm); }
.check input { appearance: none; width: 16px; height: 16px; margin: 2px 0 0; flex: none; border: 1px solid var(--border-strong); border-radius: var(--r-xs); background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: all var(--dur-1) var(--ease); }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--brand); border-color: var(--brand); }
.check input[type="checkbox"]:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.check input[type="checkbox"]:indeterminate { background: var(--brand); border-color: var(--brand); }
.check input[type="checkbox"]:indeterminate::after { content: ""; width: 8px; height: 2px; background: #fff; border-radius: 1px; }
.check input[type="radio"]:checked::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--t-sm); }
.switch input { appearance: none; width: 34px; height: 20px; margin: 0; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur-2) var(--ease); flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-2) var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(14px); }

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; border-radius: var(--r-sm); background: var(--sunken); border: 1px solid var(--border); gap: 2px; }
.segmented button { height: calc(var(--ctl-h-sm) - 2px); padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text-2); font-size: var(--t-xs); font-weight: 550; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Badge y estado */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-full); font-size: var(--t-xs); font-weight: 550; white-space: nowrap; border: 1px solid var(--_bd, var(--neutral-bd)); background: var(--_bg, var(--neutral-bg)); color: var(--_fg, var(--neutral-fg)); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--_dot, currentColor); flex: none; }
.badge.neutral { --_fg: var(--neutral-fg); --_bg: var(--neutral-bg); --_bd: var(--neutral-bd); --_dot: var(--neutral-solid); }
.badge.info { --_fg: var(--info-fg); --_bg: var(--info-bg); --_bd: var(--info-bd); --_dot: var(--info-solid); }
.badge.success { --_fg: var(--success-fg); --_bg: var(--success-bg); --_bd: var(--success-bd); --_dot: var(--success-solid); }
.badge.warning { --_fg: var(--warning-fg); --_bg: var(--warning-bg); --_bd: var(--warning-bd); --_dot: var(--warning-solid); }
.badge.danger { --_fg: var(--danger-fg); --_bg: var(--danger-bg); --_bd: var(--danger-bd); --_dot: var(--danger-solid); }
.badge.violet { --_fg: var(--violet-fg); --_bg: var(--violet-bg); --_bd: var(--violet-bd); --_dot: var(--violet-solid); }
.badge.outline { --_bg: var(--surface); --_bd: var(--border-strong); --_fg: var(--text-2); }
.badge.custom { --_bg: var(--surface); --_bd: var(--border); --_fg: var(--text); }
.badge.sq { border-radius: var(--r-xs); height: 20px; padding: 0 6px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--sunken); color: var(--text-2); font-variant-numeric: tabular-nums; }
.count.attn { background: var(--brand); color: var(--on-brand); }
.count.danger { background: var(--danger-solid); color: #fff; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-xs); border: 1px solid var(--border); border-bottom-width: 2px; background: var(--surface); font-size: 11px; font-weight: 550; color: var(--text-3); font-family: var(--font-sans); }

/* Avatar */
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft-2); color: var(--brand-text); font-size: 12px; font-weight: 650; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.sq { border-radius: var(--r-sm); }

/* Tarjeta / panel */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 14px var(--card-pad); border-bottom: 1px solid var(--divider); min-height: 56px; }
.card-h .t-heading { flex: 1; min-width: 0; font-size: var(--t-base); }
.card-h .sub { font-size: var(--t-xs); color: var(--text-3); font-weight: 400; margin-top: 1px; }
.card-b { padding: var(--card-pad); }
.card-f { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px var(--card-pad); border-top: 1px solid var(--divider); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card.flush > .table-wrap { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: none; }

/* KPI */
.kpi { padding: var(--card-pad); display: grid; gap: 6px; position: relative; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: var(--t-sm); color: var(--text-2); font-weight: 500; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--t-xs); color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: var(--t-xs); padding: 1px 6px; border-radius: var(--r-xs); font-variant-numeric: tabular-nums; }
.delta.up { color: var(--success-fg); background: var(--success-bg); }
.delta.down { color: var(--danger-fg); background: var(--danger-bg); }
.delta.flat { color: var(--text-3); background: var(--sunken); }
.spark { height: 36px; width: 100%; display: block; margin-top: 4px; }

/* Tabla */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); }
.table th { position: sticky; top: 0; z-index: 1; height: 36px; padding: 0 12px; text-align: left; font-size: var(--t-xs); font-weight: 550; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort { display: inline-flex; vertical-align: middle; margin-left: 2px; opacity: 0.6; }
.table td { height: var(--row-h); padding: 0 12px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-1) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[aria-selected="true"] { background: var(--brand-soft); }
.table .r { text-align: right; }
.table .w-check { width: 40px; padding-right: 0; }
.table .cell-main { font-weight: 550; color: var(--text); }
.table .cell-sub { font-size: var(--t-xs); color: var(--text-3); }
.table a.cell-link { font-weight: 600; color: var(--text); }
.table a.cell-link:hover { color: var(--brand-text); text-decoration: underline; text-underline-offset: 3px; }
.thumb { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--sunken); border: 1px solid var(--border); flex: none; display: grid; place-items: center; color: var(--text-3); }
.row-actions { opacity: 0; transition: opacity var(--dur-1); }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }

/* Barra de filtros y acciones masivas */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .grow { flex: 1 1 260px; max-width: 380px; }
.chip-filter { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl-h-sm); padding: 0 10px; border-radius: var(--r-full); border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text-2); font-size: var(--t-xs); font-weight: 550; cursor: pointer; }
.chip-filter:hover { border-color: var(--text-3); color: var(--text); }
.chip-filter.on { border-style: solid; border-color: var(--info-bd); background: var(--info-bg); color: var(--info-fg); }
.chip-filter .x { opacity: 0.7; }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: var(--r-md); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: var(--t-sm); }
.bulkbar .btn { --_bg: transparent; --_fg: var(--surface); --_bd: color-mix(in oklab, var(--surface) 25%, transparent); box-shadow: none; }
.bulkbar .btn:hover { background: color-mix(in oklab, var(--surface) 12%, transparent); }

/* Pestañas de vista (filtros guardados) y de sección */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-3); font-size: var(--t-sm); font-weight: 550; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--brand); }

/* Avisos */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--_bd); background: var(--_bg); color: var(--text); font-size: var(--t-sm); }
.callout > svg { color: var(--_fg); margin-top: 2px; }
.callout .callout-t { font-weight: 600; color: var(--_fg); }
.callout.info { --_bg: var(--info-bg); --_bd: var(--info-bd); --_fg: var(--info-fg); }
.callout.success { --_bg: var(--success-bg); --_bd: var(--success-bd); --_fg: var(--success-fg); }
.callout.warning { --_bg: var(--warning-bg); --_bd: var(--warning-bd); --_fg: var(--warning-fg); }
.callout.danger { --_bg: var(--danger-bg); --_bd: var(--danger-bd); --_fg: var(--danger-fg); }

/* Toast */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: grid; gap: 8px; width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: var(--t-sm); animation: toast-in var(--dur-3) var(--ease); }
.toast .tt { font-weight: 600; }
.toast > svg { margin-top: 2px; }
.toast.success > svg { color: var(--success-solid); }
.toast.danger > svg { color: var(--danger-solid); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* Diálogo */
.dialog-backdrop { position: fixed; inset: 0; z-index: 80; background: var(--overlay); display: grid; place-items: center; padding: 20px; animation: fade var(--dur-2) var(--ease); }
.dialog { width: min(440px, 100%); background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop var(--dur-3) var(--ease); }
.dialog-b { padding: 20px 20px 4px; display: grid; gap: 8px; }
.dialog-f { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 20px; }
.dialog-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--danger-bg); color: var(--danger-fg); margin-bottom: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* Menú / popover */
.menu { min-width: 200px; padding: 4px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: var(--t-sm); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 8px; border: 0; background: none; border-radius: 4px; text-align: left; color: var(--text); cursor: pointer; }
.menu-item:hover, .menu-item[data-active="true"] { background: var(--sunken); }
.menu-item svg { color: var(--text-3); }
.menu-item .kbd { margin-left: auto; }
.menu-item.danger { color: var(--danger-fg); }
.menu-item.danger svg { color: var(--danger-fg); }
.menu-sep { height: 1px; background: var(--divider); margin: 4px -4px; }
.menu-label { padding: 6px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }

/* Tooltip */
.tip { position: relative; }
.tip::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(2px); padding: 4px 8px; border-radius: var(--r-xs); background: var(--text); color: var(--surface); font-size: 11px; font-weight: 500; white-space: nowrap; opacity: 0; pointer-events: none; transition: all var(--dur-1) var(--ease); z-index: 50; }
.tip:hover::after, .tip:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Vacío, esqueleto, progreso */
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 40px 24px; }
.empty-icon { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--sunken); color: var(--text-3); border: 1px solid var(--border); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--sunken) 0%, var(--divider) 50%, var(--sunken) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--r-xs); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.progress { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }

/* Línea de tiempo */
.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 24px 1fr; gap: 12px; position: relative; padding-bottom: 16px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 11.5px; top: 24px; bottom: 0; width: 1px; background: var(--border); }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--text-3); border: 1px solid var(--border); }
.tl-dot.success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.tl-dot.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.tl-dot svg { width: 12px; height: 12px; }

/* Lista de descripción */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: var(--t-sm); margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.dl .total { font-weight: 650; padding-top: 8px; border-top: 1px solid var(--divider); color: var(--text); font-size: var(--t-base); }

/* Paginación */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; font-size: var(--t-xs); color: var(--text-3); border-top: 1px solid var(--divider); }

/* Stepper de estado de pedido */
.stepper { display: flex; align-items: center; gap: 0; }
.step { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); font-weight: 550; color: var(--text-3); white-space: nowrap; }
.step .b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); background: var(--surface); font-size: 11px; }
.step.done { color: var(--text-2); }
.step.done .b { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.current { color: var(--text); }
.step.current .b { border-color: var(--brand); color: var(--brand-text); box-shadow: 0 0 0 3px var(--brand-soft-2); }
.step-line { flex: 1; min-width: 16px; height: 1.5px; background: var(--border-strong); margin: 0 8px; }
.step-line.done { background: var(--brand); }

/* ───────────── 4. Marco (app shell) ───────────── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border); }
.sb-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid transparent; }
.sb-logo { width: 28px; height: 28px; border-radius: 7px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.sb-store { min-width: 0; flex: 1; line-height: 1.2; }
.sb-store b { display: block; font-size: var(--t-sm); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-store span { font-size: 11px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.sb-store .live { width: 6px; height: 6px; border-radius: 50%; background: var(--success-solid); box-shadow: 0 0 0 2px var(--success-bg); }
.sb-scroll { flex: 1; overflow-y: auto; padding: 8px 10px 16px; scrollbar-width: thin; }
.sb-group { margin-top: 14px; }
.sb-group-label { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase; }
.sb-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text-2); font-size: var(--t-sm); font-weight: 500; position: relative; }
.sb-item svg { color: var(--text-3); }
.sb-item:hover { background: var(--sunken); color: var(--text); }
.sb-item[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border); }
.sb-item[aria-current="page"] svg { color: var(--brand); }
.sb-item .count { margin-left: auto; }
.sb-sub { margin: 2px 0 4px 26px; padding-left: 8px; border-left: 1px solid var(--border); display: grid; gap: 1px; }
.sb-sub a { display: flex; align-items: center; height: 28px; padding: 0 8px; border-radius: var(--r-xs); font-size: var(--t-xs); color: var(--text-3); font-weight: 500; }
.sb-sub a:hover { color: var(--text); background: var(--sunken); }
.sb-sub a[aria-current="page"] { color: var(--text); font-weight: 600; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; display: grid; gap: 8px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r-sm); }
.sb-user:hover { background: var(--sunken); }
.sb-user .who { min-width: 0; flex: 1; line-height: 1.25; }
.sb-user .who b { display: block; font-size: var(--t-sm); font-weight: 600; }
.sb-user .who span { font-size: 11px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 var(--page-pad); background: color-mix(in oklab, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--text-3); min-width: 0; flex: 1; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-disabled); }
.crumbs [aria-current] { color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-btn { display: flex; align-items: center; gap: 8px; width: 280px; height: var(--ctl-h-sm); padding: 0 8px 0 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-3); font-size: var(--t-sm); cursor: pointer; box-shadow: var(--shadow-xs); }
.search-btn:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-btn > span:not(.kbd) { flex: 1; text-align: left; }
.icon-btn { position: relative; display: grid; place-items: center; width: var(--ctl-h-sm); height: var(--ctl-h-sm); border-radius: var(--r-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--sunken); color: var(--text); }
.icon-btn .pip { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger-solid); box-shadow: 0 0 0 2px var(--bg); }

.page { padding: 28px var(--page-pad) 64px; display: grid; gap: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-h .lead { color: var(--text-2); font-size: var(--t-sm); margin-top: 4px; }
.page-h .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }

/* Bandeja de tareas pendientes */
.inbox { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.inbox-item { display: grid; gap: 4px; padding: 16px var(--card-pad); border-right: 1px solid var(--divider); position: relative; transition: background var(--dur-1); }
.inbox-item:last-child { border-right: 0; }
.inbox-item:hover { background: var(--surface-2); }
.inbox-item:first-child:hover { border-radius: var(--r-lg) 0 0 var(--r-lg); }
.inbox-item:last-child:hover { border-radius: 0 var(--r-lg) var(--r-lg) 0; }
.inbox-item .n { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.inbox-item .l { font-size: var(--t-xs); color: var(--text-2); }
.inbox-item .tag { position: absolute; top: 16px; right: 16px; }
.inbox-item.zero .n { color: var(--text-disabled); }

/* Gráfico */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: var(--t-xs); min-width: 168px; opacity: 0; transition: opacity var(--dur-1); z-index: 5; }
.chart-tip.on { opacity: 1; }
.chart-tip .tr { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-top: 4px; }
.chart-tip .sw { width: 10px; height: 2px; border-radius: 1px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.legend { display: flex; gap: 16px; font-size: var(--t-xs); color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 6px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--chart-compare) 0 3px, transparent 3px 5px) !important; }

.bar-list { display: grid; gap: 12px; }
.bar-list li { list-style: none; display: grid; gap: 6px; }
.bar-list .top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: var(--t-sm); }
.bar-list .bar { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.bar-list .bar span { display: block; height: 100%; border-radius: inherit; background: var(--chart-1); }

/* Paleta de comandos */
.cmdk { width: min(620px, 100%); align-self: start; margin-top: 12vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop var(--dur-3) var(--ease); }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; border-bottom: 1px solid var(--divider); }
.cmdk-in input { flex: 1; border: 0; outline: none; background: none; font-size: var(--t-md); }
.cmdk-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--divider); font-size: 11px; color: var(--text-3); background: var(--surface-2); }

/* Responsive */
.menu-toggle { display: none !important; }
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inbox { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inbox-item:nth-child(3) { border-right: 0; }
  .inbox-item:nth-child(-n + 3) { border-bottom: 1px solid var(--divider); }
  .g-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 70; left: 0; width: 280px; transform: translateX(-100%); transition: transform var(--dur-3) var(--ease); box-shadow: var(--shadow-lg); }
  .shell[data-menu="open"] .sidebar { transform: none; }
  .menu-toggle { display: grid !important; }
  .search-btn { width: auto; }
  .search-btn > span { display: none; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --page-pad: 16px; }
  .g-4 { grid-template-columns: 1fr; gap: 10px; }
  .shell[data-menu="open"]::after { content: ""; position: fixed; inset: 0; z-index: 65; background: var(--overlay); }
  .inbox { grid-template-columns: 1fr 1fr; }
  .inbox-item { border-right: 0 !important; border-bottom: 1px solid var(--divider); }
  .t-metric { font-size: 22px; }
  .hide-sm { display: none !important; }
}
