/* =====================================================================
   foodVAC · Panel comercial — estilo heredado 1:1 de la app Salas
   Fuente Cairo · fondo blanco · granate #8b1d2e · números bold tabular
   ===================================================================== */
: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: #8b1d2e;          /* granate foodVAC */
  --brand-soft: #c25266;
  --gold: #b8893d;
  --olive: #6b7d3a;
  --sage: #8a9466;
  --rust: #b85c2a;
}

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

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

/* ===== TOPBAR ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 22px 36px;
  border-bottom: 1px solid var(--line);
}
.title-block h1 {
  font-size: 34px; font-weight: 800; letter-spacing: -0.025em; line-height: 1; color: var(--ink);
}
.title-block h1 em { font-style: normal; color: var(--brand); font-weight: 800; }
.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; }

.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-family: 'Cairo', sans-serif;
  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; }

select {
  font-family: 'Cairo', sans-serif; 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;
}

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

/* ===== STATS ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 30px; }
.stat {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 6px;
  padding: 16px 20px; 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 {
  font-size: 10px; color: var(--ink-mute); text-transform: uppercase;
  letter-spacing: 0.15em; font-weight: 700;
}
.stat .value {
  font-size: 30px; font-weight: 800; margin-top: 4px; letter-spacing: -0.025em;
  color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums;
}
.stat .delta { font-size: 11.5px; color: var(--ink-mid); margin-top: 8px; font-weight: 600; }
.delta .up { color: var(--olive); }
.delta .down { color: var(--brand); }

/* ===== SECTIONS ===== */
.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: 1.5fr 1fr; }
.grid-donuts { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }

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

/* ===== 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; }

canvas { max-width: 100%; }

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

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid-donuts { grid-template-columns: 1fr; }
}

/* ===== LOGIN ===== */
#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;
}
.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-family: 'Cairo', sans-serif; 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 { margin-top: 14px; color: var(--brand); font-size: 12px; font-weight: 600; }

.logout-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 12px; font-family: 'Cairo', sans-serif; font-size: 12px; font-weight: 600;
  color: var(--ink-mid); cursor: pointer; transition: all .15s ease;
}
.logout-btn:hover { color: var(--brand); border-color: var(--brand); }

/* ===== KPIs más llamativos (v1.0) ===== */
.stat { padding: 18px 22px; }
.stat .label {
  color: var(--accent-bar, var(--ink-mute));
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
}
.stat .value { font-size: 40px; margin-top: 6px; }
.stat .delta { margin-top: 10px; }
.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); }

/* ===== Footer con versión ===== */
.footer-note {
  text-align: center; padding: 30px 0 4px;
  color: var(--ink-mute); font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer-note em { font-style: normal; color: var(--brand); font-weight: 800; }

/* ===== Ajustes v1.1: simetría y marca ===== */

/* Footer: NUNCA en mayúsculas (es foodVAC, no FOODVAC) */
.footer-note { text-transform: none; letter-spacing: 0.04em; }
.footer-note .wm { color: var(--ink); font-weight: 800; }
.footer-note .wm em { color: var(--brand); font-style: normal; font-weight: 800; }

/* Columnas simétricas en ambas filas de gráficos */
.grid2 { grid-template-columns: 1fr 1fr; }

/* Contenedores de gráfico con altura fija → tamaños homogéneos */
.chart-box { position: relative; width: 100%; }
.chart-box.tall  { height: 260px; }
.chart-box.donut { height: 230px; }   /* evita que los círculos salgan enormes */
.chart-box canvas { max-height: 100%; }

/* Top clientes: botón "ver todos" */
.cli-toggle {
  margin-top: 14px; background: transparent; border: 1px solid var(--line);
  border-radius: 5px; padding: 8px 16px; font-family: 'Cairo', sans-serif;
  font-size: 12px; font-weight: 700; color: var(--brand); cursor: pointer;
  transition: background .15s ease;
}
.cli-toggle:hover { background: var(--bg-soft); }

/* ===== Fecha de datos + botón actualizar (v1.2) ===== */
.data-date {
  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;
}
.refresh-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 12px; font-family: 'Cairo', sans-serif; font-size: 12px; font-weight: 700;
  color: var(--ink-mid); cursor: pointer; transition: all .15s ease;
}
.refresh-btn:hover { color: var(--brand); border-color: var(--brand); }
.refresh-btn.spinning { opacity: .55; pointer-events: none; }
