@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap; src: url(fonts/inter-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap; src: url(fonts/inter-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "Young Serif"; font-weight: 400; font-display: swap; src: url(fonts/young-serif-latin.woff2) format("woff2"); }

:root {
  --bg: #fbfbfb; --surface: #f3f3f3; --surface-hi: #fff; --ink: #1a1a1a;
  --muted: rgba(0,0,0,.49); --faint: rgba(0,0,0,.3);
  --line: rgba(0,0,0,.07); --line-strong: rgba(0,0,0,.18); --row-hover: rgba(0,0,0,.025);
  --accent: #1a6dff; --c1: #7aa7ff; --c2: #b7cdfb; --c3: #d9d9d9; --c4: #bdbdbd; --c5: #e6e6e6;
  --seg-bg: rgba(0,0,0,.06); --pill: #ececec; --btn: #181818; --btn-ink: #fff; --btn-hover: #333;
  --node-shadow: 0 0 0 .5px rgba(0,0,0,.06), 0 8px 24px -12px rgba(0,0,0,.18);
  --ok: #15a34a; --ok-soft: rgba(21,163,74,.1); --warn: #d97706; --warn-soft: rgba(217,119,6,.1);
  --no: #dc2626; --no-soft: rgba(220,38,38,.08);
  --soft-hover: #e2e2e2; --kpi-hover: #ececec; --thumb: #fff;
  --thumb-shadow: 0 0 0 .5px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.1);
  --shimmer: rgba(255,255,255,.6); --focus: rgba(0,0,0,.35); --ok-ring: rgba(21,163,74,.15);
  --spring: cubic-bezier(.34,1.56,.64,1); --soft: cubic-bezier(.22,.8,.28,1);
  --r: 12px; --gap: 12px;
  color-scheme: light dark;
}

/* тёмная тема включается сама вместе с системной */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --surface: #1e1e1f; --surface-hi: #262628; --ink: #ededed;
    --muted: rgba(255,255,255,.55); --faint: rgba(255,255,255,.3);
    --line: rgba(255,255,255,.07); --line-strong: rgba(255,255,255,.2); --row-hover: rgba(255,255,255,.03);
    --accent: #3d86ff; --c1: #5f95ec; --c2: #3a5d9a; --c3: #4a4a4d; --c4: #6b6b70; --c5: #333336;
    --seg-bg: rgba(255,255,255,.07); --pill: #2a2a2b; --btn: #f0f0f0; --btn-ink: #111; --btn-hover: #d8d8d8;
    --node-shadow: 0 0 0 .5px rgba(255,255,255,.07), 0 12px 28px -14px rgba(0,0,0,.8);
    --ok: #34d36b; --ok-soft: rgba(52,211,107,.12); --warn: #f5a524; --warn-soft: rgba(245,165,36,.12);
    --no: #ff5a5f; --no-soft: rgba(255,90,95,.12);
    --soft-hover: #333335; --kpi-hover: #242426; --thumb: #3a3a3c;
    --thumb-shadow: 0 0 0 .5px rgba(255,255,255,.08), 0 1px 2px rgba(0,0,0,.5);
    --shimmer: rgba(255,255,255,.08); --focus: rgba(255,255,255,.45); --ok-ring: rgba(52,211,107,.2);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif; background: var(--bg); color: var(--ink);
  font-size: 13px; line-height: 1.45; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; }
.hidden { display: none !important; }
.mono, td, .kpi-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; animation: rise .5s var(--soft) backwards; }
.login-card .logo { font-size: 26px; margin-bottom: 6px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-row { display: flex; width: 100%; height: 44px; padding: 0 5px 0 18px; align-items: center; border-radius: 999px; background: var(--pill); }
.login-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 14px; }
.login-err { min-height: 18px; margin-top: 10px; color: var(--no); font-size: 12px; }

