/* Оформление под логотип BELUCCI: буква B из мрамора с золотыми прожилками.
   Светлая тема — белый каррарский мрамор и чёрный логотип, тёмная — чёрный мрамор, белые кнопки и золотой логотип.
   Золото только тонкими штрихами (прожилки, линия под шапкой, фокус, график), всё остальное — чёрное и белое.
   По умолчанию тема как в системе; кнопка в шапке запоминает выбор (data-theme на <html>). */
:root {
  --ink: #151516;
  --ink-2: #6A6967;
  --paper: #ECECE9;
  --surface: #FBFBFA;
  --surface-2: #F3F3F1;
  --line: #DCDBD7;
  --live: #C9264F;
  --live-soft: #F8E3E8;
  --money: #0F7A55;
  --warn: #A9520C;
  --warn-soft: #FAEEE2;
  --focus: #8E6B26;
  --primary: #151516;
  --on-primary: #FBFBFA;
  --gold: #A8843E;
  --gold-hi: #D9BF85;
  --gold-lo: #7A5C22;
  --receipt: #FDFDFB;
  --receipt-ink: #1E1E20;
  --chart: #987326;
  --chart-track: #E8E6E0;
  --shade: 20, 20, 22;
  --marble: url(/marble-light.svg);
  --slab: url(/slab-light.svg);
  --slab-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 22px 44px -30px rgba(20, 20, 22, .35);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius: 10px;
  --radius-sm: 8px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Prata', 'Didot', 'Bodoni 72', 'Times New Roman', serif;
  /* суммы — Bodoni Moda: у неё единица с носиком, не путается с «l» */
  --numeral: 'Bodoni Moda', 'Prata', 'Didot', 'Bodoni 72', serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #F3F2EF;
  --ink-2: #9D9B97;
  --paper: #0F1011;
  --surface: #18191B;
  --surface-2: #1F2022;
  --line: #2A2B2E;
  --live: #F0507A;
  --live-soft: #3A1822;
  --money: #5ED3A3;
  --warn: #EBA45F;
  --warn-soft: #33241A;
  --focus: #D9B970;
  --primary: #F3F2EF;
  --on-primary: #111213;
  --gold: #C9A55E;
  --gold-hi: #F2DDA4;
  --gold-lo: #8A6B2E;
  --chart: #AE8836;
  --chart-track: #2A2B2E;
  --shade: 0, 0, 0;
  --marble: url(/marble-dark.svg);
  --slab: url(/slab-dark.svg);
  --slab-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 24px 48px -28px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #F3F2EF;
    --ink-2: #9D9B97;
    --paper: #0F1011;
    --surface: #18191B;
    --surface-2: #1F2022;
    --line: #2A2B2E;
    --live: #F0507A;
    --live-soft: #3A1822;
    --money: #5ED3A3;
    --warn: #EBA45F;
    --warn-soft: #33241A;
    --focus: #D9B970;
    --primary: #F3F2EF;
    --on-primary: #111213;
    --gold: #C9A55E;
    --gold-hi: #F2DDA4;
    --gold-lo: #8A6B2E;
    --chart: #AE8836;
    --chart-track: #2A2B2E;
    --shade: 0, 0, 0;
    --marble: url(/marble-dark.svg);
    --slab: url(/slab-dark.svg);
    --slab-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 24px 48px -28px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

/* логотип и значок кнопки темы под текущую тему */
.logo-gold, .i-sun { display: none; }
:root[data-theme="dark"] .logo-black, :root[data-theme="dark"] .i-moon { display: none; }
:root[data-theme="dark"] .logo-gold, :root[data-theme="dark"] .i-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-black, :root:not([data-theme="light"]) .i-moon { display: none; }
  :root:not([data-theme="light"]) .logo-gold, :root:not([data-theme="light"]) .i-sun { display: block; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* мрамор под всей страницей: отдельный неподвижный слой, при прокрутке не перерисовывается */
body::before {
  content: '';
  position: fixed; inset: 0 0 auto; height: 100vh; z-index: -1;
  background: var(--marble) center / cover no-repeat;
  pointer-events: none;
}
::selection { background: color-mix(in srgb, var(--gold) 38%, transparent); }
h1, h2, h3 { margin: 0; line-height: 1.15; font-family: var(--display); font-weight: 400; letter-spacing: 0; }
h1 { font-size: 2rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.boot { padding: 40px 16px; text-align: center; color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.money { color: var(--money); }
.warn { color: var(--warn); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; user-select: none; }

/* ---------- логотип, название, золотые линии ---------- */
.logo-wrap { position: relative; display: inline-block; flex: none; height: var(--logo-h, 44px); }
.logo-wrap .logo { height: 100%; width: auto; }
/* блик, который пробегает по мрамору логотипа (только по самой букве — через маску) */
.logo-wrap::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .85) 50%, transparent 62%) no-repeat;
  background-size: 260% 100%;
  background-position: 130% 0;
  -webkit-mask: var(--logo-mask, url(/logo-black.png)) center / contain no-repeat;
  mask: var(--logo-mask, url(/logo-black.png)) center / contain no-repeat;
  opacity: 0;
  pointer-events: none;
}
:root[data-theme="dark"] .logo-wrap { --logo-mask: url(/logo-gold.png); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-wrap { --logo-mask: url(/logo-gold.png); } }
.enter .logo-wrap::after { animation: sheen 1.5s .35s ease-in-out; }
.brand:hover .logo-wrap::after, .me:hover .logo-wrap::after { animation: sheen 1.2s ease-in-out; }
@keyframes sheen {
  0% { opacity: 1; background-position: 130% 0; }
  100% { opacity: 1; background-position: -30% 0; }
}

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.brand-name {
  font: 300 0.95rem/1 var(--font);
  letter-spacing: 0.42em;
  margin-right: -0.42em; /* разрядка не сдвигает слово вправо */
}

/* золотая волосяная линия под шапкой: тонкая, гаснет к краям */
.admin-top, .topbar { position: relative; }
.admin-top::after, .topbar::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -11px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 18%, var(--gold-hi) 50%, var(--gold) 82%, transparent);
  opacity: .55;
  transform-origin: left;
}
.enter .admin-top::after, .enter .topbar::after { animation: drawx 1.4s .15s var(--ease) both; }
@keyframes drawx { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- мраморная плита: главная карточка (смена модели, вход) ---------- */
.slab {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--slab-shadow);
}
.slab::before {
  content: '';
  position: absolute; inset: 0; z-index: -2;
  background: var(--slab) center / cover no-repeat;
  pointer-events: none;
}
/* золотая прожилка поперёк плиты: рисуется сама при первом открытии */
.vein { position: absolute; left: 0; top: 0; width: 100%; height: 160px; z-index: -1; pointer-events: none; overflow: visible; }
.vein path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.vein .v-main { stroke-width: 1.15; opacity: .9; }
.vein .v-branch { stroke-width: .7; opacity: .75; }
.vein .v-glow { stroke-width: 5; opacity: .12; filter: blur(2px); }
.enter .vein path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.8s .25s var(--ease) forwards; }
.enter .vein .v-branch { animation-delay: 1s; animation-duration: 1.1s; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- кнопки и поля ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 500 0.95rem/1 var(--font);
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
  min-height: 42px;
  transition: transform .12s ease, border-color .2s, background-color .2s, color .2s, filter .2s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.18); }
