/* Legit Adapter — монохромная тема (светлая / тёмная).
   Тема: атрибут data-theme на <html> (выбор пользователя), иначе — системная настройка. */

:root {
  color-scheme: light;
  /* светлая: кремовый фон вместо белого, тёмные элементы — графит, а не чёрный */
  --bg: #efeae0;
  --surface: #faf6ee;
  --surface-2: #ebe4d6;
  --text: #33312d;
  --muted: #7a746a;
  --border: #e0d8c8;
  --accent: #46433d;
  --accent-text: #faf6ee;
  --ok: #2f7d4a;
  --warn: #9a6015;
  --bad: #b8433a;
  --code: #efe8da;
  --ring: rgba(70, 67, 61, 0.2);
  --shadow: 0 1px 2px rgba(60, 50, 30, 0.05), 0 8px 24px rgba(60, 50, 30, 0.07);
  --radius: 16px;
  --radius-sm: 12px;
}

/* тёмная: серая (не чёрная), светлые заливки — тёплый бежевый вместо белого */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #232326;
  --surface: #2c2c30;
  --surface-2: #38383d;
  --text: #ece5d8;
  --muted: #a8a197;
  --border: #3e3e44;
  --accent: #e6dccb;
  --accent-text: #2a2a2d;
  --ok: #7fd49a;
  --warn: #e9c46a;
  --bad: #ef8a80;
  --code: #343439;
  --ring: rgba(230, 220, 203, 0.25);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #232326;
    --surface: #2c2c30;
    --surface-2: #38383d;
    --text: #ece5d8;
    --muted: #a8a197;
    --border: #3e3e44;
    --accent: #e6dccb;
    --accent-text: #2a2a2d;
    --ok: #7fd49a;
    --warn: #e9c46a;
    --bad: #ef8a80;
    --code: #343439;
    --ring: rgba(230, 220, 203, 0.25);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--text); text-underline-offset: 2px; }
a:hover { color: var(--muted); }

