:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --grid: #e9e8e4;
  --axis: #d3d2cb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6b6a64;
  --link: #1f63b8;
  --link-hover: #174d8f;
  --fact-neutral: #52514e;
  --hover-band: rgb(0 0 0 / 4%);
  --series-kitchen: #2a78d6;
  --series-kgloto: #eb6834;
  --series-ruta: #1baf7a;
  --series-pgs: #eda100;
  --good-bg: #e2f1e2;
  --good-fg: #0a6b0a;
  --bad-bg: #fbe6e4;
  --bad-fg: #a8231b;
  --demo-bg: #0b0b0b;
  --demo-fg: #fcfcfb;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 4px 16px rgb(0 0 0 / 4%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --grid: #262624;
    --axis: #3d3d39;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --link: #6ea8ee;
    --link-hover: #93bff3;
    --fact-neutral: #c3c2b7;
    --hover-band: rgb(255 255 255 / 5%);
    --series-kitchen: #3987e5;
    --series-kgloto: #d95926;
    --series-ruta: #199e70;
    --series-pgs: #c98500;
    --good-bg: #173219;
    --good-fg: #86d986;
    --bad-bg: #3b1916;
    --bad-fg: #ff9d92;
    --demo-bg: #f0efec;
    --demo-fg: #111110;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: #2f2f2c;
  --grid: #262624;
  --axis: #3d3d39;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --link: #6ea8ee;
  --link-hover: #93bff3;
  --fact-neutral: #c3c2b7;
  --hover-band: rgb(255 255 255 / 5%);
  --series-kitchen: #3987e5;
  --series-kgloto: #d95926;
  --series-ruta: #199e70;
  --series-pgs: #c98500;
  --good-bg: #173219;
  --good-fg: #86d986;
  --bad-bg: #3b1916;
  --bad-fg: #ff9d92;
  --demo-bg: #f0efec;
  --demo-fg: #111110;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.nw { white-space: nowrap; }
.muted { color: var(--text-muted); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 24px); }

/* ---------- плашка демо и шапка ---------- */
.demo-bar { background: var(--demo-bg); color: var(--demo-fg); font-size: 14px; }
.demo-bar .wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 9px; padding-bottom: 9px; }
.demo-tag {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid currentColor; border-radius: 6px;
  padding: 1px 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em;
}

header.top { background: var(--bg); border-bottom: 1px solid var(--border); }
.top-row { display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap; min-height: 60px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 auto; align-self: stretch; scrollbar-width: none; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 44px;
  color: var(--text-secondary); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-current="page"] { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--text-primary); }
