/* ==========================================================================
   ясно. — аудит полки. Web dashboard.
   Design system: concept B «Clarity» (design/concepts/b-clarity).
   Light, airy, calm. Warm-white surfaces, ink text, one brand colour (indigo).
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --canvas: #f6f4ef;
  --surface: #fffefb;
  --surface-2: #fbfaf6;
  --sunken: #f3f1eb;
  --line: #ebe7df;
  --line-2: #ddd8cd;

  --ink: #1b1a17;
  --ink-2: #55524a;
  --ink-3: #6f6c64;      /* AA on surface and canvas */
  --ink-4: #a29e94;      /* decoration only, never text */

  --brand: #4b4bd8;
  --brand-700: #3b3ac0;
  --brand-800: #2f2e9c;
  --brand-50: #f1f1fd;
  --brand-100: #e4e4fb;
  --brand-200: #c9c9f6;

  /* report categories: mark / ink on tint / tint */
  --k-on: #13a06c;   --k-on-ink: #0b7a51;   --k-on-tint: #e7f5ee;
  --k-out: #dc9300;  --k-out-ink: #9a6200;  --k-out-tint: #fbf2dd;
  --k-else: #c8343f; --k-else-ink: #a8222e; --k-else-tint: #fae8e9;
  --k-comp: #a24aa8; --k-comp-ink: #86358c; --k-comp-tint: #f5e9f5;
  --k-opp: #4b4bd8;  --k-opp-ink: #3b3ac0;  --k-opp-tint: #eeeefc;

  --font: "Segoe UI Variable Text", "Segoe UI Variable", "SF Pro Text", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable", "SF Pro Display", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, monospace;

  --r-xs: 2px; --r-sm: 3px; --r-md: 4px; --r-lg: 6px; --r-xl: 8px; --r-2xl: 10px;

  --e1: 0 0 0 1px rgba(27, 26, 23, .06), 0 1px 2px rgba(27, 26, 23, .05);
  --e2: 0 0 0 1px rgba(27, 26, 23, .06), 0 1px 2px rgba(27, 26, 23, .04), 0 8px 20px -8px rgba(27, 26, 23, .10);
  --e3: 0 0 0 1px rgba(27, 26, 23, .06), 0 2px 4px rgba(27, 26, 23, .04), 0 20px 44px -14px rgba(27, 26, 23, .20);
  --e4: 0 0 0 1px rgba(27, 26, 23, .08), 0 30px 80px -20px rgba(27, 26, 23, .34);

  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);

  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.5, 0, .75, 0);
  --spring: cubic-bezier(.34, 1.42, .64, 1);
  --d1: 120ms; --d2: 200ms; --d3: 380ms;

  --sb-thumb: color-mix(in srgb, var(--brand) 22%, transparent);
  --sb-thumb-hover: color-mix(in srgb, var(--brand) 48%, transparent);
  --sb-thumb-active: color-mix(in srgb, var(--brand) 70%, transparent);
}

[data-kind="on_shelf"]         { --k: var(--k-on);   --k-ink: var(--k-on-ink);   --k-tint: var(--k-on-tint); }
[data-kind="out_of_stock"]     { --k: var(--k-out);  --k-ink: var(--k-out-ink);  --k-tint: var(--k-out-tint); }
[data-kind="bought_elsewhere"] { --k: var(--k-else); --k-ink: var(--k-else-ink); --k-tint: var(--k-else-tint); }
[data-kind="competitor_only"]  { --k: var(--k-comp); --k-ink: var(--k-comp-ink); --k-tint: var(--k-comp-tint); }
[data-kind="opportunity"]      { --k: var(--k-opp);  --k-ink: var(--k-opp-ink);  --k-tint: var(--k-opp-tint); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/20px var(--font);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.ic-16 { width: 16px; height: 16px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.link { color: var(--brand-700); font-weight: 600; }
.link:hover { color: var(--brand-800); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }

.t-display { font: 650 56px/60px var(--font-display); letter-spacing: -.035em; }
.t-hero    { font: 600 64px/64px var(--font-display); letter-spacing: -.04em; }
.t-h1      { font: 650 32px/40px var(--font-display); letter-spacing: -.025em; }
.t-h2      { font: 600 20px/28px var(--font-display); letter-spacing: -.012em; }
.t-small   { font: 400 13px/20px var(--font); }
.t-eyebrow { font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- 3. Primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-md);
  font: 600 13px/1 var(--font); white-space: nowrap;
  background: var(--surface); color: var(--ink); box-shadow: var(--e1);
  transition: background var(--d1) var(--ease), box-shadow var(--d1) var(--ease), transform var(--d1) var(--ease), opacity var(--d1) var(--ease);
}
.btn:hover { background: var(--surface-2); box-shadow: var(--e2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; transform: none; box-shadow: var(--e1); background: var(--surface); }
.btn .ic { width: 18px; height: 18px; color: var(--ink-3); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgb(var(--sh) / .3), inset 0 1px 0 rgba(255, 255, 255, .16); }
.btn-primary:hover { background: var(--brand-700); box-shadow: 0 1px 2px rgb(var(--sh) / .3), 0 6px 16px -6px rgba(75, 75, 216, .55); }
.btn-primary:disabled { background: var(--brand); box-shadow: none; }
.btn-primary .ic { color: #fff; }
.btn-danger { background: var(--k-else); color: #fff; box-shadow: 0 1px 2px rgba(168, 34, 46, .3), inset 0 1px 0 rgba(255, 255, 255, .16); }
.btn-danger:hover { background: var(--k-else-ink); box-shadow: 0 1px 2px rgba(168, 34, 46, .3), 0 6px 16px -6px rgba(200, 52, 63, .5); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunken); box-shadow: none; color: var(--ink); }
.btn-ghost:disabled { background: transparent; box-shadow: none; }
.btn-danger-ghost:hover { color: var(--k-else-ink); background: var(--k-else-tint); }
.btn-danger-ghost:hover .ic { color: var(--k-else-ink); }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; border-radius: 6px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 4px; background: var(--sunken); color: var(--ink-2);
  font: 500 12px/1 var(--font); white-space: nowrap;
}
.chip .ic { width: 14px; height: 14px; }
.chip-ok .ic { color: var(--k-on-ink); }
.chip-dim { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-3); }
.chip-brand { background: var(--brand-50); color: var(--brand-800); }
.chip-brand .ic { color: var(--brand); }
.chip-demo { background: var(--k-out-tint); color: var(--k-out-ink); cursor: help; }
.chip-demo .ic { color: var(--k-out-ink); }

.kchip {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: var(--k-tint); color: var(--k-ink);
}
.kchip .ic { width: 20px; height: 20px; }
.kchip-sm { width: 24px; height: 24px; border-radius: var(--r-xs); }
.kchip-sm .ic { width: 16px; height: 16px; }
.kchip-lg { width: 40px; height: 40px; border-radius: 6px; }
.kchip-lg .ic { width: 22px; height: 22px; }
.kchip-brand { --k-tint: var(--brand-50); --k-ink: var(--brand); }
.kchip-plain { --k-tint: var(--sunken); --k-ink: var(--ink-2); }

.swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--k); flex: none; }

.card { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--e2); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px 0; flex-wrap: wrap; }
.card-head h2 { font: 600 15px/22px var(--font); letter-spacing: -.005em; }
.card-head .spacer { flex: 1; }
/* title + count only: the title wraps inside, the count stays on its line */
.card-head.tight { flex-wrap: nowrap; }
.card-head.tight h2 { flex: 1; min-width: 0; }
.card-head.tight > .kchip, .card-head.tight > .count { flex: none; }
.card-body { padding: 16px 24px 24px; }
.card-sub { padding: 4px 24px 12px; font: 400 13px/20px var(--font); color: var(--ink-3); }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: 4px; background: var(--sunken); color: var(--ink-2);
  font: 600 11px/1 var(--font); font-variant-numeric: tabular-nums;
}

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--sunken); }
.seg button {
  height: 28px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent;
  font: 500 12px/1 var(--font); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--d1) var(--ease), color var(--d1) var(--ease), box-shadow var(--d1) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--e1); }

/* forms */
.field { display: grid; gap: 6px; }
.field > span { font: 500 13px/20px var(--font); color: var(--ink-2); }
.field > small { font: 400 12px/16px var(--font); color: var(--ink-3); }
.input {
  height: 44px; padding: 0 14px; border: 0; border-radius: 6px; width: 100%;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2);
  font: 400 15px/1 var(--font); transition: box-shadow var(--d1) var(--ease);
}
textarea.input { height: auto; min-height: 72px; padding: 11px 14px; line-height: 22px; resize: vertical; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.input::placeholder { color: var(--ink-4); }
.input:hover { box-shadow: inset 0 0 0 1px #c9c3b6; }
.input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--brand), 0 0 0 4px rgba(75, 75, 216, .14); }

.search {
  position: relative; display: flex; align-items: center; flex: 1; min-width: 0; max-width: 420px;
}
.search .ic { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search .input { height: 40px; padding-left: 40px; font-size: 14px; background: var(--surface-2); }
/* The native clear button keeps its space even while hidden: free it for the placeholder. */
.search .input:placeholder-shown::-webkit-search-cancel-button { display: none; }

/* alerts: friendly inline messages */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 6px;
  font: 400 13px/20px var(--font); background: var(--sunken); color: var(--ink);
}
.alert > .ic { width: 18px; height: 18px; margin-top: 1px; color: var(--ink-3); }
.alert b { font-weight: 600; }
.alert .alert-text { flex: 1; min-width: 0; }
.alert .btn { margin: -4px -4px -4px 0; }
.alert-error { background: var(--k-else-tint); }
.alert-error > .ic { color: var(--k-else-ink); }
.alert-warning { background: var(--k-out-tint); }
.alert-warning > .ic { color: var(--k-out-ink); }
.alert-success { background: var(--k-on-tint); }
.alert-success > .ic { color: var(--k-on-ink); }
.alert-info { background: var(--brand-50); }
.alert-info > .ic { color: var(--brand); }

.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .8;
  animation: spin .8s linear infinite;
}
.spinner-sm { width: 12px; height: 12px; border-width: 1.75px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tooltip */
.tip {
  position: fixed; z-index: 200; pointer-events: none;
  display: grid; gap: 2px; min-width: 120px; max-width: 280px; padding: 8px 10px;
  background: var(--ink); color: var(--on-ink); border-radius: var(--r-sm);
  box-shadow: 0 8px 24px -8px rgba(27, 26, 23, .45);
  font: 400 12px/16px var(--font);
}
.tip strong { font: 600 14px/18px var(--font); font-variant-numeric: tabular-nums; }
.tip span { color: rgba(255, 255, 255, .72); }

/* ---------- 4. Charts ---------- */
.stack { display: flex; gap: 2px; height: 16px; }
.stack > i {
  display: block; height: 100%; background: var(--k); min-width: 4px;
  transition: filter var(--d1) var(--ease);
}
.stack > i:first-child { border-radius: 4px 0 0 4px; }
.stack > i:last-child { border-radius: 0 4px 4px 0; }
.stack > i:only-child { border-radius: 4px; }
.stack > i:hover, .stack > i:focus-visible { filter: brightness(1.08) saturate(1.05); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--k); border-radius: 3px; }
.stack-sm { height: 8px; }
.stack-sm > i { min-width: 3px; }
.stack-empty { height: 8px; border-radius: 4px; background: var(--sunken); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font: 500 12px/16px var(--font); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.pips { display: inline-flex; gap: 3px; }
.pips i { width: 6px; height: 14px; border-radius: 2px; background: var(--line-2); }
.pips i.on { background: var(--k); }

/* ---------- 5. App shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; overflow-y: auto; scrollbar-gutter: stable; }
.logo { display: inline-flex; align-items: center; height: 32px; padding: 0 8px; align-self: flex-start; border-radius: var(--r-md); }
.logo img { display: block; height: 28px; width: auto; }
.logo-lg img { height: 36px; }

.org-wrap { position: relative; margin: 12px 0 8px; }
.org {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 0; border-radius: 6px; background: transparent; text-align: left; width: 100%;
  transition: background var(--d1) var(--ease);
}
button.org:hover, button.org[aria-expanded="true"] { background: rgba(27, 26, 23, .045); }
.org > span:nth-child(2) { min-width: 0; flex: 1; }
.org-av {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 4px;
  background: var(--ink); color: var(--on-ink); font: 650 12px/1 var(--font); letter-spacing: .02em;
}
.org-av.none { background: var(--sunken); color: var(--ink-3); }
.org b { display: block; font: 600 13px/18px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org > .ic { margin-left: auto; color: var(--ink-3); width: 16px; height: 16px; }

.menu {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 6px);
  padding: 6px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--e3);
  max-height: 360px; overflow-y: auto;
  animation: pop-in var(--d2) var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-label { padding: 8px 10px 6px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px;
  border: 0; border-radius: var(--r-md); background: transparent; text-align: left; font: 500 13px/18px var(--font); color: var(--ink);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .org-av { width: 26px; height: 26px; border-radius: 4px; font-size: 11px; }
.menu-item > span:not(.org-av) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item > .ic { width: 16px; height: 16px; color: var(--brand); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }

.side-search {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; margin-bottom: 12px; padding: 0 8px 0 10px;
  border: 0; border-radius: var(--r-md); background: rgba(27, 26, 23, .04); color: var(--ink-3); text-align: left;
  font: 400 13px/1 var(--font);
  transition: background var(--d1) var(--ease), box-shadow var(--d1) var(--ease), color var(--d1) var(--ease);
}
.side-search .ic { width: 16px; height: 16px; color: var(--ink-3); }
.side-search span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-search:hover { background: var(--surface); color: var(--ink-2); box-shadow: var(--e1); }
.side-search kbd, kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 3px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2);
  font: 500 11px/1 var(--font); color: var(--ink-3); white-space: nowrap;
}

.nav { display: grid; gap: 4px; }
.nav-label { padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border-radius: var(--r-md); color: var(--ink-2); font: 500 14px/1 var(--font);
  transition: background var(--d1) var(--ease), color var(--d1) var(--ease);
}
.nav-item .ic { color: var(--ink-3); transition: color var(--d1) var(--ease); }
.nav-item:hover { background: rgba(27, 26, 23, .045); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--e1); }
.nav-item[aria-current="page"] .ic { color: var(--brand); }
.nav-item .count { margin-left: auto; background: transparent; color: var(--ink-3); }
.side-foot { margin-top: auto; padding-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.me {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 6px;
  background: transparent; text-align: left; transition: background var(--d1) var(--ease), box-shadow var(--d1) var(--ease);
}
.me:hover, .me[aria-expanded="true"] { background: var(--surface); box-shadow: var(--e1); }
.me-text { min-width: 0; flex: 1; }
.me b { display: block; font: 600 13px/18px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .me-chev { width: 16px; height: 16px; color: var(--ink-3); transition: transform var(--d2) var(--ease); }
.me[aria-expanded="true"] .me-chev { transform: rotate(180deg); }
.status-note {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 6px;
  background: var(--surface); box-shadow: var(--e1); font: 400 12px/16px var(--font); color: var(--ink-2);
}
.status-note .ic { color: var(--brand); width: 18px; height: 18px; }
.status-note b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.status-note.demo .ic { color: var(--k-out-ink); }

.sheet { margin: 8px 8px 8px 0; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--e1); min-height: calc(100vh - 16px); min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 32px 40px 64px; }
.topline { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 24px 0 32px; border-bottom: 1px solid var(--line); }
.topline:empty { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font: 500 13px/1 var(--font); color: var(--ink-3); }
.crumbs a { white-space: nowrap; border-radius: 4px; }
.crumbs a:hover { color: var(--ink); }
.crumbs .ic { width: 14px; height: 14px; color: var(--ink-4); }
.crumbs b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topline .spacer { flex: 1; }

.m-head, .tabbar, .scrim { display: none; }

.page-head { display: flex; align-items: flex-end; gap: 16px 24px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head .spacer { flex: 1; }
.page-head p { margin-top: 6px; color: var(--ink-3); font-size: 14px; }
.page-head h1 { overflow-wrap: anywhere; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eyebrow-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 10px; color: var(--ink-2); font-size: 13px; }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.meta-row .ic { width: 16px; height: 16px; color: var(--ink-3); }

/* empty states */
.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 32px 24px 36px; }
.empty-state img { width: 200px; height: auto; margin-bottom: 8px; }
.empty-state h2, .empty-state h3 { font: 600 16px/24px var(--font); }
.empty-state p { max-width: 440px; color: var(--ink-3); font: 400 13px/20px var(--font); }
.empty-state .btn { margin-top: 10px; }
.empty-sm { padding: 20px 16px 24px; }
.empty-sm img { width: 140px; }
.empty-page { max-width: 560px; margin: 40px auto; }

