/* DMCSHOPS — панель управления. Светлая и тёмная темы, ПК и мобильные. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --side: #f6f8f6;
  --surface: #ffffff;
  --surface-2: #f3f6f4;
  --line: #e6ebe7;
  --line-strong: #d4dbd6;
  --text: #131a16;
  --text-2: #4b554f;
  --muted: #7a847e;
  --brand: #17803d;
  --brand-hover: #136a33;
  --brand-soft: #e8f5ec;
  --brand-ink: #0f5f2c;
  --on-brand: #ffffff;
  --danger: #c93b3b;
  --danger-soft: #fbeceb;
  --warn: #a96a00;
  --warn-soft: #fbf3e2;
  --info: #2a6fc9;
  --info-soft: #e9f1fb;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --seq-0: #f0f4f8; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(17, 33, 23, .08);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1210;
  --side: #121714;
  --surface: #151b17;
  --surface-2: #1b221e;
  --line: #242c27;
  --line-strong: #323c36;
  --text: #e8eee9;
  --text-2: #b6c0b9;
  --muted: #869089;
  --brand: #2ea55a;
  --brand-hover: #39b867;
  --brand-soft: #16291d;
  --brand-ink: #7fd79d;
  --on-brand: #06160c;
  --danger: #e36b6b;
  --danger-soft: #2c1919;
  --warn: #e0a641;
  --warn-soft: #2b2416;
  --info: #6aa6ee;
  --info-soft: #172433;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --seq-0: #1a201d; --seq-1: #104281; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #9ec5f4;
  --shadow: 0 10px 34px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── каркас ───────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.app.collapsed { grid-template-columns: 72px 1fr; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto; }
.brand { padding: 4px 12px 22px; }
.brand b { display: block; font-size: 19px; font-weight: 750; letter-spacing: .06em; }
.brand span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 500; position: relative; }
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 14px 12px 4px; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; font-size: 13px; flex: none; }
.side-foot .who { min-width: 0; line-height: 1.25; }
.side-foot .who b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { font-size: 12px; color: var(--muted); }
.app.collapsed .brand span, .app.collapsed .nav a span, .app.collapsed .nav .badge, .app.collapsed .side-foot .who { display: none; }
.app.collapsed .brand b { font-size: 15px; letter-spacing: 0; text-align: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .spacer { flex: 1; }
.content { padding: 28px; max-width: 1440px; width: 100%; margin: 0 auto; }

.shop-pick { position: relative; }
.shop-btn { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: left; }
.shop-btn:hover { background: var(--surface-2); }
#shopPick { flex: 0 1 auto; min-width: 0; }
.shop-btn { max-width: 100%; }
.shop-btn > span { min-width: 0; white-space: nowrap; }
.shop-btn > span b, .shop-btn > span small { overflow: hidden; text-overflow: ellipsis; }
.shop-btn > svg { flex: none; width: 16px; height: 16px; }
.shop-btn .mp { width: 34px; height: 34px; }
.shop-btn b { display: block; font-weight: 600; font-size: 14px; line-height: 1.2; }
.shop-btn small { display: block; color: var(--muted); font-size: 12px; }
.mp { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
.mp.playerok { background: var(--s1); } .mp.funpay { background: var(--s2); } .mp.ggsel { background: var(--s3); } .mp.all { background: var(--brand); }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 40; }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover, .menu button.on { background: var(--surface-2); }
.menu .dot { margin-left: auto; }

.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: var(--text-2); position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; }
.icon-btn .badge { position: absolute; top: 2px; right: 0; }
.chip-btn { height: 38px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-weight: 600; cursor: pointer; }

/* ── элементы ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; stroke: currentColor; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 700; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tag.ok { background: var(--brand-soft); color: var(--brand-ink); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.on { background: var(--brand); } .dot.off { background: var(--danger); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 6px 0 2px; font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin: 0; color: var(--muted); }
.scope-tag { display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px 3px 4px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; font-weight: 600; }
.scope-tag .mp { width: 20px; height: 20px; border-radius: 6px; font-size: 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: 20px; }
.panel h2 { margin: 0 0 4px; font-size: 17px; font-weight: 650; }
.panel .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 550; font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--brand); }

/* показатели */
.kpi { padding: 18px 18px 16px; }
.kpi .label { color: var(--text-2); font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.kpi .value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; line-height: 1.15; }
.kpi .delta { font-size: 13px; color: var(--muted); }
.delta.up { color: var(--brand-ink); } .delta.down { color: var(--danger); }

/* таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; }
.cell-title { font-weight: 550; }
.cell-sub { color: var(--muted); font-size: 12.5px; }

/* формы */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 550; }
.field small { color: var(--muted); font-size: 12px; }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); outline: none; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search { max-width: 320px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.form { display: grid; gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--brand); outline-offset: 2px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

/* пустые состояния и загрузка */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* центр событий */
.inbox { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 0; height: calc(100vh - 64px - 150px); min-height: 520px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); overflow-y: auto; }
.inbox-filters { padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.card-ev { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: start; }
.card-ev:hover { background: var(--surface-2); }
.card-ev.on { background: var(--brand-soft); }
.card-ev .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-ev .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-ev .meta { text-align: right; font-size: 12px; color: var(--muted); display: grid; gap: 4px; justify-items: end; }
.card-ev.attn .t::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-left: 7px; vertical-align: middle; }
.inbox-view { display: flex; flex-direction: column; min-width: 0; }
.view-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.chat { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.msg { max-width: 72%; padding: 9px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg.me { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.msg .info { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { min-height: 42px; height: 42px; max-height: 160px; }
.back-link { display: none; }

/* модальные окна и выезжающая панель */
.overlay { position: fixed; inset: 0; background: rgba(8, 14, 10, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 10px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; flex-wrap: wrap; }
.drawer-wrap { position: fixed; inset: 0; z-index: 55; background: rgba(8, 14, 10, .35); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.drawer .chat { min-height: 200px; }

.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 90; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; font-size: 14px; }
.toast.err { background: var(--danger); color: #fff; }

/* уведомления */
.notif { width: 360px; right: 0; left: auto; max-height: 440px; overflow-y: auto; }
.notif .n { display: grid; gap: 2px; padding: 10px; border-radius: 8px; }
.notif .n b { font-size: 13.5px; font-weight: 600; }
.notif .n span { font-size: 12.5px; color: var(--muted); }

/* графики */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; z-index: 2; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13.5px; }
.bar-row .track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 4px; background: var(--s1); }
.heat { display: grid; grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; color: var(--muted); }
.heat .c { aspect-ratio: 1; border-radius: 3px; background: var(--seq-0); min-height: 10px; }
.stackbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface-2); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--side); }
.login-box { width: min(400px, 100%); }
.login-box .brand { padding: 0 0 22px; text-align: center; }
.login-box .brand b { font-size: 26px; }

/* ── мобильные ───────────────────────────────────────── */
.burger { display: none; }
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 70; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.nav-open .side { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(8,14,10,.4); z-index: 65; }
  .app.collapsed .brand span, .app.collapsed .nav a span, .app.collapsed .side-foot .who { display: initial; }
  .burger { display: grid; }
  .collapse-btn { display: none; }
  .top { padding: 0 12px; gap: 4px; }
  .shop-btn small, .hide-sm { display: none; }
  .content { padding: 18px 16px; }
  .page-head h1 { font-size: 24px; }
  .g2 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 64px - 120px); }
  .inbox.viewing .inbox-list { display: none; }
  .inbox:not(.viewing) .inbox-view { display: none; }
  .back-link { display: inline-flex; }
  .msg { max-width: 88%; }
  .notif { width: min(360px, calc(100vw - 24px)); position: fixed; top: 60px; right: 12px; }
  .search { max-width: none; flex: 1; }
  .modal { border-radius: 14px; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* таблицы: действия в строке, ссылки */
.row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
a.plain-link { color: inherit; text-decoration: none; }
a.plain-link:hover { text-decoration: underline; color: var(--brand-ink); }
td svg, th svg { width: 16px; height: 16px; stroke: currentColor; }
.kpi .label svg { width: 18px; height: 18px; stroke: currentColor; flex: none; }
.kpi .label > span { display: flex; gap: 8px; align-items: center; min-width: 0; }
td.r, td.num { white-space: nowrap; }
/* таблицы-карточки на телефоне */
@media (max-width: 860px) {
  .toolbar .search { flex: 1 1 100%; }
  table.rt thead { display: none; }
  table.rt, table.rt tbody { display: block; }
  table.rt tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.rt tr:last-child { border-bottom: 0; }
  table.rt td { padding: 0; border: 0; text-align: left; }
  table.rt td.r { text-align: right; }
  table.rt .c-main { grid-column: 1 / -1; order: -1; max-width: none !important; }
  table.rt .c-end { grid-column: 2; }
  table.rt .hide-sm { display: none; }
  table.rt tr.click:hover td { background: transparent; }
  table.rt tr.click:hover { background: var(--surface-2); }
  table.rt td.l-sm { text-align: left; align-self: center; }
  table.rt .o1 { order: 1; } table.rt .o2 { order: 2; } table.rt .o3 { order: 3; }
}
:root { accent-color: var(--brand); }
