/* ============================================================
   AgoraFC · Sistema de diseño
   Tokens, componentes y utilidades. Sin dependencias externas.
   ============================================================ */

:root {
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --surface-2:     #fafbfe;
  --surface-3:     #f1f4fa;
  --ink:           #0e1729;
  --ink-2:         #334155;
  --muted:         #6b7a90;
  --line:          #e4e8f0;
  --line-2:        #eef1f7;

  --brand:         #2b4bf2;
  --brand-ink:     #1e37b8;
  --brand-soft:    #eef1fe;
  --accent:        #0e9f8f;
  --accent-soft:   #e6f7f5;

  --ok:            #0f9f6e;
  --ok-soft:       #e6f6ef;
  --warn:          #b45309;
  --warn-soft:     #fef4e6;
  --danger:        #c62828;
  --danger-soft:   #fdecec;
  --info:          #1d4ed8;
  --info-soft:     #eaefff;

  --radio:         12px;
  --radio-sm:      8px;
  --sombra:        0 1px 2px rgba(16,24,40,.04), 0 8px 24px -12px rgba(16,24,40,.12);
  --sombra-alta:   0 24px 60px -20px rgba(16,24,40,.28);
  --lateral:       250px;
  --lateral-min:   74px;
  --altura-barra:  60px;
  --fuente:        ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:          ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-tema="oscuro"] {
  --bg:            #0a1020;
  --surface:       #111a2e;
  --surface-2:     #16203a;
  --surface-3:     #1a2540;
  --ink:           #eef2fb;
  --ink-2:         #c2cbe0;
  --muted:         #8a99b5;
  --line:          #22304d;
  --line-2:        #1a2740;
  --brand-soft:    #1a2450;
  --accent-soft:   #0d302c;
  --ok-soft:       #0c2f24;
  --warn-soft:     #33240c;
  --danger-soft:   #341417;
  --info-soft:     #16204a;
  --sombra:        0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  --sombra-alta:   0 24px 60px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fuente);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; color: var(--ink); }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; }
p  { margin: 0; }
a  { color: var(--brand); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

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

/* ---------- Iconos ------------------------------------------- */

.ico {
  width: 18px; height: 18px;
  flex: 0 0 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico.grande { width: 22px; height: 22px; flex-basis: 22px; }
.ico.pequeno { width: 14px; height: 14px; flex-basis: 14px; }

/* ---------- Estructura --------------------------------------- */

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

.lateral {
  width: var(--lateral);
  flex: 0 0 var(--lateral);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .18s ease, flex-basis .18s ease;
  z-index: 40;
}

.app[data-mini="1"] .lateral { width: var(--lateral-min); flex-basis: var(--lateral-min); }
.app[data-mini="1"] .ocultable { display: none; }

.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--altura-barra);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.marca-simbolo {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--brand), var(--accent));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
  letter-spacing: -.04em;
}

.marca-texto { display: flex; flex-direction: column; line-height: 1.15; }
.marca-texto strong { font-size: 14px; letter-spacing: -.02em; }
.marca-texto span   { font-size: 10.5px; color: var(--muted); letter-spacing: .02em; }

.nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-grupo { margin-bottom: 16px; }

.nav-titulo {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 8px;
}

.nav-enlace {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radio-sm);
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13.5px;
  transition: background .12s, color .12s;
  position: relative;
}

