:root {
  --bg: #0b1115; --side: #10191d; --panel: #141e23; --panel2: #19252b; --line: #29383d; --text: #e9f2f0; --muted: #93a7aa;
  --mint: #b8ef65; --mint-ink: #15231c; --cyan: #61d8d0; --amber: #e8bc73; --bad: #ff7a7a;
  --accent-bg: linear-gradient(140deg, #1b352b, var(--panel) 68%); --accent-line: #385342;
}
:root.light {
  --bg: #f3f6f5; --side: #fff; --panel: #fff; --panel2: #f5f8f7; --line: #dfe7e5; --text: #12201c; --muted: #66797b;
  --mint: #7fc236; --mint-ink: #fff; --cyan: #138f87; --amber: #b9852c; --bad: #d64545;
  --accent-bg: linear-gradient(140deg, #e8f6dc, #fff 68%); --accent-line: #bfe29a;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* каркас */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); padding: 24px 14px; display: flex; flex-direction: column; gap: 30px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 10px; font-weight: 750; font-size: 20px; letter-spacing: -.05em; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 10px; background: var(--mint); color: var(--mint-ink); }
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2.4; }
.brand small { display: block; font-size: 9px; color: var(--muted); font-weight: 600; letter-spacing: .16em; margin-top: -3px; }
.plus { color: var(--mint); }
.nav { display: grid; gap: 4px; }
.nav button { border: 0; background: transparent; color: var(--muted); text-align: left; padding: 11px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; width: 100%; font-weight: 500; }
.nav button:hover { background: var(--panel2); color: var(--text); }
.nav button.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 var(--mint); }
.side-foot { margin-top: auto; border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-size: 12px; color: var(--muted); }
.side-foot b { color: var(--text); font-weight: 600; display: block; margin-bottom: 3px; }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--mint); vertical-align: 1px; }
.dot.off { background: var(--muted); }
.main { min-width: 0; }
.topbar { height: 64px; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 34px; gap: 10px; color: var(--muted); font-size: 13px; }
.topbar b { color: var(--text); font-weight: 600; }
.top-right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); color: var(--mint); font-weight: 700; font-size: 12px; }
.content { max-width: 1240px; margin: 0 auto; padding: 34px 34px 60px; }
.tabbar { display: none; }