/* ---------- shell ---------- */
.side { position: fixed; top: 0; bottom: 0; left: 16px; width: 220px; padding: 16px 0; display: flex; flex-direction: column; z-index: 10; }
.side-top { display: flex; align-items: center; height: 28px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-family: "Young Serif", Georgia, serif; font-size: 19px; letter-spacing: -.01em; text-decoration: none; }
.logo .folder { width: 24px; height: 19px; flex: none; filter: drop-shadow(0 1px 1.5px rgba(30,110,170,.28)); }
.nav { margin-top: 32px; }
.group { margin-bottom: 30px; }
.group h4 { margin: 0 0 4px; color: var(--faint); font-size: 11.5px; font-weight: 400; }
.nav a { position: relative; display: flex; align-items: center; height: 24px; color: var(--muted); text-decoration: none; transition: color .15s; }
.nav a:hover, .nav a.active { color: var(--ink); }
.nav a.active::before { content: ""; position: absolute; left: -16px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: pop .35s var(--spring); }
.nav a em { margin-left: auto; margin-right: 14px; font-style: normal; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; display: grid; gap: 12px; justify-items: start; }
.main { margin-left: 268px; padding: 24px 24px 48px 0; max-width: 1480px; min-width: 0; }
#app { overflow-x: clip; }
.top { display: flex; align-items: center; gap: 12px; min-height: 28px; margin-bottom: 26px; }
.crumbs { color: var(--faint); } .crumbs b { color: var(--ink); font-weight: 500; } .crumbs i { font-style: normal; margin: 0 .4em; }
.top-r { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.live { color: var(--muted); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-ring); }
.live.err i { background: var(--no); box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.btn { height: 28px; padding: 0 12px; border-radius: 999px; background: var(--btn); color: var(--btn-ink); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none;
  transition: background-color .15s, transform .2s var(--spring); }
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(.96); }
.btn svg { width: 13px; height: 13px; }
.btn.spin svg { animation: spin .8s linear infinite; }
.btn-soft { background: var(--pill); color: var(--ink); }
.btn-soft:hover { background: var(--soft-hover); }
.page-title { margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.page-sub { margin: 0 0 22px; color: var(--muted); }
.view { animation: rise .4s var(--soft) backwards; }
.stack > * + * { margin-top: var(--gap); }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.kpi { background: var(--surface); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpis-sys .kpi-value { font-size: 20px; }
.kpi-hint { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { font-style: normal; font-weight: 600; color: var(--ok); }
.delta.down { color: var(--no); }
a.kpi { text-decoration: none; transition: background-color .15s; }
a.kpi:hover { background: var(--kpi-hover); }

/* segmented control со скользящим ползунком */
.seg { position: relative; display: inline-flex; padding: 2px; border-radius: 999px; background: var(--seg-bg); }
.seg-thumb { position: absolute; top: 2px; bottom: 2px; left: 0; border-radius: 999px; background: var(--thumb); box-shadow: var(--thumb-shadow);
  transition: transform .35s var(--spring), width .35s var(--spring); }
.seg button { position: relative; z-index: 1; height: 26px; padding: 0 12px; border-radius: 999px; color: var(--muted); font-size: 12.5px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: color .2s; }
.seg button:hover, .seg button[aria-selected="true"] { color: var(--ink); }
.seg em { font-style: normal; font-size: 11px; color: var(--faint); }

/* chart */
.chart-wrap { position: relative; height: 230px; touch-action: pan-y; }
.chart-svg { width: 100%; height: 100%; overflow: visible; }
.ch-grid { stroke: var(--line); }
.ch-lbl { fill: var(--faint); font-size: 11px; font-family: inherit; }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ch-cursor { stroke: var(--faint); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.ch-stop-a { stop-color: var(--accent); stop-opacity: .2; }
.ch-stop-b { stop-color: var(--accent); stop-opacity: 0; }
.ch-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.ch-hover { opacity: 0; transition: opacity .15s; }
.chart-wrap:hover .ch-hover, .chart-wrap.touch .ch-hover { opacity: 1; }
.ch-tip { position: absolute; top: 0; left: 0; transform: translate(-50%, calc(-100% - 10px)); background: var(--btn); color: var(--btn-ink); padding: 6px 10px; border-radius: 9px;
  display: flex; flex-direction: column; font-size: 11.5px; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px -6px rgba(0,0,0,.35); }
.ch-tip b { font-size: 13px; } .ch-tip span { opacity: .65; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); }

.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--gap); }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(70px, 120px) 1fr 56px 96px; align-items: center; gap: 12px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 99px; background: var(--seg-bg); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: left; animation: grow .7s var(--soft) backwards; }
.bar-num { color: var(--muted); text-align: right; }
.bar-sum { text-align: right; font-weight: 600; }
.stack-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; gap: 2px; margin-bottom: 14px; }
.legend { display: flex; flex-direction: column; gap: 9px; }
.lg-row { display: grid; grid-template-columns: 10px 1fr 44px 40px; gap: 10px; align-items: center; }
.lg-row b, .lg-row .muted { text-align: right; font-variant-numeric: tabular-nums; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; }
.c0 { background: var(--accent); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); } .c5 { background: var(--c5); }

