:root {
  color-scheme: light;
  --bg: #eceef2;
  --card: #ffffff;
  --card-2: #f4f5f8;
  --ink: #111214;          /* black cards, active pill */
  --line: #e6e8ee;
  --text: #15171c;
  --text-2: #5f6573;
  --muted: #9aa0ad;
  --lime: #d8f550;
  --lime-deep: #c4e632;
  --blue: #2f7cf6;
  --blue-soft: #8db6fb;
  --safe: #0ca30c;
  --warning: #fab219;
  --high: #ec835a;
  --critical: #d03b3b;
  --r-card: 22px;
  --r-inner: 16px;
  --r-pill: 999px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(17, 18, 20, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: 14.5px; line-height: 1.5; font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { max-width: 1320px; margin: 0 auto; padding: 18px 22px 32px; }

/* ── top bar ───────────────────────────────────────── */
.top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
  background: var(--card); border-radius: var(--r-card); padding: 10px 12px 10px 14px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand img { width: 38px; height: 38px; border-radius: 11px; }
.pills { display: flex; justify-content: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.pills a { text-decoration: none; padding: 8px 16px; border-radius: var(--r-pill); font-weight: 500; font-size: 14px; color: var(--text); white-space: nowrap; }
.pills a:hover { background: var(--card-2); }
.pills a[aria-current="page"] { background: var(--ink); color: #fff; }
.addr { display: flex; align-items: center; gap: 8px; background: var(--card-2); border-radius: var(--r-pill); padding: 0 14px; height: 42px; width: 300px; }
.addr svg { width: 18px; height: 18px; fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linecap: round; flex: none; }
.addr input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 13.5px; }
.addr input::placeholder { color: var(--muted); }
.addr:focus-within { box-shadow: 0 0 0 2px var(--blue); }

#view { outline: none; padding-top: 22px; }
.foot { color: var(--muted); font-size: 12.5px; text-align: center; padding-top: 26px; }

/* ── greeting row ──────────────────────────────────── */
.greet { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.greet-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.greet h1 { font-size: 30px; font-weight: 600; letter-spacing: -.025em; margin: 0; }
.greet h1 .addr-chip { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 10px; letter-spacing: 0; }
.round {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: inline-grid; place-items: center; text-decoration: none; cursor: pointer; flex: none;
}
.round svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.round:hover { background: var(--card-2); }
.greet-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: var(--r-pill);
  background: var(--card); border: 1px solid var(--line); font-size: 13.5px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip-pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip-pill.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--safe); flex: none; }
.dot.off { background: var(--warning); }

/* ── card system ──────────────────────────────────── */
.dash {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.05fr);
  grid-template-areas: "list chart wallet" "list table table";
}
.a-list { grid-area: list; } .a-chart { grid-area: chart; } .a-wallet { grid-area: wallet; } .a-table { grid-area: table; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sim-controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; }
.card .card-head .chips { justify-content: flex-end; }
.card-head { flex-wrap: wrap; }
code { background: var(--card-2); border-radius: 8px; padding: 2px 7px; font-size: 13px; }
.btn svg, .chip-pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card { background: var(--card); border-radius: var(--r-card); padding: 20px 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; margin: 0; }
.card-head .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.go { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; text-decoration: none; flex: none; }
.go svg { width: 15px; height: 15px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.go:hover { background: var(--card-2); }
h1 { font-size: 30px; font-weight: 600; letter-spacing: -.025em; margin: 0; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; margin: 0; }
.lede { color: var(--text-2); margin: 4px 0 0; max-width: 64ch; }
.muted { color: var(--muted); }
.dim { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.section { margin-top: 16px; }

/* big money: grey cents like the reference */
.money { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.money .cents { color: var(--muted); font-weight: 600; }
.big { font-size: 46px; font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }

/* ── position tiles (left column, like "Investments") ── */
.tiles { display: flex; flex-direction: column; }
.tile {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 16px 16px 26px; border-radius: var(--r-inner); text-decoration: none; background: var(--card-2);
  margin-top: -12px; position: relative;
}
.tile:first-child { margin-top: 0; }
.tile:last-child { padding-bottom: 16px; }
.tile.ink { background: var(--ink); color: #fff; }
.tile.lime { background: var(--lime); }
.tile.plain { background: var(--card); border: 1px solid var(--line); }
.tile .coin { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: #fff; color: var(--ink); }
.tile.ink .coin { background: #2a2c31; color: #fff; }
.tile.lime .coin { background: var(--ink); color: var(--lime); }
.tile b { font-size: 15.5px; font-weight: 600; display: block; }
.tile small { font-size: 12px; opacity: .75; }
.tile .r { text-align: right; }
.tile .r b { font-size: 16px; }

/* ── level badges: coloured square + dark text (readable on white) ── */
.level { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; white-space: nowrap; color: var(--text); }
.level::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--muted); flex: none; }
.level.SAFE::before, .level.RECOVERED::before { background: var(--safe); }
.level.WARNING::before { background: var(--warning); }
.level.HIGH_RISK::before, .level.RAPID_DROP::before, .level.PRICE_NEAR::before { background: var(--high); }
.level.COLLATERAL_DOWN::before, .level.DEBT_UP::before { background: var(--warning); }
.level.CRITICAL::before { background: var(--critical); }
.tile.ink .level { color: #fff; }
.pill-level { display: inline-flex; padding: 3px 10px; border-radius: var(--r-pill); background: var(--card-2); }
.tile.ink .pill-level { background: #2a2c31; }
.tile.lime .pill-level { background: rgba(255,255,255,.55); }

/* ── wallet card (right column) ───────────────────── */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0 18px; }
.actions a { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; font-size: 11.5px; color: var(--text-2); }
.actions .sq { width: 100%; aspect-ratio: 1.25; max-height: 50px; border-radius: 14px; background: var(--card-2); display: grid; place-items: center; }
.actions .sq svg { width: 19px; height: 19px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.actions a:hover .sq { background: #e9ebf0; }
.label { color: var(--text-2); font-size: 13px; }
.health-bar { position: relative; height: 44px; border-radius: var(--r-pill); background: var(--card-2); margin: 10px 0 8px; overflow: hidden; }
.health-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--lime); border-radius: var(--r-pill); }
.health-bar .knob { position: absolute; top: 4px; width: 36px; height: 36px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); display: grid; place-items: center; font-weight: 800; font-size: 13px; transform: translateX(-100%); }
.health-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.health-meta b { color: var(--text); font-size: 15px; }
.inner { background: var(--card-2); border-radius: var(--r-inner); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.inner .ico { width: 30px; height: 30px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.mix { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 10px 0 8px; }
.mix span { display: block; }
.mix-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.mix-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.pct-up { background: var(--lime); padding: 2px 8px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; }

/* ── segmented toggle (Monthly / Annually) ────────── */
.seg { display: inline-flex; background: var(--card-2); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer; font-size: 13px; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--blue); color: #fff; }

/* chips (filters) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: var(--r-pill); padding: 7px 14px; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--card-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .count { opacity: .55; margin-left: 5px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: var(--r-pill); background: var(--ink); color: #fff; border: 0; text-decoration: none; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { background: #2a2c31; }
.btn.quiet { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.field { display: flex; align-items: center; gap: 8px; }
.field input, .field select, select.sel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 9px 14px; }
.field input { width: 140px; }
.back { color: var(--text-2); text-decoration: none; }

/* ── tables (like "Transaction History") ──────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 13px; padding: 4px 12px 12px; white-space: nowrap; }
td { padding: 13px 12px; white-space: nowrap; vertical-align: middle; }
tbody tr:nth-child(even) td { background: var(--card-2); }
tbody tr td:first-child { border-radius: 12px 0 0 12px; }
tbody tr td:last-child { border-radius: 0 12px 12px 0; }
th.r, td.r { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef3fe; }
.asset { display: flex; align-items: center; gap: 10px; }
.asset .coin { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.asset b { font-weight: 600; }
.asset small, .stack-sub { display: block; color: var(--muted); font-size: 11.5px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--card-2); border-radius: var(--r-pill); padding: 1px 8px; margin-left: 6px; vertical-align: 1px; }

/* ── hero (position detail) ───────────────────────── */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 24px; align-items: end; }
.ruler { grid-column: 1 / -1; margin-top: 14px; }
.ruler svg { display: block; width: 100%; height: 74px; overflow: visible; }
.ruler .tick-label { fill: var(--text-2); font-size: 11.5px; }
.ruler .liq-label { fill: var(--critical); font-size: 11.5px; font-weight: 600; }
.ruler .marker-label { fill: var(--text); font-size: 13px; font-weight: 700; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kv > div { background: var(--card-2); border-radius: var(--r-inner); padding: 14px 16px; }
.kv .k { color: var(--text-2); font-size: 12.5px; }
.kv .v { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kv .v small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }

.improve { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.improve > div { background: var(--card-2); border-radius: var(--r-inner); padding: 16px 18px; }
.improve > div.hl { background: var(--lime); }
.improve .target { color: var(--text-2); font-size: 12.5px; margin-bottom: 8px; }
.improve .target b { color: var(--text); font-size: 18px; }
.improve .act { font-size: 14px; }
.improve .act .num { font-weight: 700; }
.improve .or { color: var(--muted); font-size: 12px; margin: 4px 0; }
.improve .ok { font-weight: 600; }

/* ── charts ───────────────────────────────────────── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: #dfe2e9; stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis text { fill: var(--text-2); font-size: 11.5px; }
.chart .ref-label { font-size: 11.5px; fill: var(--text-2); }
.chart .crosshair { stroke: #b9bfcb; stroke-width: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 11px; font-size: 12.5px; line-height: 1.45; box-shadow: 0 8px 24px rgba(0,0,0,.18); max-width: 260px; }
.tooltip .t { opacity: .7; margin-bottom: 2px; }
.donut-wrap { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; align-items: center; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.donut-legend div { display: grid; grid-template-columns: 12px minmax(0,1fr) auto; gap: 10px; align-items: center; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }

/* ── alerts list ──────────────────────────────────── */
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.events li { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 14px; padding: 13px 16px; background: var(--card-2); border-radius: var(--r-inner); align-items: center; }
.events .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.events.compact li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 11px 14px; }
.events.compact li .what { grid-column: 1 / -1; font-size: 13px; }

/* ── states ───────────────────────────────────────── */
.empty { background: var(--card); border-radius: var(--r-card); padding: 44px 36px; max-width: 680px; }
.empty h1 { font-size: 28px; }
.empty p { color: var(--text-2); }
.notice { background: #fff6dc; border-radius: var(--r-inner); padding: 12px 16px; font-size: 13.5px; margin-bottom: 14px; }
.notice.info { background: #e8f0fe; }
.error { color: var(--critical); }
.skeleton { color: var(--muted); padding: 40px 4px; }

/* ── responsive ───────────────────────────────────── */
@media (max-width: 1150px) {
  .dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "chart chart" "list wallet" "table table"; }
}
@media (max-width: 960px) {
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .top { grid-template-columns: auto 1fr; }
  .pills { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .addr { width: auto; justify-self: end; max-width: 220px; }
}
@media (max-width: 720px) {
  .page { padding: 10px 12px 24px; }
  .dash { grid-template-columns: minmax(0, 1fr); grid-template-areas: "wallet" "list" "chart" "table"; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .greet h1 { font-size: 24px; }
  .greet h1 .addr-chip { display: block; margin: 2px 0 0; }
  .improve { grid-template-columns: minmax(0, 1fr); }
  .events li { grid-template-columns: minmax(0, 1fr) auto; }
  .events li .what { grid-column: 1 / -1; }
  .big { font-size: 38px; }
  .money { font-size: 30px; }
  .addr { max-width: 170px; }
  .brand span { display: none; }
  .pills a { padding: 8px 12px; font-size: 13.5px; }
  /* tables become one block per row; every value keeps its label */
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; width: 100%; }
  table.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px; border-radius: var(--r-inner); background: var(--card-2); margin-bottom: 8px; }
  table.stack tbody tr td, table.stack tbody tr:nth-child(even) td { display: block; padding: 0; background: transparent; border-radius: 0; text-align: left; white-space: normal; }
  table.stack td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11.5px; }
  table.stack td:first-child { grid-column: 1 / -1; }
  table.stack td:first-child::before { content: none; }
}
/* ── settings editor ──────────────────────────────── */
.lvl-row, .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; background: var(--card-2); border-radius: var(--r-inner); margin-bottom: 8px; cursor: pointer; }
.lvl-row .field input { width: 96px; text-align: right; font-weight: 700; }
.lvl-row .field input:invalid { border-color: var(--critical); }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: #d5d9e1; position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .15s; }
.switch:checked { background: var(--ink); }
.switch:checked::after { left: 21px; }
.switch:disabled { opacity: .55; cursor: not-allowed; }
.switch-row:has(.switch:disabled) { cursor: default; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn:disabled { opacity: .5; cursor: progress; }
.form-status { min-height: 1.5em; margin: 12px 0 0; font-size: 13.5px; }
.form-status.ok { color: var(--safe); }
#forget { cursor: pointer; }
.wallet-switch { max-width: 260px; font-weight: 600; cursor: pointer; }
/* Inside Telegram the app has its own header; keep the page compact. */
.tma .page { padding-top: 10px; }
.tma .foot { padding-bottom: 12px; }
@media (prefers-reduced-motion: no-preference) {
  .health-bar .fill, .health-bar .knob { transition: left .4s ease, width .4s ease; }
}