.nav-enlace:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-enlace[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 620; }
[data-tema="oscuro"] .nav-enlace[aria-current="page"] { color: #b9c6ff; }

.nav-enlace[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px; top: 50%;
  width: 3px; height: 18px;
  transform: translateY(-50%);
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-insignia {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 20px;
  padding: 1px 7px;
}

.nav-insignia.ambar { background: var(--warn-soft); color: var(--warn); }

.lateral-pie {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.avatar {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
}

.lateral-pie .datos { min-width: 0; line-height: 1.2; }
.lateral-pie .datos strong { display: block; font-size: 12.5px; }
.lateral-pie .datos span   { font-size: 11px; color: var(--muted); }

/* ---------- Barra superior ----------------------------------- */

.cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.barra {
  height: var(--altura-barra);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.migas { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.migas strong { color: var(--ink); font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.migas .sep { opacity: .45; }
.migas a { color: var(--muted); }

.barra-acciones { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.buscador {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 10px;
  min-width: 210px;
  cursor: text;
}

.buscador input {
  border: 0; background: none; outline: none;
  font-family: inherit; font-size: 13px; color: var(--ink);
  width: 100%;
}

.buscador input::placeholder { color: var(--muted); }
.buscador kbd { flex: 0 0 auto; }

kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--muted);
}

.contenido { padding: 22px 20px 60px; max-width: 1340px; width: 100%; margin: 0 auto; }

/* ---------- Botones ------------------------------------------ */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radio-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: filter .12s, background .12s, border-color .12s;
  white-space: nowrap;
  text-decoration: none;
}

.boton:hover { filter: brightness(1.06); text-decoration: none; }
.boton:active { transform: translateY(1px); }
.boton:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.boton.secundario { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.boton.secundario:hover { background: var(--surface-2); }
.boton.fantasma { background: transparent; color: var(--muted); }
.boton.fantasma:hover { background: var(--surface-2); color: var(--ink); }
.boton.peligro { background: var(--danger); }
.boton.exito { background: var(--ok); }
.boton.pequeno { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.boton.bloque { width: 100%; }

.boton-icono {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 9px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
  flex: 0 0 34px;
}
.boton-icono:hover { background: var(--surface-2); color: var(--ink); }
.boton-icono[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- Tarjetas ----------------------------------------- */

.tarjeta {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
}

.tarjeta-cabecera {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}

.tarjeta-cabecera .derecha { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tarjeta-cuerpo { padding: 18px; }
.tarjeta-pie { padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); }

/* ---------- Métricas ----------------------------------------- */

.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }

.metrica {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radio);
  padding: 15px 17px;
  box-shadow: var(--sombra);
}

.metrica-etiqueta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 550; margin-bottom: 7px; }
.metrica-valor { font-size: 25px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.metrica-pie { margin-top: 7px; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.tendencia { font-weight: 650; font-size: 11.5px; display: inline-flex; align-items: center; gap: 3px; }
.tendencia.arriba { color: var(--ok); }
.tendencia.abajo { color: var(--danger); }

.punto { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.punto.ok { background: var(--ok); }
.punto.warn { background: var(--warn); }
.punto.danger { background: var(--danger); }
.punto.info { background: var(--info); }
.punto.neutro { background: var(--muted); }

/* ---------- Rejillas ----------------------------------------- */

.rejilla { display: grid; gap: 16px; }
.rejilla.dos { grid-template-columns: 1.65fr 1fr; }
.rejilla.igual { grid-template-columns: 1fr 1fr; }
.rejilla.tres { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1080px) {
  .rejilla.dos, .rejilla.igual, .rejilla.tres { grid-template-columns: 1fr; }
}

/* ---------- Tablas ------------------------------------------- */

.tabla-envoltura { overflow-x: auto; }

table.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }

table.tabla th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 13px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.tabla th.ordenable { cursor: pointer; user-select: none; }
table.tabla th.ordenable:hover { color: var(--ink); }
table.tabla th .flecha { opacity: .4; font-size: 9px; margin-left: 3px; }

table.tabla td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  color: var(--ink-2);
}

table.tabla tbody tr { transition: background .1s; }
table.tabla tbody tr:hover { background: var(--surface-2); }
table.tabla tbody tr:last-child td { border-bottom: 0; }
table.tabla tbody tr.seleccionada { background: var(--brand-soft); }

table.tabla td.principal { color: var(--ink); font-weight: 600; }
table.tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tabla .cuf { font-family: var(--mono); font-size: 11px; color: var(--muted); }
table.tabla td.chico, table.tabla .chico { font-size: 12px; }

table.tabla.compacta td { padding: 7px 13px; }
table.tabla.compacta th { padding: 7px 13px; }

/* ---------- Estados ------------------------------------------ */

.estado {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 620;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.estado::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.estado.ok      { background: var(--ok-soft);     color: var(--ok); }
.estado.warn    { background: var(--warn-soft);   color: var(--warn); }
.estado.danger  { background: var(--danger-soft); color: var(--danger); }
.estado.info    { background: var(--info-soft);   color: var(--info); }
.estado.neutro  { background: var(--surface-3);   color: var(--muted); }

/* ---------- Formularios -------------------------------------- */

.campo { margin-bottom: 14px; }
.campo > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.campo .ayuda { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.campo .error { font-size: 11.5px; color: var(--danger); margin-top: 4px; font-weight: 550; }
.campo.invalido input, .campo.invalido select { border-color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radio-sm);
  padding: 8px 11px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--muted); }
input:disabled, select:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }

select { cursor: pointer; }

.fila-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fila-campos.tres { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .fila-campos, .fila-campos.tres { grid-template-columns: 1fr; } }

.barra-filtros {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface-2);
}

.barra-filtros select, .barra-filtros input { width: auto; min-width: 130px; padding: 6px 10px; font-size: 12.5px; }

/* ---------- Pestañas ----------------------------------------- */

.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }

.pestana {
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.pestana:hover { color: var(--ink); }
.pestana[aria-selected="true"] { color: var(--brand-ink); border-bottom-color: var(--brand); }

.pestanas.dentro { border: 0; margin: 0; }

/* ---------- Avisos ------------------------------------------- */

.aviso {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radio-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  align-items: flex-start;
}

.aviso.ok     { background: var(--ok-soft);     border-color: color-mix(in srgb, var(--ok) 24%, transparent);     color: var(--ok); }
.aviso.warn   { background: var(--warn-soft);   border-color: color-mix(in srgb, var(--warn) 24%, transparent);   color: var(--warn); }
.aviso.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 24%, transparent); color: var(--danger); }
.aviso.info   { background: var(--info-soft);   border-color: color-mix(in srgb, var(--info) 24%, transparent);   color: var(--info); }
.aviso.neutro { background: var(--surface-2);   border-color: var(--line); color: var(--ink-2); }

.aviso strong { display: block; margin-bottom: 2px; }
.aviso .texto { color: var(--ink-2); font-size: 12.5px; }
.aviso .ico { margin-top: 1px; }

/* ---------- Actividad / línea de tiempo ----------------------- */

.actividad { list-style: none; margin: 0; padding: 0; }

.actividad li {
  display: flex;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-2);
}