/* skeletons */
.sk { display: block; border-radius: 4px; background: linear-gradient(90deg, var(--sunken) 0%, #f9f7f2 50%, var(--sunken) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-line { height: 12px; }
.sk-h1 { height: 32px; width: 240px; margin-top: 8px; }
.sk-eyebrow { height: 10px; width: 90px; }
.sk-card { padding: 24px; display: grid; gap: 14px; }
.sk-row { display: grid; grid-template-columns: 36px 1fr 120px; gap: 14px; align-items: center; }
.sk-av { width: 36px; height: 36px; border-radius: 4px; }
.sk-hero { height: 64px; width: 120px; }
.sk-bar { height: 16px; }

/* ---------- 6. Dashboard ---------- */
.overview { padding: 28px 28px 8px; }
.ov-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px 48px; align-items: end; }
.ov-hero .t-hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ov-hero .t-hero small { font: 500 16px/24px var(--font); letter-spacing: 0; color: var(--ink-3); }
.insight {
  justify-self: end; max-width: 520px; display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.insight p { font: 400 14px/20px var(--font); color: var(--ink-2); }
.insight p b { color: var(--ink); font-weight: 600; }
.insight .go { margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; font: 600 13px/20px var(--font); color: var(--brand-700); border-radius: 4px; }
.insight .go:hover { color: var(--brand-800); }
.insight .go .ic { width: 16px; height: 16px; }
.ov-bar { margin: 24px 0 8px; }
.ov-empty { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: center; padding: 8px 0 24px; }
.ov-empty img { width: 220px; height: auto; }
.ov-empty h2 { margin-bottom: 6px; }
.ov-empty p { color: var(--ink-2); max-width: 520px; }

.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 16px -12px 0; }
.tile {
  position: relative; display: grid; gap: 10px; align-content: start; padding: 16px 12px 20px;
  border-radius: var(--r-lg); border: 0; background: transparent; text-align: left;
  transition: background var(--d2) var(--ease);
}
.tile + .tile::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 22px; width: 1px; background: var(--line); }
.tile:hover { background: var(--surface-2); }
.tile:hover::before, .tile:hover + .tile::before { opacity: 0; }
.tile-top { display: flex; align-items: center; gap: 10px; }
.tile-top b { font: 600 13px/18px var(--font); color: var(--ink); }
.tile-val { display: flex; align-items: baseline; gap: 8px; }
.tile-val strong { font: 600 36px/40px var(--font-display); letter-spacing: -.03em; }
.tile-val span { display: inline-flex; align-items: center; gap: 6px; font: 500 13px/1 var(--font); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tile p { font: 400 12px/16px var(--font); color: var(--ink-3); }

.grid { display: grid; gap: 20px; margin-top: 20px; }
.grid-main { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-aside { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.sbars { display: grid; gap: 4px; margin-top: 12px; }
.sbar {
  display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 16px;
  padding: 10px 8px; margin: 0 -8px; border-radius: 6px; transition: background var(--d1) var(--ease);
}
.sbar:hover { background: var(--surface-2); }
.sbar-name { min-width: 0; }
.sbar-name b { display: block; font: 600 14px/20px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbar-name small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); }
.sbar-track { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sbar-track .stack { height: 20px; }
.sbar-track .stack > i { display: grid; place-items: center; font: 600 11px/1 var(--font); font-style: normal; font-variant-numeric: tabular-nums; color: #fff; overflow: hidden; }
.sbar-track .stack > i.on-light { color: var(--ink); }
.sbar-total { font: 600 14px/1 var(--font); font-variant-numeric: tabular-nums; }
.sbar-none { font: 400 12px/16px var(--font); color: var(--ink-3); }
.sbar-axis { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; margin-top: 4px; }
.sbar-axis > div { position: relative; height: 16px; border-top: 1px solid var(--line); }
.sbar-axis span { position: absolute; top: 4px; transform: translateX(-50%); font: 500 11px/1 var(--font); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { position: relative; overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.tbl th {
  padding: 0 12px 10px; text-align: left; font: 500 12px/16px var(--font); color: var(--ink-3);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--d1) var(--ease); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr[data-href] { cursor: pointer; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl th:first-child, .tbl td:first-child { padding-left: 24px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 24px; }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl td.actions .btn + .btn { margin-left: 4px; }
.tbl-compact td { padding-top: 10px; padding-bottom: 10px; }
.th-k { display: inline-flex; align-items: center; gap: 6px; }
.th-k .ic { width: 16px; height: 16px; color: var(--k-ink); }
.tbl .zero { color: var(--ink-4); }
.store-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.store-cell > span:last-child { min-width: 0; }
.store-av {
  width: 36px; height: 36px; border-radius: 4px; flex: none; display: grid; place-items: center;
  background: var(--sunken); color: var(--ink-2); font: 650 12px/1 var(--font);
}
.store-av .ic { width: 18px; height: 18px; }
.store-cell b { display: block; font: 600 14px/20px var(--font); }
.store-cell a:hover b { color: var(--brand-700); }
.store-cell small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); }
.tbl .go-cell { width: 40px; color: var(--ink-4); }
.tbl tbody tr:hover .go-cell { color: var(--ink-2); }
.tbl .stack-cell { width: 180px; }
.table-scroll {
  max-height: 480px; overflow-y: auto;
  /* scroll shadow: a soft edge at the bottom while more rows follow; the local cover hides it at the end */
  background:
    linear-gradient(var(--surface), var(--surface)) center bottom / 100% 24px no-repeat local,
    linear-gradient(to top, rgba(27, 26, 23, .09), rgba(27, 26, 23, 0)) center bottom / 100% 18px no-repeat scroll;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.table-scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.tbl-foot { padding: 12px 24px 16px; color: var(--ink-3); font: 400 12px/16px var(--font); border-top: 1px solid var(--line); }

/* ranked lists */
.rank { list-style: none; margin: 0; padding: 4px 12px 12px; }
.rank li {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 6px; transition: background var(--d1) var(--ease);
}
.rank li:hover { background: var(--surface-2); }
.rank .n { font: 600 12px/1 var(--font); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rank b { display: block; font: 500 14px/20px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank small .mono { font-size: 11px; }
.pres { display: inline-flex; align-items: center; gap: 8px; font: 500 12px/1 var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.more-btn { margin: 0 24px 20px; width: calc(100% - 48px); }
.card-empty { padding: 16px 24px 24px; color: var(--ink-3); font: 400 13px/20px var(--font); }

.brands { list-style: none; margin: 0; padding: 4px 24px 20px; display: grid; gap: 14px; }
.brands li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: center; }
.brand-av { width: 32px; height: 32px; border-radius: 4px; background: var(--sunken); display: grid; place-items: center; font: 650 12px/1 var(--font); color: var(--ink-2); }
.brands .row1 { display: flex; justify-content: space-between; gap: 8px; font: 500 14px/20px var(--font); }
.brands .row1 b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brands .row1 span { color: var(--ink-3); font: 400 12px/20px var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar { height: 6px; border-radius: 3px; background: var(--sunken); margin-top: 6px; overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: 0 3px 3px 0; background: var(--k); }

.leaders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.leader { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: start; }
.leader small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); }
.leader b { display: block; font: 600 14px/20px var(--font); margin-top: 2px; overflow-wrap: anywhere; }
.leader b span { font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 7. Visit report ---------- */
.visit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.aside { position: sticky; top: 24px; display: grid; gap: 16px; }
.note-quote {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 6px 12px 6px 10px; max-width: 100%;
  border-radius: 4px; background: var(--sunken); font: 400 13px/20px var(--font); color: var(--ink-2); overflow-wrap: anywhere;
}
.note-quote::before { content: ""; flex: none; width: 3px; height: 14px; border-radius: 2px; background: var(--ink-4); }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px;
  border-radius: 999px; background: var(--sunken); color: var(--ink-2); font: 600 12px/1 var(--font); white-space: nowrap;
}
.status-pill .ic { width: 14px; height: 14px; }
.status-done { background: var(--k-on-tint); color: var(--k-on-ink); }
.status-processing { background: var(--brand-50); color: var(--brand-700); }
.status-error { background: var(--k-else-tint); color: var(--k-else-ink); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.fbtn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 8px; flex: none;
  border: 0; border-radius: 4px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2);
  font: 500 13px/1 var(--font); color: var(--ink-2); white-space: nowrap;
  transition: background var(--d1) var(--ease), box-shadow var(--d1) var(--ease), color var(--d1) var(--ease);
}
.fbtn:hover { box-shadow: inset 0 0 0 1px #c9c3b6; color: var(--ink); }
.fbtn .ic { width: 18px; height: 18px; color: var(--k-ink, var(--ink-3)); }
.fbtn .count { background: var(--sunken); }
.fbtn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); box-shadow: none; }
.fbtn[aria-pressed="true"] .ic { color: #fff; }
.fbtn[aria-pressed="true"] .count { background: rgba(255, 255, 255, .16); color: #fff; }
.fbtn-all { padding-left: 14px; }

.group { margin-bottom: 32px; }
.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.group > .advice { margin-bottom: 10px; }
.group-head h2 { font: 600 18px/24px var(--font-display); letter-spacing: -.01em; }
.group-head p { font: 400 13px/18px var(--font); color: var(--ink-3); }
.group-head .count { margin-left: 2px; vertical-align: 2px; }
.items { display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; padding: 18px 20px;
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--e1);
  transition: box-shadow var(--d2) var(--ease), transform var(--d2) var(--ease);
}
.item:hover { box-shadow: var(--e2); transform: translateY(-1px); }
.item-name { font: 600 15px/22px var(--font); letter-spacing: -.005em; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font: 400 12px/16px var(--font); color: var(--ink-3); }
.item-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-4); }
.brand-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 3px; background: var(--sunken); color: var(--ink-2); font: 600 11px/1 var(--font); }
.facts { display: flex; gap: 28px; align-items: flex-start; margin: 0; }
.fact { display: grid; gap: 4px; min-width: 64px; }
.fact dt { font: 500 11px/16px var(--font); color: var(--ink-3); white-space: nowrap; }
.fact dd { margin: 0; font: 600 14px/20px var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fact dd.none, .fact .none { color: var(--ink-4); font-weight: 500; }
.facings { display: inline-flex; align-items: center; gap: 6px; }
.facings .pips i { width: 4px; height: 12px; border-radius: 1.5px; }
.advice {
  grid-column: 1 / -1; margin: 0; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border-radius: 4px; background: var(--k-tint); color: var(--ink); font: 400 13px/20px var(--font);
}
.advice .ic { width: 18px; height: 18px; color: var(--k-ink); margin-top: 1px; }
.analogs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.analogs > span { font: 500 12px/16px var(--font); color: var(--ink-3); margin-right: 2px; }
.analog {
  display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 10px 0 4px; border-radius: 4px; max-width: 100%;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); font: 500 12px/16px var(--font); color: var(--ink);
}
.analog .mono { padding: 3px 5px; border-radius: 3px; background: var(--brand-50); color: var(--brand-700); font-size: 11px; flex: none; }

.sum-card { padding: 20px; }
.sum-card .stack { height: 12px; margin: 14px 0 6px; }
.m-total { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.m-total strong { font: 650 40px/44px var(--font-display); letter-spacing: -.035em; }
.m-total span { font: 400 14px/20px var(--font); color: var(--ink-3); }
.sum-list { list-style: none; margin: 8px -8px 0; padding: 0; display: grid; }
.sum-list button, .sum-list a {
  width: 100%; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 8px; border: 0; border-radius: 4px; background: transparent; text-align: left; font: 500 13px/18px var(--font);
  transition: background var(--d1) var(--ease);
}
.sum-list button:hover, .sum-list a:hover { background: var(--surface-2); }
.sum-list button[aria-pressed="true"] { background: var(--k-tint); }
.sum-list .v { font: 600 14px/1 var(--font); font-variant-numeric: tabular-nums; }
.sum-list .p { font: 500 12px/1 var(--font); color: var(--ink-3); font-variant-numeric: tabular-nums; width: 34px; text-align: right; }
.cov { padding: 20px; }
.cov h3, .photos h3 { font: 600 14px/20px var(--font); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.cov .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cov .empty { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; }
.cov .empty img { width: 180px; height: auto; display: block; margin: 0 auto 6px; }
.cov .empty p { font: 400 13px/20px var(--font); color: var(--ink-2); }
.cov .empty .chips { justify-content: center; margin: 10px 0 12px; }

.photos { padding: 20px; }
.photos h3 { margin-bottom: 12px; }
.strip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo {
  position: relative; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--sunken);
  box-shadow: inset 0 0 0 1px rgba(27, 26, 23, .06); padding: 0; border: 0;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--d3) var(--ease); }
.photo:hover img { transform: scale(1.04); }
.photo .badge {
  position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px 0 6px;
  border-radius: 4px; background: rgba(27, 26, 23, .72); color: #fff; font: 600 11px/1 var(--font);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.photo .badge .ic { width: 12px; height: 12px; }
.gen-meta { margin-top: 12px; font: 400 12px/16px var(--font); color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.gen-meta .ic { width: 14px; height: 14px; color: var(--brand); }

.processing { padding: 24px; display: grid; gap: 18px; }
.processing-head { display: flex; gap: 14px; align-items: center; }
.processing-head .kchip { color: var(--brand); }
.processing-head b { display: block; font: 600 15px/22px var(--font); }
.processing-head small { display: block; font: 400 13px/18px var(--font); color: var(--ink-3); }
.scan-bar { height: 4px; border-radius: 2px; background: var(--brand-50); overflow: hidden; position: relative; }
.scan-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 35%; border-radius: 2px; background: var(--brand); animation: scan 1.6s var(--ease) infinite; }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* ---------- 8. Store page ---------- */
.upload { padding: 20px 24px 24px; margin-bottom: 20px; display: grid; gap: 16px; }
.upload-head { display: flex; gap: 12px; align-items: center; }
.upload-head b { display: block; font: 600 15px/22px var(--font); }
.upload-head small { display: block; font: 400 13px/18px var(--font); color: var(--ink-3); }
.dropzone {
  position: relative; display: grid; justify-items: center; gap: 8px; padding: 24px 16px; text-align: center;
  border-radius: var(--r-lg); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-2);
  background-image: none; cursor: pointer; transition: box-shadow var(--d1) var(--ease), background var(--d1) var(--ease);
}
.dropzone:hover, .dropzone.drag { box-shadow: inset 0 0 0 1.5px var(--brand-200), 0 0 0 4px var(--brand-50); background: var(--brand-50); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .kchip { --k-tint: var(--brand-100); --k-ink: var(--brand); }
.dropzone b { font: 600 14px/20px var(--font); }
.dropzone small { font: 400 12px/16px var(--font); color: var(--ink-3); }
.dropzone:focus-within { box-shadow: inset 0 0 0 1.5px var(--brand), 0 0 0 4px rgba(75, 75, 216, .14); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--sunken); margin: 0; box-shadow: inset 0 0 0 1px rgba(27, 26, 23, .06); animation: thumb-in var(--d3) var(--ease); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: rgba(27, 26, 23, .72); color: #fff;
}
.thumb-remove .ic { width: 14px; height: 14px; }
@keyframes thumb-in { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.visit-list { list-style: none; margin: 0; padding: 4px 12px 12px; }
.visit-list a {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 150px 16px; gap: 14px; align-items: center;
  padding: 12px; border-radius: 6px; transition: background var(--d1) var(--ease);
}
.visit-list a:hover { background: var(--surface-2); }
.visit-list b { display: block; font: 600 14px/20px var(--font); }
.visit-list small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit-list .ic-chev { width: 16px; height: 16px; color: var(--ink-4); }
.visit-list .vstack { display: grid; gap: 6px; }
.visit-list .vstack span { font: 500 11px/1 var(--font); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }

.store-grid > .col-main { grid-column: 1; grid-row: 1; display: grid; gap: 20px; min-width: 0; align-content: start; }
.store-grid > .col-aside { grid-column: 2; grid-row: 1; display: grid; gap: 16px; position: sticky; top: 24px; }
.catalog-side { position: sticky; top: 24px; min-width: 0; }
@media (max-width: 1180px) {
  .store-grid > .col-main { grid-row: 2; }
  .store-grid > .col-aside { grid-column: 1; position: static; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
  .catalog-side { position: static; }
}

/* ---------- 9. Catalog / import ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 20px 24px 16px; }
.toolbar .spacer { flex: 1; }
/* desktop: every category chip stays reachable with a mouse, so the row wraps */
.toolbar-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 24px 14px; }
.cat-chip { border: 0; cursor: pointer; transition: background var(--d1) var(--ease), color var(--d1) var(--ease); }
.cat-chip:hover { color: var(--ink); background: #ebe8e0; }
.cat-chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.cat-chip[aria-pressed="true"] .count { background: rgba(255, 255, 255, .16); color: #fff; }
.cat-chip .count { height: 18px; min-width: 18px; background: rgba(27, 26, 23, .06); }

.import { padding: 20px 24px 24px; display: grid; gap: 14px; align-content: start; }
.import-head { display: flex; gap: 12px; align-items: flex-start; }
.import-head b { display: block; font: 600 15px/22px var(--font); }
.import-head p { font: 400 13px/20px var(--font); color: var(--ink-3); margin-top: 2px; }
.example { margin: 0; padding: 12px 14px; border-radius: 6px; background: var(--sunken); white-space: pre-wrap; overflow-wrap: anywhere; font: 400 12px/20px var(--mono); color: var(--ink-2); }
/* one CSV row per line; a row that has to wrap gets a hanging indent so it still reads as one row */
.example .ln { display: block; padding-left: 2ch; text-indent: -2ch; }
.example .h { color: var(--brand-700); font-weight: 600; }
.cols { display: flex; flex-wrap: wrap; gap: 6px; }
.cols .chip { font-family: var(--mono); font-size: 11px; height: 22px; }
.file-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.file-pick {
  position: relative; flex: 1; min-width: 200px; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px;
  border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-2); color: var(--ink-3); cursor: pointer;
  font: 400 13px/1 var(--font); transition: box-shadow var(--d1) var(--ease);
}
.file-pick:hover { box-shadow: inset 0 0 0 1.5px var(--brand-200); }
.file-pick:focus-within { box-shadow: inset 0 0 0 1.5px var(--brand), 0 0 0 4px rgba(75, 75, 216, .14); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-pick .ic { color: var(--ink-3); }
.file-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick.has-file { color: var(--ink); }
.file-pick.has-file .ic { color: var(--brand); }
.import-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.import-stats div { padding: 10px 12px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.import-stats strong { display: block; font: 600 22px/28px var(--font-display); letter-spacing: -.02em; }
.import-stats span { font: 500 12px/16px var(--font); color: var(--ink-3); }
.import-errors { margin: 0; padding: 10px 14px 10px 30px; border-radius: 6px; background: var(--k-else-tint); max-height: 200px; overflow-y: auto; font: 400 12px/18px var(--font); color: var(--ink); }

.role-chip { display: inline-flex; flex: none; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 4px; white-space: nowrap; font: 600 12px/1 var(--font); background: var(--sunken); color: var(--ink-2); }
.role-root { background: var(--ink); color: var(--on-ink); }
.role-admin { background: var(--brand-50); color: var(--brand-800); }
.role-agent { background: var(--k-on-tint); color: var(--k-on-ink); }

/* ---------- 10. Dialogs ---------- */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0;
  border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--e4);
}
.dialog[open] { animation: dialog-in var(--d3) var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog::backdrop { background: rgba(27, 26, 23, .32); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog-body { display: grid; gap: 16px; padding: 24px; }
.dialog-body h2 { font: 600 20px/28px var(--font-display); letter-spacing: -.012em; }
.dialog-body > p { color: var(--ink-2); margin-top: -8px; overflow-wrap: anywhere; }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; }
.dialog-head .kchip-danger { --k-tint: var(--k-else-tint); --k-ink: var(--k-else-ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(14, 14, 13, .92); color: #fff;
}
.lightbox::backdrop { background: transparent; }
.lightbox[open] { display: grid; place-items: center; animation: fade-in var(--d2) var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); border-radius: 6px; display: block; object-fit: contain; }
.lb-btn {
  position: absolute; width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.lb-btn:hover { background: rgba(255, 255, 255, .18); }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); font: 600 12px/1 var(--font); padding: 8px 12px; border-radius: 4px; background: rgba(255, 255, 255, .1); }

/* ---------- 11. Login ---------- */
.login { display: grid; grid-template-columns: minmax(420px, 560px) minmax(0, 1fr); min-height: 100vh; }
.login-form { display: flex; flex-direction: column; padding: 32px 56px; background: var(--surface); gap: 24px; }
.login-form form { margin: auto 0; display: grid; gap: 18px; max-width: 380px; width: 100%; }
.login-form [hidden] { display: none !important; }
.login-form h1 { margin-top: 4px; }
.login-form .lede { color: var(--ink-3); font: 400 15px/22px var(--font); margin-top: -6px; margin-bottom: 8px; }
.login-form .btn-lg { width: 100%; margin-top: 6px; }
.login-form .help { font: 400 13px/20px var(--font); color: var(--ink-3); }
.app-get { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color var(--d2) var(--ease), background-color var(--d2) var(--ease); }
.app-get:hover { border-color: var(--line-2, var(--line)); background: var(--surface-2); }
.app-get:focus-visible { outline: none; box-shadow: var(--focus); }
.app-get > .ic:first-child { width: 20px; height: 20px; color: var(--brand-700); flex: none; }
.app-get span { flex: 1; min-width: 0; }
.app-get b { display: block; font: 600 14px/20px var(--font); }
.app-get small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); }
.app-get > .ic:last-child { color: var(--ink-3); }
.login-foot { display: flex; justify-content: space-between; gap: 12px; font: 400 12px/16px var(--font); color: var(--ink-3); }
.pw { position: relative; }
.pw .input { padding-right: 96px; }
.pw button { position: absolute; right: 6px; top: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-3); font: 500 12px/1 var(--font); }
.pw button:hover { background: var(--sunken); color: var(--ink); }

.hero {
  position: relative; margin: 12px; border-radius: var(--r-2xl); overflow: hidden;
  background:
    radial-gradient(120% 80% at 100% 0%, #e9e9fb 0%, rgba(233, 233, 251, 0) 60%),
    linear-gradient(180deg, #f3f2fb 0%, #f6f4ef 100%);
  box-shadow: inset 0 0 0 1px rgba(27, 26, 23, .05);
  display: flex; flex-direction: column; padding: 56px 56px 40px;
}
.eyebrow-chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 8px;
  border-radius: 4px; background: color-mix(in srgb, var(--surface) 80%, transparent); box-shadow: var(--e1); font: 600 12px/1 var(--font); color: var(--brand-700);
}
.eyebrow-chip .ic { width: 16px; height: 16px; color: var(--brand); }
.hero h2 { margin-top: 20px; max-width: 640px; }
.hero h2 em { font-style: normal; color: var(--brand); }
.hero .sub { margin-top: 14px; max-width: 520px; font: 400 17px/26px var(--font); color: var(--ink-2); }
.hero-art { position: relative; flex: 1; min-height: 420px; margin-top: 24px; display: grid; place-items: center; }
.hero-art > img { width: min(100%, 640px); height: auto; display: block; filter: drop-shadow(0 30px 40px rgba(27, 26, 23, .08)); }
.hero-art > img.hero-photo {
  width: min(100%, 460px); aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 42%;
  border-radius: 8px; filter: none; box-shadow: 0 40px 80px -24px rgb(var(--sh) / .35), 0 0 0 1px rgba(27, 26, 23, .06);
}
.float {
  position: absolute; background: color-mix(in srgb, var(--surface) 92%, transparent); border-radius: 8px; box-shadow: var(--e3); padding: 14px 16px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: float-in 700ms var(--ease) both;
}
.float-a { left: -8px; bottom: 2%; width: 260px; animation-delay: 250ms; }
.float-b { right: 0; top: 6%; width: 236px; animation-delay: 450ms; }
@keyframes float-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.float .row { display: flex; align-items: center; gap: 10px; }
.float b { display: block; font: 600 13px/18px var(--font); }
.float small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); }
.float .big { font: 600 28px/32px var(--font-display); letter-spacing: -.03em; margin-top: 10px; }
.float .stack { height: 8px; margin-top: 10px; }
.hero-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hero-legend > span {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--surface) 70%, transparent); box-shadow: var(--e1); font: 500 12px/1 var(--font); color: var(--ink-2);
}
.hero-legend .kchip-sm { width: 22px; height: 22px; border-radius: 4px; }

