* { box-sizing: border-box; }

/* Chef brand palette (BRAND.md) — Плита/Томат/Базилик/Горчица/Китель/Сталь.
   --bg/--card/--card-2/--panel are Плита (#17191C) at increasing elevation,
   derived by keeping the ORIGINAL theme's exact lightness steps between
   those four tokens (this app was dark navy before the rebrand) so the
   depth hierarchy that was already tuned doesn't shift, just the hue does.
   --pos is a brightened tint of brand Базилик (#2F7D5B), not the literal
   hex — see BRAND.md's measured contrast table: pure Базилик on Плита is
   3.53:1, which fails AA for anything smaller than large/bold text, and
   --pos is used for small bold numbers (cmp-value, kv li b, etc). This
   tint (#3c9f74) measures 5.37:1 on #17191C. --neg reuses Томат (the brand
   deck doesn't define a separate "bad" color; Томат already reads as
   negative/attention and passes 4.7:1 on Плита, see BRAND.md). */
:root {
  --bg: #17191c;
  --card: #202226;
  --card-2: #1c1e21;
  --panel: #25282d;
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #faf8f4;
  --muted: #8f97a3;
  --muted-2: #6a7381;
  --accent: #e5533d;
  --pos: #3c9f74;
  --neg: #e5533d;
  --gold: #e0a526;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Commissioner", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 56px;
}

h1, h2 { font-family: "Geologica", "Commissioner", sans-serif; }

.hidden { display: none !important; }