.actividad li:last-child { border-bottom: 0; }
.actividad .hora { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 46px; }
.actividad .detalle { font-size: 12.8px; color: var(--ink-2); }
.actividad .detalle strong { color: var(--ink); font-weight: 620; }

.linea-tiempo { list-style: none; margin: 0; padding: 0 0 0 8px; }

.linea-tiempo li {
  position: relative;
  padding: 0 0 20px 24px;
  border-left: 2px solid var(--line);
}

.linea-tiempo li:last-child { border-left-color: transparent; padding-bottom: 0; }

.linea-tiempo li::before {
  content: "";
  position: absolute;
  left: -7px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
}

.linea-tiempo li.ok::before     { border-color: var(--ok); background: var(--ok); }
.linea-tiempo li.warn::before   { border-color: var(--warn); background: var(--warn); }
.linea-tiempo li.danger::before { border-color: var(--danger); background: var(--danger); }

.linea-tiempo .titulo { font-size: 13px; font-weight: 600; color: var(--ink); }
.linea-tiempo .cuando { font-size: 11.5px; color: var(--muted); }
.linea-tiempo .nota   { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ---------- Gráfico ------------------------------------------ */

.grafico { padding: 18px; }
.grafico svg { width: 100%; height: 170px; display: block; overflow: visible; }
.eje-texto { font-size: 10px; fill: var(--muted); font-family: var(--fuente); }

.leyenda { display: flex; gap: 16px; padding: 0 18px 16px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.leyenda span { display: flex; align-items: center; gap: 6px; }
.leyenda i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* ---------- Vacío y carga ------------------------------------ */

.vacio { text-align: center; padding: 40px 20px; color: var(--muted); }
.vacio .ico { width: 34px; height: 34px; flex-basis: 34px; opacity: .45; margin-bottom: 10px; }
.vacio p { font-size: 13px; }

.esqueleto {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: brillo 1.2s infinite;
  border-radius: 6px;
  height: 12px;
}

@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Modal y cajón ------------------------------------ */

.velo {
  position: fixed; inset: 0;
  background: rgba(11,17,32,.5);
  backdrop-filter: blur(3px);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.velo.abierto { display: grid; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--sombra-alta);
  width: min(580px, 100%);
  max-height: 88vh;
  overflow: auto;
  animation: subir .18s ease;
}

.modal.ancho { width: min(820px, 100%); }

@keyframes subir { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-cabecera { display: flex; align-items: center; gap: 10px; padding: 17px 20px 13px; }
.modal-cabecera h2 { font-size: 16px; }
.modal-cabecera .cerrar { margin-left: auto; }
.modal-cuerpo { padding: 0 20px 4px; }
.modal-pie { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 20px 20px; flex-wrap: wrap; }

.cajon {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(460px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--sombra-alta);
  transform: translateX(100%);
  transition: transform .22s ease;
  z-index: 120;
  display: flex;
  flex-direction: column;
}

.cajon.abierto { transform: none; }
.cajon-cabecera { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cajon-cabecera h2 { font-size: 15px; }
.cajon-cabecera .cerrar { margin-left: auto; }
.cajon-cuerpo { padding: 18px; overflow-y: auto; flex: 1; }
.cajon-pie { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Avisos flotantes --------------------------------- */

.brindis { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }

.brindis .item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 10px;
  box-shadow: var(--sombra-alta);
  padding: 11px 15px;
  font-size: 13px;
  color: var(--ink-2);
  min-width: 250px;
  max-width: 340px;
  animation: entrar .2s ease;
}

.brindis .item.error { border-left-color: var(--danger); }
.brindis .item.aviso { border-left-color: var(--warn); }
.brindis .item strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 2px; }

@keyframes entrar { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Acceso ------------------------------------------- */

.acceso {
  position: fixed; inset: 0;
  background: var(--bg);
  display: none;
  place-items: center;
  z-index: 300;
  padding: 20px;
}

.acceso.abierto { display: grid; }

.acceso-caja {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--sombra-alta);
  padding: 28px 26px;
}

.acceso-marca { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }

/* ---------- Paleta de comandos -------------------------------- */

.paleta { width: min(560px, 100%); align-self: start; margin-top: 12vh; }

.paleta input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 16px 20px;
  font-size: 14.5px;
  background: var(--surface);
}

.paleta input:focus { box-shadow: none; border-color: var(--line); }

.paleta-lista { max-height: 340px; overflow-y: auto; padding: 6px; }

.paleta-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-2);
}

