/* ===========================================================================
   Consola de operacion — ControlPOS Tickets Digitales

   Hoja unica y sin dependencias: la consola la sirve el propio backend Java y
   no hay paso de build de front. El objetivo no es "que se vea bonito" sino
   que se pueda operar: densidad alta, numeros alineados, jerarquia clara y
   estados de carga y vacio que digan algo.

   Orden: tokens · temas · layout · sidebar · topbar · KPIs · tarjetas · graficas ·
   desglose · filtros · tablas · paginacion · pie · toast · movil.
   =========================================================================== */

:root {
  color-scheme: light;

  --ink-900: #0b1220;
  --ink-800: #1a2436;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-050: #f8fafc;

  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-ink: #1e40af;
  --brand-soft: #eff4ff;
  --brand-line: #d7e3fb;
  --brand-light: #60a5fa;                 /* extremo claro de los degradados */
  --brand-ring: rgba(37, 99, 235, .12);   /* halo de foco en campos */

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;

  --surface: #ffffff;
  --page: #f4f6fa;
  --line: #e6eaf1;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 12px 32px -18px rgba(15, 23, 42, .28);

  --sidebar-w: 244px;
  --sidebar-w-min: 68px;
  --topbar-h: 60px;

  /* Apariencia. Todo lo que cambia entre un tema y otro pasa por aqui: la
     hoja no vuelve a tocar un color a mano mas abajo. El tema base (ControlPOS)
     es este bloque; los demas solo redefinen tokens, no reglas. */
  --btn-radius: var(--radius-sm);
  --primary-bg: var(--brand);
  --primary-fg: #fff;
  --primary-hover: var(--brand-dark);
  --mark-bg: linear-gradient(135deg, var(--brand), var(--brand-light));
  --mark-fg: #fff;
  --mark-shadow: rgba(37, 99, 235, .7);
  --avatar-bg: var(--brand-soft);
  --avatar-fg: var(--brand-ink);
  --avatar-line: var(--brand-line);
  --chart-line: var(--brand);
  --chart-fill: rgba(37, 99, 235, .10);
  --bar-gradient: linear-gradient(180deg, var(--brand-light), var(--brand));
  --rank-gradient: linear-gradient(90deg, var(--brand-light), var(--brand));
  --toast-bg: var(--ink-900);

  /* Menu lateral: claro en el tema base, oscuro en Verifone. */
  --side-bg: var(--surface);
  --side-line: var(--line);
  --side-text: var(--ink-600);
  --side-text-strong: var(--ink-900);
  --side-sub: var(--ink-500);
  --side-icon: var(--ink-400);
  --side-icon-hover: var(--ink-600);
  --side-label: var(--ink-400);
  --side-hover: var(--ink-050);
  --side-active-bg: var(--brand-soft);
  --side-active-text: var(--brand-ink);
  --side-active-icon: var(--brand);
  --side-accent: var(--brand);
  --side-scope: var(--ink-500);
  --side-scope-global: var(--brand-ink);
  --side-select-bg: var(--surface);
  --side-select-line: var(--ink-200);
  --side-select-fg: var(--ink-700);

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Consolas, "Liberation Mono", monospace;
}

/* ---------------------------------------------------------------- temas -- */
/* Verifone: la identidad de 2023 (NORD ID) — negro, blanco, aguamarina
   (#6EFFD2) como color de marca y "Blue Ribbon" (#1234FF) de acento. Grises
   neutros en vez de azulados, botones en pildora y radios mas amplios. Se
   activa con data-theme="verifone" en <html>; lo pone theme.js antes de
   pintar y lo recuerda el navegador. */