/* ---------- 12. Responsive ---------- */
@media (max-width: 1280px) {
  .page { padding: 28px 28px 56px; }
  .visit-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
  .grid-aside { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1180px) {
  .grid-main, .grid-aside { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* tablet: the stores table keeps every number; category headers shrink to their glyph (name stays for screen readers and in the tooltip) */
  #stores-table .th-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #stores-table .th-k .ic { width: 18px; height: 18px; }
  #stores-table .stack-cell { width: 120px; }
  .ov-top { grid-template-columns: minmax(0, 1fr); }
  .insight { justify-self: stretch; max-width: none; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 4px; }
  .tile:nth-child(4)::before { display: none; }
  .login { grid-template-columns: minmax(380px, 480px) minmax(0, 1fr); }
  .login-form { padding: 32px 40px; }
  .hero { padding: 40px 36px 32px; }
  .hero .t-display { font-size: 44px; line-height: 48px; }
}
@media (max-width: 1024px) {
  .visit-grid { grid-template-columns: minmax(0, 1fr); }
  /* report first: summary on top, then the items, then coverage and photos */
  .visit-grid > .aside { display: contents; }
  .visit-grid > .aside > .sum-card { order: -1; }
  .visit-grid > .aside > .cov, .visit-grid > .aside > .photos { order: 1; }
  .strip { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tbl .stack-cell { width: 120px; }
}
@media (max-width: 900px) and (min-width: 769px) {
  .shell { grid-template-columns: 216px minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .hero { display: none; }
  /* no photo column: the form sits in the middle instead of hugging the left edge */
  .login-form { align-items: center; }
  .login-form > .logo { align-self: flex-start; }
  .login-form form { margin: auto; max-width: 400px; }
  .login-foot { align-self: stretch; }
  /* the numbers stay, the mini bar goes: the «Структура по магазинам» card above shows it */
  #stores-table .stack-cell { display: none; }
}

/* phones and narrow tablets: compact header + bottom navigation + drawer */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .shell { display: block; min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .m-head {
    position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 8px 0 12px;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--canvas) 86%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(20px); backdrop-filter: saturate(1.6) blur(20px);
    box-shadow: 0 1px 0 var(--line);
  }
  .m-head .logo { padding: 0 4px; align-self: center; }
  .m-head .logo img { height: 26px; }
  .m-head .spacer { flex: 1; }
  .m-head .btn-icon { width: 44px; height: 44px; }
  .m-head .btn-icon .ic { width: 22px; height: 22px; color: var(--ink-2); }
  .m-head .chip-demo { height: 24px; padding: 0 8px; font-size: 11px; }

  .side {
    position: fixed; z-index: 80; top: 0; left: 0; bottom: 0; height: auto; width: min(304px, 86vw);
    background: var(--canvas); box-shadow: var(--e4); padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-104%); transition: transform var(--d3) var(--ease); visibility: hidden;
  }
  .drawer-open .side { transform: none; visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(27, 26, 23, .32); opacity: 0; pointer-events: none; transition: opacity var(--d3) var(--ease); }
  .drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .nav-item { height: 44px; }

  .sheet { margin: 0; border-radius: 0; box-shadow: none; background: var(--canvas); min-height: 0; }
  .topline { min-height: 44px; padding: 0 16px; border-bottom: 0; overflow-x: auto; scrollbar-width: none; }
  .topline::-webkit-scrollbar { display: none; }
  .topline .chip-demo { display: none; }
  .crumbs { font-size: 13px; }
  .page { padding: 12px 16px 32px; }
  .topline + .page { padding-top: 4px; }
  .upload, .card[id], .group { scroll-margin-top: 68px; }

  .tabbar {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: calc(64px + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(20px); backdrop-filter: saturate(1.6) blur(20px);
    box-shadow: 0 -1px 0 var(--line);
  }
  .tab { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 52px; border: 0; background: transparent; color: var(--ink-3); font: 500 11px/12px var(--font); border-radius: 6px; }
  .tab .ic { width: 24px; height: 24px; }
  .tab[aria-current="page"] { color: var(--brand); }

  .t-h1 { font-size: 28px; line-height: 34px; }
  .page-head { margin-bottom: 20px; gap: 14px; align-items: flex-start; }
  .page-head > .spacer { display: none; }
  .page-head .head-actions { width: 100%; }
  .page-head .head-actions .btn-primary { flex: 1; }
  .head-actions .chip { order: 9; }

  .card { border-radius: 8px; box-shadow: var(--e1); }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 18px; }
  .card-sub, .card-empty { padding-left: 16px; padding-right: 16px; }

  .overview { padding: 18px 16px 6px; }
  .t-hero { font-size: 52px; line-height: 56px; }
  .ov-hero .t-hero small { font-size: 14px; line-height: 20px; }
  .insight { padding: 12px; gap: 12px; }
  .insight .kchip-lg { width: 32px; height: 32px; border-radius: 4px; }
  .ov-bar { margin-top: 18px; }
  .ov-empty { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; gap: 12px; }
  .ov-empty img { width: 180px; }
  .tiles { display: flex; overflow-x: auto; gap: 8px; margin: 14px -16px 10px; padding: 2px 16px 4px; scrollbar-width: none; }
  .tiles::-webkit-scrollbar { display: none; }
  .tile { flex: none; width: 148px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: 8px; padding: 12px; gap: 8px; }
  .tile + .tile::before { display: none; }
  .tile-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tile-top .kchip { width: 24px; height: 24px; border-radius: 3px; }
  .tile-top .kchip .ic { width: 16px; height: 16px; }
  .tile-val strong { font-size: 26px; line-height: 28px; }
  .tile p { display: none; }

  .grid { gap: 14px; margin-top: 14px; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sbar { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .sbar-name { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
  .sbar-axis { display: none; }
  .leaders { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .rank { padding: 4px 4px 8px; }
  .rank li { padding: 10px 12px; }
  .brands { padding: 4px 16px 16px; }
  .more-btn { margin: 0 16px 16px; width: calc(100% - 32px); }

  /* tables become lists of cards */
  .tbl.stackable thead { display: none; }
  .tbl.stackable, .tbl.stackable tbody { display: block; }
  .tbl.stackable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .tbl.stackable tr:last-child { border-bottom: 0; }
  .tbl.stackable td { display: block; padding: 0; border: 0; background: transparent !important; }
  .tbl.stackable td:first-child, .tbl.stackable td:last-child { padding: 0; }
  .tbl.stackable td.primary { grid-column: 1; }
  .tbl.stackable td.side-cell { grid-column: 2; grid-row: 1; text-align: right; align-self: center; }
  .tbl.stackable td.full { grid-column: 1 / -1; }
  .tbl.stackable td[data-label]:not(.primary):not(.side-cell)::before { content: attr(data-label) " · "; color: var(--ink-3); font-size: 12px; }
  .tbl.stackable td.m-hide { display: none; }
  .tbl.stackable td.sub { font-size: 13px; color: var(--ink-2); }
  .tbl.stackable td.actions { grid-column: 1 / -1; text-align: left; margin-top: 6px; }
  .tbl.stackable td.actions .btn { height: 36px; }
  .tbl.stackable tr.empty-row { display: block; }
  .tbl.stackable td.stack-cell { width: auto; grid-column: 1 / -1; margin-top: 6px; }
  .tbl.stackable .go-cell { display: none; }
  /* the page scrolls; no nested scroll box above the tab bar */
  .table-scroll { max-height: none; overflow-y: visible; background: none; border-radius: 0; }

  .toolbar { padding: 14px 16px 12px; }
  .search { max-width: none; }
  /* phones: one swipeable row; the fade on the right shows that more chips follow */
  .toolbar-chips {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 16px 12px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  }
  .toolbar-chips::-webkit-scrollbar { display: none; }

  .visit-grid { gap: 14px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px 4px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .group-head { position: sticky; top: 56px; z-index: 2; background: var(--canvas); padding: 8px 0; margin-bottom: 8px; }
  .item { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; gap: 10px; }
  .facts { gap: 16px; flex-wrap: wrap; }
  .fact { min-width: 0; }
  .meta-row { gap: 4px 14px; }
  .head-actions .btn { min-height: 40px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .visit-list { padding: 4px 4px 8px; }
  .visit-list a { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; }
  .visit-list .vstack { grid-column: 2 / -1; }
  .visit-list .vstack span { text-align: left; }
  .visit-list .ic-chev { display: none; }
  .upload { padding: 16px; }
  .import { padding: 16px; }
  .import-stats strong { font-size: 18px; }

  .dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 8px 8px 0 0; }
  .dialog[open] { animation: sheet-in var(--d3) var(--ease); }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .dialog-body { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .dialog-actions .btn { flex: 1; height: 44px; }
  .input { font-size: 16px; }

  .login { display: flex; flex-direction: column; min-height: 100vh; }
  .login-form { order: 2; flex: 1; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--surface); gap: 20px; }
  .login-form > .logo { display: none; }
  .login-form form { margin: 0; max-width: none; }
  .hero { order: 1; display: flex; margin: 0; border-radius: 0; padding: 20px 20px 0; box-shadow: none; }
  .hero .m-logo { display: block; }
  .hero h2.t-display { font-size: 30px; line-height: 34px; margin-top: 16px; }
  .hero .sub { font-size: 14px; line-height: 20px; margin-top: 8px; }
  .hero .eyebrow-chip { display: none; }
  .hero-art { min-height: 0; margin: 8px 0 -6px; }
  .hero-art > img { width: min(100%, 300px); }
  .hero-art > img.hero-photo { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; box-shadow: 0 16px 32px -16px rgb(var(--sh) / .35); }
  .float, .hero-legend { display: none; }
}
.m-logo { display: none; }
.m-logo img { height: 28px; display: block; }

/* ---------- 13. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .stack > i, .pips i.on, .hbar i, .swatch { forced-color-adjust: none; }
}

/* ---------- Category chips v2 (solid tiles) ---------- */
/* ==========================================================================
   ясно. — v2-solid chips: category tiles, hero legend, eyebrow chip.
   Drop-in for server/web/style.css: same selectors and --k* variables.
   Replaces: [data-kind] rules, .kchip* block, .eyebrow-chip*, .hero-legend*.
   Needs the :root tokens from style.css (--k-*, --brand*, --ink*, --e1, --ease, --d*).
   ========================================================================== */

/* ---------- category variables ----------
   --k       mark colour (charts, swatches)
   --k-ink   icon/text on the tint
   --k-tint  pale plate
   --k-tile  base of the solid tile; amber is pulled toward its ink so the
             white glyph keeps >= 3:1 (WCAG 1.4.11), the rest use the mark. */
[data-kind="on_shelf"]         { --k: var(--k-on);   --k-ink: var(--k-on-ink);   --k-tint: var(--k-on-tint);   --k-tile: var(--k-on); }
[data-kind="out_of_stock"]     { --k: var(--k-out);  --k-ink: var(--k-out-ink);  --k-tint: var(--k-out-tint);  --k-tile: color-mix(in oklab, var(--k-out) 66%, var(--k-out-ink)); }
[data-kind="bought_elsewhere"] { --k: var(--k-else); --k-ink: var(--k-else-ink); --k-tint: var(--k-else-tint); --k-tile: var(--k-else); }
[data-kind="competitor_only"]  { --k: var(--k-comp); --k-ink: var(--k-comp-ink); --k-tint: var(--k-comp-tint); --k-tile: var(--k-comp); }
[data-kind="opportunity"]      { --k: var(--k-opp);  --k-ink: var(--k-opp-ink);  --k-tint: var(--k-opp-tint);  --k-tile: var(--k-opp); }

/* ---------- .kchip: neutral plate (brand / plain / danger / spinner) ---------- */
.kchip {
  position: relative; isolation: isolate;
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: var(--k-tint); color: var(--k-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k-ink, var(--ink)) 10%, transparent);
}
.kchip .ic { width: 20px; height: 20px; }
.kchip-sm { width: 24px; height: 24px; border-radius: 4px; }
.kchip-sm .ic { width: 16px; height: 16px; }
.kchip-lg { width: 40px; height: 40px; border-radius: 6px; }
.kchip-lg .ic { width: 24px; height: 24px; }
.kchip-brand { --k-tint: var(--brand-50); --k-ink: var(--brand); }
.kchip-plain { --k-tint: var(--sunken); --k-ink: var(--ink-2); }

/* ---------- .kchip[data-kind]: solid category tile ----------
   Gradient body (light top, deeper bottom), 1px top highlight, hairline
   inner edge, soft coloured drop. White glyph with a 1px contact shadow. */
.kchip[data-kind] {
  color: #fff;
  background:
    linear-gradient(180deg,
      color-mix(in oklab, var(--k-tile) 84%, #fff) 0%,
      var(--k-tile) 46%,
      color-mix(in oklab, var(--k-tile) 70%, var(--k-ink)) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .30),
    inset 0 0 0 1px color-mix(in srgb, var(--k-ink) 28%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--k-ink) 30%, transparent),
    0 1px 2px color-mix(in srgb, var(--k-ink) 30%, transparent),
    0 4px 10px -4px color-mix(in srgb, var(--k-tile) 60%, transparent);
  transition: transform var(--d2) var(--ease), box-shadow var(--d2) var(--ease);
}
/* glossy sheen on the upper half */
.kchip[data-kind]::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 70% at 30% 0%, rgba(255, 255, 255, .26) 0%, rgba(255, 255, 255, 0) 62%);
}
.kchip[data-kind] .ic { filter: drop-shadow(0 1px 0 color-mix(in srgb, var(--k-ink) 45%, transparent)); }
.kchip-sm[data-kind] {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .28),
    inset 0 0 0 1px color-mix(in srgb, var(--k-ink) 26%, transparent),
    0 1px 2px color-mix(in srgb, var(--k-ink) 28%, transparent);
}
.kchip-sm[data-kind] .ic { width: 15px; height: 15px; filter: none; }

/* lift with the tile / legend item it lives in */
.tile:hover .kchip[data-kind],
.sum-list a:hover .kchip[data-kind],
.sum-list button:hover .kchip[data-kind] {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .30),
    inset 0 0 0 1px color-mix(in srgb, var(--k-ink) 28%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--k-ink) 30%, transparent),
    0 2px 3px color-mix(in srgb, var(--k-ink) 26%, transparent),
    0 8px 16px -6px color-mix(in srgb, var(--k-tile) 75%, transparent);
}

/* ---------- hero legend: tile + strong label ---------- */
.hero-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero-legend > span {
  display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 15px 0 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  box-shadow:
    0 0 0 1px rgba(27, 26, 23, .06),
    0 1px 2px rgba(27, 26, 23, .05),
    0 8px 18px -12px rgb(var(--sh) / .28),
    inset 0 1px 0 var(--hl);
  font: 600 13px/1 var(--font); letter-spacing: -.006em; color: var(--ink);
  white-space: nowrap;
  transition: transform var(--d2) var(--ease), box-shadow var(--d2) var(--ease), background var(--d2) var(--ease);
  animation: legend-in 520ms var(--ease) backwards;
}
.hero-legend > span:nth-child(1) { animation-delay: 520ms; }
.hero-legend > span:nth-child(2) { animation-delay: 580ms; }
.hero-legend > span:nth-child(3) { animation-delay: 640ms; }
.hero-legend > span:nth-child(4) { animation-delay: 700ms; }
.hero-legend > span:nth-child(5) { animation-delay: 760ms; }
.hero-legend > span:hover {
  transform: translateY(-1px); background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow:
    0 0 0 1px rgba(27, 26, 23, .07),
    0 2px 4px rgba(27, 26, 23, .05),
    0 12px 24px -12px rgb(var(--sh) / .34),
    inset 0 1px 0 var(--hl);
}
.hero-legend .kchip-sm { width: 24px; height: 24px; border-radius: 4px; }
.hero-legend .kchip-sm .ic { width: 16px; height: 16px; }
@keyframes legend-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- eyebrow chip: gradient hairline + sparkle badge ---------- */
@property --eb-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.eyebrow-chip {
  align-self: flex-start; position: relative;
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 5px;
  border: 1px solid transparent; border-radius: 4px;
  background:
    linear-gradient(color-mix(in srgb, var(--surface) 90%, transparent), color-mix(in srgb, var(--surface) 90%, transparent)) padding-box,
    conic-gradient(from var(--eb-a) at 50% 50%,
      rgba(75, 75, 216, .70), rgba(162, 74, 168, .55) 22%, rgba(75, 75, 216, .16) 45%,
      rgba(75, 75, 216, .16) 70%, rgba(75, 75, 216, .70)) border-box;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 1px 2px rgb(var(--sh) / .08), 0 8px 20px -10px rgba(75, 75, 216, .45);
  font: 600 12px/1 var(--font); letter-spacing: .005em; color: var(--brand-800);
  animation: eb-spin 9s linear infinite;
}
.eyebrow-chip .ic {
  width: 22px; height: 22px; padding: 4px; border-radius: 4px; color: #fff;
  background: linear-gradient(150deg, #7a7af0 0%, var(--brand) 55%, var(--brand-800) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 1px 2px rgb(var(--sh) / .35), 0 3px 8px -3px rgba(75, 75, 216, .6);
  animation: eb-twinkle 4.8s var(--ease) infinite;
}
/* a tiny glint that pops next to the badge */
.eyebrow-chip::after {
  content: ""; position: absolute; left: 21px; top: 1px; width: 7px; height: 7px;
  background: var(--brand);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  opacity: 0; transform: scale(.3);
  animation: eb-glint 4.8s var(--ease) infinite;
}
@keyframes eb-spin { to { --eb-a: 360deg; } }
@keyframes eb-twinkle {
  0%, 70%, 100% { transform: none; }
  78% { transform: rotate(-12deg) scale(1.08); }
  86% { transform: rotate(6deg) scale(.98); }
}
@keyframes eb-glint {
  0%, 72% { opacity: 0; transform: scale(.3) rotate(0deg); }
  80% { opacity: 1; transform: scale(1) rotate(45deg); }
  92%, 100% { opacity: 0; transform: scale(.4) rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .kchip[data-kind], .hero-legend > span { transition: none; }
  .hero-legend > span, .eyebrow-chip, .eyebrow-chip .ic, .eyebrow-chip::after { animation: none; }
  .tile:hover .kchip[data-kind], .hero-legend > span:hover { transform: none; }
}

/* ==========================================================================
   14. Accounts, admin panel, palette, toasts, motion (v3)
   ========================================================================== */

/* ---------- custom scrollbars: thin, rounded, brand-tinted, transparent track ----------
   Chromium/WebKit use the pseudo-elements (setting scrollbar-width/-color there would disable
   them), Firefox gets the standard properties. */
/* The page behind an open dialog/drawer does not scroll and shows no second scrollbar;
   --sbw (set by app.js) keeps the layout from jumping by the scrollbar width. */
html.modal-lock { overflow: hidden; padding-right: var(--sbw, 0px); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--sb-thumb); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box; min-height: 40px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
::-webkit-scrollbar-thumb:active { background-color: var(--sb-thumb-active); }
::-webkit-scrollbar-corner, ::-webkit-scrollbar-button { background: transparent; display: none; }
/* inside cards, drawers and menus: a slimmer bar */
.card ::-webkit-scrollbar, .menu::-webkit-scrollbar, .drawer-body::-webkit-scrollbar, .pal-list::-webkit-scrollbar,
.side::-webkit-scrollbar, .dialog::-webkit-scrollbar, .table-wrap::-webkit-scrollbar, .import-errors::-webkit-scrollbar { width: 10px; height: 10px; }
.side::-webkit-scrollbar-thumb { background-color: transparent; }
.side:hover::-webkit-scrollbar-thumb { background-color: var(--sb-thumb); }
.side::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
@supports (-moz-appearance: none) {
  * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
  *:hover { scrollbar-color: var(--sb-thumb-hover) transparent; }
}

/* ---------- avatars ---------- */
.av {
  --av: 32px;
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--av); height: var(--av); border-radius: 50%; overflow: hidden;
  background: var(--sunken); vertical-align: middle;
}
.av > img, .av > svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.av > img { box-shadow: inset 0 0 0 1px rgba(27, 26, 23, .08); }
.av > img:not([src]) { visibility: hidden; } /* picture still loading (blob fetch): keep the tinted circle */
.av-sq { border-radius: 4px; }
.av-sq[style*="--av:26px"], .av-sq[style*="--av:24px"] { border-radius: 4px; }
.av-none { color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); background: var(--surface-2); }
.av-none .ic { width: 55%; height: 55%; max-width: 18px; max-height: 18px; }
.av-sys { background: linear-gradient(150deg, var(--brand-50), var(--brand-100)); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand-100); }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; vertical-align: middle; }
.who > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-row .who .ic { width: 12px; height: 12px; }
.who-line { display: flex !important; align-items: center; gap: 6px; }
.who-line > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-xs { height: 18px; padding: 0 6px; font-size: 11px; vertical-align: 1px; margin-left: 4px; }

