/*
  Цвета взяты из витрины кондитерской, а не из набора «аналитика по умолчанию»:
  фисташка — рост и текущий выбор, малина — падение и срочное, карамель —
  предупреждение, эспрессо — текст. Таблицы на белом, страница — на бледной
  фисташке, чтобы лист с цифрами читался как лист.
*/
:root {
  --ground: #EEF1E8;
  --paper: #FFFFFF;
  --ink: #26201C;
  --ink-hover: #3B332D;
  --muted: #6A655E;
  --line: #DCE1D3;
  --hover: #F6F8F1;
  --pistachio: #4E6C25;
  --pistachio-soft: #E1E9D1;
  --raspberry: #A8294C;
  --raspberry-soft: #F5E0E6;
  --caramel: #8C5A0E;
  --caramel-soft: #F3E6CF;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}

a { color: var(--pistachio); text-underline-offset: 0.18em; }

:focus-visible { outline: 2px solid var(--pistachio); outline-offset: 2px; }

button, input, select { font: inherit; color: inherit; }

/* ── Шапка ─────────────────────────────────────────────────────────── */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 32px;
  padding: 10px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.nav { display: flex; flex-wrap: wrap; gap: 0 22px; }

.nav a {
  padding: 8px 0 6px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover { color: var(--ink); }

.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--pistachio); }

.who {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

.who form { margin: 0; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--pistachio);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.data-state {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--pistachio-soft);
  color: var(--pistachio);
  text-decoration: none;
  white-space: nowrap;
}

.data-state.warn { background: var(--caramel-soft); color: var(--caramel); }
.data-state.crit { background: var(--raspberry-soft); color: var(--raspberry); }
.data-state[aria-current="page"] { box-shadow: inset 0 0 0 1.5px currentColor; }

main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 72px; }

/* ── Фильтры ───────────────────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
  margin-bottom: 36px;
}

/* Сегментный переключатель — выбор из взаимоисключающих вариантов,
   которые сужают данные: период, «все позиции / только в минусе». */
.presets, .toggles {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.toggles { display: inline-flex; margin: -4px 0 18px; }

.presets a, .toggles a {
  padding: 7px 14px;
  border-right: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.presets a:last-child, .toggles a:last-child { border-right: 0; }
.presets a:hover, .toggles a:hover { background: var(--hover); }
.presets a[aria-current], .toggles a[aria-current] { background: var(--pistachio); color: var(--paper); }

.range, .outlet, .snapshot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }

.range label, .outlet label, .snapshot label { display: flex; align-items: center; gap: 6px; color: var(--muted); }

input[type="date"], select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

.button {
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
}

.button:hover { background: var(--hover); }

/* ── Обзор ─────────────────────────────────────────────────────────── */

.summary { margin-bottom: 28px; }

.summary.with-chart {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  align-items: end;
  gap: 24px 56px;
}

.lede {
  max-width: 30em;
  margin: 0 0 10px;
  font-size: clamp(23px, 2.5vw, 32px);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.lede-detail { max-width: 44em; margin: 0; color: var(--muted); font-size: 17px; }

.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .now { fill: var(--pistachio); }
.chart .base { fill: var(--pistachio-soft); }
.chart text { fill: var(--muted); font-family: var(--font); font-size: 12px; text-anchor: middle; }
.chart text.weekend { fill: var(--ink); font-weight: 600; }
.chart figcaption { margin-top: 6px; color: var(--muted); font-size: 13px; }

/* ── Заголовки экранов ─────────────────────────────────────────────── */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
}

.page-head h1 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }

.scope { margin: 4px 0 0; color: var(--muted); }

/* Разрез — другой взгляд на те же данные, поэтому и вид другой. */
.views { display: flex; flex-wrap: wrap; gap: 4px; }

.views a {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}

.views a:hover { background: var(--pistachio-soft); }
.views a[aria-current] { background: var(--ink); color: var(--paper); }

/* ── Таблицы ───────────────────────────────────────────────────────── */

.sheet {
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px 8px;
}

.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }

.export {
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  text-decoration: none;
}

.export:hover { background: var(--ink-hover); }

.scroll { max-height: 75vh; overflow: auto; }

.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }

.grid th, .grid td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  min-width: 5.5em;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  vertical-align: bottom;
  white-space: normal;
}

.grid td.text { min-width: 12em; max-width: 30em; white-space: normal; }

.grid .money, .grid .price, .grid .int, .grid .qty, .grid .pct, .grid .delta_pct, .grid .hour { text-align: right; }

.grid tbody tr:hover td { background: var(--hover); }

/* Итог — как в бухгалтерской книге: черта сверху, двойная снизу. */
.grid tfoot td {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
  background: var(--paper);
  font-weight: 600;
}

.grid .neg { color: var(--raspberry); }
.grid .pos { color: var(--pistachio); }

.grid.compact th, .grid.compact td { padding: 5px 10px; font-size: 13px; }