/* ---------- парольный вход по прямой ссылке ---------- */

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gate-title {
  font-family: "Geologica", sans-serif;
  font-size: 24px;
  font-weight: 800;
  margin: 0;
}
.gate-sub { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 8px; }
.gate-input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.gate-input:focus { outline: none; border-color: var(--accent); }
.gate-btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.gate-status { font-size: 12px; color: var(--neg); min-height: 14px; margin: 0; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 4px 0 18px;
  position: relative;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
  flex-shrink: 0;
}
.brand-logo-icon {
  height: 26px;
  width: auto;
  display: block;
}
.brand-wordmark {
  /* Logotype specifically uses Montserrat ExtraBold, not the Geologica
     used for headings elsewhere — see BRAND.md Typography. */
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.view-tabs { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: "Commissioner", sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.pill svg { color: var(--muted); flex-shrink: 0; }

.branch-btn { font-weight: 700; }
.branch-btn.locked { cursor: default; }
.range-pill {
  flex: 1; min-width: 150px; color: var(--muted); font-weight: 500;
  cursor: pointer; position: relative; text-align: left;
  font-family: "Commissioner", sans-serif;
}
.range-pill:hover { border-color: var(--accent); }
.range-pill #range-text { color: var(--text); font-weight: 600; }
.range-pill.custom-active { border-color: var(--gold); }
.range-pill.custom-active #range-text { color: var(--gold); }

.range-popover {
  position: absolute; z-index: 35; top: 52px; left: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  min-width: 280px;
}
.range-popover-row { display: flex; gap: 12px; }
.range-popover-row label {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; color: var(--muted); font-weight: 700;
}
.range-popover-row input[type="date"] {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; color: var(--text);
  font-family: "Commissioner", sans-serif; font-size: 13px; color-scheme: dark;
}
.range-popover-actions { display: flex; gap: 8px; margin-top: 14px; }
.range-apply {
  flex: 1; background: var(--accent); border: none; color: #fff;
  font-family: "Commissioner", sans-serif; font-weight: 700; font-size: 13px;
  padding: 10px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-align: center; text-decoration: none; box-sizing: border-box;
}
.range-reset {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-family: "Commissioner", sans-serif; font-weight: 600; font-size: 13px;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
.range-reset:hover { color: var(--text); }

.reports-popover { left: auto; right: 0; min-width: 320px; }
.reports-popover-text { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.reports-popover-text b { color: var(--text); }
.reports-popover input.tenant-link {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
}

.icon-pill { padding: 11px 12px; }

.tochki-toggle { cursor: pointer; color: var(--muted); }
.tochki-toggle.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tochki-toggle.active svg { color: #fff; }

/* ---------- точки: сравнение ---------- */
.tochki-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-top: 16px;
}
.tochki-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 20px; cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.tochki-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.tochki-name { font-size: 15px; font-weight: 800; margin-bottom: 14px; }
.tochki-revenue { font-family: var(--font-mono); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tochki-share { font-size: 12px; color: var(--muted); margin: 2px 0 16px; }
.tochki-stats { display: flex; flex-direction: column; gap: 8px; }
.tochki-stat-row { display: flex; justify-content: space-between; font-size: 13px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.tochki-stat-row:first-child { border-top: none; padding-top: 0; }
.tochki-stat-row span:first-child { color: var(--muted); }
.tochki-stat-row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.tochki-stat-row .fc-ok { color: var(--pos); }
.tochki-stat-row .fc-warn { color: var(--gold); }
.tochki-stat-row .fc-bad { color: var(--neg); }

/* ---------- меню: ABC-анализ ---------- */
.menu-stats {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0;
}
.menu-stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; min-width: 120px;
}
.menu-stat-label { font-size: 11px; color: var(--muted); }
.menu-stat-value { font-family: var(--font-mono); font-size: 19px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.menu-stat.abc-a .menu-stat-value { color: var(--pos); }
.menu-stat.abc-b .menu-stat-value { color: var(--gold); }
.menu-stat.abc-c .menu-stat-value { color: var(--neg); }

/* ---------- техкарты ---------- */
.techcards-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.techcards-list { list-style: none; margin: 0; padding: 0; }
.techcards-list li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft);
  font-size: 14px;
}
.techcards-list li:first-child { border-top: none; }
.techcards-list li span { color: var(--muted); font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.techcards-empty { text-align: center; color: var(--muted); padding: 30px; margin: 0; }

.no-cost-banner {
  background: rgba(229, 83, 61, 0.08);
  border: 1px solid rgba(229, 83, 61, 0.3);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}
.no-cost-head { color: var(--text); }
.no-cost-head b { color: var(--neg); }
.no-cost-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.no-cost-list li { font-size: 12px; color: var(--muted); }
.no-cost-list li b { color: var(--text); font-weight: 600; }

.menu-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.menu-search, .menu-cat-filter {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; color: var(--text); font-size: 13px; font-family: inherit;
}
.menu-search { flex: 1; min-width: 160px; }
.menu-search:focus, .menu-cat-filter:focus { outline: none; border-color: var(--accent); }
.menu-abc-filter { display: flex; gap: 6px; }
.abc-chip {
  width: 30px; height: 30px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-weight: 800; font-size: 13px;
  cursor: pointer; transition: opacity .12s;
}
.abc-chip.abc-a.active { background: rgba(60, 159, 116, .16); border-color: var(--pos); color: var(--pos); }
.abc-chip.abc-b.active { background: rgba(224, 165, 38, .16); border-color: var(--gold); color: var(--gold); }
.abc-chip.abc-c.active { background: rgba(229, 83, 61, .16); border-color: var(--neg); color: var(--neg); }
.abc-chip:not(.active) { opacity: .4; }

.menu-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--card); }
.menu-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.menu-table th, .menu-table td { padding: 10px 14px; text-align: left; white-space: nowrap; }
.menu-table th {
  background: rgba(255,255,255,0.04); color: var(--muted); font-weight: 700;
  font-size: 11px;
  position: sticky; top: 0;
}
.menu-table td:nth-child(4), .menu-table th:nth-child(4),
.menu-table td:nth-child(5), .menu-table th:nth-child(5),
.menu-table td:nth-child(6), .menu-table th:nth-child(6),
.menu-table td:nth-child(7), .menu-table th:nth-child(7),
.menu-table td:nth-child(8), .menu-table th:nth-child(8) { text-align: right; font-variant-numeric: tabular-nums; }
.menu-table td:nth-child(4), .menu-table td:nth-child(5),
.menu-table td:nth-child(6), .menu-table td:nth-child(7),
.menu-table td:nth-child(8) { font-family: var(--font-mono); }
.menu-table td:nth-child(2) { white-space: normal; font-weight: 600; }
.menu-table td:nth-child(3) { color: var(--muted); font-size: 12px; }
.menu-table tbody tr { border-top: 1px solid var(--border-soft); cursor: pointer; transition: background .1s; }
.menu-table tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
.menu-cls-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; font-size: 11px; font-weight: 800;
}
.menu-cls-badge.A { background: rgba(60, 159, 116, .16); color: var(--pos); }
.menu-cls-badge.B { background: rgba(224, 165, 38, .16); color: var(--gold); }
.menu-cls-badge.C { background: rgba(229, 83, 61, .16); color: var(--neg); }
.menu-table td.mt-fc.fc-ok { color: var(--pos); }
.menu-table td.mt-fc.fc-warn { color: var(--gold); }
.menu-table td.mt-fc.fc-bad { color: var(--neg); }

.fc-alert-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(229, 83, 61, 0.15);
  color: var(--neg);
  white-space: nowrap;
  cursor: help;
}
.menu-empty { text-align: center; color: var(--muted); padding: 30px; margin: 0; }

.period-switch {
  display: inline-flex;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px;
}

.pbtn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: "Commissioner", sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 11px;
  cursor: pointer;
}