/* org block uses the generated company picture */
.org > .av { box-shadow: 0 0 0 1px rgba(27, 26, 23, .06); }
.menu-item .av { flex: none; }

/* ---------- sidebar user block + user menu ---------- */
.m-me { display: none; }
.user-menu {
  position: fixed; left: 0; right: auto; top: 0; z-index: 120; width: 272px; max-height: none;
  transform-origin: bottom left; animation: menu-up var(--d2) var(--ease-out);
}
.user-menu[data-from="top"] { transform-origin: top right; animation-name: menu-down; }
@keyframes menu-up { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes menu-down { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.um-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.um-head > span:last-child { min-width: 0; }
.um-head b { display: block; font: 600 13px/18px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-head small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item > .ic { width: 18px; height: 18px; color: var(--ink-3); }
.user-menu .menu-item { min-height: 36px; }
.user-menu .menu-item kbd { margin-left: auto; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); background: var(--surface-2); }
.menu-danger:hover { background: var(--k-else-tint); color: var(--k-else-ink); }
.menu-danger:hover .ic { color: var(--k-else-ink); }

/* ---------- buttons: press feedback, busy state ---------- */
.btn { transition: background var(--d1) var(--ease), box-shadow var(--d1) var(--ease), transform 160ms var(--spring), opacity var(--d1) var(--ease), color var(--d1) var(--ease); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy .ic { opacity: 0; }
.btn.is-busy::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger).is-busy::after { border-color: var(--ink-3); border-right-color: transparent; }
.spacer { flex: 1; }

/* ---------- empty / error states ---------- */
.empty-ic {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 10px; border-radius: 8px;
  background: linear-gradient(160deg, var(--brand-50), var(--brand-100)); color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand-100), 0 10px 24px -12px rgba(75, 75, 216, .5);
}
.empty-ic .ic { width: 28px; height: 28px; }
.empty-ic-error { background: linear-gradient(160deg, var(--k-else-tint), #f6d6d9); color: var(--k-else-ink); box-shadow: inset 0 0 0 1px #f3cdd1, 0 10px 24px -12px rgba(200, 52, 63, .45); }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; inset: auto 20px 20px auto; z-index: 300; margin: 0; padding: 0; border: 0; background: transparent;
  overflow: visible; width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toasts:not(:popover-open):empty { display: none; }
.toast {
  position: relative; overflow: hidden; pointer-events: auto;
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; gap: 12px; align-items: start;
  padding: 12px 12px 14px 14px; border-radius: 6px; background: var(--ink); color: var(--on-ink);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 18px 40px -14px rgba(27, 26, 23, .55), 0 2px 6px rgba(27, 26, 23, .18);
  animation: toast-in 420ms var(--spring) both;
}
.toast.out { animation: toast-out 260ms var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.98); } }
.toast-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 4px; background: rgba(255, 255, 255, .1); }
.toast-ic .ic { width: 18px; height: 18px; }
.toast-success .toast-ic { background: var(--k-on); }
.toast-error .toast-ic { background: var(--k-else); }
.toast-warning .toast-ic { background: color-mix(in oklab, var(--k-out) 70%, var(--k-out-ink)); }
.toast-info .toast-ic { background: var(--brand); }
.toast-text { display: grid; gap: 2px; padding-top: 4px; font: 400 13px/20px var(--font); color: rgba(255, 255, 255, .86); overflow-wrap: anywhere; }
.toast-text b { font: 600 14px/20px var(--font); color: #fff; }
.toast-x { width: 28px; height: 28px; border: 0; border-radius: 4px; display: grid; place-items: center; background: transparent; color: rgba(255, 255, 255, .6); }
.toast-x:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.toast-x .ic { width: 16px; height: 16px; }
.toast-timer { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: rgba(255, 255, 255, .28); transform-origin: left; animation: toast-timer var(--toast-ms, 4s) linear forwards; }
.toast.paused .toast-timer { animation-play-state: paused; }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- dialogs: spring in, quick out ---------- */
.dialog[open] { animation: dialog-in 420ms var(--spring); }
.dialog[open]::backdrop, .drawer[open]::backdrop, .palette[open]::backdrop { animation: fade-in var(--d3) var(--ease); }
.dialog.closing { animation: dialog-out 200ms var(--ease-in) forwards; }
.closing::backdrop { animation: fade-out 220ms var(--ease) forwards; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade-out { to { opacity: 0; } }
.dialog-body > p.alert { margin-top: 0; }
.dialog-head > div { flex: 1; min-width: 0; }
.dialog-head p { margin-top: 4px; }
.dialog-actions .spacer { flex: 1; }
.dialog-head .kchip-brand { color: var(--brand); }
.kchip-danger { --k-tint: var(--k-else-tint); --k-ink: var(--k-else-ink); }
.shake { animation: shake 420ms var(--ease) !important; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.lightbox.closing { animation: fade-out 200ms var(--ease) forwards; }

/* ---------- drawer (user details) ---------- */
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0 0 0 auto; padding: 0; border: 0;
  width: min(480px, 100vw); height: 100vh; max-height: 100vh; max-width: 100vw;
  background: var(--surface); color: var(--ink); box-shadow: var(--e4);
  border-radius: var(--r-xl) 0 0 var(--r-xl); overflow: hidden;
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in 460ms cubic-bezier(.32, .72, 0, 1); }
.drawer.closing { animation: drawer-out 240ms var(--ease-in) forwards; }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out { to { transform: translateX(100%); } }
.drawer::backdrop { background: rgba(27, 26, 23, .28); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--line); }
.drawer-id { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.drawer-id > div { min-width: 0; }
.drawer-id h2 { font: 600 18px/24px var(--font-display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.drawer-id p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; color: var(--ink-3); }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 24px; }
.dsec { display: grid; gap: 14px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.dsec:last-child { border-bottom: 0; }
.dsec h3 { font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.dsec > p { font: 400 13px/20px var(--font); color: var(--ink-2); }
.dsec-danger .btn { justify-self: start; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { display: flex; align-items: flex-start; gap: 6px; font: 400 12px/16px var(--font); color: var(--ink-3); }
.hint .ic { width: 14px; height: 14px; margin-top: 1px; flex: none; }
.drawer-av { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.drawer-av .av-actions { flex: 1; min-width: 0; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-2); }
.dirty-note { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/16px var(--font); color: var(--k-out-ink); animation: fade-in var(--d2) var(--ease); }
.dirty-note .ic { color: var(--k-out); }
.kv { display: grid; gap: 0; margin: 0; }
.kv > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; align-items: center; min-height: 36px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { font: 400 13px/20px var(--font); color: var(--ink-3); }
.kv dd { margin: 0; font: 500 13px/20px var(--font); color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.t-break { word-break: break-all; }

/* switch */
.switch-row { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.switch-row > div { flex: 1; min-width: 0; }
.switch-row b { display: block; font: 600 14px/20px var(--font); }
.switch-row small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); margin-top: 2px; }
.switch {
  position: relative; flex: none; width: 44px; height: 26px; padding: 0; border: 0; border-radius: 999px;
  background: var(--line-2); transition: background var(--d2) var(--ease), box-shadow var(--d2) var(--ease);
}
.switch i {
  position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(27, 26, 23, .28); transition: transform 320ms var(--spring);
}
.switch[aria-checked="true"] { background: var(--k-on); }
.switch[aria-checked="true"] i { transform: translateX(18px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.switch:active:not(:disabled) i { width: 24px; }
.switch[aria-checked="true"]:active:not(:disabled) i { transform: translateX(14px); }

/* user status */
.ustatus { display: inline-flex; align-items: center; gap: 6px; font: 500 13px/20px var(--font); white-space: nowrap; }
.ustatus.on { color: var(--k-on-ink); }
.ustatus.on i { width: 8px; height: 8px; border-radius: 50%; background: var(--k-on); box-shadow: 0 0 0 3px var(--k-on-tint); }
.ustatus.off { color: var(--k-else-ink); }
.ustatus .ic { width: 14px; height: 14px; }
.drawer-id .ustatus { font-size: 12px; }
.tbl tr.is-disabled .av { filter: grayscale(1); opacity: .6; }
.tbl tr.is-disabled b { color: var(--ink-3); }
.users-tbl tr[data-user] { cursor: pointer; }
.users-tbl td.primary { min-width: 240px; }

/* ---------- forms in cards ---------- */
.form-card { display: flex; flex-direction: column; min-width: 0; }
.form-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 24px 20px; flex: 1; }
.form-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); min-height: 53px; }
.form-note { display: inline-flex; align-items: center; gap: 6px; font: 400 12px/16px var(--font); color: var(--ink-3); }
.form-note .ic { color: var(--ink-3); }
.card-head > .ic { color: var(--ink-3); width: 20px; height: 20px; }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--k-else), 0 0 0 4px rgba(200, 52, 63, .12); }
.field-error { display: flex; align-items: center; gap: 6px; font: 500 12px/16px var(--font); color: var(--k-else-ink) !important; animation: fade-in var(--d2) var(--ease); }
.field-error .ic { width: 14px; height: 14px; }
.input:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; box-shadow: inset 0 0 0 1px var(--line); }
.select-sm { flex: none; }
.select-sm .input { height: 40px; font-size: 13px; padding-left: 12px; background-color: var(--surface-2); min-width: 168px; }

/* password strength */
.strength { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.strength-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: 1; max-width: 200px; }
.strength-bar i { height: 4px; border-radius: 2px; background: var(--line); transition: background var(--d2) var(--ease), transform var(--d2) var(--spring); }
.strength-label { font: 500 12px/16px var(--font); color: var(--ink-3); min-width: 0; }
.strength[data-score="1"] .strength-bar i:nth-child(-n+1) { background: var(--k-else); }
.strength[data-score="2"] .strength-bar i:nth-child(-n+2) { background: var(--k-out); }
.strength[data-score="3"] .strength-bar i:nth-child(-n+3) { background: color-mix(in oklab, var(--k-on) 70%, var(--k-out)); }
.strength[data-score="4"] .strength-bar i { background: var(--k-on); }
.strength[data-score="1"] .strength-label { color: var(--k-else-ink); }
.strength[data-score="2"] .strength-label { color: var(--k-out-ink); }
.strength[data-score="3"] .strength-label, .strength[data-score="4"] .strength-label { color: var(--k-on-ink); }

/* ---------- profile ---------- */
.profile-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 24px 28px; }
.profile-hero-sk { display: flex; gap: 24px; align-items: center; }
.ph-av { position: relative; width: 96px; height: 96px; }
.ph-av .av { box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line), 0 16px 32px -16px rgb(var(--sh) / .45); }
.ph-edit {
  position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: var(--ink); color: var(--on-ink); box-shadow: 0 0 0 3px var(--surface), 0 4px 10px -4px rgba(27, 26, 23, .5);
  transition: transform 220ms var(--spring), background var(--d1) var(--ease);
}
.ph-edit:hover { transform: scale(1.08); background: var(--brand); }
.ph-edit .ic { width: 16px; height: 16px; }
.ph-id { min-width: 0; }
.ph-id h2 { overflow-wrap: anywhere; }
.ph-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ph-tags .chip, .ph-tags .role-chip { height: 24px; }
.ph-meta { display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 14px 0 0; }
.ph-meta div { display: grid; gap: 2px; }
.ph-meta dt { font: 500 11px/16px var(--font); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.ph-meta dd { margin: 0; font: 500 13px/20px var(--font); }
.av-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-hero .av-actions { flex-direction: column; align-items: stretch; }
.profile-grid { align-items: stretch; }

/* crop dialog */
.crop-dialog { width: min(600px, calc(100vw - 32px)); }
.crop-wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.crop-stage {
  position: relative; width: 300px; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--sunken);
  cursor: grab; touch-action: none; box-shadow: inset 0 0 0 1px var(--line);
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage canvas { display: block; width: 100%; height: 100%; }
.crop-ring { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle closest-side, transparent calc(100% - 1px), rgba(27, 26, 23, .5) 100%); }
.crop-ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .92), 0 0 0 1px rgba(27, 26, 23, .12); }
.crop-grid { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity var(--d2) var(--ease);
  background: linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)) 33.33% 0 / 1px 100% no-repeat,
    linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)) 66.66% 0 / 1px 100% no-repeat,
    linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)) 0 33.33% / 100% 1px no-repeat,
    linear-gradient(rgba(255, 255, 255, .35), rgba(255, 255, 255, .35)) 0 66.66% / 100% 1px no-repeat; }
