/* «Сводка» — кабинет владельца сети винных магазинов (ARCHITECTURE.md §6.4).
   Идея: тёмно-синий лист сверху с главной цифрой раздела и «пульсом дня», ниже — спокойные списки.
   Цвета: ночь и янтарь — фирменные (иконка), рост — «лоза», падение — «бордо», вторичный текст — «пробка».
   Один шрифт — Onest (OFL, лежит в /static/fonts), цифры моноширинные, чтобы суммы стояли столбиком. */

@font-face { font-family: "Onest"; font-weight: 400; font-display: swap;
  src: url("fonts/onest-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap;
  src: url("fonts/onest-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191-2193, U+2212, U+2215, U+25B2, U+25BC, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap;
  src: url("fonts/onest-cyrillic-700-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap;
  src: url("fonts/onest-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191-2193, U+2212, U+2215, U+25B2, U+25BC, U+FEFF, U+FFFD; }

:root {
  --night: #0E1A3A;          /* фирменный тёмно-синий: лист сверху */
  --night-raised: #1B2B58;   /* поля и переключатели на листе */
  --on-night: #EEF1F8;
  --on-night-dim: #9EA9C8;
  --amber: #FF8C1A;          /* единственный акцент: пульс, выбранное */
  --amber-ink: #2B1600;
  --amber-soft: #B45A00;     /* янтарный текст на светлом */
  --paper: #F4F5F9;
  --surface: #FFFFFF;
  --ink: #141B33;
  --cork: #7C7468;           /* вторичный текст — тёплый «пробковый» серый */
  --rule: #E0E2EA;
  --vine: #3E8E5A;           /* рост */
  --bordeaux: #A8243D;       /* падение, минус */
  --vine-night: #7FCF9A;
  --bordeaux-night: #FF97AA;
  --nav-h: 58px;
  --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --night: #15244D; --night-raised: #22356A;
    --paper: #0A1129; --surface: #111A36; --ink: #E8ECF6; --cork: #A79E91; --rule: #222D50;
    --vine: #6CC08A; --bordeaux: #F07A8E; --amber-soft: #FFAE5C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.45 "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
}
a { color: inherit; }
p { margin: 0; }
h1 { font-size: 25px; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 17px; line-height: 1.3; margin: 0 0 4px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- лист сверху ---------- */
.sheet {
  background: var(--night); color: var(--on-night);
  border-radius: 0 0 28px 28px;
  padding: env(safe-area-inset-top) 0 22px;
}
.sheet > *, main { max-width: 720px; margin-inline: auto; padding-inline: max(var(--gutter), env(safe-area-inset-left)); }
.top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; }
.top-actions { display: flex; margin-right: -10px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--on-night-dim); }
.icon-btn:hover { color: var(--on-night); }

.fresh { font-size: 13px; color: var(--on-night-dim); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--vine-night); flex: none; }
.fresh-warn::before { background: var(--amber); }
.fresh-warn { color: #FFC48A; }
.fresh-alert::before { background: var(--bordeaux-night); }
.fresh-alert { color: var(--bordeaux-night); font-weight: 700; }

/* выбор магазина и периода */
.pickers { margin-top: 2px; }
.store-pick select, .store-one {
  width: 100%; min-height: 46px; font: inherit; font-size: 17px; font-weight: 700;
  color: var(--on-night); background: var(--night-raised); border: 0; border-radius: 14px; padding: 0 44px 0 14px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%239EA9C8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.store-one { display: flex; align-items: center; background-image: none; }
.chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 12px auto 0; padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 20px; border: 1px solid rgba(255, 255, 255, .14); color: var(--on-night-dim);
  text-decoration: none; font-size: 15px; white-space: nowrap;
}
.chips a[aria-current] { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 700; }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.dates label { font-size: 13px; color: var(--on-night-dim); margin: 0; }
.dates input { width: 100%; margin-top: 4px; background: var(--night-raised); color: var(--on-night); border: 0; color-scheme: dark; }
.dates button { grid-column: 1 / -1; background: var(--on-night); color: var(--night); border: 0; font-weight: 700; }
.period { font-size: 13px; color: var(--on-night-dim); margin-top: 8px; }
.tabs { display: flex; gap: 4px; background: var(--night-raised); border-radius: 14px; padding: 4px; margin-top: 4px; margin-bottom: 10px; }
.sheet > .tabs { margin-inline: max(var(--gutter), env(safe-area-inset-left)); }
.tabs a { flex: 1; text-align: center; min-height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; text-decoration: none; color: var(--on-night-dim); font-size: 15px; }
.tabs a[aria-current] { background: var(--on-night); color: var(--night); font-weight: 700; }

/* главная цифра раздела */
.hero { margin-top: 20px; }
.hero-label { font-size: 15px; color: var(--on-night-dim); }
.hero-num { font-size: 44px; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 6px; }
.hero-name { font-size: 28px; font-weight: 700; margin: 2px 0 4px; }
.hero-sub, .hero-cmp { font-size: 15px; color: var(--on-night-dim); margin-top: 2px; }
.cmp { font-weight: 700; }
.cmp.up { color: var(--vine); }
.cmp.down { color: var(--bordeaux); }
.sheet .cmp.up { color: var(--vine-night); }
.sheet .cmp.down { color: var(--bordeaux-night); }
.sheet .cmp:not(.up):not(.down) { color: var(--on-night); }

/* пульс дня */
.pulse { margin: 16px 0 0; }
.pulse svg { display: block; width: 100%; height: auto; overflow: visible; }
.pulse-base { stroke: rgba(255, 255, 255, .14); stroke-width: 1; }
.pulse-yday { fill: none; stroke: var(--on-night-dim); stroke-width: 1.4; stroke-dasharray: 3 4; opacity: .8; }
.pulse-now { stroke: rgba(255, 255, 255, .22); stroke-width: 1; stroke-dasharray: 2 3; }
.pulse-today { fill: none; stroke: var(--amber); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.pulse-today.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s cubic-bezier(.3, .7, .2, 1) .15s forwards; }
.pulse-dot { fill: #fff; stroke: var(--amber); stroke-width: 2; }
.pulse-hour { fill: var(--on-night-dim); font-size: 9px; text-anchor: middle; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.pulse-legend { display: flex; gap: 16px; font-size: 13px; color: var(--on-night-dim); margin-top: 6px; }
.pulse-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-today::before { content: ""; width: 16px; height: 3px; border-radius: 2px; background: var(--amber); }
.key-yday::before { content: ""; width: 16px; height: 0; border-top: 2px dashed var(--on-night-dim); }
.versus { margin: 14px 0 0; }
.versus div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.versus dt { color: var(--on-night-dim); font-size: 15px; }
.versus dd { margin: 0; font-weight: 700; text-align: right; }
.versus .versus-full dt, .versus .versus-full dd { font-size: 14px; font-weight: 400; color: var(--on-night-dim); }
.chart { position: relative; height: 170px; margin-top: 16px; }

/* ---------- списки под листом ---------- */
main { padding-top: 6px; }
.block { margin-top: 26px; }
.block > h2 + .note { margin-bottom: 4px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--rule); }
.line {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  min-height: 54px; padding: 10px 0; text-decoration: none; color: inherit;
}
.line-main { min-width: 0; overflow-wrap: anywhere; }
.line-num { margin-left: auto; text-align: right; white-space: nowrap; font-weight: 700; }
.line-note { display: block; font-size: 13px; font-weight: 400; color: var(--cork); margin-top: 1px; }
.weekday { color: var(--cork); font-size: 14px; }
.bar { display: block; width: 100%; height: 2px; margin-top: -2px; }
.bar rect { fill: var(--amber); opacity: .6; }
.neg { color: var(--bordeaux); }
.note { font-size: 13px; color: var(--cork); margin-top: 8px; }
.empty { padding: 18px 0; color: var(--cork); border-bottom: 0 !important; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; line-height: 1.6; padding: 0 8px; border-radius: 10px;
  background: rgba(255, 140, 26, .16); color: var(--amber-soft); vertical-align: 2px; }
.sheet .badge { color: #FFB872; background: rgba(255, 140, 26, .2); }

/* данные неполные / раздел недоступен (ARCHITECTURE.md §11.3) */
.data-note { margin: 16px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  background: rgba(255, 140, 26, .12); color: var(--amber-soft); }
.data-note a { font-weight: 700; }
.view-as { margin: 16px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 600;
  background: var(--bordeaux); color: #fff; }
.levels { list-style: none; padding: 0; margin: 8px 0 0; }
.levels li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.state { display: inline-block; font-size: 12px; font-weight: 700; padding: 0 8px; border-radius: 10px; line-height: 1.7; }
.state-ok { background: rgba(62, 142, 90, .15); color: var(--vine); }
.state-partial { background: rgba(255, 140, 26, .16); color: var(--amber-soft); }
.state-none { background: rgba(124, 116, 104, .16); color: var(--cork); }
.todo { margin-top: 6px; font-size: 14px; }
.store-states { font-size: 13px; color: var(--cork); margin-top: 4px; }

/* раскрытие строки: внутреннее — с янтарной чертой слева */
details.drill > summary, details.fold > summary { list-style: none; cursor: pointer; }
details.drill > summary::-webkit-details-marker, details.fold > summary::-webkit-details-marker { display: none; }
details.drill > summary::after, details.fold > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--cork); border-bottom: 2px solid var(--cork);
  transform: rotate(-45deg); transition: transform .15s;
}
details[open] > summary::after { transform: rotate(45deg); }
details.drill[open] > summary .line-main { font-weight: 700; }
.drill-body { margin: 0 0 14px 2px; padding-left: 14px; border-left: 2px solid var(--amber); }
.list-sub > li { border-bottom-style: dashed; }
.list-sub .line { min-height: 44px; padding: 8px 0; }
.list-sub .line-num { font-weight: 400; }
details.fold { border-bottom: 1px solid var(--rule); }
details.fold > summary { display: flex; align-items: center; gap: 8px; min-height: 52px; }
details.fold > summary h2 { margin: 0; }
details.fold > summary .count { color: var(--cork); margin-right: auto; }
.block-aside { border: 1px dashed var(--rule); border-radius: 18px; padding: 14px 14px 4px; }
.block-aside .list > li:last-child { border-bottom: 0; }

/* ---------- формы ---------- */
label { display: block; font-size: 14px; color: var(--cork); margin: 12px 0; }
input:not([type=hidden]):not([type=date]), .dates input {
  display: block; width: 100%; min-height: 46px; margin-top: 4px; padding: 0 14px;
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px;
}
.dates input { padding: 0 10px; }
.search { margin-top: 8px; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px;
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 12px; cursor: pointer; text-decoration: none; margin: 6px 0;
}
.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 700; }
.quiet { background: none; border: 0; color: var(--cork); text-decoration: underline; padding: 0; min-height: 44px; }
.wide, .more { width: 100%; }
.stack button { margin-top: 4px; }
.error { color: var(--bordeaux); margin: 8px 0; }
.ok { color: var(--vine); margin: 8px 0; }

/* вход и «нет связи» — вся страница тёмная */
body.night { background: var(--night); color: var(--on-night); padding-bottom: 0; }
.door { max-width: 380px; min-height: 100vh; margin: 0 auto; padding: 14vh 24px 32px; display: flex; flex-direction: column; }
.door-mark { width: 84px; height: 42px; margin-bottom: 18px; }
.door h1 { font-size: 31px; margin-bottom: 6px; }
.door-sub { color: var(--on-night-dim); margin-bottom: 18px; }
.door label { color: var(--on-night-dim); }
.door input:not([type=hidden]) { background: var(--night-raised); border-color: transparent; color: var(--on-night); }
.door button, .door .btn { width: 100%; margin-top: 10px; }
.door .error { color: var(--bordeaux-night); }
.door-note { font-size: 13px; color: var(--on-night-dim); margin-top: auto; padding-top: 32px; }

/* ---------- нижняя навигация ---------- */
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
}
nav.bottom a {
  position: relative; flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: var(--nav-h); font-size: 13px; color: var(--cork); text-decoration: none;
}
nav.bottom a[aria-current] { color: var(--ink); font-weight: 700; }
nav.bottom a[aria-current]::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 26px; height: 3px; margin-left: -13px;
  border-radius: 0 0 3px 3px; background: var(--amber);
}

.ios-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 11;
  background: var(--night); color: var(--on-night); border-radius: 16px; padding: 14px 16px; font-size: 15px;
}
.ios-hint .link { background: none; border: 0; color: var(--amber); padding: 0; min-height: 36px; margin: 6px 0 0; font-weight: 700; }

.htmx-request .drill-body { opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  .pulse-today.draw { animation: none; stroke-dashoffset: 0; }
  details > summary::after { transition: none; }
}
.spaced { margin-top: 18px; }

/* показатели ядра (Я2–Я13) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; margin: 8px 0 0; }
.kpis div { padding: 10px 0; border-top: 2px solid var(--rule); }
.kpis dt { font-size: 13px; color: var(--cork); }
.kpis dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; }
.kpis dd.cmp, .kpis dd.line-note { font-size: 13px; }
.heat { width: 100%; border-collapse: separate; border-spacing: 2px; margin-top: 8px; table-layout: fixed; }
.heat th { font-size: 11px; font-weight: 400; color: var(--cork); text-align: center; }
.heat th:first-child { width: 22px; }
.heat td { height: 18px; border-radius: 3px; background: var(--rule); }
.heat td.l1 { background: rgba(255, 140, 26, .18); }
.heat td.l2 { background: rgba(255, 140, 26, .36); }
.heat td.l3 { background: rgba(255, 140, 26, .55); }
.heat td.l4 { background: rgba(255, 140, 26, .78); }
.heat td.l5 { background: var(--amber); }
.late { color: var(--bordeaux); }

/* переключатель сети (если у пользователя их несколько) */
.client-pick { margin: 0 0 10px; }
.client-pick select { width: 100%; min-height: 40px; font: inherit; font-size: 15px; color: var(--on-night);
  background: transparent; border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; padding: 0 12px; }

/* «Настройки» владельца */
.check { display: flex; gap: 10px; align-items: center; font-weight: 400; }
.access { border: 1px solid var(--rule); border-radius: 12px; padding: 8px 12px 10px; margin: 0; }
.access legend { font-weight: 700; padding: 0 4px; }
.secret-once code { display: inline-block; font-size: 22px; padding: 10px 14px; background: var(--surface);
  border: 2px solid var(--amber); border-radius: 12px; user-select: all; }