/* шапка страницы */
.eyebrow { color: var(--mint); text-transform: uppercase; font-size: 10px; letter-spacing: .2em; font-weight: 700; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 32px; letter-spacing: -.045em; line-height: 1.1; margin: 6px 0 6px; font-weight: 700; }
.page-head p { color: var(--muted); margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .hint { color: var(--muted); font-size: 12px; margin-left: auto; }

/* кнопки и поля */
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 10px 16px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; font-weight: 600; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--cyan); }
.btn.primary { color: var(--mint-ink); background: var(--mint); border-color: var(--mint); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 11px; font-size: 12px; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); }
select.pill-select { width: auto; min-width: 170px; background: var(--panel); font-weight: 500; }
textarea { min-height: 76px; resize: vertical; }
label { font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.x { background: none; border: 0; color: var(--muted); font-size: 17px; line-height: 1; padding: 4px; border-radius: 6px; }
.x:hover { color: var(--bad); background: var(--panel2); }

/* карточки */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.card { padding: 20px; min-height: 128px; display: flex; flex-direction: column; }
.card .head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.card strong { display: block; font-size: 27px; letter-spacing: -.045em; margin-top: 12px; line-height: 1.1; font-weight: 650; font-variant-numeric: tabular-nums; }
.card .note { color: var(--muted); font-size: 11.5px; margin-top: auto; padding-top: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card.accent { border-color: var(--accent-line); background: var(--accent-bg); }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 6px; font-weight: 600; background: var(--panel2); color: var(--muted); }
.chip.up { background: rgba(184, 239, 101, .12); color: var(--mint); }
.chip.down { background: rgba(255, 122, 122, .12); color: var(--bad); }
.chip.p { background: rgba(232, 188, 115, .14); color: var(--amber); }
.good { color: var(--mint); } .bad { color: var(--bad); } .muted { color: var(--muted); }

.hero { display: grid; grid-template-columns: 1fr 1.1fr; margin-top: 16px; border-color: var(--accent-line); background: var(--accent-bg); }
.hero > div { padding: 26px; }
.hero > div + div { border-left: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; align-content: center; }
.hero .big { font-size: 40px; font-weight: 700; letter-spacing: -.05em; margin: 10px 0 8px; font-variant-numeric: tabular-nums; }
.hero p { color: var(--muted); margin: 0; font-size: 13px; max-width: 380px; }
.kv small { color: var(--muted); font-size: 12px; display: block; }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-top: 16px; }
.panel { padding: 22px; min-width: 0; margin-top: 16px; }
.grid2 .panel { margin-top: 0; }
.panel h2 { font-size: 17px; margin: 0; letter-spacing: -.02em; font-weight: 650; }
.panel .sub { color: var(--muted); font-size: 13px; margin: 3px 0 16px; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.legend b { color: var(--text); margin-left: 6px; font-weight: 600; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 11px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.seg button.on { background: var(--panel2); color: var(--text); }
.chart svg { width: 100%; height: 230px; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10px; }
.donut-wrap { display: grid; place-items: center; position: relative; margin: 6px 0 14px; }
.donut-wrap .center { position: absolute; text-align: center; }
.donut-wrap .center small { color: var(--muted); font-size: 12px; display: block; }
.donut-wrap .center b { font-size: 22px; letter-spacing: -.04em; }
.mix-row { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.bar { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--cyan); border-radius: 4px; }

/* таблицы */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.wrap { white-space: normal; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.n, th.n { text-align: right; }
tbody tr:hover td { background: var(--panel2); }

/* формы */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.form .wide { grid-column: span 2; }
.form .full { grid-column: 1 / -1; }
.empty { color: var(--muted); padding: 30px 10px; text-align: center; }
.note-line { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
code { background: var(--panel2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 11px 16px; border-radius: 12px; display: none; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
.login .brand { margin-bottom: 22px; padding: 0; }

/* телефон / Telegram */
@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero, .grid2 { grid-template-columns: 1fr; }
  .hero > div + div { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 0 18px; height: 56px; position: sticky; top: 0; background: var(--bg); z-index: 10; }
  .topbar .crumb { display: none; }
  .content { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 26px; }
  .card { padding: 15px; min-height: 112px; }
  .card strong { font-size: 21px; }
  .hero > div { padding: 20px; }
  .hero .big { font-size: 32px; }
  .panel { padding: 16px; }
  .form .wide { grid-column: 1 / -1; }
  .hide-m { display: none; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; background: var(--side);
    border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 20; }
  .tabbar button { border: 0; background: none; color: var(--muted); display: grid; justify-items: center; gap: 3px; font-size: 11px; font-weight: 500; padding: 4px 0; }
  .tabbar button.on { color: var(--mint); }
  .tabbar svg.i { width: 21px; height: 21px; }
}
.metrics.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .metrics.three { grid-template-columns: 1fr 1fr; } .metrics.three .card:first-child { grid-column: 1 / -1; } }

/* модели, делёж, аккаунты */
.pill-date { width: auto; background: var(--panel); }
.models { display: flex; align-items: center; gap: 10px; margin: -6px 0 18px; color: var(--muted); overflow-x: auto; }
.models .seg { flex: none; }
.clickable { cursor: pointer; }
.mix-row.clickable:hover { color: var(--mint); }
.split .split-period { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.split .split-period b { color: var(--text); font-weight: 600; }
.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.split-col { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.split-name { font-weight: 650; margin-bottom: 8px; }
.split-row, .split-total { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; color: var(--muted); }
.split-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.split-total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; color: var(--text); font-weight: 600; }
.split-total b { font-size: 19px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 18px; }
form.inline { display: flex; gap: 6px; }
form.inline input { padding: 6px 9px; min-width: 110px; }
@media (max-width: 760px) { .split-grid { grid-template-columns: 1fr; } }
.split-big { font-size: 28px; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.split .sub b { color: var(--text); font-weight: 600; }
.toolbar .hint b { color: var(--text); font-weight: 600; }