.crop-stage.dragging .crop-grid { opacity: 1; }
.crop-stage:focus-visible { box-shadow: var(--focus); border-radius: 8px; }
.crop-side { display: grid; gap: 12px; }
.crop-previews { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.crop-pv { display: grid; justify-items: center; gap: 6px; }
.crop-pv canvas { border-radius: 50%; box-shadow: 0 0 0 1px var(--line); background: var(--sunken); }
.crop-pv small { font: 400 11px/16px var(--font); color: var(--ink-3); }
.crop-zoom { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 8px; }
.crop-zoom .btn { font: 600 18px/1 var(--font); }

/* range */
input[type="range"] {
  --fill: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--brand) var(--fill), var(--line) var(--fill)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 1px rgba(27, 26, 23, .12), 0 2px 6px rgba(27, 26, 23, .22); transition: transform 200ms var(--spring);
}
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(27, 26, 23, .12), 0 2px 6px rgba(27, 26, 23, .22); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible { box-shadow: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }

/* avatar picker */
.picker-dialog { width: min(520px, calc(100vw - 32px)); }
.av-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.av-opt {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--d1) var(--ease), transform 220ms var(--spring), background var(--d1) var(--ease);
  animation: pop-opt 420ms var(--spring) backwards; animation-delay: calc(var(--j, 0) * 30ms);
}
.av-opt svg { width: 72px; height: 72px; border-radius: 50%; }
.av-opt:hover { transform: translateY(-2px); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2), var(--e2); }
.av-opt[aria-checked="true"] { background: var(--brand-50); box-shadow: inset 0 0 0 2px var(--brand); }
.av-check {
  position: absolute; right: 8px; top: 8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; opacity: 0; transform: scale(.4); transition: opacity var(--d1) var(--ease), transform 260ms var(--spring);
}
.av-check .ic { width: 14px; height: 14px; }
.av-opt[aria-checked="true"] .av-check { opacity: 1; transform: none; }
@keyframes pop-opt { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

/* ---------- admin panel ---------- */
.admin-tabs {
  position: relative; display: flex; gap: 4px; margin: -8px 0 24px; padding: 0 0 0; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.atab {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; flex: none;
  border-radius: 4px 4px 0 0; color: var(--ink-3); font: 500 14px/1 var(--font); white-space: nowrap;
  transition: color var(--d1) var(--ease), background var(--d1) var(--ease);
}
.atab .ic { width: 18px; height: 18px; color: var(--ink-4); transition: color var(--d1) var(--ease); }
.atab:hover { color: var(--ink); background: rgba(27, 26, 23, .03); }
.atab:hover .ic { color: var(--ink-3); }
.atab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.atab[aria-current="page"] .ic { color: var(--brand); }
.atab-ink {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; border-radius: 2px; background: var(--brand);
  transition: transform 420ms var(--ease-out), width 420ms var(--ease-out);
}
.admin-body { min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.stat {
  position: relative; display: grid; grid-template-rows: auto auto auto; align-content: start; gap: 10px; min-width: 0;
  padding: 16px 18px 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--e2);
  transition: transform 260ms var(--spring), box-shadow var(--d2) var(--ease);
}
.stat-link:hover { transform: translateY(-2px); box-shadow: var(--e3); }
.stat-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stat-label { font: 500 13px/18px var(--font); color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-go { width: 16px; height: 16px; color: var(--ink-4); transition: color var(--d1) var(--ease), transform var(--d2) var(--ease); }
.stat-link:hover .stat-go { color: var(--brand); transform: translate(2px, -2px); }
.stat-val { font: 600 32px/36px var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-sub { font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid-ov { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: stretch; }
.grid-ov > .card { display: flex; flex-direction: column; min-width: 0; }
.grid-ov > .card > .card-body { flex: 1; display: flex; flex-direction: column; }

.chart-kpis { display: inline-flex; gap: 16px; font: 400 12px/16px var(--font); color: var(--ink-3); flex-wrap: wrap; }
.chart-kpis b { font: 600 13px/16px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-empty { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font: 400 13px/20px var(--font); color: var(--ink-3); }
.vchart { display: grid; grid-template-columns: 28px minmax(0, 1fr); grid-template-rows: 1fr auto; column-gap: 10px; row-gap: 8px; flex: 1; min-height: 220px; }
.vchart-y { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
  font: 500 11px/1 var(--font); color: var(--ink-3); font-variant-numeric: tabular-nums; margin: -5px 0; }
.vchart-plot { grid-column: 2; grid-row: 1; position: relative; min-height: 0; }
.vchart-grid { position: absolute; inset: 0; pointer-events: none; }
.vchart-grid i { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--line); }
.vchart-grid i:first-child { border-top: 1px solid var(--line-2); }
.vchart-bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 4px; align-items: end; }
.vbar { position: relative; height: 100%; display: flex; align-items: flex-end; border-radius: 4px; outline: none; }
.vbar i {
  display: block; width: 100%; min-height: 0; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #7474ec, var(--brand)); transform-origin: bottom;
  transition: filter var(--d1) var(--ease), transform var(--d2) var(--spring);
}
.vbar.zero i { height: 2px !important; background: var(--line-2); border-radius: 1px; }
.vbar.today i { background: linear-gradient(180deg, var(--brand), var(--brand-800)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--brand-200); }
.vbar:hover i, .vbar:focus-visible i { filter: brightness(1.12) saturate(1.1); }
.vbar:hover::before, .vbar:focus-visible::before { content: ""; position: absolute; inset: 0 -2px; border-radius: 3px; background: rgba(75, 75, 216, .06); }
.vchart-x { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 4px; font: 500 11px/16px var(--font); color: var(--ink-3); }
.vchart-x span { justify-self: center; white-space: nowrap; }
.vchart-x span:first-child { justify-self: start; }
.vchart-x span:last-child { justify-self: end; color: var(--brand-700); font-weight: 600; }

.rbar { display: flex; gap: 3px; height: 12px; border-radius: 3px; overflow: hidden; }
.rbar i { display: block; height: 100%; min-width: 6px; transition: filter var(--d1) var(--ease); }
.rbar i:hover, .rbar i:focus-visible { filter: brightness(1.15); }
.role-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; }
.role-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 40px; gap: 12px; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); font: 500 13px/20px var(--font); }
.role-list li:last-child { border-bottom: 0; }
.role-list b { font: 600 15px/20px var(--font); font-variant-numeric: tabular-nums; }
.role-list .p { font: 500 12px/1 var(--font); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.role-dot { width: 10px; height: 10px; border-radius: 3px; }
.roles-foot { display: flex; align-items: center; gap: 8px; margin: 12px 0 16px; padding: 10px 12px; border-radius: 4px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font: 400 12px/16px var(--font); color: var(--ink-2); }
.roles-foot .ic { color: var(--k-on-ink); flex: none; }
.roles-card .btn-block { margin-top: auto; }

.rec-status { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 6px; margin-bottom: 8px; }
.rec-status b { display: block; font: 600 14px/20px var(--font); }
.rec-status small { display: block; font: 400 12px/16px var(--font); color: var(--ink-3); }
.rec-status.ok { background: var(--k-on-tint); }
.rec-status.demo { background: var(--k-out-tint); }
.pulse-dot { position: relative; width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--k-on); }
.rec-status.demo .pulse-dot { background: var(--k-out); }
.pulse-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: pulse 2s var(--ease-out) infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .6; } to { transform: scale(2.8); opacity: 0; } }
.rec-card .kv > div { grid-template-columns: 128px minmax(0, 1fr); }

