:root {
  /* тёмная приборная тема по умолчанию, как у активности Quantum */
  --bg: #0b0e13;
  --surface: #12171f;
  --surface-2: #19202a;
  --surface-3: #222b37;
  --border: #212b38;
  --ink: #e6ebf2;
  --ink-2: #a2adbd;
  --ink-3: #6b7788;
  --brand: #4f8ef7;
  --brand-ink: #0b1220;
  --brand-soft: rgba(79, 142, 247, .14);
  --quantum: #b58cff;
  --quantum-soft: rgba(181, 140, 255, .14);
  --good: #3dd68c;
  --good-soft: rgba(61, 214, 140, .13);
  --warn: #f2b84b;
  --warn-soft: rgba(242, 184, 75, .13);
  --bad: #f0686a;
  --bad-soft: rgba(240, 104, 106, .13);
  --twitch: #9146ff;
  --youtube: #ff0033;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-2: #f5f7fa;
    --surface-3: #e8ecf2;
    --border: #dce2ea;
    --ink: #121821;
    --ink-2: #465163;
    --ink-3: #758196;
    --brand: #2b6de0;
    --brand-ink: #ffffff;
    --brand-soft: rgba(43, 109, 224, .1);
    --quantum: #7a45d6;
    --quantum-soft: rgba(122, 69, 214, .1);
    --good: #16945c;
    --good-soft: rgba(22, 148, 92, .1);
    --warn: #b07808;
    --warn-soft: rgba(176, 120, 8, .1);
    --bad: #d23c3f;
    --bad-soft: rgba(210, 60, 63, .09);
    --shadow: 0 10px 30px rgba(20, 30, 60, .08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
body { min-height: 100vh; overflow-x: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-soft), transparent); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #2a5bd7); color: #fff; font-weight: 800; font-size: 26px; }
.login-card h1 { margin-bottom: 6px; }
.login-card form { margin-top: 22px; display: grid; gap: 12px; text-align: left; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; border-bottom: 1px solid var(--border); }
.brand-row img, .brand-row .logo { width: 40px; height: 40px; border-radius: 12px; margin: 0; font-size: 18px; }
.brand-row .t { font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 9px; color: var(--ink-2); font-weight: 550; }
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.active { background: var(--brand-soft); color: var(--brand); }
.nav .ic { width: 20px; text-align: center; }
.nav button.locked { opacity: .35; cursor: not-allowed; filter: grayscale(1); }
.nav button.locked:hover { background: none; color: var(--ink-2); }
.smode { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 14px; }
.streamer-on .smode { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 6px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.live { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.main { padding: 28px 32px 60px; min-width: 0; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.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)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card > h2 { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card .sub { margin: -8px 0 14px; color: var(--ink-3); font-size: 13px; }
.stat .label { color: var(--ink-3); font-size: 13px; font-weight: 550; }
.stat .value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; }
.stat .hint { font-size: 12.5px; color: var(--ink-3); }
.span2 { grid-column: span 2; }

/* ---------- forms ---------- */
label.field { display: grid; gap: 6px; align-content: start; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.field .help { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0; outline: none; font-weight: 400; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=number] { max-width: 140px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--border); transition: filter .15s, transform .05s; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { all: unset; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--ink-3); }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--border); }
.switch:last-child { border-bottom: 0; }
.switch .txt b { display: block; font-weight: 600; }
.switch .txt span { color: var(--ink-3); font-size: 13px; }
.toggle { position: relative; width: 42px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle i { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; transition: .2s; }
.toggle i::after { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + i { background: var(--brand); border-color: var(--brand); }
.toggle input:checked + i::after { transform: translateX(18px); }
.toggle input:focus-visible + i { box-shadow: 0 0 0 3px var(--brand-soft); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { all: unset; cursor: pointer; padding: 6px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-3); border-radius: 99px; padding: 4px 6px 4px 11px; font-size: 13px; }
.chip button { all: unset; cursor: pointer; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-3); }
.chip button:hover { background: var(--bad-soft); color: var(--bad); }

/* ---------- lists & tables ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--ink-3); font-size: 13px; }
.item.click { cursor: pointer; border-radius: 9px; }
.item.click:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); flex: none; object-fit: cover; }
.rank { width: 26px; text-align: center; font-weight: 700; color: var(--ink-3); flex: none; }
.num { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.twitch { background: rgba(145,70,255,.15); color: #a970ff; }
.pill.youtube { background: rgba(255,0,51,.13); color: #ff4d6d; }
.empty { color: var(--ink-3); padding: 18px 4px; text-align: center; font-size: 14px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--ink-3); font-weight: 600; font-size: 12.5px; padding: 8px 8px; border-bottom: 1px solid var(--border); }
table.t td { padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; max-height: 220px; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--brand); }
.chart .bar.dim { opacity: .35; }
.chart .hit { fill: transparent; cursor: pointer; }
.tip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; }
.tip b { display: block; font-size: 13px; }
.legend-row { display: flex; gap: 14px; margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- live banner ---------- */
.live-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bad-soft), transparent); border: 1px solid var(--border); margin-bottom: 16px; }