.sq { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.user { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.user form { margin: 0; }
.who { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); color: var(--text-primary);
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- период ---------- */
main.wrap { padding-top: 20px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 16px; }
#view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.period { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-1); color: var(--text-secondary);
  font-size: 14px; cursor: pointer;
}
.chip:hover { color: var(--text-primary); }
.chip[aria-pressed="true"] { background: var(--text-primary); border-color: var(--text-primary); color: var(--bg); font-weight: 600; }
.custom { display: none; gap: 6px; align-items: center; }
.custom.on { display: inline-flex; flex-wrap: wrap; }
.custom input { min-height: 36px; border: 1px solid var(--border); background: var(--surface-1); border-radius: 10px; padding: 0 8px; }
.toolbar-end { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.stamp { color: var(--text-muted); font-size: 13px; }

/* ---------- общие блоки ---------- */
.box {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.panel { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.panel h3 { font-size: 15px; font-weight: 650; }
.panel-head { display: flex; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.panel-head .legend { margin-left: auto; }
.legend { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; flex: none; display: inline-block; }
.sw-line { width: 16px; height: 0; border-top: 2px solid var(--text-primary); display: inline-block; }
.sw-mark { width: 2px; height: 10px; background: var(--text-primary); display: inline-block; }
.hint { font-size: 13px; color: var(--text-muted); }

.pill {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 650; white-space: nowrap;
}
.pill.good { background: var(--good-bg); color: var(--good-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }

.pbar { position: relative; height: 6px; border-radius: 3px; background: var(--grid); }
.pbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.pbar .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-primary); }
.pbar.dash { background: none; border: 1px dashed var(--axis); }

/* ---------- сводка: главная цифра ---------- */
.hero-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: stretch; }
.hero { flex: 1 1 400px; padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.hero-head { display: flex; flex-direction: column; gap: 4px; }
.hero-head .t { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hero-head h1 { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.hero-total { font-size: 48px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; white-space: nowrap; }
.hero-wait { font-size: 13px; color: var(--text-muted); }
.shares { display: flex; flex-direction: column; gap: 8px; }
.share-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--grid); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.tile .k { font-size: 13px; color: var(--text-secondary); }
.tile .v { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tile .v b { font-size: 22px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.tile .s { font-size: 13px; color: var(--text-muted); }
.tile .v.none { color: var(--text-muted); font-size: 15px; gap: 6px; }
.fbar { display: flex; flex-direction: column; gap: 6px; }
.fbar .track { position: relative; height: 8px; border-radius: 4px; background: var(--grid); }
.fbar .track > div { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.fbar .fc { background: var(--axis); }
.fbar .ft { background: var(--fact-neutral); }
.fbar .track > .mark { left: auto; top: -4px; bottom: -4px; width: 2px; border-radius: 0; background: var(--text-primary); }
.fbar .legend { font-size: 12px; color: var(--text-muted); }
.fbar .sw { width: 10px; height: 6px; }
.intra { border-top: 1px solid var(--border); padding-top: 14px; display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text-secondary); }
.intra svg { flex: none; margin-top: 1px; }
.intra b { color: var(--text-primary); }

.hchart { flex: 1.45 1 520px; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.hchart h2 { font-size: 15px; font-weight: 600; }

/* ---------- столбики по дням ---------- */
.cols { display: flex; gap: 8px; min-width: 0; }
.cols-y { position: relative; width: 52px; flex: none; font-size: 11px; color: var(--text-muted); text-align: right; }
.cols-y span { position: absolute; right: 6px; white-space: nowrap; }
.cols-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cols-plot { position: relative; border-bottom: 1px solid var(--axis); }
.cols-plot .gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.cols-row { position: absolute; inset: 0; display: flex; }
.col { position: relative; flex: 1 1 0; min-width: 0; }
.col.on { background: var(--hover-band); }
.col .vl { position: absolute; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--text-secondary); white-space: nowrap; z-index: 1; }
.col .vl span { background: var(--surface-1); padding: 0 3px; border-radius: 3px; }
.col.on .vl span { background: none; }
.col .st { position: absolute; bottom: 0; display: flex; flex-direction: column-reverse; gap: 1px; }
.col .st > div { flex: none; }
.col .pl { position: absolute; left: 0; right: 0; border-top: 2px solid var(--text-primary); }
.col.today .st { opacity: .5; }
.cols-x { position: relative; height: 18px; font-size: 12px; color: var(--text-muted); }
.cols-x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.cols-x .now { color: var(--text-primary); font-weight: 600; }
.cols.mini { gap: 0; }
.cols.mini .cols-main { gap: 4px; }
.cols.mini .pl { border-top-width: 1.5px; }
.cols.mini .col.today .st { opacity: .45; }
.cols.mini .cols-x { height: 15px; font-size: 11px; }
.empty { color: var(--text-muted); font-size: 14px; padding: 8px 0; }

/* ---------- карточки бизнесов ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.card { border-top: 4px solid var(--c); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; flex-direction: column; gap: 1px; }
.card-head h2 { font-size: 17px; font-weight: 650; }
.sub { font-size: 13px; color: var(--text-muted); }
.money { display: flex; flex-direction: column; gap: 2px; }
.money .big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; }
.money .usd { font-size: 15px; color: var(--text-secondary); white-space: nowrap; }
.planbox { display: flex; flex-direction: column; gap: 6px; min-height: 66px; }
.planbox .row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.planbox .row .pill { margin-left: auto; }
.planbox .none { color: var(--text-muted); }
dl.kv { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
dl.kv div { display: flex; justify-content: space-between; gap: 12px; }
dl.kv dt { color: var(--text-secondary); }
dl.kv dd { margin: 0; font-weight: 600; white-space: nowrap; }
.more {
  margin-top: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; align-self: flex-start;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.wait { display: flex; flex-direction: column; gap: 10px; }
.wait .msg { font-size: 14px; color: var(--text-secondary); }
.skeleton { height: 14px; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
.skeleton.l { height: 30px; width: 60%; }
.skeleton.chart { height: 56px; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.err-box { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-secondary); }
.err-box svg { flex: none; color: var(--bad-fg); margin-top: 1px; }
.err-box b { color: var(--text-primary); }
.err-box .btn { margin-top: 8px; }
.foot-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
.foot-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.foot-legend .sw-line { border-top-width: 1.5px; }
.foot-legend .sw { background: #9b9a93; opacity: .45; }

/* ---------- раздел бизнеса ---------- */
.sec-head { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.sec-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.sec-head .sq { width: 14px; height: 14px; border-radius: 4px; }
.sec-head .links { margin-left: auto; font-size: 14px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.summary .tile { background: var(--surface-1); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 12px 14px; border-radius: 12px; }
.kpi .label { color: var(--text-secondary); font-size: 13px; }
.kpi .value { font-size: 22px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.kpi .unit { color: var(--text-muted); font-size: 14px; font-weight: 500; margin-left: 3px; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; }

.items { display: grid; gap: 12px; }
.item { display: grid; grid-template-columns: minmax(110px, 1.2fr) 2fr; gap: 6px 16px; align-items: center; font-size: 14px; }
.item .name { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .nums { display: flex; align-items: center; gap: 8px 12px; justify-content: flex-end; flex-wrap: wrap; }
.item .nums .of { color: var(--text-muted); }
.item .pbar { grid-column: 1 / -1; }
.item.extra .name { font-style: italic; }

.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.hbar .track { height: 10px; }
.hbar .fill { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { white-space: nowrap; font-weight: 600; }
.hbar .share { color: var(--text-muted); font-weight: 400; margin-left: 6px; font-size: 13px; }

details.table-view summary { cursor: pointer; color: var(--link); font-size: 14px; }
.tbl-wrap { overflow-x: auto; max-height: 420px; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
td.num, th.num { text-align: right; white-space: nowrap; }
th { color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); z-index: 1; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 22px 16px;
  border: 1.5px dashed var(--axis); border-radius: 12px; cursor: pointer; color: var(--text-secondary); font-size: 14px;
}
.drop:hover, .drop.over { border-color: var(--text-primary); background: var(--surface-2); }
.drop b { color: var(--text-primary); }
.drop u { color: var(--link); text-decoration: none; }
.drop small { color: var(--text-muted); font-size: 13px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.up-result { font-size: 14px; color: var(--text-secondary); }
.up-result.err { color: var(--bad-fg); }
.warns { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-secondary); display: grid; gap: 2px; }

/* ---------- бюджет ---------- */
.budget-src { border-top: 4px solid var(--c); }
.budget-src .meta { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-muted); }
.budget-src .meta b { color: var(--text-secondary); font-weight: 600; }
.budget-src .tbl-wrap { max-height: none; }
.btable td:first-child { min-width: 220px; }
.btable tr.total td { font-weight: 700; border-top: 1px solid var(--axis); }
.btable tr.income td:first-child, .btable tr.expense td:first-child { font-weight: 600; }
.btable tr.child td { color: var(--text-secondary); font-size: 13px; }
.btable tr.child td:first-child { padding-left: 34px; font-weight: 400; }
.tog {
  border: 0; background: none; padding: 0; margin-right: 6px; cursor: pointer; color: var(--text-muted);
  width: 18px; display: inline-flex; justify-content: center; transition: transform .15s;
}
.tog[aria-expanded="true"] { transform: rotate(90deg); }
.tog-pad { display: inline-block; width: 24px; }

/* ---------- подсказка ---------- */
.tip {
  position: absolute; pointer-events: none; z-index: 20; transform: translateX(-50%);
  background: var(--text-primary); color: var(--bg); border-radius: 8px; padding: 7px 10px; font-size: 13px;
  white-space: nowrap; display: none; line-height: 1.5;
}
.tip b { font-weight: 650; }
.tip .r { display: flex; align-items: center; gap: 6px; }
.tip .r span:last-child { margin-left: auto; padding-left: 12px; }
.tip .r.sum { border-top: 1px solid color-mix(in srgb, var(--bg) 30%, transparent); margin-top: 3px; padding-top: 3px; }

@media (max-width: 640px) {
  .hero, .hchart { padding: 18px 16px; }
  .hero-total { font-size: 38px; }
  .card { padding: 16px; }
  .cols-y { width: 44px; }
  .toolbar-end { margin-left: 0; }
}