/* activity */
.act-list { list-style: none; margin: 0; padding: 4px 12px 12px; display: grid; }
.act {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 6px; transition: background var(--d1) var(--ease);
}
.act:hover { background: var(--surface-2); }
.act-pic { position: relative; width: 36px; height: 36px; display: grid; place-items: start; }
.act-badge {
  position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 3px; display: grid; place-items: center;
  background: var(--brand); color: #fff; box-shadow: 0 0 0 2px var(--surface);
}
.act-badge .ic { width: 12px; height: 12px; }
.act[data-tone="ok"] .act-badge { background: var(--k-on); }
.act[data-tone="danger"] .act-badge { background: var(--k-else); }
.act[data-tone="warn"] .act-badge { background: color-mix(in oklab, var(--k-out) 70%, var(--k-out-ink)); }
.act[data-tone="plum"] .act-badge { background: var(--k-comp); }
.act[data-tone="plain"] .act-badge { background: var(--ink-3); }
.act:hover .act-badge { box-shadow: 0 0 0 2px var(--surface-2); }
.act-body { min-width: 0; display: grid; gap: 2px; }
.act-text { font: 500 14px/20px var(--font); color: var(--ink); overflow-wrap: anywhere; }
.act-meta { font: 400 12px/16px var(--font); color: var(--ink-3); }
.act-time { font: 400 12px/16px var(--font); color: var(--ink-3); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.act-compact .act { padding-top: 8px; padding-bottom: 8px; }
.act-days { padding: 0 0 4px; }
.act-day + .act-day { margin-top: 4px; }
.act-day-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 24px 6px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.act-day .act-list { padding-top: 0; }
.act-new { animation: rise-sm 380ms var(--ease-out) backwards; }
.list-foot { padding: 0 24px 20px; }
.list-foot:empty { display: none; }
.list-end { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 0 4px; font: 400 12px/16px var(--font); color: var(--ink-3); }
.list-end .ic { color: var(--k-on-ink); }

/* settings */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.window-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 16px; align-items: center; }
.num-input { position: relative; display: block; }
.num-input .input { padding-right: 44px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.num-input .input::-webkit-outer-spin-button, .num-input .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font: 400 13px/1 var(--font); color: var(--ink-3); pointer-events: none; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.explain { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-radius: 6px; background: var(--brand-50); }
.explain p { font: 400 13px/20px var(--font); color: var(--ink-2); }
.explain p + p { margin-top: 6px; }
.explain b { color: var(--ink); font-weight: 600; }
.side-card .card-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.side-card .kv > div { grid-template-columns: 120px minmax(0, 1fr); }

/* ---------- command palette ---------- */
.palette {
  width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 96px)); margin: 12vh auto auto; padding: 0; border: 0;
  border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: var(--e4); overflow: hidden;
}
.palette[open] { display: flex; animation: dialog-in 360ms var(--spring); }
.palette.closing { animation: dialog-out 160ms var(--ease-in) forwards; }
.palette::backdrop { background: rgba(27, 26, 23, .3); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.pal-box { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.pal-search { display: flex; align-items: center; gap: 12px; padding: 0 16px 0 18px; height: 60px; border-bottom: 1px solid var(--line); flex: none; }
.pal-search .ic { width: 20px; height: 20px; color: var(--brand); }
.pal-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font: 400 16px/1 var(--font); outline: none; }
.pal-search input::placeholder { color: var(--ink-4); }
.pal-list { list-style: none; margin: 0; padding: 6px 8px 8px; overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.pal-group { padding: 10px 10px 4px; font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.pal-item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 20px; gap: 12px; align-items: center; min-height: 44px; padding: 6px 10px;
  border-radius: 4px; cursor: pointer; color: var(--ink);
}
.pal-item[aria-selected="true"] { background: var(--brand-50); }
.pal-pic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 4px; background: var(--sunken); color: var(--ink-2); }
.pal-pic .ic { width: 16px; height: 16px; }
.pal-pic .av { --av: 24px; }
.pal-item[aria-selected="true"] .pal-pic { background: var(--surface); color: var(--brand); box-shadow: var(--e1); }
.pal-text { min-width: 0; display: grid; }
.pal-label { font: 500 14px/20px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-label mark { background: transparent; color: var(--brand-700); font-weight: 650; text-decoration: underline; text-decoration-color: var(--brand-200); text-underline-offset: 3px; }
.pal-text small { font: 400 12px/16px var(--font); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-enter { width: 20px; height: 20px; color: var(--brand); opacity: 0; transform: translateX(-4px); transition: opacity var(--d1) var(--ease), transform var(--d1) var(--ease); }
.pal-enter .ic { width: 18px; height: 18px; }
.pal-item[aria-selected="true"] .pal-enter { opacity: 1; transform: none; }
.pal-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 32px 16px; color: var(--ink-3); font: 400 14px/20px var(--font); }
.pal-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--surface-2); font: 400 12px/20px var(--font); color: var(--ink-3); flex: none; }
.pal-foot span { display: inline-flex; align-items: center; gap: 4px; }
.pal-foot kbd { margin-right: 2px; }