.pbtn.active { background: var(--accent); color: #fff; }

/* branch dropdown */

.branch-menu {
  position: absolute;
  top: 52px;
  left: 0;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  min-width: 260px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.branch-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 14px;
  border-radius: 11px;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
}
.branch-menu-item .branch-item-name { flex: 1; }

.branch-menu-item:hover { background: rgba(255, 255, 255, 0.05); }
.branch-menu-item.active { color: var(--accent); font-weight: 700; }
.branch-menu-item .edit-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 2px 6px; font-size: 13px; cursor: pointer;
}
.branch-menu-item .edit-btn:hover { color: var(--text); }

/* ---------- hero ---------- */

.hero {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 30px 30px 26px;
}

.hero-title {
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 26px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.85fr);
  gap: 22px;
  align-items: start;
}

.hero-left { display: flex; flex-direction: column; gap: 16px; }

.mini-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 20px 22px;
}

.cmp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cmp-label { font-size: 15px; color: var(--text); font-weight: 500; }
.cmp-row-right { display: flex; align-items: center; gap: 8px; }
.cmp-value { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.cmp-value.pos { color: var(--pos); }

.explain-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  min-width: 24px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.explain-btn:hover { border-color: var(--gold); }
.explain-btn:disabled { opacity: 0.5; cursor: wait; }
.cmp-value.neg { color: var(--neg); }

.cmp-sub { font-size: 12px; color: var(--muted-2); margin-top: 4px; }

.kv { list-style: none; margin: 16px 0 0; padding: 0; }
.kv li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 14px;
}
.kv li:first-child { border-top: none; }
.kv li span { color: var(--muted); }
.kv li b { font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.kv li b.neg { color: var(--neg); }
.kv li b.pos { color: var(--pos); }

.forecast {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px 18px;
}

.fc-check {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 7px;
  background: rgba(224, 165, 38, 0.15);
  color: var(--gold);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  margin-top: 2px;
}

.fc-label { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.fc-value { font-size: 20px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; margin: 3px 0; font-family: var(--font-mono); }
.fc-sub { font-size: 12px; color: var(--muted-2); }

.hero-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 8px 22px;
}

.big-stat {
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
}
.big-stat:first-child { border-top: none; }

.bs-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.bs-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.bs-value.neg { color: var(--neg); }

/* ---------- generic block ---------- */

.block { margin-top: 34px; }

.block-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

.block-sub { font-size: 13px; color: var(--muted-2); margin: 6px 0 0; }

/* ---------- intraday comparison (накопительно к текущему часу) ---------- */

.intraday-cmp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.intraday-cmp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.intraday-cmp-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.intraday-cmp-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.intraday-cmp-value.pos { color: var(--pos); }
.intraday-cmp-value.neg { color: var(--neg); }
.intraday-cmp-sub { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

.chart-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin: 18px 0 4px;
}
.chart-legend .legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-left: 12px;
}
.chart-legend .legend-dot:first-child { margin-left: 0; }