:root[data-theme="dark"] .btn.primary:hover { filter: brightness(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary:hover { filter: brightness(.9); } }
.btn.live { background: var(--live); border-color: var(--live); color: #fff; }
.btn.danger { color: var(--live); }
.btn.danger:hover { border-color: var(--live); }
.btn.big { width: 100%; min-height: 58px; font-size: 1.05rem; font-weight: 600; letter-spacing: .01em; }
.btn.link { border: 0; background: none; padding: 6px 6px; min-height: 0; color: var(--ink-2); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 4px; }
.btn.link:hover { color: var(--ink); text-decoration-color: var(--gold); }
.btn.sm { padding: 7px 13px; min-height: 34px; font-size: 0.875rem; }

label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 0.95rem; }
input, select, textarea {
  font: 400 1rem/1.3 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
  transition: border-color .2s, box-shadow .2s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--ink-2) 55%, var(--line)); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.hint { font-size: 0.8rem; color: var(--ink-2); line-height: 1.4; }
.error { color: var(--live); font-size: 0.9rem; min-height: 1.3em; }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 56px 16px 32px; }
.auth-inner { width: 100%; max-width: 400px; display: grid; gap: 26px; justify-items: center; }
.auth-brand { display: grid; justify-items: center; gap: 16px; }
.auth-brand .logo-wrap { --logo-h: 104px; }
.auth-brand .brand-name { font-size: 0.85rem; letter-spacing: 0.6em; margin-right: -0.6em; color: var(--ink-2); }
.auth-card { width: 100%; display: grid; gap: 16px; padding: 26px 22px 22px; }
.auth-card h1 { font-size: 2.1rem; }
.auth-top { position: fixed; top: 12px; right: 12px; z-index: 5; }

