/* =====================================================================
   foodVAC UI · v1 · estilos compartidos de las apps internas
   Fuente de verdad: styles.css de Comercial (informes.foodvac.es), que a su
   vez hereda 1:1 de Salas. Copiado fielmente, no reinterpretado, salvo:
   color de marca = rojo de foodvac.es y cabecera fija con borde rojo (Car, 2026-10-02).
   Uso:  <link rel="stylesheet" href="https://ui.foodvac.es/v1/foodvac.css">
         y despues el styles.css propio de la app solo con lo especifico.
   Regla: /v1/ solo admite cambios compatibles. Lo que rompa va a /v2/.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

/* ===== TOKENS =====
   Rojo de marca tomado de foodvac.es (#d10929): VAC, botones, hovers, bordes activos.
   Negro para cabecera/pie/titulos en la web; en las apps, negro para "food" y titulos. */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --bg-card: #ffffff;
  --bg-hover: #f0efeb;
  --line: #e5e3dd;
  --line-soft: #efeee9;
  --line-strong: #d4d1c9;

  --ink: #1a1a1a;
  --ink-mid: #5e5e5e;
  --ink-mute: #9a9a96;

  --brand: #d10929;          /* rojo foodVAC (foodvac.es) */
  --brand-dark: #a30720;     /* rojo oscuro: hover/pulsado */
  --brand-soft: #e5566a;     /* rojo claro: acentos secundarios */
  --brand-tint: #fbe9ec;     /* fondo rojo muy suave (totales, filas destacadas) */
  --gold: #b8893d;
  --olive: #6b7d3a;
  --sage: #8a9466;
  --rust: #b85c2a;

  /* Alias con los nombres de la guia de estilos / portal */
  --rojo: var(--brand);
  --rojo-osc: var(--brand-dark);
  --granate: var(--brand);       /* nombre antiguo; mismo valor que --rojo */
  --granate-osc: var(--brand-dark);
  --fondo: var(--bg);
  --texto: var(--ink);
  --suave: var(--ink-mid);
  --borde: var(--line);

  --font: 'Cairo', system-ui, sans-serif;
}

/* ===== BASE ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font-family: var(--font); }
a { color: var(--brand); }
[hidden] { display: none !important; }   /* gana a cualquier display de las clases */

/* ===== MARCA =====
   Marcado exacto: food<em>VAC</em>. VAC en rojo, NUNCA cursiva, NUNCA mayusculas. */
.marca, .login-mark, .title-block h1, .footer-note .wm { font-weight: 800; color: var(--ink); }
.marca em, .login-mark em, .title-block h1 em, .footer-note .wm em, .footer-note em {
  font-style: normal; color: var(--brand); font-weight: 800; text-transform: none;
}

/* ===== TOPBAR =====
   Fija arriba (sticky: se queda pegada al hacer scroll sin necesitar un hueco en el body)
   con borde inferior rojo. Decision de Car, 2026-10-02; es la unica diferencia con Comercial. */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 22px 36px;
  border-bottom: 2px solid var(--brand);
  background: var(--bg);
}
.title-block h1 {
  font-size: 34px; font-weight: 800; letter-spacing: -0.025em; line-height: 1; color: var(--ink);
}
.title-block h1 a { color: inherit; text-decoration: none; }
.title-block .meta {
  font-size: 11px; color: var(--ink-mute); text-transform: uppercase;
  letter-spacing: 0.15em; margin-top: 6px; font-weight: 600;
}
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-actions .quien { font-size: 12px; font-weight: 600; color: var(--ink-mid); }

/* ===== CONMUTADOR DE VISTAS ===== */
.view-switcher {
  display: flex; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px;
}
.view-btn {
  background: transparent; border: none; color: var(--ink-mid);
  padding: 8px 16px; border-radius: 3px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  cursor: pointer; transition: all .15s ease;
}
.view-btn:hover { color: var(--ink); }
.view-btn.active { background: var(--brand); color: #fff; }

/* ===== CONTROLES DE FORMULARIO ===== */
select {
  font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 4px;
  padding: 8px 10px; cursor: pointer;
}
.search-box, .input {
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; color: var(--ink); background: #fff;
}
.search-box:focus, .input:focus, select:focus { outline: none; border-color: var(--brand); }

/* ===== BOTONES ===== */
/* Secundario (es el refresh-btn / logout-btn de Comercial) */
.btn, .refresh-btn, .logout-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 12px; font-size: 12px; font-weight: 700;
  color: var(--ink-mid); cursor: pointer; transition: all .15s ease;
}
.btn:hover, .refresh-btn:hover, .logout-btn:hover { color: var(--brand); border-color: var(--brand); }
.refresh-btn.spinning, .btn.spinning, .btn[disabled] { opacity: .55; pointer-events: none; }
.logout-btn { font-weight: 600; }

