:root {
  --bg: #0e1119;
  --bg2: #151a26;
  --card: #1a2030;
  --line: #2a3246;
  --text: #ecebe6;
  --muted: #9aa0ad;
  --gold: #d4a957;
  --gold2: #f0cf8c;
  --gold-dim: #8a6a33;
  --up: #6fcf97;
  --down: #f08a7e;
  --prev: #5d6680;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
.splash { display: grid; place-items: center; min-height: 100dvh; }
.splash-logo { width: 140px; opacity: .9; }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: radial-gradient(ellipse at 50% 20%, #222a3c 0%, var(--bg) 60%); }
.login-logo { width: 168px; height: 168px; }
.wordmark { margin: 6px 0 2px; font-size: 44px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(180deg, #f4f3ef 0%, #a9a8a2 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); font-size: 11px; letter-spacing: .28em; text-transform: uppercase; text-align: center; }
.acrostic { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin: 18px 0 26px; max-width: 360px; }
.acrostic span { font-size: 11px; color: var(--muted); }
.acrostic b { color: var(--gold); font-weight: 800; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.field input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); outline: none; font-size: 17px; }
.field input:focus { border-color: var(--gold); }
.code-input { letter-spacing: .5em; text-align: center; font-size: 26px !important; }
.btn { padding: 15px; border-radius: 12px; border: 0; font-weight: 700; font-size: 16px; cursor: pointer;
  background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1b1408; }
.btn:disabled { opacity: .55; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.err { color: var(--down); font-size: 14px; min-height: 20px; text-align: center; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- каркас ---------- */
.top { position: sticky; top: 0; z-index: 5; padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(14, 17, 25, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 10px; }
.top-logo { width: 30px; height: 30px; }
.top-title { font-weight: 800; letter-spacing: .08em; font-size: 17px; }
.top-sub { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; color: var(--muted); cursor: pointer; font-size: 13px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 10px; padding: 4px; border-radius: 12px; background: var(--bg2); }
.seg button { border: 0; background: none; padding: 8px 0; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--gold2); box-shadow: 0 0 0 1px var(--gold-dim) inset; }
main { padding: 14px 16px calc(92px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b)); background: rgba(21, 26, 38, .96); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; cursor: pointer; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--gold2); }

/* ---------- карточки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.range { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--bg2); border-radius: 12px; padding: 12px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 800; margin-top: 2px; }
.kpi .d { font-size: 12px; margin-top: 2px; }
.kpi.big { grid-column: 1 / -1; }
.kpi.big .v { font-size: 30px; color: var(--gold2); }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.lg-cur { background: var(--gold2); }
.legend i.lg-prev { background: var(--prev); }
.list { display: grid; gap: 12px; }
.item-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-val { font-weight: 700; white-space: nowrap; }
.item-sub { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--bg2); margin-top: 6px; overflow: hidden; }
.bar .p { position: absolute; left: 0; top: 0; bottom: 0; background: var(--prev); opacity: .55; border-radius: 4px; }
.bar .c { position: absolute; left: 0; top: 2px; bottom: 2px; background: linear-gradient(90deg, var(--gold-dim), var(--gold2)); border-radius: 3px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }
.ctl { display: grid; gap: 8px; }
.ctl-row { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg2); border-radius: 12px; cursor: pointer; }
.ctl-row .n { font-weight: 800; font-size: 18px; }
.ctl-row .n.warn { color: var(--gold2); } .ctl-row .n.ok { color: var(--up); }
.ctl-details { font-size: 13px; color: var(--muted); padding: 4px 12px 8px; display: grid; gap: 4px; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.pnl { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.pnl th, table.pnl td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); }
table.pnl th:first-child, table.pnl td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
table.pnl tr.hdr td { color: var(--gold); font-weight: 700; padding-top: 12px; }
table.pnl tr.total td { font-weight: 700; }
.chips { display: flex; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--bg2); color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.chip.on { color: var(--gold2); border-color: var(--gold-dim); }
.foot { color: var(--muted); font-size: 11px; text-align: center; margin-top: 8px; }
.install { display: none; }
.install.show { display: block; }
.asof { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.asof input { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; color: var(--text); }