:root[data-theme="verifone"] {
  --ink-900: #0a0a0a;
  --ink-800: #171717;
  --ink-700: #333333;
  --ink-600: #4d4d4d;
  --ink-500: #6b6b6b;
  --ink-400: #9a9a9a;
  --ink-300: #cfcfcf;
  --ink-200: #e3e3e3;
  --ink-100: #f0f0f0;
  --ink-050: #f7f7f7;

  --brand: #1234ff;
  --brand-dark: #0d27cc;
  --brand-ink: #0b1f9e;
  --brand-soft: #eef1ff;
  --brand-line: #cdd5ff;
  --brand-light: #6effd2;
  --brand-ring: rgba(18, 52, 255, .14);

  --accent: #6effd2;
  --accent-ink: #0a0a0a;

  --surface: #ffffff;
  --page: #f4f4f4;
  --line: #e6e6e6;

  --radius: 14px;
  --radius-sm: 10px;
  --btn-radius: var(--radius-pill);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 14px 34px -20px rgba(0, 0, 0, .35);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* El boton principal es aguamarina con texto negro: la firma de la marca. */
  --primary-bg: var(--accent);
  --primary-fg: var(--accent-ink);
  --primary-hover: #52f0c2;
  --mark-bg: var(--accent);
  --mark-fg: var(--accent-ink);
  --mark-shadow: rgba(110, 255, 210, .5);
  --avatar-bg: var(--ink-900);
  --avatar-fg: var(--accent);
  --avatar-line: var(--ink-900);
  --chart-line: var(--brand);
  --chart-fill: rgba(18, 52, 255, .09);
  --bar-gradient: linear-gradient(180deg, var(--accent), var(--brand));
  --rank-gradient: linear-gradient(90deg, var(--accent), var(--brand));
  --toast-bg: var(--ink-900);

  --side-bg: #0a0a0a;
  --side-line: rgba(255, 255, 255, .09);
  --side-text: #b8b8b8;
  --side-text-strong: #ffffff;
  --side-sub: #8a8a8a;
  --side-icon: #8a8a8a;
  --side-icon-hover: #dcdcdc;
  --side-label: #707070;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active-bg: rgba(110, 255, 210, .11);
  --side-active-text: var(--accent);
  --side-active-icon: var(--accent);
  --side-accent: var(--accent);
  --side-scope: #8a8a8a;
  --side-scope-global: var(--accent);
  --side-select-bg: rgba(255, 255, 255, .06);
  --side-select-line: rgba(255, 255, 255, .14);
  --side-select-fg: #ffffff;
}
/* Detalles que no son un color: pildoras y numeros mas apretados. */
:root[data-theme="verifone"] .pill { font-weight: 700; }
:root[data-theme="verifone"] .kpi-value { letter-spacing: -0.03em; font-weight: 720; }
:root[data-theme="verifone"] .page-title { letter-spacing: -0.02em; }
:root[data-theme="verifone"] .field-inline select,
:root[data-theme="verifone"] .link-icon { border-radius: var(--radius-pill); }
:root[data-theme="verifone"] .kpi-delta.is-up { background: rgba(110, 255, 210, .35); color: #0a5c44; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink-900);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand); }

/* Foco visible siempre: se opera con teclado mas de lo que se cree. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.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;
}

/* ---------------------------------------------------------------- layout -- */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content {
  padding: 22px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1560px;
  width: 100%;
  flex: 1;
}

/* --------------------------------------------------------------- sidebar -- */
/* Claro y con poco contraste interno: el color se reserva para el estado
   activo y para las alertas, no para decorar el armazon. */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .16s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--side-line);
  color: var(--side-text-strong); text-decoration: none;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: var(--mark-bg);
  color: var(--mark-fg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px -4px var(--mark-shadow);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.2; font-weight: 700; font-size: 14.5px; min-width: 0; }
.brand-name small { font-size: 11px; font-weight: 500; color: var(--side-sub); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; color: var(--side-label);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 10px 11px 6px;
}
.sidebar-nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--side-icon); transition: color .12s ease; }
.sidebar-nav a:hover { background: var(--side-hover); color: var(--side-text-strong); }
.sidebar-nav a:hover svg { color: var(--side-icon-hover); }
.sidebar-nav a.is-active { background: var(--side-active-bg); color: var(--side-active-text); font-weight: 650; }
.sidebar-nav a.is-active svg { color: var(--side-active-icon); }
/* Barra de acento: marca la seccion sin depender solo del color de fondo. */
.sidebar-nav a.is-active::before {
  content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--side-accent);
}

.nav-badge {
  margin-left: auto;
  min-width: 20px; padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft); color: #7c3f00;
  font-size: 11px; font-weight: 700; text-align: center;
}