/* Primario (es el gen-btn de Comercial) */
.btn-primary, .gen-btn {
  padding: 10px 26px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  transition: opacity .15s ease;
}
.btn-primary:hover, .gen-btn:hover { opacity: 0.88; }
.btn-primary[disabled] { opacity: .55; pointer-events: none; }

/* Contorno granate (es el gen-mini / cli-toggle de Comercial) */
.btn-outline, .gen-mini {
  padding: 8px 16px; border: 1px solid var(--brand); border-radius: 6px; cursor: pointer;
  background: #fff; color: var(--brand); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; transition: all .15s ease;
}
.btn-outline:hover, .gen-mini:hover { background: var(--brand); color: #fff; }
.cli-toggle {
  margin-top: 14px; background: transparent; border: 1px solid var(--line);
  border-radius: 5px; padding: 8px 16px;
  font-size: 12px; font-weight: 700; color: var(--brand); cursor: pointer;
  transition: background .15s ease;
}
.cli-toggle:hover { background: var(--bg-soft); }

/* ===== ETIQUETAS ===== */
.data-date, .tag {
  display: inline-block;
  font-size: 11px; font-weight: 600; color: var(--ink-mid);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 4px; padding: 6px 10px; white-space: nowrap;
}
.tag { padding: 3px 9px; }
.tag.brand { color: var(--brand); border-color: var(--brand); background: #fff; }
.tag.ok { color: var(--olive); border-color: var(--olive); background: #fff; }
.tag.warn { color: var(--rust); border-color: var(--rust); background: #fff; }

/* ===== LAYOUT ===== */
.main { padding: 24px 36px 60px; max-width: 1500px; margin: 0 auto; }
.main.estrecho { max-width: 960px; }

.section { margin-bottom: 30px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.section-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.section-title em { font-style: normal; color: var(--brand); font-weight: 800; }
.section-meta {
  font-size: 10.5px; color: var(--ink-mute); text-transform: uppercase;
  letter-spacing: 0.15em; font-weight: 600;
}

.grid2 { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: 18px; grid-template-columns: 1fr 1fr 1fr; }

.panel {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 6px;
  padding: 20px 22px;
}

.filtros-detalle { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filtros-detalle > .view-switcher { flex: 0 0 auto; }
.filtros-detalle .search-box { flex: 0 0 calc((100% - 48px) / 4); margin-left: auto; }

/* ===== KPIs (stats) ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 30px; }
.stats.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats.stats-2 { grid-template-columns: repeat(2, 1fr); }
.stat {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 6px;
  padding: 18px 22px; position: relative;
}
.stat::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent-bar, var(--brand)); border-radius: 6px 0 0 6px;
}
.stat .label {
  color: var(--accent-bar, var(--ink-mute));
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
}
.stat .value {
  font-size: 40px; font-weight: 800; margin-top: 6px; letter-spacing: -0.025em;
  color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums;
}
.stat .value .up   { color: var(--olive); }
.stat .value .down { color: var(--brand); }
.stat .delta { font-size: 11.5px; color: var(--ink-mid); margin-top: 10px; font-weight: 600; }
.delta .up { color: var(--olive); }
.delta .down { color: var(--brand); }
.stat .d-pct { font-size: 17px; font-weight: 800; line-height: 1.1; }
.stat .d-pct.up   { color: var(--olive); }
.stat .d-pct.down { color: var(--brand); }
.stat .d-abs { font-size: 11px; color: var(--ink-mute); margin-top: 3px; font-weight: 600; }
.stat .d-abs .up   { color: var(--olive); }
.stat .d-abs .down { color: var(--brand); }

/* ===== LISTAS (top clientes) ===== */
.cli-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft);
}
.cli-row:last-child { border-bottom: 0; }
.cli-name { font-size: 13px; color: var(--ink); font-weight: 500; }
.cli-val { font-size: 13px; color: var(--ink-mid); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ===== TABLAS ===== */
.tabla-wrap {
  max-height: 600px; overflow: auto;
  border: 1px solid var(--line); border-radius: 8px;
}
.tabla-detalle {
  width: 100%; border-collapse: collapse; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tabla-detalle th, .tabla-detalle td {
  padding: 9px 12px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.tabla-detalle thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-soft); color: var(--ink-mid);
  font-weight: 800; font-size: 11px; letter-spacing: 0.02em;
  cursor: pointer; user-select: none; border-bottom: 2px solid var(--line);
}
.tabla-detalle thead th:hover { color: var(--brand); }
.tabla-detalle thead th .arrow { color: var(--brand); margin-left: 3px; }
.tabla-detalle th.col-cli, .tabla-detalle td.col-cli {
  text-align: left; position: sticky; left: 0; z-index: 1;
  background: #fff; font-weight: 600; color: var(--ink); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis;
}
.tabla-detalle thead th.col-cli { z-index: 3; background: var(--bg-soft); }
.tabla-detalle tbody tr:hover td { background: var(--bg-soft); }
.tabla-detalle tbody tr:hover td.col-cli { background: #f2f1ec; }
.tabla-detalle .pct.up   { color: var(--olive); font-weight: 700; }
.tabla-detalle .pct.down { color: var(--brand); font-weight: 700; }
.tabla-detalle .pct.na   { color: var(--ink-mute); }
.tabla-detalle tfoot td {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--brand-tint); font-weight: 800; color: var(--ink); font-size: 13px;
  border-top: 2px solid var(--brand); border-bottom: none;
  box-shadow: 0 -3px 8px rgba(0,0,0,0.06);
}
.tabla-detalle tfoot td.col-cli { z-index: 3; background: var(--brand-tint); color: var(--brand); }

/* ===== ESTADOS ===== */
.loading { color: var(--ink-mute); font-style: italic; padding: 50px; text-align: center; }
.error { color: var(--brand); padding: 24px; font-weight: 600; }
.vacio { color: var(--ink-mid); padding: 24px; text-align: center; }

/* ===== LOGIN =====
   Pantalla a pantalla completa. El boton es el oficial de Google Identity Services
   (google.accounts.id.renderButton) dentro de .gsi-boton. La clase .login-btn se
   mantiene para las apps que aun llevan el boton propio con flujo por redireccion. */
#login-screen, .login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-content { text-align: center; padding: 40px; }
.login-mark { font-size: 48px; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); line-height: 1; }
.login-mark em { font-style: normal; color: var(--brand); }
.login-sub {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--ink-mute); margin: 12px 0 34px; font-weight: 600;
}
.gsi-boton { display: flex; justify-content: center; min-height: 44px; }
.login-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 12px 22px; font-size: 14px; font-weight: 600;
  color: var(--ink); cursor: pointer; transition: all .15s ease;
}
.login-btn:hover { border-color: var(--brand); box-shadow: 0 6px 24px rgba(0,0,0,.07); }
.login-info { margin-top: 22px; font-size: 12px; color: var(--ink-mid); }
.login-info strong { color: var(--brand); }
#login-error, .login-error { margin-top: 14px; color: var(--brand); font-size: 12px; font-weight: 600; }

/* ===== PIE CON VERSION =====
   NUNCA en mayusculas: es foodVAC, no FOODVAC. */
.footer-note {
  text-align: center; padding: 30px 0 4px;
  color: var(--ink-mute); font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: none;
}

/* ===== MOVIL ===== */
@media (max-width: 900px) {
  .stats, .stats.stats-3 { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .filtros-detalle .search-box { flex-basis: calc((100% - 16px) / 2); }
}
@media (max-width: 600px) {
  /* Cabecera compacta: al ser fija no puede comerse media pantalla */
  .topbar { padding: 10px 16px; gap: 8px 10px; }
  .title-block h1 { font-size: 24px; }
  .title-block .meta { display: none; }
  .top-actions { gap: 8px; }
  .main { padding: 18px 18px 50px; }
  .stats, .stats.stats-3, .stats.stats-2 { grid-template-columns: 1fr; }
  .stat .value { font-size: 32px; }
  .filtros-detalle .search-box { flex-basis: 100%; margin-left: 0; }
  .login-mark { font-size: 40px; }
}