.sort {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

th[aria-sort="ascending"] .sort::after { content: " ↑"; }
th[aria-sort="descending"] .sort::after { content: " ↓"; }

.empty, .note { margin: 0; padding: 12px 16px 16px; color: var(--muted); }
.note { max-width: 60em; font-size: 13px; }

/* ── Качество данных ───────────────────────────────────────────────── */

.issue {
  margin: 0 0 12px;
  padding: 10px 16px;
  border-left: 4px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: var(--paper);
}

.issue.crit { border-left-color: var(--raspberry); }
.issue.warn { border-left-color: var(--caramel); }
.issue p { max-width: 46em; margin: 0; }

.issues { display: grid; gap: 12px; max-width: 62em; margin-bottom: 40px; }
.issues .issue { margin: 0; padding: 16px 20px; }
.issues h2 { max-width: 34em; margin: 0 0 6px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.issues .todo { margin-top: 8px; }
.issues .since { margin-top: 4px; color: var(--muted); font-size: 13px; }
.issues details { margin-top: 10px; }
.issues summary { color: var(--pistachio); cursor: pointer; }
.issues details .scroll { max-height: 360px; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; }

.all-clear { margin: 0 0 32px; font-size: 20px; }

.state.failed, .state.stale { color: var(--raspberry); }
.state.ok { color: var(--pistachio); }

.resolved { margin: 0; padding: 4px 16px 16px 36px; }
.resolved li { margin: 4px 0; }

/* ── Вход ──────────────────────────────────────────────────────────── */

.login { display: grid; min-height: 100vh; place-items: center; padding: 24px; }

.login form {
  display: grid;
  gap: 14px;
  width: min(100%, 380px);
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.login h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.login .hint { margin: 0; color: var(--muted); font-size: 14px; }
.login label { display: grid; gap: 4px; color: var(--muted); font-size: 14px; }

.login input {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 16px;
}

.login .error { margin: 0; color: var(--raspberry); }

.button.primary {
  padding: 10px;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.button.primary:hover { background: var(--ink-hover); }

/* ── Графики над таблицами ─────────────────────────────────────────── */

/* Полоски — разрез: кто больше. Подпись, полоска и сумма в одну строку,
   чтобы читалось как список, а не как картинка. */
.bars { margin: 0; padding: 2px 16px 16px; border-bottom: 1px solid var(--line); }

.bars ol {
  display: grid;
  grid-template-columns: minmax(7em, max-content) minmax(80px, 1fr) max-content;
  align-items: center;
  gap: 5px 14px;
  max-width: 76em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bars li { display: contents; }
.bar-label { max-width: 24em; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.bar-label a { color: var(--ink); text-decoration-color: var(--line); }
.bar-label a:hover { color: var(--pistachio); }
.bar-track { height: 10px; border-radius: 2px; background: var(--hover); }
.bar-fill { display: block; height: 100%; min-width: 2px; border-radius: 2px; background: var(--pistachio); }
.bar-fill.neg { background: var(--raspberry); }
.bar-value { font-size: 14px; text-align: right; white-space: nowrap; }
.bar-value.neg { color: var(--raspberry); }
.bars figcaption, .series figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; }

/* Столбцы — время: дни и часы. */
.series { margin: 0; padding: 4px 16px 14px; border-bottom: 1px solid var(--line); }
.series-scroll { overflow-x: auto; }
.series svg { display: block; width: 100%; height: auto; }
.series rect { fill: var(--pistachio); }
.series rect:hover { fill: var(--ink); }
.series text { fill: var(--muted); font-family: var(--font); font-size: 11px; text-anchor: middle; }
.series text.mark { fill: var(--ink); font-weight: 600; }

/* ── Ссылки вниз, подфильтры, карточки ──────────────────────────────── */

.grid td a { color: inherit; text-decoration-color: var(--pistachio); text-decoration-thickness: 1.5px; }
.grid td a:hover { color: var(--pistachio); }

.summary-line { margin: 6px 0 0; font-size: 17px; }

.subfilters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: -4px 0 18px; }
.subfilters .toggles { margin: 0; }

.chip {
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: var(--pistachio-soft);
  font-size: 14px;
}

.chip a { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 13px; text-decoration: none; }
.chip a:hover { background: var(--ink); color: var(--paper); }

.back { margin: 0 0 14px; }

/* Полями вровень: последний ряд растягивается, серых дыр в сетке нет. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin: 0 0 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.facts div { flex: 1 1 190px; padding: 10px 14px; background: var(--paper); }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 2px 0 0; font-weight: 500; }

.lead-note { max-width: 52em; margin: -6px 0 20px; color: var(--muted); }

/* ── Что есть в iiko ───────────────────────────────────────────────── */

.catalog-intro { max-width: 52em; margin: -6px 0 18px; color: var(--muted); }

.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 34px; }
.toc a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); text-decoration: none; }
.toc a:hover { border-color: var(--pistachio); }

.catalog-block { margin: 0 0 44px; scroll-margin-top: 16px; }
.catalog-block > h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.block-lead { max-width: 52em; margin: 0 0 16px; color: var(--muted); }

/* Чек — единственное место с «бумагой»: это и есть предмет разговора. */
.receipts { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; align-items: start; }

.receipt {
  position: relative;
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  background: var(--paper);
  font-size: 14px;
}

.receipt::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -9px;
  left: -1px;
  height: 9px;
  background: radial-gradient(circle at 6px 0, var(--paper) 5.5px, transparent 6px) 0 0 / 12px 9px repeat-x;
}