/* ---------- KPI cards (Сводка) ---------- */

.kpi-scroll {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.kpi {
  border-radius: 20px;
  padding: 18px 18px 20px;
  border: 1px solid var(--border-soft);
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-ico { font-size: 20px; }
.kpi-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6); font-weight: 700; margin-top: 12px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* 5 KPI tiles, each a dark gradient so the white text stays readable —
   recolored into the brand family (Томат × 2, Плита-neutral, Базилик,
   Горчица) instead of the old purple/blue/pink/teal rainbow. */
.kpi.c0 { background: linear-gradient(155deg, #67271e, #2f120e); }
.kpi.c1 { background: linear-gradient(155deg, #2e3238, #151619); }
.kpi.c2 { background: linear-gradient(155deg, #5f241c, #2b100d); }
.kpi.c3 { background: linear-gradient(155deg, #1f513b, #0d2118); }
.kpi.c4 { background: linear-gradient(155deg, #574319, #281f0b); }

/* ---------- советы шефа (заменяет прежнюю карусель инсайтов) ---------- */

.insight-callout {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s;
}
.insight-callout:hover { color: var(--text); }

.chef-advice-panel {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px 24px 20px;
}
.chef-advice-panel .block-title { margin-bottom: 4px; }
.advice-sub { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 4px; }

#advice-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.chef-advice-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px 18px;
}
.chef-advice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chef-advice-area {
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
  color: var(--gold); background: rgba(224, 165, 38, 0.14);
  padding: 4px 10px; border-radius: 999px;
}
.chef-advice-effect { font-size: 13px; font-weight: 700; color: var(--pos); font-family: var(--font-mono); white-space: nowrap; }
.chef-advice-title { font-size: 15px; font-weight: 700; margin: 12px 0 14px; line-height: 1.4; }
.chef-advice-buttons { display: flex; gap: 10px; }
.chef-advice-accept {
  flex: 1; background: var(--accent); border: none; color: #fff;
  font-family: "Commissioner", sans-serif; font-weight: 700; font-size: 13px;
  padding: 10px; border-radius: 10px; cursor: pointer;
}
.chef-advice-later {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-family: "Commissioner", sans-serif; font-weight: 600; font-size: 13px;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
}
.chef-advice-later:hover { color: var(--text); }

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 22px;
  margin-top: 16px;
}

.card-title {
  font-size: 12px;
  color: var(--muted); font-weight: 700; margin-bottom: 16px;
}

/* line chart wrapper */
#weekday-chart svg, #hour-chart svg { width: 100%; height: auto; display: block; }

/* ---------- paired charts ---------- */
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.chart-pair .card { margin-top: 0; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.chart-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dotmark { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dotmark.green { background: var(--pos); }
.dotmark.violet { background: #e0a526; }
.chart-badge {
  font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border-soft);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}

/* ---------- главные моменты ---------- */
.moments { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.moment {
  display: flex; align-items: center; gap: 14px;
  border-radius: 16px; padding: 16px 18px;
  border: 1px solid var(--border-soft);
}
.moment.m-green  { background: linear-gradient(120deg, rgba(60,159,116,0.16), rgba(60,159,116,0.03)); }
.moment.m-red    { background: linear-gradient(120deg, rgba(229,83,61,0.16), rgba(229,83,61,0.03)); }
.moment.m-violet { background: linear-gradient(120deg, rgba(224,165,38,0.16), rgba(224,165,38,0.03)); }
.moment.m-teal   { background: linear-gradient(120deg, rgba(230,149,137,0.16), rgba(230,149,137,0.03)); }
.moment-date {
  flex-shrink: 0; width: 60px; text-align: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
  border-right: 1px solid var(--border-soft); padding-right: 12px;
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.moment-ico { font-size: 22px; flex-shrink: 0; }
.moment-body { min-width: 0; }
.moment-title { font-size: 16px; font-weight: 800; }
.moment-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------- leaderboard cards ---------- */
.lead-card { padding: 24px; }
.lead-heading { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.lead-sub { font-size: 13px; color: var(--muted-2); margin: 6px 0 18px; }
.lead-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.lead-row {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent, #e5533d);
  border-radius: 14px; padding: 14px 16px;
}
.lead-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.lead-name { font-size: 15px; font-weight: 700; }
.lead-value { font-size: 15px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); }
.lead-meta { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.lead-track { height: 5px; border-radius: 3px; background: var(--panel); overflow: hidden; }
.lead-fill { height: 100%; background: var(--accent, #e5533d); border-radius: 3px; }

/* ---------- rank grid (categories / dishes / foodcost) ---------- */
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rank-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 14px 16px;
}
.rank-head { display: flex; align-items: baseline; gap: 8px; }
.rank-medal { font-size: 15px; }
.rank-num {
  width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--panel); border-radius: 6px;
}
.rank-name { font-size: 14px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { font-size: 15px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); }
.rank-bar { height: 4px; border-radius: 2px; background: var(--panel); overflow: hidden; margin: 9px 0 7px; }
.rank-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #f0c26a); border-radius: 2px; }
.rank-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

.rank-item.fc-ok   { border-left: 3px solid var(--pos); }
.rank-item.fc-warn { border-left: 3px solid var(--gold); }
.rank-item.fc-bad  { border-left: 3px solid var(--neg); }
.rank-item.fc-ok   .fc-pct { color: var(--pos); }
.rank-item.fc-warn .fc-pct { color: var(--gold); }
.rank-item.fc-bad  .fc-pct { color: var(--neg); }
.rank-item.fc-ok   .rank-fill { background: var(--pos); }
.rank-item.fc-warn .rank-fill { background: var(--gold); }
.rank-item.fc-bad  .rank-fill { background: var(--neg); }

.more-btn {
  margin-top: 14px; width: 100%;
  background: transparent; border: 1px solid var(--border);
  color: var(--gold); font-family: "Commissioner", sans-serif; font-weight: 700; font-size: 13px;
  padding: 12px; border-radius: 12px; cursor: pointer;
}
.more-btn:hover { background: rgba(255,255,255,0.03); }

/* top dishes */
.hbar-list { list-style: none; margin: 0; padding: 0; }
.hbar-list li { margin-bottom: 14px; }
.hbar-list li:last-child { margin-bottom: 0; }
.hbar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 7px; }
.hbar-top .name { font-weight: 600; }
.hbar-top .value { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-family: var(--font-mono); }
.hbar-track { height: 7px; border-radius: 4px; background: var(--panel); overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--pos)); border-radius: 4px; }

/* channels */
.stacked-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin-bottom: 16px; background: var(--panel); }
.stacked-bar .seg { min-width: 2px; }

.channel-list { list-style: none; margin: 0; padding: 0; }
.channel-list li {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft);
}
.channel-list li:first-child { border-top: none; }
.channel-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.channel-name .swatch { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.channel-name .share { color: var(--muted); font-weight: 700; }
.channel-sub { font-size: 12px; color: var(--muted-2); margin-top: 3px; }
.channel-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); }

/* staff */
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border-soft);
  padding: 6px 11px; border-radius: 999px;
}
.staff-toggle {
  margin-top: 14px; width: 100%;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--muted); font-family: "Commissioner", sans-serif; font-weight: 600; font-size: 13px;
  padding: 10px; border-radius: 12px; cursor: pointer;
}
.staff-toggle:hover { color: var(--text); }

.staff-list { list-style: none; margin: 0; padding: 0; }
.staff-list li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft);
}
.staff-list li:first-child { border-top: none; }
.staff-main { display: flex; align-items: center; gap: 11px; }
.staff-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }
.staff-dot.on { background: var(--pos); box-shadow: 0 0 0 3px rgba(60, 159, 116, 0.15); }
.staff-name { font-size: 14px; font-weight: 600; }
.staff-role { font-size: 12px; color: var(--muted-2); margin-top: 1px; }
.staff-phone { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.error {
  position: sticky; top: 8px; z-index: 45;
  margin: 0 auto 14px; width: max-content; max-width: 92%;
  background: rgba(229, 83, 61, 0.15);
  border: 1px solid rgba(229, 83, 61, 0.4);
  color: #f1a89d; font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; text-align: center;
}

.skeleton { color: var(--muted-2); }

body.loading #app { opacity: 0.5; transition: opacity .15s; pointer-events: none; }

/* ---------- clickable leaderboard rows ---------- */

.lead-row, .rank-item, .channel-list li, .kv li {
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.lead-row:hover, .rank-item:hover { background: rgba(255, 255, 255, 0.035); transform: translateX(2px); }
.channel-list li:hover { background: rgba(255, 255, 255, 0.03); }
.channel-list li { border-radius: 12px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.channel-list li:first-child { border-top: none; }

/* ---------- drill-down panel ---------- */

.dd-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 6, 12, 0.65);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px);
}
.dd-overlay.hidden { display: none; }

.dd-panel {
  width: 100%; max-width: 720px;
  max-height: 88vh;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
  animation: dd-slide-up .22s ease;
}
@keyframes dd-slide-up { from { transform: translateY(24px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }

.dd-handle {
  width: 40px; height: 4px; border-radius: 3px;
  background: var(--border); margin: 12px auto 4px;
  flex-shrink: 0;
}

.dd-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 10px 22px 14px; flex-shrink: 0;
}
.dd-kicker { font-size: 11px; color: var(--muted); font-weight: 700; }
.dd-title { font-size: 22px; font-weight: 800; margin: 4px 0 0; letter-spacing: -0.01em; }
.dd-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.dd-close, .dd-maximize {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border-soft);
  color: var(--muted); font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
}
.dd-close:hover, .dd-maximize:hover { color: var(--text); }

.dd-period { margin: 0 22px 14px; align-self: flex-start; flex-shrink: 0; }

/* full-window mode — toggled via the maximize button */
.dd-panel.maximized {
  width: 100vw; max-width: 100vw;
  height: 100vh; max-height: 100vh;
  border-radius: 0; border: none;
  animation: none;
}
.dd-panel.maximized .dd-handle { display: none; }
.dd-panel.maximized .dd-body { max-height: none; flex: 1; }

.dd-body { overflow-y: auto; padding: 0 22px 28px; }

.dd-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.dd-stat {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: 12px 14px;
}
.dd-stat-label { font-size: 10.5px; color: var(--muted); font-weight: 700; }
.dd-stat-value { font-size: 17px; font-weight: 800; margin-top: 5px; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.dd-stat-value.pos { color: var(--pos); }
.dd-stat-value.neg { color: var(--neg); }
.dd-stat-loading { display: flex; align-items: center; padding: 6px 4px; color: var(--muted); font-size: 13px; font-weight: 600; }

.dd-chartcard {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border-soft);
  border-radius: 16px; padding: 16px; margin-bottom: 14px;
}
.dd-chart-title { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
#dd-daily-chart svg, #dd-hourly-chart svg { width: 100%; height: auto; display: block; }

@media (min-width: 760px) {
  .dd-overlay { align-items: center; }
  .dd-panel { border-radius: 26px; border-bottom: 1px solid var(--border); max-height: 82vh; }
  .dd-handle { display: none; }
}

/* ---------- chat assistant ---------- */

.chat-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ad311f);
  border: none; color: #fff; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 10px 28px rgba(229, 83, 61, 0.45);
  transition: transform .15s;
}
.chat-fab:hover { transform: scale(1.06); }
.chat-fab:active { transform: scale(0.96); }

.chat-panel { display: flex; flex-direction: column; max-height: 80vh; }
.chat-panel .dd-head { flex-shrink: 0; }
.chat-panel.maximized { max-height: 100vh; height: 100vh; }

.chat-suggestions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 0 22px 14px; flex-shrink: 0;
}
.chat-suggestions .chip {
  cursor: pointer; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-family: "Commissioner", sans-serif;
}
.chat-suggestions .chip:hover { background: rgba(255,255,255,0.06); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 4px 22px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 180px;
}

