/*
 * El Panel con el lenguaje visual de ntropix (ADR-020): el de ntropix-core, portado a CSS plano.
 * Origen: ntropix-core @ 39e255c — `src/app/globals.css` (tokens) y `src/components/ui/` (recetas).
 * Para resincronizar, comparar contra ese commit.
 *
 * Blanco y negro, el cyan como única señal (anillo de foco y barra del ítem activo), filetes
 * finos en vez de superficies, General Sans para leer e IBM Plex Mono para rotular y para los
 * códigos. Escalas cerradas: siete escalones de espaciado (4·8·12·16·24·32·48) y cinco
 * tipográficos (12·16·20·24·32). Un solo radio de 2 px. Sin JavaScript (ADR-014).
 */

/* ---- Fuentes, auto-alojadas y embebidas en el binario ----------------------- */
@font-face { font-family: 'General Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/general-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/ibm-plex-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/ibm-plex-mono-600.woff2') format('woff2'); }

/* ---- Tokens: modo claro ----------------------------------------------------- */
:root {
  color-scheme: light dark;

  --color-background: oklch(1 0 0); /* #FFFFFF */
  --color-foreground: oklch(0.1776 0 0); /* #111111 */
  --color-card: oklch(1 0 0);
  --color-muted: oklch(0.9672 0 0); /* #F4F4F4 */
  --color-muted-foreground: oklch(0.5417 0 0); /* #6F6F6F */
  --color-border: oklch(0.8853 0 0); /* #D9D9D9, el filete */
  --color-input: oklch(0.6665 0 0); /* #949494, el borde de lo que se opera */
  --color-primary: oklch(0.1448 0 0); /* #0A0A0A */
  --color-primary-foreground: oklch(0.9851 0 0); /* #FAFAFA */
  --color-ring: oklch(0.6089 0.1109 221.72); /* #0891B2 */
  --color-signal: oklch(0.6089 0.1109 221.72);
  --color-success: oklch(0.9505 0.015 164.72);
  --color-success-foreground: oklch(0.4411 0.0645 162.28);
  --color-warning: oklch(0.9561 0.0277 88.75);
  --color-warning-foreground: oklch(0.444 0.083 80.88);
  --color-destructive: oklch(0.9547 0.0164 22.08);
  --color-destructive-foreground: oklch(0.4605 0.1487 29.56);
  --color-destructive-solid: oklch(0.5003 0.1821 29.51); /* #B42318 */
  --shadow-overlay: 0 8px 24px -8px oklch(0 0 0 / 0.18);

  --font-sans: 'General Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  --radius: 2px;
  --row-height: 44px;
  --control-height: 40px;
  --cell-padding-x: 12px;
  --sidebar-width: 16rem;
}

:root[data-theme='light'] { color-scheme: light; }

/* ---- Tokens: modo oscuro ------------------------------------------------------
 * Los mismos nombres con otros valores, dos veces: el tema elegido en el menú (cookie →
 * `data-theme`) y el del sistema operativo. CSS no deja compartir el bloque entre un selector y
 * un `@media`; `theme_test.go` verifica que las dos copias sean idénticas.
 */
:root[data-theme='dark'] {
  color-scheme: dark;
  --color-background: oklch(0.1448 0 0); /* #0A0A0A */
  --color-foreground: oklch(0.9702 0 0); /* #F5F5F5 */
  --color-card: oklch(0.1638 0 0); /* #0E0E0E */
  --color-muted: oklch(0.2002 0 0); /* #161616 */
  --color-muted-foreground: oklch(0.6334 0 0); /* #8A8A8A */
  --color-border: oklch(0.285 0 0); /* #2A2A2A */
  --color-input: oklch(0.4891 0 0); /* #606060 */
  --color-primary: oklch(0.9702 0 0);
  --color-primary-foreground: oklch(0.1448 0 0);
  --color-ring: oklch(0.7971 0.1339 211.53); /* #22D3EE */
  --color-signal: oklch(0.7971 0.1339 211.53);
  --color-success: oklch(0.26 0.025 162);
  --color-success-foreground: oklch(0.84 0.07 162);
  --color-warning: oklch(0.27 0.03 85);
  --color-warning-foreground: oklch(0.86 0.09 85);
  --color-destructive: oklch(0.27 0.035 27);
  --color-destructive-foreground: oklch(0.82 0.09 27);
  --color-destructive-solid: oklch(0.7109 0.1459 26.41); /* #EF7A70 */
  --shadow-overlay: 0 8px 24px -8px oklch(0 0 0 / 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --color-background: oklch(0.1448 0 0); /* #0A0A0A */
    --color-foreground: oklch(0.9702 0 0); /* #F5F5F5 */
    --color-card: oklch(0.1638 0 0); /* #0E0E0E */
    --color-muted: oklch(0.2002 0 0); /* #161616 */
    --color-muted-foreground: oklch(0.6334 0 0); /* #8A8A8A */
    --color-border: oklch(0.285 0 0); /* #2A2A2A */
    --color-input: oklch(0.4891 0 0); /* #606060 */
    --color-primary: oklch(0.9702 0 0);
    --color-primary-foreground: oklch(0.1448 0 0);
    --color-ring: oklch(0.7971 0.1339 211.53); /* #22D3EE */
    --color-signal: oklch(0.7971 0.1339 211.53);
    --color-success: oklch(0.26 0.025 162);
    --color-success-foreground: oklch(0.84 0.07 162);
    --color-warning: oklch(0.27 0.03 85);
    --color-warning-foreground: oklch(0.86 0.09 85);
    --color-destructive: oklch(0.27 0.035 27);
    --color-destructive-foreground: oklch(0.82 0.09 27);
    --color-destructive-solid: oklch(0.7109 0.1459 26.41); /* #EF7A70 */
    --shadow-overlay: 0 8px 24px -8px oklch(0 0 0 / 0.6);
  }
}