/* table */
.table-card { padding-bottom: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -18px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; padding: 8px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
.r { text-align: right; }
.m-only { display: none; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.uid { display: inline-flex; align-items: center; gap: 4px; }
.uid a { text-decoration: none; border-bottom: 1px dashed var(--line-strong); }
.uid a:hover { color: var(--accent); border-color: var(--accent); }
.copy { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; color: var(--faint); transition: color .15s, background-color .15s; }
.copy:hover { color: var(--ink); background: var(--seg-bg); }
.copy svg { width: 13px; height: 13px; }
.copy.ok { color: var(--ok); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 550; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.approved { color: var(--ok); background: var(--ok-soft); }
.pill.pending { color: var(--warn); background: var(--warn-soft); }
.pill.rejected { color: var(--no); background: var(--no-soft); }
.search { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--seg-bg); color: var(--faint); }
.search svg { width: 14px; height: 14px; flex: none; }
.search input { border: 0; outline: 0; background: none; width: 190px; color: var(--ink); }
.empty { padding: 40px 0; text-align: center; color: var(--faint); }
.pager { display: flex; justify-content: center; gap: 4px; margin-top: 12px; align-items: center; color: var(--faint); }
.pager button { min-width: 30px; height: 30px; padding: 0 6px; border-radius: 999px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager button:hover:not(:disabled) { background: var(--seg-bg); }
.pager button[aria-current="page"] { background: var(--btn); color: var(--btn-ink); }
.pager button:disabled { opacity: .35; cursor: default; }
.loading-row td { height: 220px; text-align: center; color: var(--faint); }
tbody.busy { opacity: .45; transition: opacity .15s; }

/* skeleton */
.sk { position: relative; overflow: hidden; background: var(--seg-bg); border-radius: 6px; color: transparent !important; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--shimmer), transparent); animation: shimmer 1.2s infinite; }

/* ---------- поиск пользователя ---------- */
.us { display: flex; flex-direction: column; align-items: center; padding-top: 24px; }
.us-title { margin: 0; font-size: 30px; letter-spacing: -.03em; font-weight: 650; text-align: center; }
.us-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; text-align: center; }
.us-bar { display: flex; gap: 8px; margin-top: 22px; width: min(620px, 100%); }
.us-chip { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px 0 12px; border-radius: 999px; background: var(--pill); font-weight: 550; white-space: nowrap; }
.us-chip svg { width: 20px; height: 20px; }
.us-input { flex: 1; min-width: 0; display: flex; align-items: center; height: 44px; padding: 0 5px 0 18px; border-radius: 999px; background: var(--pill); }
.us-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 14px; font-variant-numeric: tabular-nums; }
.us-clear { width: 28px; height: 28px; display: grid; place-items: center; color: var(--faint); border-radius: 50%; }
.us-clear:hover { color: var(--ink); }
.us-clear svg { width: 14px; height: 14px; }
.us-go { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; margin-left: 4px; transition: transform .2s var(--spring), opacity .2s; }
.us-go:active { transform: scale(.9); }
.us-go:disabled { opacity: .4; cursor: default; }
.us-go svg { width: 16px; height: 16px; }
.us-recent { margin: 10px 0 0; color: var(--faint); font-size: 12px; min-height: 18px; text-align: center; }
.us-recent a { color: var(--muted); cursor: pointer; text-decoration: none; font-variant-numeric: tabular-nums; }
.us-recent a:hover { color: var(--accent); }