.paleta-item[aria-selected="true"], .paleta-item:hover { background: var(--brand-soft); color: var(--brand-ink); }
.paleta-item .ruta { margin-left: auto; font-size: 11px; color: var(--muted); }
.paleta-item .ico { opacity: .7; }

/* ---------- Detalle de documento ------------------------------ */

.detalle-cabecera {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.detalle-cabecera .titulo h1 { font-size: 24px; letter-spacing: -.03em; }
.detalle-cabecera .titulo .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.detalle-cabecera .acciones { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.datos-clave { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

.dato-clave .etiqueta { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 3px; }
.dato-clave .valor { font-size: 13.5px; font-weight: 600; color: var(--ink); word-break: break-word; }
.dato-clave .valor.mono { font-family: var(--mono); font-size: 12px; font-weight: 500; }

.xml {
  background: #0d1424;
  color: #c8d3ea;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  padding: 16px;
  border-radius: var(--radio-sm);
  overflow: auto;
  max-height: 380px;
  white-space: pre;
  margin: 0;
}

[data-tema="claro"] .xml { background: #0d1424; }

.xml .et { color: #7aa2ff; }
.xml .at { color: #9ae6b4; }
.xml .va { color: #f6c177; }

/* ---------- Bloques de numeración ----------------------------- */

.bloque {
  border: 1px solid var(--line);
  border-radius: var(--radio-sm);
  padding: 14px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.bloque .rango { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.bloque .barra-progreso { flex: 1; min-width: 140px; height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bloque .barra-progreso i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }

/* ---------- Utilidades ---------------------------------------- */

.entre { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fila  { display: flex; align-items: center; gap: 10px; }
.fila.fin { justify-content: flex-end; }
.envolver { flex-wrap: wrap; }
.tenue { color: var(--muted); }
.chico { font-size: 12px; }
.mini  { font-size: 11px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.oculto { display: none !important; }
.ahorarapido { white-space: nowrap; }
.crecer { flex: 1; }
.centro { text-align: center; }

.solo-lectura {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radio-sm);
  padding: 9px 11px;
  font-size: 13px;
  color: var(--ink-2);
}

.encabezado-vista { margin-bottom: 18px; display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.encabezado-vista h1 { margin-bottom: 3px; }
.encabezado-vista p { color: var(--muted); font-size: 13px; max-width: 640px; }
.encabezado-vista .derecha { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.separador { height: 1px; background: var(--line); margin: 18px 0; }

@media print {
  .lateral, .barra, .brindis, .cajon, .velo { display: none !important; }
  .contenido { max-width: none; padding: 0; }
}

/* ============================================================
   Compatibilidad con las páginas existentes
   Estas clases ya se usan en los .razor. El sistema de diseño
   las redefine aquí para que el cambio de hoja no rompa nada.
   ============================================================ */

/* Tarjetas de métrica antiguas: .tarjeta > .numero + .etiqueta */
.tarjeta .numero {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
  color: var(--ink);
}

.tarjeta .etiqueta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
}

.tarjeta-metrica {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radio);
  padding: 15px 17px;
  box-shadow: var(--sombra);
  min-width: 140px;
}

.tarjetas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

/* Rejillas antiguas */
.rejilla-2-igual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.rejilla-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

@media (max-width: 900px) {
  .rejilla-2-igual, .rejilla-4 { grid-template-columns: 1fr; }
}

/* Tablas antiguas: celda principal y contenedor */
.principal-celda { font-weight: 600; color: var(--ink); }

/* Listas de definición del detalle */
.detalle {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radio);
  padding: 16px;
}

.detalle dt { font-weight: 600; color: var(--muted); font-size: 12.5px; }
.detalle dd { margin: 0; color: var(--ink); }

@media (max-width: 720px) { .detalle { grid-template-columns: 1fr; } }

/* Formularios con fieldset */
.formulario fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radio);
  background: var(--surface);
  margin: 0 0 16px;
  padding: 14px 16px 16px;
}

.formulario legend { font-weight: 650; padding: 0 6px; font-size: 13.5px; }
.formulario label { display: block; margin: 10px 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

.formulario input, .formulario select {
  display: block;
  width: 100%;
  max-width: 460px;
  margin-top: 4px;
}

/* Acciones */
.acciones, .fila-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

/* Pestañas antiguas por panel */
.panel-pestana { display: none; }
.panel-pestana.activa { display: block; }

.pestanas .pestana.activa {
  color: var(--brand-ink);
  border-bottom-color: var(--brand);
}

/* Estados del backend en minúsculas */
.estado.accepted             { background: var(--ok-soft);     color: var(--ok); }
.estado.observed             { background: var(--warn-soft);   color: var(--warn); }
.estado.unknownoutcome       { background: var(--info-soft);   color: var(--info); }
.estado.receptionrejected    { background: var(--danger-soft); color: var(--danger); }
.estado.rejected             { background: var(--danger-soft); color: var(--danger); }
.estado.pending              { background: var(--warn-soft);   color: var(--warn); }
.estado.cancelled            { background: var(--surface-3);   color: var(--muted); }
.estado.cancellationpending  { background: var(--warn-soft);   color: var(--warn); }
.estado.requiresreissue      { background: var(--danger-soft); color: var(--danger); }
.estado.replaced             { background: var(--surface-3);   color: var(--muted); }
.estado.failedtechnical      { background: var(--danger-soft); color: var(--danger); }
.estado.sincronizado         { background: var(--ok-soft);     color: var(--ok); }

/* Avisos antiguos */
.aviso.error   { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 24%, transparent); color: var(--danger); }
.aviso.info    { background: var(--info-soft);   border-color: color-mix(in srgb, var(--info) 24%, transparent);   color: var(--info); }
.aviso.exito   { background: var(--ok-soft);     border-color: color-mix(in srgb, var(--ok) 24%, transparent);     color: var(--ok); }

/* Texto */
.texto-tenue, .texto-suave, .pista { color: var(--muted); font-size: 12.5px; }
.negrita { font-weight: 650; }
.ocupado { color: var(--muted); font-size: 12.5px; }
.text-danger { color: var(--danger); font-size: 12.5px; }
.mono, code { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* Vacío antiguo */
.vacio { color: var(--muted); }

/* Botón secundario con el nombre antiguo */
.boton-secundario {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.boton-secundario:hover { background: var(--surface-2); }

/* Barra de error de Blazor */
#blazor-error-ui {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 18px;
  background: var(--warn-soft);
  border-top: 1px solid var(--warn);
  color: var(--warn);
  font-size: 13px;
  z-index: 400;
}

#blazor-error-ui .dismiss { cursor: pointer; margin-left: 12px; }
#blazor-error-ui .reload { color: var(--warn); text-decoration: underline; }

/* Ajustes de la barra superior del portal */
.barra .marca-simbolo { display: none; }

@media (max-width: 860px) {
  .app[data-mini="0"] .lateral { width: var(--lateral-min); flex-basis: var(--lateral-min); }
  .app[data-mini="0"] .ocultable { display: none; }
}