.chat-msg { max-width: 86%; display: flex; flex-direction: column; gap: 4px; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  overflow-x: auto; max-width: 100%;
}
.chat-msg.user .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: var(--panel); border: 1px solid var(--border-soft); border-bottom-left-radius: 4px; }
.chat-msg.assistant .chat-bubble.error { background: rgba(229,83,61,0.1); border-color: rgba(229,83,61,0.3); color: #f1a89d; }

.chat-table {
  width: 100%; border-collapse: collapse; margin: 8px 0;
  font-size: 12.5px;
}
.chat-table th, .chat-table td {
  border: 1px solid var(--border-soft); padding: 6px 9px; text-align: left;
}
.chat-table th { background: rgba(255,255,255,0.04); font-weight: 700; color: var(--muted); }

.chat-trace {
  font-size: 11px; color: var(--muted-2); display: flex; gap: 6px; flex-wrap: wrap;
}
.chat-trace span {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: 999px; padding: 3px 9px;
}

.chat-typing { display: flex; gap: 4px; padding: 13px 15px; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: chat-bounce 1.1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-input-row {
  display: flex; gap: 10px; padding: 14px 22px 20px; flex-shrink: 0;
  border-top: 1px solid var(--border-soft); margin-top: 10px;
}
.chat-input {
  flex: 1; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 16px; color: var(--text);
  font-family: "Commissioner", sans-serif; font-size: 14px; outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  background: var(--accent); border: none; color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.chat-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 560px) {
  .chat-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; }
  .chat-suggestions { padding: 0 16px 12px; }
  .chat-body { padding: 4px 16px; }
  .chat-input-row { padding: 12px 16px 16px; }
}

@media (max-width: 560px) {
  .dd-stats { grid-template-columns: 1fr 1fr; }
  .dd-title { font-size: 19px; }
}

.load-bar {
  position: sticky; top: 8px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  width: max-content; margin: 0 auto 10px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 9px 16px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(229,83,61,0.4);
}
.load-bar span {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .kpi-scroll {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .kpi-scroll::-webkit-scrollbar { height: 0; }
  .kpi { flex: 0 0 46%; scroll-snap-align: start; }
  .chart-pair, .moments, .rank-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  #app { padding: 12px 13px 48px; }
  .hero { padding: 22px 18px 20px; border-radius: 22px; }
  .topbar { gap: 8px; }
  .range-pill { order: 3; flex-basis: 100%; }
  .period-switch { flex: 1; justify-content: space-between; }
  .pbtn { flex: 1; padding: 8px 4px; }
  .block-title { font-size: 20px; }
  .lead-heading { font-size: 19px; }
  .kpi { flex-basis: 62%; }
  .insight { flex-basis: 90%; padding: 20px; }
  .bs-value { font-size: 23px; }
  .lead-card { padding: 18px; }
  .moment { padding: 14px; gap: 10px; }
  .moment-date { width: 48px; padding-right: 9px; }
}

/* Выбор заведения на входе — когда ссылка без ?branch=. */
.gate-branch-pick {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-bottom: 14px;
}
.gate-branch-btn {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border, #2a2e34);
  background: var(--card, #1d2024);
  color: var(--text, #e8eaed);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.gate-branch-btn:hover { border-color: var(--accent, #e8622c); }