.sidebar-foot {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--side-line);
  display: flex; align-items: center; gap: 10px;
}
.scope-note {
  flex: 1; min-width: 0;
  font-size: 11.5px; color: var(--side-scope);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scope-note.scope-global { color: var(--side-scope-global); }
.sidebar-collapse svg { transition: transform .16s ease; }
.sidebar .icon-btn { color: var(--side-icon); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: var(--side-text-strong); }

/* Selector de apariencia. Vive en el menu y no en la barra superior porque
   se toca una vez y ya; la barra es para lo que se usa a diario. */
.sidebar-theme {
  padding: 10px 14px;
  border-top: 1px solid var(--side-line);
}
.sidebar-theme label {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 700; color: var(--side-label);
  text-transform: uppercase; letter-spacing: .08em;
  cursor: pointer;
}
.sidebar-theme label svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--side-icon); }
.sidebar-theme select {
  margin-left: auto;
  height: 28px; max-width: 120px;
  padding: 0 24px 0 8px;
  border: 1px solid var(--side-select-line); border-radius: var(--radius-sm);
  background: var(--side-select-bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 6px center;
  background-size: 13px;
  appearance: none;
  color: var(--side-select-fg);
  font: inherit; font-size: 12px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
  cursor: pointer;
}
.sidebar-theme select:hover { border-color: var(--side-icon); }

/* Modo compacto: solo iconos. Se recuerda en la sesion del navegador y solo
   aplica en escritorio; en movil el menu ya es un cajon completo. */
@media (min-width: 901px) {
  .app.nav-collapsed .sidebar { width: var(--sidebar-w-min); }
  .app.nav-collapsed .brand-name,
  .app.nav-collapsed .nav-group-label,
  .app.nav-collapsed .scope-note,
  .app.nav-collapsed .sidebar-theme,
  .app.nav-collapsed .nav-badge,
  .app.nav-collapsed .nav-text { display: none; }
  .app.nav-collapsed .sidebar-nav a { justify-content: center; padding: 10px; }
  .app.nav-collapsed .sidebar-brand { justify-content: center; padding: 14px 0; }
  .app.nav-collapsed .sidebar-foot { justify-content: center; }
  .app.nav-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
}

/* ---------------------------------------------------------------- topbar -- */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
/* El titulo cede espacio; las herramientas no se encogen ni se montan encima. */
.topbar-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.crumbs, .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs { font-size: 11.5px; color: var(--ink-400); }
.crumbs span + span::before { content: "/"; margin: 0 6px; color: var(--ink-300); }
.page-title { font-size: 16.5px; line-height: 1.2; }

.topbar-tools { margin-left: auto; flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.updated-at {
  font-size: 11.5px; color: var(--ink-500);
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.updated-at::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); flex-shrink: 0;
}

.field-inline select {
  height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 8px center;
  background-size: 15px;
  appearance: none;
  font: inherit; font-size: 13px; color: var(--ink-700);
  max-width: 230px;
  cursor: pointer;
}
.field-inline select:hover { border-color: var(--ink-300); background-color: var(--ink-050); }

.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--avatar-fg);
  border: 1px solid var(--avatar-line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; max-width: 140px; }
.user-meta strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 11px; color: var(--ink-500); text-transform: capitalize; }
.user-chip form { margin: 0; }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-500);
  cursor: pointer;
}
.icon-btn:hover { background: var(--ink-100); color: var(--ink-900); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.is-busy svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.menu-toggle { display: none; }

/* ------------------------------------------------------------------ KPIs -- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 3px;
  min-height: 128px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.kpi:hover { border-color: var(--ink-200); box-shadow: var(--shadow); }
.kpi-label {
  font-size: 11.5px; font-weight: 650; color: var(--ink-500);
  text-transform: uppercase; letter-spacing: .045em;
}
.kpi-value {
  font-size: 26px; font-weight: 680; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi-hint { font-size: 12px; color: var(--ink-500); }

/* Variacion contra la ventana anterior del mismo largo. Solo se pinta cuando
   hay un periodo acotado con el que comparar. */
.kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: var(--ink-100); color: var(--ink-600);
}
.kpi-delta svg { width: 12px; height: 12px; }
.kpi-delta.is-up { background: var(--ok-soft); color: var(--ok); }
.kpi-delta.is-down { background: var(--bad-soft); color: var(--bad); }
.kpi-spark { margin-top: auto; padding-top: 10px; }
.kpi-spark svg { display: block; width: 100%; height: 30px; }

/* Esqueleto de carga: ocupa el mismo alto que el dato real, para que la
   pagina no de un salto cuando llegan los numeros. */