.tree { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; padding: 26px 0 10px; }
.tree-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.ln { fill: none; stroke-width: 1.4; }
.ln-solid { stroke: var(--line-strong); }
.ln-dash { stroke: var(--accent); stroke-dasharray: 5 5; opacity: .9; animation: lnIn .5s ease backwards; }
.t-root { position: relative; z-index: 1; height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; border-radius: 999px; background: var(--pill); animation: pop .4s var(--spring) backwards; }
.node-main { margin-top: 26px; width: min(340px, 100%); }
.t-kids { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; width: 100%; margin-top: 54px; align-items: start; }
.node { position: relative; z-index: 1; background: var(--surface-hi); border-radius: 14px; padding: 13px 14px; box-shadow: var(--node-shadow); min-width: 0;
  opacity: 0; transform: translateY(8px) scale(.98); filter: blur(4px);
  transition: opacity .45s var(--soft), transform .55s var(--spring), filter .45s; }
.node.in { opacity: 1; transform: none; filter: none; }
.node-head b { display: block; font-size: 13px; font-weight: 600; }
.node-status { display: block; font-size: 12px; margin-top: 1px; }
.node-status.loading { color: var(--accent); }
.node-status.loading::after { content: ""; animation: dots 1s steps(4) infinite; }
.node-status.ok { color: var(--ok); } .node-status.info { color: var(--accent); }
.node-status.warn { color: var(--warn); } .node-status.no { color: var(--no); } .node-status.muted { color: var(--faint); }
.node.done .node-status.final { animation: rise .4s ease backwards; }
.node-body { display: grid; grid-template-rows: 0fr; overflow: hidden; transition: grid-template-rows .5s var(--soft); }
.node-body > div { min-height: 0; }
.node.done.has-body .node-body { grid-template-rows: 1fr; padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; padding: 2.5px 0; }
.kv > span { color: var(--faint); white-space: nowrap; }
.kv > b { font-weight: 550; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kv a { color: var(--accent); text-decoration: none; }
.kv .copy { width: 18px; height: 18px; margin-left: 2px; vertical-align: -4px; }
.node-list { margin-top: 8px; display: flex; flex-direction: column; }
.li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12px; padding: 5px 0; }
.li b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li > span:last-child { color: var(--faint); white-space: nowrap; }
.li-dot { width: 7px; height: 7px; border-radius: 50%; }
.li-dot.approved { background: var(--ok); } .li-dot.pending { background: var(--warn); } .li-dot.rejected { background: var(--no); }
.more { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--accent); text-decoration: none; }
.li-dot.ok { background: var(--ok); } .li-dot.info { background: var(--accent); } .li-dot.warn { background: var(--warn); }
.li-dot.no { background: var(--no); } .li-dot.muted { background: var(--faint); }