.receipt p { margin: 0; }
.receipt-why { margin-bottom: 10px !important; color: var(--pistachio); font-size: 13px; font-weight: 600; }
.receipt header { padding-bottom: 10px; border-bottom: 1px dashed var(--muted); color: var(--muted); font-size: 13px; }
.receipt-outlet { color: var(--ink); font-size: 15px; font-weight: 600; }
.receipt-lines { margin: 0; padding: 10px 0; list-style: none; border-bottom: 1px dashed var(--muted); }
.receipt-lines li { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 3px 0; }
.rl-sum { text-align: right; }
.rl-note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.receipt-lines li.removed .rl-name, .receipt-lines li.removed .rl-sum { color: var(--raspberry); text-decoration: line-through; }
.receipt-lines li.removed .rl-note { color: var(--raspberry); }
.receipt footer { padding-top: 8px; }
.receipt footer p { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.receipt footer p span:last-child { text-align: right; }
.receipt .receipt-total { margin-bottom: 4px !important; color: var(--ink); font-size: 16px; font-weight: 600; }
.receipt-storno { color: var(--raspberry) !important; font-weight: 600; }

.field-filter { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--muted); }
.field-filter input { width: min(22em, 70vw); padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }

.tag-group { margin: 0 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.tag-group > summary { padding: 10px 16px; cursor: pointer; }
.tag-group[open] > summary { border-bottom: 1px solid var(--line); }
.tag-name { font-weight: 600; }
.tag-meta { color: var(--muted); font-size: 14px; }

.scroll.small { max-height: 520px; }
.grid.fields td { vertical-align: top; }
.grid.fields code, .field-names code, .endpoint code { color: var(--muted); font-size: 12px; }
.grid.fields tr.is-empty td { color: var(--muted); }
.field-title { font-weight: 500; }
.examples { max-width: 44em !important; }

.example {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--hover);
  font-size: 13px;
  white-space: nowrap;
}

.hidden-value { color: var(--caramel); font-size: 13px; }
.blank { color: var(--muted); font-size: 13px; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.loaded { background: var(--pistachio); color: var(--paper); }
.pill.open { background: var(--pistachio-soft); color: var(--pistachio); }
.pill.closed { background: var(--raspberry-soft); color: var(--raspberry); }
.pill.missing { background: var(--hover); color: var(--muted); }

.source { margin: 0 0 12px; padding: 14px 18px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.source-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.source-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.source p { max-width: 60em; margin: 6px 0 0; }
.source-note { color: var(--muted); font-size: 14px; }
.source-error { color: var(--raspberry); font-size: 13px; }
.source .scroll.small { max-width: 60em; max-height: 320px; margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; }
.chips-line { line-height: 1.9; }
.field-names { font-size: 13px; line-height: 1.8; }
.field-names > span { color: var(--muted); }
.field-names code { margin-right: 8px; white-space: nowrap; }
.endpoint { margin-top: 8px !important; }
.source-examples { margin-top: 10px; }
.source-examples summary { color: var(--pistachio); cursor: pointer; }
.example-list { display: grid; gap: 10px; margin-top: 10px; }
.example-record { padding: 10px 12px; overflow-x: auto; border-radius: 6px; background: var(--hover); font-size: 13px; }

.kv { display: grid; gap: 2px; margin: 0; }
.kv > div { display: grid; grid-template-columns: minmax(8em, 14em) 1fr; gap: 12px; }
.kv dt { color: var(--muted); overflow-wrap: anywhere; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-list { margin: 0; padding-left: 1.3em; }
.kv-list > li { padding: 4px 0; }
.kv-list > li + li { border-top: 1px dotted var(--line); }

/* ── Узкие экраны ──────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .summary.with-chart { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .bar { padding: 10px 16px; gap: 6px 16px; }
  .nav { order: 3; flex-wrap: nowrap; width: 100%; overflow-x: auto; }
  .who { gap: 12px; }
  .who .user { display: none; }
  main { padding: 16px 16px 56px; }
  .filters { margin-bottom: 28px; }
  .presets { max-width: 100%; overflow-x: auto; }
  .lede-detail { font-size: 15px; }
  /* На телефоне у каждой строки своя сетка: подпись и сумма сверху, полоска под ними. */
  .bars ol { display: block; }
  .bars li { display: grid; grid-template-columns: minmax(0, 1fr) max-content; grid-template-areas: "label value" "track track"; gap: 2px 10px; margin-bottom: 8px; }
  .bar-label { grid-area: label; max-width: none; }
  .bar-value { grid-area: value; }
  .bar-track { grid-area: track; }
  .kv > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media print {
  .bar, .filters, .views, .toggles, .export, .subfilters, .toc, .field-filter { display: none; }
  body { background: var(--paper); }
  .scroll { max-height: none; overflow: visible; }
}