.kpi.is-loading { position: relative; overflow: hidden; }
.kpi.is-loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .14), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .kpi.is-loading::after { animation: none; }
  .icon-btn.is-busy svg { animation: none; }
}

/* ---------------------------------------------------------------- tarjetas */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-wide { grid-column: 1 / -1; }
/* En pantalla ancha la grafica principal ocupa dos tercios y el estado
   operativo se queda al lado, no debajo. */
.card-main { grid-column: span 2; }
@media (max-width: 1180px) { .card-main { grid-column: 1 / -1; } }

.card-head { padding: 15px 18px 12px; border-bottom: 1px solid var(--line); }
.card-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 14.5px; }
.card-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 3px; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.banner-card { border-color: #f3d9a4; background: #fffdf6; }
.banner-card .card-head { border-bottom-color: #f3d9a4; }

.legend { display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--ink-500); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--brand); display: inline-block; }

/* -------------------------------------------------------------- graficas -- */
.chart { padding: 14px 18px 16px; min-height: 150px; }
.chart-plot { display: flex; gap: 10px; }
.chart-scale {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 10.5px; color: var(--ink-400); text-align: right;
  min-width: 34px; height: 156px;
  font-variant-numeric: tabular-nums;
}
/* Lineas guia horizontales: leer una altura sin ellas es adivinar. */
.bars {
  position: relative;
  flex: 1;
  display: flex; align-items: flex-end; gap: 3px;
  height: 156px;
  background-image: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 25%);
}
.bar-col {
  position: relative;
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  height: 100%; min-width: 0;
  border-radius: 4px 4px 0 0;
}
.bar {
  background: var(--bar-gradient);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: filter .12s ease;
}
.bar-col:hover { background: var(--brand-soft); }
.bar-col:hover .bar { filter: saturate(1.25) brightness(1.05); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-400); margin-top: 8px; }
.chart-foot { margin-top: 10px; font-size: 12px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.chart-empty { padding: 26px 0; text-align: center; font-size: 12.5px; color: var(--ink-500); }

.ranking { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px; align-items: center; gap: 10px; }
.rank-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { grid-column: 1 / -1; height: 6px; background: var(--ink-100); border-radius: var(--radius-pill); overflow: hidden; }
.rank-fill { height: 100%; background: var(--rank-gradient); border-radius: var(--radius-pill); }
.rank-value { font-size: 12.5px; color: var(--ink-600); text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* -------------------------------------------------------------- desglose -- */
/* Estado operativo del periodo: cuantos tickets se recuperaron, cuantos
   siguen sin abrirse y cuantos estan por vencer. */
.breakdown { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.bd-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.bd-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-300); }
.bd-dot.is-ok { background: var(--ok); }
.bd-dot.is-warn { background: #d97706; }
.bd-dot.is-bad { background: var(--bad); }
.bd-label { font-size: 13px; color: var(--ink-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-value { font-size: 12.5px; color: var(--ink-600); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bd-track { grid-column: 2 / -1; height: 6px; background: var(--ink-100); border-radius: var(--radius-pill); overflow: hidden; }
.bd-fill { height: 100%; border-radius: var(--radius-pill); background: var(--ink-300); }
.bd-fill.is-ok { background: var(--ok); }
.bd-fill.is-warn { background: #d97706; }
.bd-fill.is-bad { background: var(--bad); }
.bd-foot {
  display: flex; align-items: flex-start; gap: 7px;
  padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-500);
}
.bd-foot svg { width: 14px; height: 14px; color: var(--ink-400); flex-shrink: 0; margin-top: 2px; }

/* --------------------------------------------------------------- filtros -- */
.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.field > span { font-size: 11.5px; font-weight: 650; color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select {
  height: 36px; padding: 0 10px;
  border: 1px solid var(--ink-200); border-radius: var(--radius-sm);
  background: var(--surface); font: inherit; font-size: 13.5px; color: var(--ink-900);
}
.field input:hover, .field select:hover { border-color: var(--ink-300); }
.field input:focus, .field select:focus {
  border-color: var(--brand); outline: none;
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.field-check { flex-direction: row; align-items: center; gap: 7px; min-width: auto; height: 36px; }
.field-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.field-check span { font-size: 13px; color: var(--ink-700); text-transform: none; letter-spacing: 0; font-weight: 500; }
.filters-actions { display: flex; gap: 8px; margin-left: auto; }

.btn {
  height: 36px; padding: 0 15px;
  border: 1px solid var(--ink-200); border-radius: var(--btn-radius);
  background: var(--surface); color: var(--ink-700);
  font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s ease, border-color .12s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--ink-050); border-color: var(--ink-300); }
.btn-primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- tablas -- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table thead th {
  position: sticky; top: 0;
  background: var(--ink-050);
  font-size: 11px; font-weight: 700; color: var(--ink-500);
  text-transform: uppercase; letter-spacing: .05em;
  z-index: 1;
}
.data-table tbody tr { transition: background .1s ease; }
.data-table tbody tr:hover { background: var(--brand-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink-700); }
.cell-sub { display: block; font-size: 11.5px; color: var(--ink-500); font-weight: 400; }

.pill {
  display: inline-block; padding: 2px 9px;
  border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 650;
  border: 1px solid transparent;
}
.pill-venta { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.pill-devolucion { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.pill-cancelacion { background: var(--bad-soft); color: var(--bad); border-color: #fecaca; }
.pill-check_in, .pill-checkout { background: var(--info-soft); color: var(--info); border-color: #bae6fd; }
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.pill-muted { background: var(--ink-100); color: var(--ink-500); border-color: var(--ink-200); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }

.row-actions { display: flex; gap: 6px; }
.link-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--ink-500);
  border: 1px solid var(--line);
  background: var(--surface);
}
.link-icon:hover { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-line); }
.link-icon svg { width: 15px; height: 15px; }

/* Estados vacio / carga / error: nunca una tabla en blanco sin explicacion. */
.state-row td { padding: 34px 14px; text-align: center; color: var(--ink-500); white-space: normal; }
.state-row:hover { background: transparent; }
.state-title { display: block; font-weight: 600; color: var(--ink-700); margin-bottom: 3px; }

/* ------------------------------------------------------------ paginacion -- */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.pager-info { font-size: 12.5px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.pager-actions { display: flex; gap: 6px; }

/* -------------------------------------------------------------------- pie */
.app-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 24px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  font-size: 11.5px; color: var(--ink-500);
}
.app-foot span { display: inline-flex; align-items: center; gap: 6px; }
.app-foot svg { width: 13px; height: 13px; color: var(--ink-400); }
/* El sello de version se lee cuando se busca y no estorba cuando no. */
.app-foot .foot-version { font-variant-numeric: tabular-nums; color: var(--ink-400); }

/* ----------------------------------------------------------------- toast -- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  max-width: 380px; padding: 12px 15px;
  border-radius: var(--radius); box-shadow: var(--shadow);
  background: var(--toast-bg); color: #fff; font-size: 13.5px;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--bad); }

/* Un secreto que solo se muestra una vez merece su propio tratamiento. */
.secret {
  font-family: var(--mono); font-size: 12.5px;
  background: rgba(255, 255, 255, .12);
  padding: 6px 8px; border-radius: 6px;
  margin-top: 8px; word-break: break-all; display: block;
}

/* La hora del ultimo refresco es lo primero que sobra cuando la barra
   empieza a apretar: el boton de actualizar sigue ahi. */
@media (max-width: 1240px) {
  .updated-at { display: none; }
}

/* --------------------------------------------------------------- movil ---- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .sidebar-collapse { display: none; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .user-meta, .updated-at, .crumbs { display: none; }
  /* Los selectores se encogen antes que empujar la barra fuera de pantalla. */
  .topbar-tools { min-width: 0; gap: 6px; }
  .field-inline { flex: 1 1 auto; min-width: 0; }
  .field-inline select { width: 100%; max-width: 150px; min-width: 0; }
  .user-chip { padding-left: 8px; }
  .app-foot { padding: 10px 16px; }
}

/* En telefono la barra pasa a dos filas: titulo arriba, filtros abajo. Apretar
   todo en una sola linea deja los selectores inservibles. */
@media (max-width: 620px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; row-gap: 8px; }
  .topbar-tools { width: 100%; margin-left: 0; }
  .field-inline select { max-width: none; }
  .user-chip { margin-left: auto; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters-actions { margin-left: 0; }
  .field { min-width: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 22px; }
  .app-foot { font-size: 11px; gap: 6px 12px; }
}