/* ---------- экран модели ---------- */
.shell { max-width: 560px; margin: 0 auto; padding: 18px 16px 48px; display: grid; gap: 30px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar .who { display: grid; }
.topbar .me { display: flex; align-items: center; gap: 14px; }
.topbar .who strong { font: 400 1.35rem/1.15 var(--display); }

.demo-banner { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: var(--radius); font-size: 0.9rem; }

.panel { padding: 22px 20px; display: grid; gap: 18px; }
.panel.on { border-color: var(--live); box-shadow: 0 0 0 1px var(--live), var(--slab-shadow); }

.status-line { display: flex; align-items: center; gap: 10px; font-weight: 600; flex-wrap: wrap; }
.status-line .since { font-weight: 400; color: var(--ink-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-2); flex: none; }
.dot.live { background: var(--live); animation: pulse 2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); } 80%, 100% { box-shadow: 0 0 0 10px transparent; } }

.earned { display: grid; gap: 4px; }
.earned .amount {
  font: 450 clamp(2.9rem, 14vw, 4.2rem)/1 var(--numeral);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums lining-nums;
  margin: 2px 0 4px;
}
.earned .usd { font-size: 1.15rem; color: var(--money); font-weight: 600; }

.sites { display: grid; gap: 0; border-top: 1px solid var(--line); }
.site-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.site-row .name { font-weight: 600; }
.site-row .delta { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.site-row .detail { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.site-row .detail.warn { color: var(--warn); }

.site-row .sub-usd { display: block; font-weight: 400; font-size: 0.8rem; color: var(--ink-2); }
.ok { color: var(--money); }

/* ---------- расширение ---------- */
.ext-line { font-size: 0.9rem; color: var(--ink-2); }
.ext-line.ok { color: var(--money); }
.ext-box { background: var(--warn-soft); color: var(--ink); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.ext-box b { color: var(--warn); }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.steps .btn { vertical-align: middle; }
code { font: 0.85em var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; user-select: all; }
.msites { display: grid; gap: 12px; }
.msite { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.msite-head { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.msite-head .grow { flex: 1 1 200px; }
.msite-head .check { min-height: 42px; }
.checks { display: grid; gap: 8px; }

.poll-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 0.875rem; color: var(--ink-2); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.total { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; display: grid; gap: 2px; }
.total b { font: 500 1.6rem/1.2 var(--numeral); font-variant-numeric: tabular-nums lining-nums; }

.history { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.history li + li { border-top: 1px solid var(--line); }
.history button { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 13px 16px; transition: background-color .15s; }
.history button:hover { background: var(--surface-2); }
.history button:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.history .h-date { font-weight: 600; }
.history .h-usd { font-weight: 600; color: var(--money); text-align: right; font-variant-numeric: tabular-nums; }
.history .h-sub { color: var(--ink-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.empty { padding: 22px 16px; color: var(--ink-2); text-align: center; }

/* ---------- чек ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--ink);
  max-width: min(440px, calc(100vw - 24px)); width: 100%;
  max-height: calc(100vh - 24px);
}
dialog.wide { max-width: min(760px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(var(--shade), .55); backdrop-filter: blur(3px); }
dialog[open] { animation: rise .26s var(--ease); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; display: grid; gap: 14px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.receipt-wrap { display: grid; gap: 12px; padding-bottom: 4px; }
.receipt {
  position: relative;
  background: var(--receipt);
  color: var(--receipt-ink);
  font: 400 0.9rem/1.55 var(--mono);
  padding: 22px 22px 22px;
  border-radius: 4px 4px 0 0;
  margin-bottom: 10px;
  box-shadow: 0 18px 40px -18px rgba(var(--shade), .55);
}
/* чек «выезжает из принтера» сверху вниз */
dialog[open] .receipt { animation: print 1s var(--ease) both; }
@keyframes print {
  from { clip-path: inset(0 0 100% 0); transform: translateY(-18px); }
  to { clip-path: inset(0 0 -14px 0); transform: none; }
}
.receipt::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background:
    linear-gradient(135deg, var(--receipt) 50%, transparent 50%) 0 0 / 14px 10px repeat-x,
    linear-gradient(225deg, var(--receipt) 50%, transparent 50%) 0 0 / 14px 10px repeat-x;
}
.receipt .r-brand { display: grid; justify-items: center; gap: 8px; margin-bottom: 12px; }
.receipt .r-brand img { height: 62px; width: auto; }
.receipt .r-title { text-align: center; font-weight: 600; font-size: 1.05rem; letter-spacing: 0.08em; }
.receipt .r-sub { text-align: center; }
.receipt .r-rule { border: 0; border-top: 1px dashed currentColor; opacity: .55; margin: 10px 0; }
.receipt .r-rule.double { border-top: 3px double currentColor; opacity: .8; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 12px; }
.receipt .r-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.receipt .r-site { font-weight: 600; margin-top: 6px; }
.receipt .r-total { font-weight: 600; font-size: 1.05rem; }
.receipt .r-grand { font-weight: 600; font-size: 1.35rem; }
.receipt .r-note { font-size: 0.8rem; margin-top: 6px; }
.receipt .r-foot { text-align: center; font-size: 0.78rem; opacity: .7; margin-top: 8px; }
.receipt-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.receipt-actions .btn:not(.primary) { background: var(--surface); }

.edit-box { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 12px; }
.edit-box[hidden] { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- админка ---------- */
.admin { max-width: 1200px; margin: 0 auto; padding: 16px 16px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; }
#demo-slot:empty, #ext-banner:empty { display: none; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.admin-top .actions, .topbar .actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.theme-btn { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; }
.theme-btn svg { width: 18px; height: 18px; transition: transform .5s var(--ease); }
.theme-btn:hover svg { transform: rotate(-25deg); }

/* вкладки: выбранную подсвечивает «таблетка», которая переезжает к нажатой */
.tabs { position: relative; display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-ind { position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px; background: var(--primary); transition: transform .45s var(--ease), width .45s var(--ease); pointer-events: none; }
.tabs button { all: unset; position: relative; z-index: 1; cursor: pointer; padding: 8px 16px; border-radius: 999px; font-weight: 500; color: var(--ink-2); white-space: nowrap; transition: color .3s; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected=true] { color: var(--on-primary); }
.tabs:not(.ready) button[aria-selected=true] { background: var(--primary); }
.tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.summary { display: flex; gap: 14px 36px; flex-wrap: wrap; align-items: baseline; }
.summary div { display: grid; }
.summary b { font: 500 1.9rem/1.2 var(--numeral); font-variant-numeric: tabular-nums lining-nums; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: 0.82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; color: var(--ink-2); font-size: 0.82rem; }
tr.clickable { cursor: pointer; }
tr.clickable td { transition: background-color .15s; }
tr.clickable:hover td { background: var(--surface-2); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.live { background: var(--live-soft); color: var(--live); }
.pill .dot { width: 8px; height: 8px; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filters label { min-width: 150px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.card.off { opacity: .6; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: grid; gap: 16px; max-width: 760px; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
.form legend { font: 400 1.2rem/1.2 var(--display); margin-bottom: 4px; padding: 0; }

pre.raw { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; font: 0.8rem/1.45 var(--mono); max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }

/* ---------- статистика ---------- */
.stack.tight { gap: 10px; }
.nowrap { white-space: nowrap; }
.scope-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; display: grid; gap: 3px; align-content: start; }
.t-label { color: var(--ink-2); font-size: 0.85rem; font-weight: 500; }
.t-value { font: 500 1.85rem/1.15 var(--numeral); font-variant-numeric: tabular-nums lining-nums; }
.t-foot, .t-note { font-size: 0.85rem; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .delta { display: block; }
.delta.up { color: var(--money); }
.delta.down { color: var(--warn); }
.delta.flat { color: var(--ink-2); font-weight: 500; white-space: normal; }

.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.insights li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: baseline; }
.insights .ins-ico { font-size: 0.8rem; color: var(--ink-2); text-align: center; }
.insights li.down .ins-ico { color: var(--warn); }
.insights li.up .ins-ico { color: var(--money); }

.chart { display: grid; gap: 6px; padding-top: 18px; }
.chart-plot { position: relative; height: 190px; margin-left: 58px; }
.chart .grid span { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.chart .grid i { position: absolute; right: calc(100% + 8px); top: 0; transform: translateY(-50%); font-style: normal; font-size: 0.75rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart .cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.chart .col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; border-radius: 4px; }
.chart .col:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.chart .bar { width: min(24px, 100%); background: var(--chart); border-radius: 4px 4px 0 0; transform-origin: bottom; animation: growy .75s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.chart .col:hover .bar, .chart .col:focus-visible .bar { background: color-mix(in srgb, var(--chart) 78%, var(--surface)); }
.chart .cap { position: absolute; left: 50%; transform: translate(-50%, -4px); font-size: 0.75rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; pointer-events: none; animation: fadein .4s .7s both; }
.chart .xlabels { margin-left: 58px; display: flex; gap: 2px; }
.chart .xlabels span { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; font-size: 0.72rem; color: var(--ink-2); white-space: nowrap; overflow: visible; font-variant-numeric: tabular-nums; }
.chart-table summary { cursor: pointer; color: var(--ink-2); font-size: 0.88rem; }
.chart-table table { margin-top: 8px; }
.chart-tip { position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--paper); padding: 7px 11px; border-radius: 9px; display: grid; gap: 1px; font-size: 0.82rem; max-width: 260px; box-shadow: 0 8px 24px -10px rgba(var(--shade), .5); }
.chart-tip[hidden] { display: none; }
.chart-tip b { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.chart-tip span { opacity: .8; }
@keyframes growy { from { transform: scaleY(0); } to { transform: none; } }
@keyframes growx { from { transform: scaleX(0); } to { transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.share { display: block; width: 100%; min-width: 90px; height: 6px; border-radius: 3px; background: var(--chart-track); overflow: hidden; margin-top: 7px; }
.share i { display: block; height: 100%; background: var(--chart); border-radius: 0 3px 3px 0; transform-origin: left; animation: growx .9s .1s var(--ease) both; }

/* ---------- увольнение ---------- */
/* фактура штемпельной краски: мелкие непрокрасы */
:root { --ink-tex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -3 2.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* кнопку «Уволить» надо держать: кольцо заполняется, кнопка наливается красным, карточка дрожит всё сильнее */
.btn.hold { position: relative; isolation: isolate; overflow: hidden; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.btn.hold::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--live-soft); transform: scaleX(0); transform-origin: left; transition: transform .25s ease; }
.btn.hold.holding::before { transform: scaleX(1); transition: transform 1.5s linear; }
.btn.hold:disabled { cursor: not-allowed; opacity: .45; }
.hold-ring { width: 16px; height: 16px; flex: none; transform: rotate(-90deg); }
.hold-ring circle { fill: none; stroke: currentColor; stroke-width: 2.4; }
.hold-ring circle:first-child { opacity: .25; }
.hold-fill { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .25s ease; }
.holding .hold-fill { stroke-dashoffset: 0; transition: stroke-dashoffset 1.5s linear; }
.card.trembling { animation: tremble 1.5s linear both; }
@keyframes tremble {
  0%, 35% { transform: none; }
  40% { transform: translate(-.4px, 0) rotate(-.1deg); }
  45% { transform: translate(.5px, 0) rotate(.12deg); }
  50% { transform: translate(-.7px, .2px) rotate(-.18deg); }
  55% { transform: translate(.8px, -.2px) rotate(.2deg); }
  60% { transform: translate(-1px, 0) rotate(-.25deg); }
  65% { transform: translate(1.1px, .3px) rotate(.28deg); }
  70% { transform: translate(-1.3px, -.3px) rotate(-.32deg); }
  75% { transform: translate(1.4px, 0) rotate(.36deg); }
  80% { transform: translate(-1.6px, .4px) rotate(-.4deg); }
  85% { transform: translate(1.8px, -.4px) rotate(.45deg); }
  90% { transform: translate(-2px, 0) rotate(-.5deg); }
  95% { transform: translate(2px, .3px) rotate(.5deg); }
  100% { transform: none; }
}

/* печать падает с размаху, карточка вздрагивает, от удара идёт золотая трещина */
.card { position: relative; }
.fire-fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.fire-fx .crack { position: absolute; left: 0; top: 0; overflow: visible; }
.crack path { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .5s .42s cubic-bezier(.3, .6, .2, 1) forwards; }
.crack .c-shadow { stroke: rgba(0, 0, 0, .4); stroke-width: 4; filter: blur(1.2px); }
.crack .c-gold { stroke-width: 2; }
.crack .c-branch { stroke-width: 1.1; animation-delay: .72s; animation-duration: .35s; }
.fire-fx .stamp {
  position: absolute;
  transform: translate(-50%, -50%) rotate(-11deg);
  font: 800 1.75rem/1 var(--font);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--live);
  border: 3px solid currentColor;
  border-radius: 10px;
  padding: 9px 12px 8px 17px;
  white-space: nowrap;
  opacity: .93;
  -webkit-mask: var(--ink-tex);
  mask: var(--ink-tex);
  animation: slam .4s both;
}
@keyframes slam {
  0% { transform: translate(-50%, -50%) rotate(-20deg) scale(2.8); opacity: 0; animation-timing-function: cubic-bezier(.55, 0, .9, .4); }
  68% { transform: translate(-50%, -50%) rotate(-11deg) scale(.93); opacity: .95; animation-timing-function: ease-out; }
  100% { transform: translate(-50%, -50%) rotate(-11deg) scale(1); opacity: .93; }
}
.card.slammed { animation: thud .34s .26s ease-out; }
@keyframes thud {
  0% { transform: none; }
  20% { transform: translateY(4px) scale(.992); }
  45% { transform: translate(-3px, -1px) rotate(-.3deg); }
  70% { transform: translate(2px, 1px) rotate(.2deg); }
  100% { transform: none; }
}
.fire-fx .impact { position: absolute; width: 180px; height: 180px; margin: -90px 0 0 -90px; border-radius: 50%; border: 2px solid var(--live); opacity: 0; animation: impact .55s .27s ease-out both; }
@keyframes impact { from { transform: scale(.3); opacity: .55; } to { transform: scale(1.6); opacity: 0; } }
.fire-fx.settled .stamp, .fire-fx.settled .crack path { animation: none; }
.fire-fx.settled .crack path { stroke-dashoffset: 0; }
.fire-fx.settled .impact { display: none; }
.shard { pointer-events: none; }

/* «Уволенные» */
.fired-list { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.fired-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px 16px; padding: 12px 16px; }
.fired-row + .fired-row { border-top: 1px solid var(--line); }
.fired-who { display: grid; }
.mini-stamp {
  font: 800 .7rem/1 var(--font); letter-spacing: .14em; text-transform: uppercase;
  color: var(--live); border: 1.5px solid currentColor; border-radius: 5px; padding: 4px 6px 3px 8px;
  transform: rotate(-6deg); opacity: .95;
  -webkit-mask: var(--ink-tex); mask: var(--ink-tex);
}
.fired-row.just .mini-stamp { animation: slam-mini .45s .25s both; }
@keyframes slam-mini {
  0% { transform: rotate(-14deg) scale(2.4); opacity: 0; animation-timing-function: cubic-bezier(.55, 0, .9, .4); }
  70% { transform: rotate(-6deg) scale(.92); opacity: .9; animation-timing-function: ease-out; }
  100% { transform: rotate(-6deg) scale(1); opacity: .95; }
}

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 999px;
  font-size: 0.95rem; max-width: calc(100vw - 32px); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .3s var(--ease); z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--live); color: #fff; }

/* смена темы: новая тема раскрывается кругом от кнопки (анимацию задаёт app.js) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .summary { gap: 10px 22px; }
  .summary b { font-size: 1.55rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px; }
  .t-value { font-size: 1.4rem; }
  .total b { font-size: 1.35rem; }
  .chart-plot, .chart .xlabels { margin-left: 50px; }
  th, td { padding: 10px; }
  .brand .logo-wrap { --logo-h: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: #fff; }
  body::before { display: none; }
  #app, #toast, .receipt-actions, .edit-box, .no-print { display: none !important; }
  dialog { position: static; max-width: none; max-height: none; }
  dialog::backdrop { display: none; }
  .receipt { box-shadow: none; animation: none; }
}