/* keyboard help */
.keys-dialog { width: min(560px, calc(100vw - 32px)); }
.keys-x { margin: -6px -8px 0 0; }
.keys-body { display: grid; gap: 18px; }
.keys-group h3 { margin-bottom: 6px; }
.keys-group dl { margin: 0; display: grid; }
.keys-group dl > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; border-bottom: 1px solid var(--line); }
.keys-group dl > div:last-child { border-bottom: 0; }
.keys-group dt { font: 400 14px/20px var(--font); color: var(--ink-2); }
.keys-group dd { margin: 0; display: inline-flex; align-items: center; gap: 4px; }
.keys-group kbd { min-width: 24px; height: 24px; font-size: 12px; color: var(--ink-2); }
.keys-plus { font: 400 11px/1 var(--font); color: var(--ink-3); padding: 0 2px; }

/* ---------- motion: entrance, charts, highlights ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes rise-sm { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes reveal-x { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
#view > .page:not(.enter) { animation: none; }
.enter > .page-head { animation: rise 520ms var(--ease-out) backwards; }
.enter.enter-keep-head > .page-head, .enter.enter-keep-head > .admin-tabs { animation: none; }
.enter .rise { animation: rise 560ms var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 55ms + 60ms); }
.enter.enter-keep-head > .admin-tabs.rise { animation: none; }
.enter .rise-row { animation: rise-sm 420ms var(--ease-out) backwards; animation-delay: calc(var(--j, 0) * 26ms + 160ms); }
.enter .ov-bar .stack, .enter .sbar-track .stack, .enter .sum-card .stack, .enter .stack-cell .stack, .enter .vstack .stack, .enter .rbar {
  animation: reveal-x 900ms var(--ease-out) backwards; animation-delay: 220ms;
}
.enter .sbars > .rise-row .stack { animation-delay: calc(var(--j, 0) * 40ms + 260ms); }
.enter .hbar i { transform-origin: left; animation: grow-x 900ms var(--ease-out) backwards; animation-delay: 300ms; }
.enter .vbar i { animation: grow-y 700ms var(--ease-out) backwards; animation-delay: calc(var(--j, 0) * 16ms + 240ms); }
.enter .pips i.on { animation: fade-in 400ms var(--ease) backwards; animation-delay: 360ms; }
.row-pop { animation: rise-sm 360ms var(--ease-out) backwards; animation-delay: calc(var(--j, 0) * 22ms); }
.pane-in { animation: rise-sm 320ms var(--ease-out); }
.flash { animation: flash 1400ms var(--ease) 1; }
tr.flash td { animation: flash-bg 1600ms var(--ease) 1; }
@keyframes flash { 0%, 100% { box-shadow: var(--e2); } 25% { box-shadow: 0 0 0 3px var(--brand-200), var(--e2); } }
@keyframes flash-bg { 0%, 100% { background: transparent; } 20% { background: var(--brand-50); } }

/* hover lifts */
.card.stat-like, .tile, .sbar, .rank li { will-change: auto; }
.item { transition: box-shadow var(--d2) var(--ease), transform 260ms var(--spring); }
.item:hover { transform: translateY(-2px); }
.photo { transition: transform 260ms var(--spring), box-shadow var(--d2) var(--ease); }
.photo:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgba(27, 26, 23, .06), var(--e2); }
.nav-item:active, .tab:active, .atab:active, .menu-item:active { transform: scale(.98); }
.nav-item, .tab, .atab, .menu-item { transition: background var(--d1) var(--ease), color var(--d1) var(--ease), transform 160ms var(--spring); }

/* skeleton shimmer: a moving sheen over the warm grey */
.sk { position: relative; overflow: hidden; background: var(--sunken); animation: none; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: sk-sheen 1.5s var(--ease) infinite;
}
@keyframes sk-sheen { to { transform: translateX(100%); } }
[aria-busy="true"] { animation: fade-in 300ms var(--ease) 80ms backwards; }

/* ---------- responsive (new parts) ---------- */
@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .grid-ov { grid-template-columns: minmax(0, 1fr); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-hero { grid-template-columns: auto minmax(0, 1fr); }
  .profile-hero .av-actions { grid-column: 1 / -1; flex-direction: row; }
}
@media (max-width: 1024px) {
  .grid-2.profile-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .m-head .btn-icon + .m-me, .m-head .m-me { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; border-radius: 50%; }
  .m-me .av { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2); }
  .side-search { height: 44px; }
  .side-search kbd { display: none; }
  .me { min-height: 52px; }
  .toasts { inset: auto 12px calc(84px + env(safe-area-inset-bottom)) 12px; width: auto; }
  .toast { animation-name: toast-in-m; }
  @keyframes toast-in-m { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; gap: 8px; }
  .stat-val { font-size: 26px; line-height: 30px; }
  .stat-sub { white-space: normal; }
  .admin-tabs { margin: -4px -16px 16px; padding: 0 12px; }
  .atab { height: 44px; padding: 0 10px; font-size: 14px; }
  .chart-kpis { width: 100%; }
  .vchart { min-height: 180px; grid-template-columns: 22px minmax(0, 1fr); column-gap: 6px; }
  .vchart-bars, .vchart-x { gap: 2px; }
  .vchart-x span:not(:first-child):not(:last-child) { display: none; }
  .act-list { padding: 4px 4px 8px; }
  .act { grid-template-columns: 36px minmax(0, 1fr); align-items: start; gap: 4px 12px; padding: 10px 12px; }
  .act-time { grid-column: 2; text-align: left; }
  .act-day-head { padding: 12px 16px 6px; }
  .list-foot { padding: 0 16px 16px; }
  .toolbar .seg { order: 3; }
  /* The select wraps to its own full-width row instead of being squeezed («Любой ста»). */
  .toolbar .select-sm { flex: 1 1 168px; }
  .toolbar .seg { flex: 1 1 auto; }
  .toolbar .seg button { flex: 1 1 auto; }
  .toolbar .select-sm .input { min-width: 0; width: 100%; }
  .users-tbl td.primary { min-width: 0; }
  .tbl.stackable.users-tbl td.side-cell { display: none; }
  .tbl.stackable.users-tbl tr { grid-template-columns: minmax(0, 1fr) auto; }
  .tbl.stackable.users-tbl td[data-label="Роль"] { grid-column: 2; grid-row: 1; align-self: center; }
  .tbl.stackable.users-tbl td[data-label="Роль"]::before { content: none !important; }
  .tbl.stackable.users-tbl td[data-label]:not([data-label="Роль"]) { grid-column: 1 / -1; padding-left: 48px; }
  .profile-hero { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; padding: 24px 16px; gap: 16px; }
  .ph-tags, .ph-meta { justify-content: center; }
  .profile-hero .av-actions { justify-content: center; }
  .form-body { padding: 14px 16px 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100vw; border-radius: 0; }
  .drawer-head { padding: calc(14px + env(safe-area-inset-top)) 12px 14px 16px; }
  .drawer-body { padding: 0 16px 16px; }
  .drawer-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .drawer-foot .dirty-note { display: none; }
  .crop-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .crop-stage { width: min(300px, calc(100vw - 64px)); }
  .crop-side { justify-items: center; }
  .av-grid { gap: 8px; }
  .av-opt svg { width: 56px; height: 56px; }
  /* Sheets span the full width: these rules come after the generic .dialog sheet rule. */
  .crop-dialog, .picker-dialog, .keys-dialog { width: 100vw; max-width: 100vw; }
  .picker-dialog .dialog-actions { flex-wrap: wrap; }
  .picker-dialog .dialog-actions [data-role="shuffle"] { flex-basis: 100%; }
  .picker-dialog .dialog-actions .spacer { display: none; }
  .palette { width: calc(100vw - 16px); margin: 8px auto auto; max-height: calc(100vh - 16px); border-radius: 8px; }
  .pal-foot { display: none; }
  .pal-item kbd { display: none; }
  .window-row { grid-template-columns: minmax(0, 1fr) 104px; }
  .kv > div, .rec-card .kv > div, .side-card .kv > div { grid-template-columns: 112px minmax(0, 1fr); }
  .settings-grid { gap: 14px; }
  .user-menu { width: min(300px, calc(100vw - 16px)); }
  .dialog[open] { animation: sheet-in 460ms cubic-bezier(.32, .72, 0, 1); }
  .dialog.closing { animation: sheet-out 220ms var(--ease-in) forwards; }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-delay: 0s !important; }
  .sk::after, .pulse-dot::after { animation: none !important; }
  .enter *, .enter > .page-head { animation: none !important; }
  .btn:active:not(:disabled), .nav-item:active, .tab:active, .atab:active, .menu-item:active,
  .stat-link:hover, .item:hover, .photo:hover, .av-opt:hover, .ph-edit:hover { transform: none; }
  .atab-ink, .switch i { transition: none; }
}