/* ---------- progress ---------- */
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.good > i { background: var(--good); }

/* ---------- drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { width: min(520px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--border);
  padding: 22px; overflow-y: auto; box-shadow: var(--shadow); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.drawer-head .avatar { width: 52px; height: 52px; }
.close { margin-left: auto; }
.drawer .stat .value { font-size: 20px; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ach > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 13px; }
.ach > div.off { opacity: .45; }
.ach .e { font-size: 20px; }

.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.modal p { color: var(--ink-2); }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--surface-3); border: 1px solid var(--border); border-left: 4px solid var(--good); padding: 11px 14px;
  border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; max-width: 360px; animation: slide .2s ease-out; }
.toast.err { border-left-color: var(--bad); }

.streamer { display: grid; grid-template-columns: 1.1fr 1fr 1.3fr auto; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rate-row { display: grid; grid-template-columns: 1.6fr 1fr 1fr auto; gap: 10px; align-items: end; padding: 8px 0; }
.help-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); }
.help-box ol { margin: 6px 0 0; padding-left: 18px; }

/* ---------- mobile ---------- */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; position: sticky; top: 0; height: auto; z-index: 10; padding: 10px 16px; gap: 8px; flex-direction: column; }
  .brand-row { padding: 0 0 8px; }
  .nav { flex-direction: row; overflow-x: auto; min-width: 0; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .nav button { white-space: nowrap; padding: 7px 11px; }
  .side-foot { display: none; }
  .nav button.locked { display: none; }
  .main { padding: 18px 16px 60px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .value { font-size: 24px; }
  .streamer, .rate-row { grid-template-columns: 1fr 1fr; }
  input[type=number] { max-width: none; }
}
.chip .avatar { width: 20px; height: 20px; margin-left: -5px; }
textarea { resize: vertical; min-height: 80px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-size: 12px; font-weight: 600; color: var(--ink-3); text-align: center; padding: 4px 0; }
.cal-cell { min-height: 96px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-cell.empty-cell { background: transparent; border-style: dashed; opacity: .4; }
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.cal-day { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.cal-item { all: unset; display: block; font-size: 11.5px; line-height: 1.3; padding: 3px 6px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.cal-item.ev { background: var(--brand-soft); color: var(--brand); cursor: pointer; }
.cal-item.ev.done { background: var(--surface-3); color: var(--ink-3); }
.cal-item.ev.cancelled { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.cal-item.st { background: rgba(145,70,255,.15); color: #a970ff; }
.cal-list { display: none; }
@media (max-width: 760px) {
  .cal, .cal-head { display: none; }
  .cal-list { display: flex; flex-direction: column; }
}

/* ---------- achievement tracks ---------- */
.tracks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.track { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.track.off { opacity: .6; }
.track-head { display: flex; gap: 10px; align-items: center; }
.track-head .e { font-size: 20px; }
.level-steps { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: 13px; }
.level-steps .step { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.level-steps .pill { margin-left: 4px; }
@media (max-width: 760px) { .tracks { grid-template-columns: 1fr; } }


/* ---------- оформление: типографика и детали (общий стиль с активностью) ---------- */
body { -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 16px; height: 16px; }
h1 { font: 600 22px/1.2 var(--display); letter-spacing: -.01em; text-wrap: balance; }
h2 { font: 600 15px/1.3 var(--font); }
h3 { font: 500 11px/1.3 var(--mono); letter-spacing: .08em; }
.card > h2 { font-size: 15px; }
.stat .label { font: 500 11px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.stat .value { font: 500 28px/1.15 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 8px; }
.stat .hint { margin-top: 2px; }
code, .mono { font-family: var(--mono); }
table, .num { font-variant-numeric: tabular-nums; }

/* логотип и меню */
.logo { background: var(--surface-3); color: var(--ink); font: 700 20px/1 var(--display); border: 1px solid var(--border); }
.login { background: var(--bg); }
.login-card { box-shadow: none; }
.login-card h1 { font: 700 18px/1 var(--display); letter-spacing: .3em; margin-top: 4px; }
.brand-row .t { font: 700 12px/1.2 var(--display); letter-spacing: .28em; text-transform: uppercase; }
.nav button { font-weight: 500; border-radius: 8px; padding: 8px 10px; }
.nav button .i { color: var(--ink-3); }
.nav button:hover .i { color: var(--ink-2); }
.nav button.active { background: var(--surface-2); color: var(--ink); box-shadow: inset 2px 0 0 var(--brand); border-radius: 0 8px 8px 0; }
.nav button.active .i { color: var(--brand); }
.nav .ic { display: inline-flex; width: auto; }
.smode { font-weight: 500; border-radius: 8px; }
.btn { border-radius: 8px; }
.btn.primary:hover { filter: brightness(1.08); }
input, select, textarea { border-radius: 8px; }
.card { border-color: var(--border); }
@media (max-width: 760px) {
  .nav button.active { box-shadow: inset 0 -2px 0 var(--brand); border-radius: 8px 8px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.main > .card + .grid, .main > .grid + .card, .main > .card + .card, .main > .grid + .grid { margin-top: 16px; }