/* список UDID: первые три видно сразу, остальные по кнопке; каждый раскрывается */
.ud-list { margin-top: 6px; display: flex; flex-direction: column; }
.ud + .ud { border-top: 1px solid var(--line); }
.ud-more { display: none; }
.ud-list.show-all .ud-more { display: block; }
.ud summary { list-style: none; display: grid; grid-template-columns: 8px auto minmax(0, 1fr) 10px; gap: 8px; align-items: center; padding: 7px 0; cursor: pointer; font-size: 12px; }
.ud summary::-webkit-details-marker { display: none; }
.ud summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint); transform: rotate(-45deg); transition: transform .25s var(--spring); justify-self: center; }
.ud[open] summary::after { transform: rotate(45deg); }
.ud summary:hover .ud-id { color: var(--accent); }
.ud-id { font-weight: 550; }
.ud-st { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--faint); }
.ud-st.ok { color: var(--ok); } .ud-st.info { color: var(--accent); } .ud-st.warn { color: var(--warn); } .ud-st.no { color: var(--no); }
.ud-body { padding: 0 0 10px 16px; animation: rise .3s var(--soft); }
.ud-full { display: flex; align-items: center; gap: 2px; font-size: 11.5px; word-break: break-all; margin-bottom: 4px; }
.ud-full .copy { flex: none; }
.ud-body .node-list { margin-top: 4px; }
.t-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 22px; opacity: 0; transform: translateY(6px); transition: opacity .4s, transform .5s var(--spring); }
.t-actions.in { opacity: 1; transform: none; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  background: var(--btn); color: var(--btn-ink); padding: 8px 14px; border-radius: 999px; transition: opacity .2s, transform .35s var(--spring); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; filter: blur(3px); transform: translateY(6px); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes lnIn { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

@media (width <= 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
  .t-kids { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (width <= 820px) {
  .side { position: sticky; top: 0; bottom: auto; left: 0; width: auto; height: auto; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 0;
    background: color-mix(in srgb, var(--bg) 92%, transparent); box-shadow: 0 .5px 0 var(--line); }
  .nav { display: flex; gap: 20px; margin: 8px -16px 0; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .group { display: flex; gap: 20px; margin: 0; flex: none; }
  .group h4, .side-foot, .nav a em { display: none; }
  .nav a { height: 38px; font-size: 15px; white-space: nowrap; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--ink); }
  .nav a.active::before { display: none; }
  .main { margin-left: 0; padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
  .top { margin-bottom: 18px; }
  .crumbs { display: none; }
  .t-kids { grid-template-columns: 1fr; margin-top: 26px; }
  .tree-lines { display: none; }
  .us-chip span { display: none; }
  .us-title { font-size: 24px; }
  .us-sub { font-size: 13px; }
  .bar-row { grid-template-columns: 80px 1fr 80px; }
  .bar-num { display: none; }
  .page-title { font-size: 20px; }
  .card { padding: 16px 14px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .kpis-sys .kpi-value { font-size: 18px; }

  /* шапка карточки: вкладки листаются пальцем, поиск на всю ширину */
  .card-head { margin-bottom: 10px; }
  .head-tools { width: 100%; min-width: 0; }
  .head-tools > div { max-width: 100%; min-width: 0; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
  .search { flex: 1 1 100%; height: 38px; }
  .search input { width: 100%; min-width: 0; }

  /* таблицы превращаются в карточки */
  .table-wrap { margin: 0 -14px; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  /* невидимые переносы: после «товар + сумма» и после «пользователь + статус» */
  .table-wrap tbody tr::before, .table-wrap tbody tr::after { content: ""; flex: 1 1 100%; height: 0; }
  .table-wrap tbody tr::before { order: 3; }
  .table-wrap tbody tr::after { order: 4; }
  .table-wrap tbody tr.loading-row::before, .table-wrap tbody tr.loading-row::after,
  .table-wrap tbody tr:has(td[colspan])::before, .table-wrap tbody tr:has(td[colspan])::after { display: none; }
  .table-wrap tbody tr:last-child { border-bottom: 0; }
  .table-wrap td { padding: 0; border: 0; white-space: nowrap; min-width: 0; }
  .table-wrap td[colspan] { flex: 1 1 100%; }
  .loading-row td { height: 120px; display: grid !important; place-items: center; }
  .m-only { display: inline; }
  .m-hide { display: none; }
  .m-badge.muted { font-size: 12px; }
  .m-title { order: 1; flex: 1 1 0; font-weight: 600; max-width: none; overflow: hidden; text-overflow: ellipsis; }
  .m-amt { order: 2; margin-left: auto; font-weight: 650; }
  .m-user { order: 3; flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; }
  .m-badge { order: 4; margin-left: auto; }
  .m-meta { order: 5; font-size: 12px; }
  .m-last { order: 6; }
  .m-sep::before { content: "·"; margin-right: 10px; color: var(--faint); }
  tr:has(.m-title-2) .m-user { order: 0; flex: 1 1 0; font-weight: 600; }
  .m-title-2 { order: 3; flex: 1 1 100%; font-weight: 400; color: var(--muted); }
  .pager { flex-wrap: wrap; }

  /* iOS не зумит поля ввода с шрифтом от 16px */
  input { font-size: 16px !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
