/* Puromenu Dashboard B2B */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s-2026: #2a78d6;        /* serie principal (año en curso) */
  --s-2025: #c3c2b7;        /* serie contexto (año anterior) */
  --seg-ka: #2a78d6;
  --seg-ir: #eb6834;
  --seg-can: #1baf7a;
  --seg-di: #eda100;
  --good: #006300;
  --bad: #d03b3b;
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-300: #6da7ec;
  --seq-400: #3987e5; --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;
  --accent-wash: rgba(42, 120, 214, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s-2026: #3987e5;
    --s-2025: #4a4a46;
    --seg-ka: #3987e5;
    --seg-ir: #d95926;
    --seg-can: #199e70;
    --seg-di: #c98500;
    --good: #0ca30c;
    --bad: #e66767;
    --accent-wash: rgba(57, 135, 229, 0.16);
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
button { font: inherit; }

/* ---- Login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 340px;
}
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card p.sub { color: var(--ink-2); margin-bottom: 22px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--ink-2); margin: 12px 0 4px; }
.login-card input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--baseline);
  border-radius: 8px; background: var(--page); color: var(--ink); font: inherit;
}
.login-card input:focus { outline: 2px solid var(--s-2026); outline-offset: -1px; border-color: transparent; }
.login-card button {
  width: 100%; margin-top: 20px; padding: 10px;
  background: var(--s-2026); color: #fff; border: 0; border-radius: 8px;
  font-weight: 600; cursor: pointer;
}
.login-error { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---- Shell ---- */
header.app {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  flex-wrap: wrap;
}
header.app .brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
header.app .brand span { color: var(--s-2026); }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
nav.tabs button {
  border: 0; background: none; color: var(--ink-2);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500;
}
nav.tabs button:hover { background: var(--accent-wash); }
nav.tabs button.active { background: var(--accent-wash); color: var(--s-2026); font-weight: 600; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.header-right label.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.header-right .sync { white-space: nowrap; }
.header-right button.linky { border: 0; background: none; color: var(--ink-2); cursor: pointer; text-decoration: underline; padding: 0; }

main { max-width: 1480px; margin: 0 auto; padding: 22px; }

/* ---- Tiles / cards ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.tile .label { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.tile .value { font-size: 22px; font-weight: 600; }
.tile .value.hero { font-size: 29px; }
.tile .delta { font-size: 12px; margin-top: 3px; color: var(--ink-2); }
.tile .delta .up { color: var(--good); font-weight: 600; }
.tile .delta .down { color: var(--bad); font-weight: 600; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.card .cap { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.chart-box { position: relative; height: 300px; }
.card .foot { font-size: 11px; color: var(--muted); margin-top: 10px; }
.card .tablebtn {
  border: 0; background: none; color: var(--ink-2); cursor: pointer;
  font-size: 12px; text-decoration: underline; padding: 0; margin-top: 8px;
}

/* cuadros resumen (estilo DASHBOARD Excel 25) */
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 12px; }
.sum-block { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-1); }
.sum-block .sum-title {
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  padding: 7px 12px; display: flex; align-items: center; gap: 7px;
  background: color-mix(in srgb, var(--acc, var(--ink-2)) 12%, var(--surface-1));
}
.sum-block .sum-rows { padding: 8px 12px 10px; }
.sum-block .sum-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 2.5px 0; }
.sum-block .sum-row .k { color: var(--ink-2); }
.sum-block .sum-row .v { font-variant-numeric: tabular-nums; font-weight: 500; }
.sum-block .sum-row.main .v { font-weight: 700; font-size: 13.5px; }
.sum-block .sum-row .up { color: var(--good); font-weight: 700; }
.sum-block .sum-row .down { color: var(--bad); font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Tables ---- */
.tbl-wrap { overflow-x: auto; }
table.data {
  border-collapse: collapse; width: 100%; font-size: 13px;
}
table.data th {
  text-align: right; font-weight: 600; color: var(--ink-2);
  padding: 7px 8px; border-bottom: 1px solid var(--baseline);
  white-space: nowrap; cursor: pointer; user-select: none;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th.txt, table.data td.txt { text-align: left; }
table.data td {
  padding: 6px 8px; border-bottom: 1px solid var(--grid);
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.data td.txt:first-child { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
table.data tr.total td { font-weight: 700; border-top: 1px solid var(--baseline); }
table.data td .up { color: var(--good); font-weight: 600; }
table.data td .down { color: var(--bad); font-weight: 600; }
table.data tr:hover td { background: var(--accent-wash); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: baseline; }

/* heatmap */
table.heat td { text-align: center; min-width: 52px; }
table.heat td.cell { color: var(--ink); }
table.heat td.cell.deep { color: #fff; }

/* ---- Config ---- */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.cfg-grid label { font-size: 12px; color: var(--ink-2); display: block; margin-bottom: 3px; }
.cfg-grid input {
  width: 100%; padding: 7px 9px; border: 1px solid var(--baseline); border-radius: 7px;
  background: var(--page); color: var(--ink); font: inherit; text-align: right;
  font-variant-numeric: tabular-nums;
}
.btn-primary {
  padding: 9px 18px; background: var(--s-2026); color: #fff;
  border: 0; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.cfg-msg { font-size: 13px; margin-left: 12px; }
.cfg-msg.ok { color: var(--good); }
.cfg-msg.err { color: var(--bad); }

/* selector de mes + filas de cliente clicables */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; color: var(--ink-2); }
.toolbar select {
  padding: 6px 10px; border: 1px solid var(--baseline); border-radius: 7px;
  background: var(--surface-1); color: var(--ink); font: inherit;
}
table.data tr.cli-row { cursor: pointer; }
table.data tr.sel td { background: var(--accent-wash); }
.cap a { color: var(--s-2026); }

.hidden { display: none !important; }