/* Bajo el breakpoint único vuelve el piso táctil. */
@media (width < 768px) {
  :root { --control-height: 44px; }
}

/* ---- Base ------------------------------------------------------------------- */
*, ::before, ::after, ::backdrop { box-sizing: border-box; border-color: var(--color-border); }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, pre, ul { margin: 0; }
h1 { font-size: 2rem; line-height: 2.5rem; font-weight: 600; }
h2 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; }
h3 { font-size: 1rem; line-height: 1.5rem; font-weight: 600; }
strong, b { font-weight: 600; }
small { font-size: 0.75rem; line-height: 1rem; }
ul { padding: 0; list-style: none; }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--color-input); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

code, pre, kbd { font-family: var(--font-mono); font-size: inherit; }
.small { font-size: 0.75rem; line-height: 1rem; }
code.small { word-break: break-all; }

svg.icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* El anillo de foco: 2 px con 2 px de separación, nunca removido. */
:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 2px; }

/* El único movimiento: el color, en hover y foco. */
a, button, .nav-item, tbody tr { transition-property: color, background-color, border-color, text-decoration-color; transition-duration: 150ms; transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* La micro-etiqueta técnica: rotula, nunca es el contenido. */
.label-mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted-foreground);
}

.muted { color: var(--color-muted-foreground); }
.h-xl { font-size: 1.5rem; line-height: 2rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-family: var(--font-mono); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- Logotipo (proporciones de la landing, en em) --------------------------- */
.logo { display: inline-flex; align-items: center; gap: 0.5em; color: var(--color-foreground); text-decoration: none; font-size: 1.25rem; }
.logo svg { height: 1.5em; width: auto; flex-shrink: 0; fill: currentColor; }
.logo .wordmark { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 0.8; font-family: var(--font-sans); }
.logo .name { font-size: 1em; font-weight: 700; letter-spacing: 0.04em; }
.logo .descriptor { margin-top: 0.28em; font-size: 0.5em; font-weight: 600; letter-spacing: 0.08em; }

/* ---- Armazón: barra lateral y contenido sobre el mismo fondo, con un filete ---- */
.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px;
  border-right: 1px solid var(--color-border);
}
.sidebar-header { display: flex; align-items: center; height: 48px; padding: 0 8px; }
.sidebar-header a { display: inline-flex; border-radius: var(--radius); text-decoration: none; }
.nav-group { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.nav-group-label { display: flex; align-items: center; height: 32px; padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  height: var(--control-height); padding: 8px;
  border-radius: var(--radius); border-left: 2px solid transparent;
  color: var(--color-muted-foreground); text-decoration: none;
}
.nav-item:hover { background-color: var(--color-muted); color: var(--color-foreground); }
.nav-item[aria-current='page'] { border-left-color: var(--color-signal); font-weight: 600; color: var(--color-foreground); }
.sidebar-footer { margin-top: auto; }

.user-button {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 48px; padding: 8px;
  border: 0; border-radius: var(--radius); background: none; color: var(--color-muted-foreground);
  font: inherit; text-align: left; cursor: default;
}
.user-button:hover { background-color: var(--color-muted); color: var(--color-foreground); }
.user-button .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-button .who strong { color: var(--color-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 9999px;
  background-color: var(--color-muted); color: var(--color-foreground);
  font-size: 0.75rem; line-height: 1rem; font-weight: 600;
}

.content { display: flex; flex-direction: column; gap: 24px; padding: 24px; min-width: 0; }

/* ---- Menú (popover): lo único que flota además del diálogo ------------------ */
.menu[popover] {
  position: fixed; inset: auto auto 64px 8px; margin: 0;
  width: calc(var(--sidebar-width) - 16px); padding: 4px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background-color: var(--color-card); color: var(--color-foreground);
  box-shadow: var(--shadow-overlay);
}
.menu-label { padding: 4px 8px; font-size: 0.75rem; line-height: 1rem; color: var(--color-muted-foreground); }
.menu-label strong { display: block; color: var(--color-foreground); font-size: 1rem; line-height: 1.5rem; }
.menu-separator { height: 1px; margin: 4px -4px; background-color: var(--color-border); border: 0; }
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px;
  border: 0; border-radius: var(--radius); background: none; color: var(--color-foreground);
  font: inherit; text-align: left; cursor: default;
}
.menu-item:hover { background-color: var(--color-muted); }
a.menu-item { text-decoration: none; }
.menu-item .check { margin-left: auto; width: 6px; height: 6px; border-radius: 9999px; background-color: currentColor; }

/* ---- Encabezado de página: kicker, título y un filete que lo cierra ------------ */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.page-header .heading { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.page-header h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-header .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--color-muted-foreground); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-actions form { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 8px; width: fit-content; color: var(--color-muted-foreground); text-decoration: none; }
.back:hover { color: var(--color-foreground); }

/* ---- Secciones -------------------------------------------------------------- */
.section { display: flex; flex-direction: column; gap: 16px; }
.section + .section { padding-top: 24px; border-top: 1px solid var(--color-border); }
.section-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-header > div { display: flex; flex-direction: column; gap: 4px; }

/* ---- Métricas --------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--color-border); border-radius: var(--radius); background-color: var(--color-card); }
.stat-value { font-size: 1.5rem; line-height: 2rem; font-weight: 600; }
.stat-value small { font-size: 1rem; line-height: 1.5rem; font-weight: 400; color: var(--color-muted-foreground); }

meter { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 4px; border: 0; border-radius: var(--radius); background: var(--color-muted); }
meter::-webkit-meter-bar { height: 4px; border: 0; border-radius: var(--radius); background: var(--color-muted); }
meter::-webkit-meter-optimum-value { background: var(--color-foreground); }
meter::-webkit-meter-suboptimum-value { background: var(--color-warning-foreground); }
meter::-webkit-meter-even-less-good-value { background: var(--color-destructive-solid); }
meter::-moz-meter-bar { background: var(--color-foreground); }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--color-warning-foreground); }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--color-destructive-solid); }
.usage { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }

/* ---- Tablas: sin tarjeta, entre dos filetes ----------------------------------- */
.table-container { width: 100%; overflow-x: auto; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
table { width: 100%; border-collapse: collapse; text-align: left; }
tr { height: var(--row-height); border-bottom: 1px solid var(--color-border); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background-color: var(--color-muted); }
th, td { padding: 8px var(--cell-padding-x); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 8px; }
th:last-child, td:last-child { padding-right: 8px; }
th { font-family: var(--font-mono); font-size: 0.75rem; line-height: 1rem; font-weight: 400; text-transform: uppercase; letter-spacing: 0.14em; color: var(--color-muted-foreground); white-space: nowrap; }
th.num { text-align: right; }
td form { margin: 0; }
td .stack { display: flex; flex-direction: column; }
td .stack, td.nowrap { white-space: nowrap; }
td.nowrap code.small { word-break: normal; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
/* Las acciones por fila van en la primera columna, "Acciones", como íconos con tooltip (como en
 * ntropix-core): el nombre de la acción es el tooltip y el aria-label. */
th.actions, td.actions-cell { width: 1%; white-space: nowrap; }
td.actions-cell > :not(dialog) { display: inline-flex; vertical-align: middle; }
td.actions-cell > * + :not(dialog) { margin-left: 4px; }
td.actions-cell dialog { text-align: left; white-space: normal; }

/* ---- Badge ------------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content;
  padding: 4px 8px; border-radius: var(--radius);
  font-size: 0.75rem; line-height: 1rem; font-weight: 600; white-space: nowrap;
  background-color: var(--color-muted); color: var(--color-muted-foreground);
}
.badge.success { background-color: var(--color-success); color: var(--color-success-foreground); }
.badge.warning { background-color: var(--color-warning); color: var(--color-warning-foreground); }
.badge.destructive { background-color: var(--color-destructive); color: var(--color-destructive-foreground); }
.badge.primary { background-color: var(--color-primary); color: var(--color-primary-foreground); }

/* ---- Alertas ---------------------------------------------------------------- */
.alert {
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 4px; align-items: start;
  padding: 12px 16px; border: 1px solid; border-radius: var(--radius);
}
.alert > svg { grid-row: span 2; margin-top: 4px; }
.alert > :not(svg) { grid-column: 2; }
.alert.success { border-color: var(--color-success-foreground); background-color: var(--color-success); color: var(--color-success-foreground); }
.alert.warning { border-color: var(--color-warning-foreground); background-color: var(--color-warning); color: var(--color-warning-foreground); }
.alert.destructive { border-color: var(--color-destructive-foreground); background-color: var(--color-destructive); color: var(--color-destructive-foreground); }
.alert .alert-title { font-weight: 600; }
.alert code { color: inherit; }
.alert .alert-list { margin: 4px 0 0; padding-left: 1.1em; }
.alert .alert-list a { color: inherit; text-decoration: underline; }

/* El secret que se muestra una sola vez. */
.secret {
  padding: 12px; overflow-x: auto; user-select: all;
  border: 1px solid var(--color-input); border-radius: var(--radius);
  background-color: var(--color-card); color: var(--color-foreground);
}

/* ---- Botones ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0;
  height: var(--control-height); padding: 0 12px;
  border: 1px solid transparent; border-radius: var(--radius);
  background-color: var(--color-primary); color: var(--color-primary-foreground);
  font: inherit; font-weight: 600; white-space: nowrap; text-decoration: none;
  cursor: default; user-select: none;
}
.btn:hover { background-color: color-mix(in oklch, var(--color-primary) 90%, transparent); }
.btn.outline { border-color: var(--color-border); background-color: var(--color-card); color: var(--color-foreground); }
.btn.outline:hover { background-color: var(--color-muted); }
.btn.ghost { background-color: transparent; color: var(--color-foreground); }
.btn.ghost:hover { background-color: var(--color-muted); }
.btn.ghost.danger { color: var(--color-destructive-foreground); }
.btn.destructive { background-color: var(--color-destructive-solid); color: var(--color-primary-foreground); }
.btn.destructive:hover { background-color: color-mix(in oklch, var(--color-destructive-solid) 90%, transparent); }
.btn.block { width: 100%; }

/* Acción de ícono solo: siempre con su tooltip (sin JavaScript: CSS sobre data-tip). */
.icon-action { position: relative; width: var(--control-height); padding: 0; }
.icon-action::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 4px); top: 50%; z-index: 20; transform: translateY(-50%);
  padding: 4px 8px; border-radius: var(--radius);
  background-color: var(--color-primary); color: var(--color-primary-foreground);
  font-size: 0.75rem; line-height: 1rem; font-weight: 400; white-space: nowrap;
  pointer-events: none; visibility: hidden; opacity: 0;
}
.icon-action:hover::after, .icon-action:focus-visible::after { visibility: visible; opacity: 1; }
.btn:disabled { opacity: 0.6; pointer-events: none; }

/* ---- Formularios ------------------------------------------------------------ */
form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.form-grid .wide, .form-grid .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field > .label { font-weight: 600; }
.field .help { font-size: 0.75rem; line-height: 1rem; color: var(--color-muted-foreground); }

input, select, textarea {
  width: 100%; min-width: 0; height: var(--control-height); padding: 0 12px;
  border: 1px solid var(--color-input); border-radius: var(--radius);
  background-color: var(--color-card); color: var(--color-foreground);
  font: inherit; outline: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 2px; }
input::placeholder { color: color-mix(in oklch, var(--color-muted-foreground) 60%, transparent); }
select {
  -webkit-appearance: none; appearance: none; padding-right: 36px;
  background-image: url('/static/chevron-down.svg'); background-repeat: no-repeat;
  background-position: right 12px center; background-size: 16px 16px;
}
input[type='checkbox'] { width: 16px; height: 16px; padding: 0; accent-color: var(--color-primary); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.filters .field { flex: 1 1 200px; }
.filters .check { display: flex; align-items: center; gap: 8px; height: var(--control-height); }

/* Pie de tabla: tamaño a la izquierda, paginado al centro, rango a la derecha. */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.page-size { display: flex; align-items: center; gap: 8px; justify-self: start; }
.page-size select { width: auto; }
.pager-nav { display: flex; align-items: center; gap: 4px; }
.pager-info { justify-self: end; white-space: nowrap; }
.pager-gap { display: inline-flex; align-items: center; justify-content: center; width: var(--control-height); color: var(--color-muted-foreground); }
.btn.square { width: var(--control-height); padding: 0; font-family: var(--font-mono); font-weight: 400; }
.btn.square[aria-current='page'] { font-weight: 600; }
.btn[aria-disabled='true'] { opacity: 0.4; pointer-events: none; }
@media (width < 768px) {
  .pager { grid-template-columns: 1fr; justify-items: center; }
  .page-size, .pager-info { justify-self: center; }
}

/* Con panel.js los filtros se aplican solos: el botón queda solo para quien no tiene JavaScript. */
.js .js-hide { display: none; }
[data-results] { display: flex; flex-direction: column; gap: 16px; }
/* Mientras llega la página nueva. */
[data-results][aria-busy='true'] { opacity: 0.6; transition: opacity 150ms; }

/* ---- Diálogo ----------------------------------------------------------------
 * Modal con `command="show-modal"`. Cuando el servidor rechaza un formulario se renderiza con
 * `open` (no modal): mismo lugar y misma forma, sin el fondo.
 */
dialog {
  position: fixed; inset: 0; z-index: 50; margin: auto;
  width: min(32rem, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 24px; border: 1px solid var(--color-border); border-radius: var(--radius);
  background-color: var(--color-card); color: var(--color-foreground);
  box-shadow: var(--shadow-overlay);
}
dialog::backdrop { background-color: color-mix(in oklch, var(--color-foreground) 20%, transparent); }
.dialog-body { display: flex; flex-direction: column; gap: 16px; }
.dialog-header { display: flex; flex-direction: column; gap: 4px; padding-right: 32px; }
.dialog-header h2 { font-size: 1.25rem; line-height: 1.75rem; }
.dialog-header p { color: var(--color-muted-foreground); }
.dialog-footer { display: flex; flex-direction: column-reverse; gap: 8px; }
.dialog-close { position: absolute; top: 8px; right: 8px; width: var(--control-height); padding: 0; }
@media (width >= 768px) {
  .dialog-footer { flex-direction: row; justify-content: flex-end; }
}

/* ---- Vacío ------------------------------------------------------------------ */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px; text-align: center; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.empty strong { font-size: 1.25rem; line-height: 1.75rem; }
.empty p { color: var(--color-muted-foreground); }

/* ---- Login: la única pantalla fuera del armazón, en tarjeta ------------------ */
.login-page { display: flex; flex-direction: column; min-height: 100vh; background-color: var(--color-muted); }
.login-main { display: flex; flex: 1; align-items: center; justify-content: center; padding: 48px 16px; }
.login-card { width: 100%; max-width: 28rem; border: 1px solid var(--color-border); border-radius: var(--radius); background-color: var(--color-card); box-shadow: var(--shadow-overlay); }
.login-card > div { display: flex; flex-direction: column; gap: 32px; padding: 24px; }
.login-card > div + div { gap: 16px; border-top: 1px solid var(--color-border); }
.login-card .heading { display: flex; flex-direction: column; gap: 8px; }
.login-footer { display: flex; justify-content: center; padding: 0 32px 24px; }
@media (width >= 768px) {
  .login-card > div { padding: 32px; }
  .login-footer { justify-content: flex-end; }
}

/* ---- Bajo 768 px la barra lateral pasa a ser una barra superior -------------- */
@media (width < 768px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 4px;
    border-right: 0; border-bottom: 1px solid var(--color-border);
    background-color: var(--color-background);
  }
  .sidebar-header { padding: 0 8px 0 0; }
  .sidebar-header .wordmark { display: none; }
  .nav-group { flex-direction: row; padding: 0; flex: 1; min-width: 0; overflow-x: auto; }
  .nav-group-label { display: none; }
  .nav-item { border-left: 0; border-bottom: 2px solid transparent; border-radius: 0; }
  .nav-item[aria-current='page'] { border-bottom-color: var(--color-signal); }
  .sidebar-footer { margin: 0; }
  .user-button { width: auto; height: var(--control-height); padding: 4px; }
  .user-button .who, .user-button > svg { display: none; }
  .menu[popover] { inset: 56px 8px auto auto; width: min(16rem, calc(100vw - 16px)); }
  .content { padding: 16px; }
  .page-header h1 { white-space: normal; }
}