/* ---------- layout ---------- */
header { background: var(--surface); border-bottom: 1px solid var(--border); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; min-height: 56px; }
nav .brand { font-weight: 700; letter-spacing: -0.01em; margin-right: 16px; display: inline-flex; align-items: center; gap: 8px; }
nav a.link { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 999px; }
nav a.link.active, nav a.link:hover { color: var(--text); background: var(--surface-2); }
nav .meta { margin-left: auto; display: inline-flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
main { padding: 20px 0 40px; }
h1 { font-size: 20px; margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }

.mark {
  width: 22px; height: 22px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 800;
}

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid > * { min-width: 0; }
.grid + .grid, .grid + .card { margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; min-width: 0; }
.grid .card { margin-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.wrap-text { overflow-wrap: anywhere; }
/* длинный текст (ошибки) — не больше 2 строк, полностью — во всплывающей подсказке */
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.big { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* ---------- forms ---------- */
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
input, select, button, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 12px;
}
button { border-radius: 999px; padding: 7px 16px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: none; border-color: var(--text); box-shadow: 0 0 0 3px var(--ring);
}
input[type=number] { width: 110px; }
button { cursor: pointer; background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 550; }
button:hover { opacity: 0.88; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.secondary:hover { background: var(--surface-2); opacity: 1; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.link-btn { background: none; border: none; padding: 0; color: var(--muted); font-weight: 400; }
button.link-btn:hover { color: var(--text); }

.flash { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.flash.bad { background: color-mix(in srgb, var(--bad) 10%, transparent); }

code, pre { background: var(--code); border-radius: 6px; font-family: ui-monospace, "JetBrains Mono", Consolas, monospace; font-size: 12px; }
code { padding: 1px 4px; word-break: break-all; }
td code.node, td.node code { word-break: normal; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td.msg { min-width: 280px; }
details pre { white-space: pre-wrap; word-break: break-word; }
pre { padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; max-height: 420px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
details summary { cursor: pointer; color: var(--muted); }

/* ---------- theme toggle ---------- */
.theme-toggle {
  position: relative; flex: none;
  width: 56px; height: 30px; padding: 0;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted);
  font-weight: 400;
}
.theme-toggle:hover { opacity: 1; border-color: var(--muted); }
.theme-toggle .icon { position: absolute; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); }
.theme-toggle .icon-sun { left: 8px; }
.theme-toggle .icon-moon { right: 8px; }
.theme-toggle .knob {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
:root[data-theme="dark"] .theme-toggle .knob { transform: translateX(26px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .knob { transform: translateX(26px); }
}

/* ---------- login ---------- */
body.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-top { display: flex; justify-content: flex-end; padding: 16px; }
.auth-main { flex: 1; display: grid; place-items: center; padding: 16px 16px 48px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 32px 28px 28px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .mark { width: 40px; height: 40px; border-radius: 14px; font-size: 20px; }
.auth-brand h1 { margin: 0; font-size: 20px; }
.auth-brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input { width: 100%; padding: 10px 12px; font-size: 15px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 76px; }
.password-wrap .reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); font-size: 12px; padding: 4px 8px; font-weight: 500;
}
.password-wrap .reveal:hover { color: var(--text); }
button.block { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; border-radius: 999px; }
.auth-card .flash { margin-bottom: 18px; font-size: 13px; }
.auth-foot { text-align: center; font-size: 12px; margin-top: 16px; }
.auth-top { gap: 10px; align-items: center; }

/* ---------- общие дополнения ---------- */
.small { font-size: 12px; }
button.small { padding: 4px 12px; font-size: 13px; }
button.danger-solid { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.flash.warn-flash { border-color: var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
/* переключатель-«таблетка»: скруглённый контейнер, активный пункт — скруглённая заливка */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.tabs a { padding: 5px 14px; text-decoration: none; color: var(--muted); border-radius: 999px; transition: background-color 0.15s ease, color 0.15s ease; }
.tabs a.active { background: var(--accent); color: var(--accent-text); }
.tabs a:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 12px 0 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .label { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- главная: блоки одной высоты в ряду ---------- */
.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
.dash-grid .span-2 { grid-column: span 2; }
.dash-card { margin: 0; display: flex; flex-direction: column; gap: 8px; min-height: 260px; }
.dash-card h2 { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dash-card .big { line-height: 1.2; }
.dash-card .big .unit { font-size: 14px; font-weight: 500; color: var(--muted); }
.dash-card p { margin: 0; }
.dash-card .card-foot { margin-top: auto; padding-top: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dash-card table.compact td { padding: 4px 6px; }
.dash-card td.node-cell { max-width: 0; width: 100%; }
.dash-card td.node-cell code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-grid .span-2 { grid-column: auto; }
}

/* ---------- каталог: игра + раскрывающиеся регионы ---------- */
table.catalog tbody.game .region-row { display: none; }
table.catalog tbody.game.open .region-row { display: table-row; }
table.catalog .game-row { cursor: pointer; }
table.catalog .game-row:hover td { background: var(--surface-2); }
table.catalog tbody.game.open .game-row td { background: var(--surface-2); border-bottom-color: transparent; }
/* скруглённая подсветка строки игры; раскрытая — скруглена только сверху, регионы «прилипают» снизу */
table.catalog .game-row td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
table.catalog .game-row td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
table.catalog tbody.game.open .game-row td:first-child { border-radius: var(--radius-sm) 0 0 0; }
table.catalog tbody.game.open .game-row td:last-child { border-radius: 0 var(--radius-sm) 0 0; }
table.catalog tbody.game.open .region-row:last-child td:first-child { border-radius: 0 0 0 var(--radius-sm); }
table.catalog tbody.game.open .region-row:last-child td:last-child { border-radius: 0 0 var(--radius-sm) 0; }
table.catalog .game-name { display: flex; gap: 6px; align-items: flex-start; font-weight: 550; }
table.catalog .expander {
  background: none; border: none; padding: 0 2px; color: var(--muted); font-weight: 400;
  line-height: 1.45; transition: transform 0.15s ease;
}
table.catalog tbody.game.open .expander { transform: rotate(90deg); }
table.catalog .region-row td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.catalog .region-name { padding-left: 30px; }
table.catalog td.badges { white-space: nowrap; }
table.catalog td.badges .badge { margin: 0 2px 2px 0; }

/* ---------- формы в колонку (прокси) ---------- */
form.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
input.wide { width: 100%; max-width: 480px; }
textarea { width: 100%; resize: vertical; line-height: 1.45; }
/* переключатель вкл/выкл товара */
button.switch {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px 0 4px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
}
button.switch .knob { width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: background-color 0.15s ease; }
button.switch.on { flex-direction: row-reverse; padding: 0 4px 0 10px; color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
button.switch.on .knob { background: var(--ok); }
button.switch:hover { opacity: 1; border-color: var(--muted); }
a.btn-link {
  display: inline-block; padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 550;
  background: var(--accent); color: var(--accent-text); text-decoration: none;
}
a.btn-link:hover { opacity: 0.88; color: var(--accent-text); }
.crumbs { margin: 0 0 12px; color: var(--muted); }
tr.current-cat td { background: var(--surface-2); }
.field select { width: 100%; max-width: 480px; }
form.stack .field { margin-bottom: 0; }
form.stack .field input { font-size: 14px; padding: 8px 12px; }
fieldset.editions { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px 10px; display: flex; flex-direction: column; gap: 4px; margin: 0; }
fieldset.editions legend { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 4px; }
fieldset:disabled { opacity: 0.6; }
.placeholder { min-height: 160px; }
.blocked-card { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
td.blocked-cell { background: color-mix(in srgb, var(--bad) 8%, transparent); }

/* статусы продаж */
.status { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.status-delivered { color: var(--ok); }
.status-processing, .status-pending { color: var(--muted); }
.status-failed, .status-refunded, .status-reconcile { color: var(--bad); }
.status-blocked { color: var(--warn); }

/* ---------- график продаж ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .hit { fill: transparent; }
.chart g:hover .hit { fill: var(--surface-2); }
.chart .bar-sold { fill: var(--accent); }
.chart .bar-failed { fill: var(--bad); }
.chart .bar-blocked { fill: var(--warn); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.sw-sold { background: var(--accent); } .sw-failed { background: var(--bad); } .sw-blocked { background: var(--warn); }

/* ---------- RU / EN ---------- */
.lang-toggle { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 999px; height: 30px; }
.lang-toggle button { background: transparent; color: var(--muted); border: none; border-radius: 999px; padding: 0 10px; font-size: 12px; font-weight: 600; }
.lang-toggle button.active { background: var(--accent); color: var(--accent-text); }
.lang-toggle button:hover:not(.active) { background: var(--surface-2); color: var(--text); opacity: 1; }

/* ---------- подвал ---------- */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 14px 0 18px; text-align: center; }
body.auth .site-footer { border-top: none; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }
body.tray-open .site-footer { padding-bottom: calc(50vh + 18px); }

/* ---------- трей логов ---------- */
.tray {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: 50vh; display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
  border-radius: 20px 20px 0 0; overflow: hidden;
}
.tray[hidden] { display: none; }
.tray-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.tray-head b { margin-right: 6px; }
.tray-close { margin-left: auto; }
.tray-body { overflow: auto; padding: 0 16px 16px; flex: 1; }
.tray-body th { position: sticky; top: 0; background: var(--surface); }
.tray-hint { margin: 8px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; user-select: none; }
.chip input { margin: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot-info, .chip-info .dot { background: #22a35a; }
.dot-debug, .chip-debug .dot { background: #f08c00; }
.dot-critical, .chip-critical .dot { background: #e03131; }
tr.log-critical td { background: color-mix(in srgb, #e03131 6%, transparent); }

/* Товар → Digiseller: выделение строк, массовые действия, картинка товара */
th.check, td.check { width: 28px; padding-right: 0; }
th.check input, td.check input { width: 16px; height: 16px; cursor: pointer; }
tr.selected td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.bulk-bar { padding: 8px 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.product-image { display: block; width: 100%; max-width: 360px; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.gallery-shots { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
.gallery-shots img { display: block; width: 176px; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.warn-text { color: var(--warn); }
#templates summary { cursor: pointer; }
#templates textarea { font-family: inherit; }

/* Окно «Шаблон для всех игр» */
.template-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.template-card > div { flex: 1 1 420px; }
dialog.modal { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 760px) { .modal-grid { grid-template-columns: 1fr; } }
fieldset.scope { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 8px; }
fieldset.scope label { display: block; cursor: pointer; }
.field-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Уведомления и трей задач — правый нижний угол */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
#task-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.toast { pointer-events: auto; position: relative; width: 100%; box-sizing: border-box; padding: 10px 34px 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 14px; animation: toast-in .2s ease-out; }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.bad { border-left: 4px solid var(--bad); }
.toast.task { display: flex; gap: 10px; align-items: center; padding-right: 14px; border-left: 4px solid var(--warn); }
.toast.task .muted { margin-left: auto; }
.toast .small { margin-top: 2px; color: var(--muted); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast-close { position: absolute; top: 6px; right: 6px; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; cursor: pointer; box-shadow: none; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--warn); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast, .spinner { animation: none; } }
body.tray-open .toasts { bottom: calc(50vh + 16px); }

/* Линейный график продаж (главная) */
.line-chart .line { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.line-chart .line-sold, .line-chart .line-revenue { stroke: var(--accent); color: var(--accent); }
.line-chart .line-failed { stroke: var(--bad); color: var(--bad); }
.line-chart .line-blocked { stroke: var(--warn); color: var(--warn); }
.line-chart .line-profit { stroke: var(--ok); color: var(--ok); }
.line-chart .area { stroke: none; }
.line-chart .area-stop-top { stop-color: var(--accent); stop-opacity: 0.22; }
.line-chart .area-stop-bottom { stop-color: var(--accent); stop-opacity: 0; }
.line-chart .zero-line { stroke: var(--muted); stroke-opacity: .5; }
.line-chart .guide { stroke: var(--muted); stroke-dasharray: 3 3; opacity: 0; }
.line-chart .dot { fill: var(--surface); stroke: currentColor; stroke-width: 2; opacity: 0; }
.line-chart .point:hover .guide, .line-chart .point:hover .dot { opacity: 1; }
.line-chart .point:hover .hit { fill: transparent; }
.sw.line-sold, .sw.line-revenue { background: var(--accent); }
.sw.line-failed { background: var(--bad); } .sw.line-blocked { background: var(--warn); } .sw.line-profit { background: var(--ok); }
.small-tabs a { padding: 4px 12px; font-size: 13px; }

/* Итог дня, сравнение периодов, товары (главная) */
.section-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.head-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.head-tools form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.head-tools select, .head-tools input[type=date] { max-width: 100%; }
.dash-section { margin-bottom: 16px; }
.dash-section .tiles { margin: 8px 0 12px; }
.tile .sub { color: var(--muted); font-size: 12px; line-height: 1.35; }
.delta { align-self: flex-start; display: inline-block; margin: 4px 0 2px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.delta.flat { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.line-chart .line-a { stroke: var(--accent); color: var(--accent); }
.line-chart .line-b { stroke: var(--muted); color: var(--muted); stroke-dasharray: 5 4; }
.sw.line-a { background: var(--accent); } .sw.line-b { background: var(--muted); }
.items-grid { display: grid; gap: 16px 24px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .items-grid { grid-template-columns: minmax(0, 1fr); } }
.items-table td.name { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.items-table .barcell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 120px; }
.items-table .bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); }
.movers h3 { margin: 0 0 6px; font-size: 15px; }
.movers ul { list-style: none; margin: 0 0 16px; padding: 0; }
.movers li { display: flex; gap: 10px; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.movers li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.movers li b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.cur-toggle a { min-width: 34px; text-align: center; font-weight: 650; font-size: 15px; }

/* Прогресс партии выставления (Склад) */
.progress { height: 12px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 18%, transparent); overflow: hidden; margin: 10px 0 0; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--ok); transition: width .4s ease; min-width: 2px; }

/* Сворачиваемые блоки главной: заголовок со сводкой виден и в свёрнутом виде */
details.fold { margin-bottom: 16px; padding: 0; }
details.fold > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 14px 18px; border-radius: var(--radius); user-select: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; width: 12px; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary h2 { margin: 0; font-size: 17px; color: var(--text); }
details.fold > summary:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
details.fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fold-sum { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; min-width: 0; }
.fold-sum .delta { margin: 0; }
details.fold[open] > summary { border-bottom: 1px solid var(--border); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.fold-body { padding: 14px 18px 16px; }
.sys-grid { display: grid; gap: 18px 28px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sys-grid > section { display: flex; flex-direction: column; min-width: 0; }
.sys-grid > section + section { border-left: 1px solid var(--border); padding-left: 28px; }
.sys-grid h3 { margin: 0 0 8px; font-size: 15px; }
.sys-grid .card-foot { margin-top: auto; padding-top: 10px; }
@media (max-width: 900px) {
  .sys-grid { grid-template-columns: minmax(0, 1fr); }
  .sys-grid > section + section { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
}
@media (max-width: 600px) { details.fold > summary { padding: 12px 14px; } .fold-body { padding: 12px 14px 14px; } }

/* Магазины: цветная метка магазина */
.shop-dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; vertical-align: middle; }
.field > span .badge, .field > span .hint { display: inline-block; text-transform: none; letter-spacing: 0; margin: 0 0 0 6px; font-weight: 500; }
.field input[type=color] { width: 64px; height: 36px; padding: 2px 4px; }
/* Левая колонка (как в кабинете Legit): «Магазины», выбор магазина, общие разделы, баланс, тема / язык / выход */
.layout { display: flex; min-height: 100vh; }
.layout-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.layout-main main { flex: 1; }
.sidebar { position: sticky; top: 0; height: 100vh; width: 248px; flex: none; display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.side-brand .mark { display: grid; place-items: center; flex: none; width: 30px; height: 30px; font-size: 15px; line-height: 1; border-radius: 10px; }
.side-brand b { display: block; letter-spacing: -0.01em; }
.side-brand span { display: block; font-size: 12px; color: var(--muted); }
.side-block { display: flex; flex-direction: column; gap: 6px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); text-decoration: none; padding: 0 6px; }
.side-label:hover { color: var(--text); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 12px; background: none; color: var(--muted); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.side-nav a:hover, .side-nav button:hover { background: var(--surface-2); color: var(--text); opacity: 1; }
.side-nav a.active { background: var(--accent); color: var(--accent-text); }
.ico { width: 18px; height: 18px; flex: none; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.balance-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); text-decoration: none; }
.balance-card:hover { color: var(--text); outline: 1px solid var(--border); }
.balance-row { display: flex; justify-content: space-between; align-items: baseline; }
.balance-row b { font-size: 16px; font-variant-numeric: tabular-nums; }
.side-toggles { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-version { padding: 0 6px; }
button.block { width: 100%; }
/* Вкладки магазина — верхней строкой справа от колонки */
.topbar { position: sticky; top: 0; z-index: 40; }
.topbar nav { padding: 0 16px; }
.topbar-shop { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; margin-right: 12px; }
.topbar-settings { margin-left: auto; display: inline-flex; padding: 6px 8px !important; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; max-width: 100vw; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .layout-main { width: 100%; max-width: 100vw; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-nav a, .side-nav button { width: auto; }
  .side-bottom { margin-top: 0; }
}
/* Выбор магазина в колонке — свой список (скругление, тема) */
.shop-menu { position: relative; }
.shop-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px; font-weight: 600; color: var(--text); user-select: none; }
.shop-menu summary .shop-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-menu summary::-webkit-details-marker { display: none; }
.shop-menu summary::after { content: "▾"; font-size: 11px; color: var(--muted); }
.shop-menu summary:hover, .shop-menu[open] summary { background: var(--surface-2); }
.shop-menu-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; max-height: 60vh; overflow: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
/* Сводка: шестерёнка — окно настроек магазина */
.gear { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); vertical-align: middle; cursor: pointer; }
.gear:hover { background: var(--surface-2); color: var(--text); opacity: 1; }
dialog.modal.shop-modal { width: min(920px, calc(100vw - 32px)); }
.shop-modal .card { margin-bottom: 12px; }
.shop-modal .grid { margin-bottom: 12px; }
.shop-menu-list a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--text); text-decoration: none; white-space: nowrap; }
.shop-menu-list a:hover { background: var(--surface-2); }
.shop-menu-list a.active { background: var(--surface-2); font-weight: 600; }