/* ---------- v3 fixes ---------- */
.toolbar .seg button { height: 34px; padding: 0 12px; font-size: 13px; }
.av-sys { background: var(--brand-100); color: var(--brand-700); box-shadow: inset 0 0 0 1px var(--brand-200); }
.av-sys .ic { width: 16px; height: 16px; }
.vbar.today.zero i { background: var(--brand); box-shadow: none; }
.stat-top .kchip { order: 2; }
.stat-top .stat-go { order: 1; opacity: 0; transform: translateX(-4px); }
.stat-link:hover .stat-top .stat-go { opacity: 1; transform: none; }
.rec-card .card-body { gap: 0; }
.rec-note { display: flex; gap: 8px; align-items: flex-start; margin-top: auto; padding: 12px 0 0; border-top: 1px solid var(--line); font: 400 12px/18px var(--font); color: var(--ink-3); }
.rec-note .ic { flex: none; margin-top: 1px; color: var(--ink-3); }
.rec-card .kv { margin-bottom: 16px; }
.brands .brand-av { border-radius: 4px; }
.pal-search input:focus, .pal-search input:focus-visible { box-shadow: none; outline: none; }
.palette:focus-visible, .drawer:focus-visible, .dialog:focus-visible { box-shadow: var(--e4); }
.profile-hero { min-height: 176px; }
.stat-top { position: relative; }
.stat-top .stat-go { position: absolute; right: 32px; top: 4px; }
@media (max-width: 768px) {
  .stat-top .stat-go { display: none; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar .seg { order: 2; }
  .toolbar .select-sm { order: 3; }
  .toolbar > .spacer, .toolbar [data-role="shown"] { display: none; }
  .user-menu kbd { display: none; }
  .profile-hero .av-actions { flex-direction: column; width: 100%; max-width: 320px; }
  .profile-hero .av-actions .btn { width: 100%; }
  .form-foot .btn-primary { flex: 1 1 100%; height: 44px; }
  .form-foot .form-note { flex: 1 1 100%; }
  .drawer-av .av-actions .btn { flex: 1 1 auto; }
}
.tbl tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r-xl); }
.tbl tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r-xl); }
.toolbar .search { min-width: 240px; }
@media (max-width: 768px) {
  .admin-tabs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .toolbar .search { min-width: 0; }
}
@media (max-width: 1180px) and (min-width: 769px) {
  .grid-ov { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-ov > .chart-card, .grid-ov > .act-card { grid-column: 1 / -1; }
  .grid-ov > .act-card { order: 3; }
}
#view:focus, #view:focus-visible { box-shadow: none; outline: none; }

.fbtn:disabled { opacity: .45; cursor: default; box-shadow: none; }

/* ---------- login photo: fills the whole right panel on desktop ---------- */
@media (min-width: 769px) {
  .hero { justify-content: flex-start; background: #0f0f0f; margin: 0; border-radius: 0; box-shadow: none; }
  html[data-theme] .hero { box-shadow: none; }
  .hero .hero-art { position: absolute; inset: 0; margin: 0; min-height: 0; z-index: 0; display: block; }
  .hero::after {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: linear-gradient(180deg, rgba(8, 8, 8, .78) 0%, rgba(8, 8, 8, .42) 26%, rgba(8, 8, 8, 0) 52%);
  }
  .hero > :not(.hero-art) { position: relative; z-index: 2; }
  .hero h2.t-display { color: #fff; text-shadow: 0 2px 24px rgba(0, 0, 0, .35); }
  .hero h2 em { color: #a9a9ff; }
  .hero .eyebrow-chip { background: rgba(20, 20, 20, .55); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
}

/* ---------- login slideshow (assets/hero.js) ---------- */
/* Each photo is shown whole (contain); a blurred, darkened copy fills the rest of the panel. */
.hero-slide { position: absolute; inset: 0; margin: 0; overflow: hidden; opacity: 0; z-index: 0; transition: opacity .9s var(--ease); }
.hero-slide.is-active { opacity: 1; z-index: 2; }
.hero-slide.was-active { opacity: 1; z-index: 1; transition: none; }
.hero-slide::before { content: ""; position: absolute; inset: -48px; background: var(--src) center / cover no-repeat; filter: blur(36px) brightness(.5) saturate(1.1); }
.hero-slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: 50% 60%; }
.hero-slide.is-active img { animation: hero-drift 9s linear both; }
@keyframes hero-drift { from { transform: scale(1.03); } to { transform: scale(1); } }
@media (min-width: 769px) {
  .hero-caption {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 80px 56px 36px;
    background: linear-gradient(0deg, rgba(8, 8, 8, .8) 0%, rgba(8, 8, 8, .4) 60%, rgba(8, 8, 8, 0) 100%);
    color: #fff; display: grid; gap: 14px; pointer-events: none;
  }
  .hero-caption [data-slide-caption] { font: 600 20px/26px var(--font-display); letter-spacing: -.01em; max-width: 520px; min-height: 26px; transition: opacity .3s var(--ease); }
  .hero-dots { display: flex; gap: 8px; pointer-events: auto; }
  .hero-dots button { width: 28px; height: 4px; padding: 0; border: 0; border-radius: 1px; background: rgba(255, 255, 255, .35); cursor: pointer; transition: background-color var(--d2) var(--ease), width var(--d2) var(--ease); }
  .hero-dots button[aria-current="true"] { width: 44px; background: #fff; }
  .hero-dots button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
}
@media (max-width: 768px) {
  .hero-art { position: relative; aspect-ratio: 16 / 10; border-radius: 6px; overflow: hidden; }
  .hero-slide:not(.is-active), .hero-caption { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-slide { transition: opacity .2s linear; }
  .hero-slide.is-active img { animation: none; }
}

/* ---------- login scenes: real screens in device frames ---------- */
.scene .scene-bg { position: absolute; inset: -24px; background: #0b0b0b var(--src, none) center / cover no-repeat; filter: brightness(.42) saturate(.9) blur(2px); }
.scene .scene-bg-plain { background: radial-gradient(80% 70% at 70% 40%, #1d1d1d 0%, #0b0b0b 70%); filter: none; }
.scene::before { display: none; }
.device { position: absolute; overflow: hidden; background: #0a0a0a; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 255, 255, .08); }
.device img { position: static; display: block; width: 100%; height: auto; object-fit: initial; animation: none !important; }
.device-phone { right: 9%; top: 56%; height: 74%; aspect-ratio: 540 / 1131; transform: translateY(-46%); border: 9px solid #161616; border-radius: 34px; }
.device-phone img { height: 100%; object-fit: cover; object-position: top; }
.device-browser { left: 7%; right: -14%; top: 27%; border-radius: 8px; }
.device-browser-low { top: 33%; }
.browser-bar { display: flex; gap: 6px; align-items: center; height: 26px; padding: 0 12px; background: #1a1a1a; border-bottom: 1px solid #262626; }
.browser-bar i { width: 9px; height: 9px; border-radius: 50%; background: #3a3a3a; }
.hero-slide.is-active .device { animation: device-in .9s var(--ease-out) both; }
@keyframes device-in { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .hero-slide.is-active .device { animation: none; } }
@media (max-width: 768px) {
  .device-phone { right: 50%; transform: translate(50%, -46%); height: 88%; }
  .device-browser { left: 6%; right: -30%; top: 14%; }
}

/* ---------- login theme button + boot watchdog (assets/theme.js) ---------- */
.login { position: relative; }
.theme-fab {
  position: absolute; top: 20px; right: 20px; z-index: 5; width: 40px; height: 40px; border: 0; border-radius: 6px;
  display: grid; place-items: center; background: var(--surface); color: var(--ink-2); box-shadow: var(--e2); cursor: pointer;
  transition: color var(--d2) var(--ease), transform var(--d2) var(--ease);
}
.theme-fab:hover { color: var(--ink); transform: translateY(-1px); }
.theme-fab:focus-visible { outline: none; box-shadow: var(--focus); }
.theme-fab .ic { width: 20px; height: 20px; }
#boot-error { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: var(--canvas); color: var(--ink); font: 400 15px/22px var(--font); }
#boot-error > div { max-width: 360px; padding: 28px; border-radius: 8px; background: var(--surface); box-shadow: var(--e3); text-align: center; }
#boot-error b { display: block; font: 650 18px/24px var(--font); }
#boot-error p { margin: 8px 0 20px; color: var(--ink-3); }
#boot-error button { height: 44px; padding: 0 22px; border: 0; border-radius: 6px; background: var(--brand); color: #fff; font: 600 15px/1 var(--font); cursor: pointer; }

.brand-rank { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 4px; background: var(--sunken); color: var(--ink-2); font: 650 13px/1 var(--font); font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .toast { background: #242424; color: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset, 0 18px 40px -14px rgba(0, 0, 0, .8); }

/* ---------- theme picker ---------- */
.theme-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 6px; background: var(--sunken); position: relative; }
.theme-switch button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 4px; background: transparent; color: var(--ink-2); font: 550 13px/1 var(--font); cursor: pointer;
  transition: background-color var(--d2) var(--ease), color var(--d2) var(--ease), box-shadow var(--d2) var(--ease);
}
.theme-switch button .ic { width: 16px; height: 16px; flex: none; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--e1); }
.theme-switch button:focus-visible { outline: none; box-shadow: var(--focus); }
.theme-switch::before {
  content: ''; position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 6px);
  border-radius: 4px; background: var(--surface); box-shadow: var(--e1);
  transition: transform .32s cubic-bezier(.3, .7, .2, 1);
}
.theme-switch:has(> button:nth-child(2)[aria-checked="true"])::before { transform: translateX(calc(100% + 4px)); }
html[data-theme="dark"] .theme-switch::before { background: #2c2c2c; box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset; }
.theme-switch button { position: relative; z-index: 1; }
.theme-switch button[aria-checked="true"] { background: transparent; box-shadow: none; color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .theme-switch::before { transition: none; } }
.um-theme { padding: 6px 8px 8px; }
.um-theme small { display: block; margin: 0 4px 6px; font: 600 11px/1 var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.um-theme .theme-switch button span { white-space: nowrap; }
.theme-card { margin-top: 20px; max-width: 720px; }
.theme-card .form-note { margin: 0 0 12px; }

/* ---------- Тёмная тема: чёрная, нейтральные серые без синевы (assets/theme.js ставит data-theme) ---------- */
:root { --on-ink: #fff; --hl: rgba(255, 255, 255, .9); --sh: 47 46 156; }
html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0a0a0a; --surface: #141414; --surface-2: #1b1b1b; --sunken: #1f1f1f;
  --line: #262626; --line-2: #343434;
  --ink: #f2f2ef; --ink-2: #c2c2bc; --ink-3: #97978f; --ink-4: #5e5e59;
  --on-ink: #0a0a0a; --hl: rgba(255, 255, 255, .06); --sh: 0 0 0;

  --brand: #6e6ef4; --brand-700: #a3a3fb; --brand-800: #c6c6fd;
  --brand-50: color-mix(in srgb, #6e6ef4 10%, #141414);
  --brand-100: color-mix(in srgb, #6e6ef4 18%, #141414);
  --brand-200: color-mix(in srgb, #6e6ef4 32%, #141414);

  --k-on: #2bc48b;   --k-on-ink: #63d9ab;   --k-on-tint: color-mix(in srgb, #2bc48b 14%, #141414);
  --k-out: #eea42c;  --k-out-ink: #f5c463;  --k-out-tint: color-mix(in srgb, #eea42c 14%, #141414);
  --k-else: #ee5d68; --k-else-ink: #f6939a; --k-else-tint: color-mix(in srgb, #ee5d68 14%, #141414);
  --k-comp: #c26fc8; --k-comp-ink: #dc9ee0; --k-comp-tint: color-mix(in srgb, #c26fc8 15%, #141414);
  --k-opp: #6e6ef4;  --k-opp-ink: #a3a3fb;  --k-opp-tint: color-mix(in srgb, #6e6ef4 15%, #141414);

  --e1: 0 0 0 1px rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .5);
  --e2: 0 0 0 1px rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px -8px rgba(0, 0, 0, .7);
  --e3: 0 0 0 1px rgba(255, 255, 255, .07), 0 2px 4px rgba(0, 0, 0, .4), 0 20px 44px -14px rgba(0, 0, 0, .8);
  --e4: 0 0 0 1px rgba(255, 255, 255, .08), 0 30px 80px -20px rgba(0, 0, 0, .9);
  --sb-thumb: rgba(255, 255, 255, .14); --sb-thumb-hover: rgba(255, 255, 255, .26); --sb-thumb-active: rgba(255, 255, 255, .38);
}
html[data-theme="dark"] body { background: var(--canvas); color: var(--ink); }
html[data-theme="dark"] img[src$="logo.svg"] { content: url(/assets/logo-dark.svg); }
html[data-theme="dark"] img[src*="empty-state"], html[data-theme="dark"] img[src*="hero-shelf"], html[data-theme="dark"] img[src*="shelf-scene"] {
  filter: invert(.88) hue-rotate(180deg) saturate(.85);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, .14); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover, html[data-theme="dark"] ::-webkit-scrollbar-thumb:active { background-color: rgba(255, 255, 255, .3); }
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease), fill .3s, stroke .3s, box-shadow .3s !important;
}
html[data-theme="dark"] .hero, html[data-theme="dark"] .hero-admin {
  background: radial-gradient(110% 80% at 100% 0%, #1d1d1d 0%, rgba(29, 29, 29, 0) 60%), linear-gradient(180deg, #121212 0%, #0a0a0a 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}
