:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111b2d;
  --surface-raised: #172338;
  --line: #2c3c53;
  --text: #f0f4fb;
  --quiet: #a6b5ca;
  --accent: #98d8ff;
  --accent-on: #0b2c42;
  --accent-soft: #203954;
  --good: #83e3be;
  --warning: #f7c580;
  --bad: #ffa7ae;
  --btc: #e9ab61;
  --cash: #6aaef5;
  --hero: #172c46;
  --header: #10192a;
  --focus: #a1dcff;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eff3f8;
  --surface: #ffffff;
  --surface-raised: #e9eff8;
  --line: #ccd7e5;
  --text: #152438;
  --quiet: #526781;
  --accent: #155784;
  --accent-on: #ffffff;
  --accent-soft: #dcecfb;
  --good: #16654d;
  --warning: #845116;
  --bad: #9c3542;
  --btc: #a16424;
  --cash: #2b6fae;
  --hero: #e2edf9;
  --header: #f8fafc;
  --focus: #185e8c;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: .9375rem; line-height: 1.5; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); }
a { color: var(--accent); }
button, select { font: inherit; }
button, select, summary, .navigation a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.skip { position: fixed; z-index: 4; top: 12px; left: 12px; padding: 8px 12px; background: var(--surface); transform: translateY(-180%); }
.skip:focus { transform: none; }
.shell { max-width: 1440px; margin: auto; display: grid; grid-template-columns: 198px minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; min-height: 74px; padding: calc(12px + var(--safe-top)) max(28px, var(--safe-right)) 12px max(28px, var(--safe-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--header); border-bottom: 1px solid var(--line); }
.brand, .top-actions, .heading, .row, .filters, .legend { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 720; font-size: 1.18rem; letter-spacing: -.025em; white-space: nowrap; }
.brand small { color: var(--quiet); font-weight: 540; letter-spacing: .015em; margin-inline-start: 8px; }
.monogram { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px;
  color: var(--accent-on); background: var(--accent); font-size: 1.32rem; line-height: 1; }
.badge { display: inline-flex; align-items: center; width: fit-content; font-size: .8125rem; font-weight: 650; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; background: var(--surface-raised); color: var(--quiet); }
.badge.good { color: var(--good); }
.badge.warning { color: var(--warning); }
.refresh, .filters button, select { border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 6px 13px;
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 610; }
button:hover, select:hover { background: var(--surface-raised); }
.navigation { min-height: calc(100vh - 74px); background: var(--header); border-inline-end: 1px solid var(--line);
  padding: 24px 12px; display: flex; flex-direction: column; gap: 6px; }
.navigation a { display: flex; align-items: center; padding: 8px 14px; min-height: 44px; text-decoration: none;
  color: var(--quiet); font-weight: 630; border: 1px solid transparent; border-radius: 10px; }
.navigation a:hover, .navigation a[aria-current] { background: var(--accent-soft); color: var(--accent); }
main { min-width: 0; padding: 32px clamp(20px, 3.5vw, 54px) 46px; }
main:focus { outline: none; }
.heading { justify-content: space-between; align-items: flex-end; flex-wrap: wrap; margin-block-end: 22px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 4.3vw, 2.7rem); line-height: 1.14; letter-spacing: -.038em; font-weight: 720; }
h2 { font-size: 1.16rem; line-height: 1.28; letter-spacing: -.014em; font-weight: 680; }
h3 { font-size: 1rem; font-weight: 650; }
.quiet { color: var(--quiet); }
.meta { font-size: .8125rem; color: var(--quiet); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warning { color: var(--warning); }
.number { overflow-wrap: anywhere; }
.unit { color: var(--quiet); font-size: .54em; white-space: nowrap; letter-spacing: 0; }
.card { min-width: 0; padding: clamp(14px, 2.4vw, 23px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stack { display: grid; gap: 16px; }
.overview-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.card h2 + p, .card h2 + .meta { margin-top: 6px; }
.hero { background: linear-gradient(122deg, var(--hero), var(--surface) 94%); }
.hero .value { font-size: clamp(1.85rem, 5.1vw, 3.5rem); font-weight: 730; line-height: 1.15; letter-spacing: -.043em; margin: 5px 0 12px; }
.row { justify-content: space-between; align-items: baseline; }
.row > :last-child { text-align: end; }
.list { margin: 12px 0 0; }
.list .row { padding: 9px 0; border-top: 1px solid var(--line); }
.list dt { color: var(--quiet); }
.list dd { margin: 0; font-weight: 590; }
.book-header { margin-bottom: 12px; }
.meter { display: block; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 6px; overflow: hidden;
  background: var(--cash); margin: 13px 0 8px; }
.meter::-webkit-progress-bar { background: var(--cash); }
.meter::-webkit-progress-value { background: var(--btc); }
.meter::-moz-progress-bar { background: var(--btc); }
.legend { justify-content: space-between; flex-wrap: wrap; font-weight: 650; }
.legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--btc); }
.legend span + span::before { background: var(--cash); }
.notice { border: 1px solid var(--line); border-inline-start: 3px solid var(--warning); background: var(--surface);
  color: var(--text); border-radius: 10px; padding: 10px 13px; }
.notice + .notice { margin-top: 8px; }
.notice-area:not(:empty) { margin-bottom: 15px; }
.filters { flex-wrap: wrap; margin-bottom: 14px; gap: 8px; }
.filters button[aria-pressed="true"] { background: var(--accent); color: var(--accent-on); border-color: transparent; }
.table-wrap { overflow: auto; overscroll-behavior-inline: contain; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; text-align: start; background: var(--surface); }
th, td { padding: 10px 12px; text-align: start; vertical-align: top; }
td:not(:first-child), .comparison th:not(:first-child) { text-align: end; }
thead th { background: var(--surface-raised); color: var(--quiet); font-size: .8125rem; font-weight: 650; }
tbody th { font-weight: 610; }
tbody tr + tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--surface-raised); }
.order-table { min-width: 570px; }
.order-table th:not(:first-child) { text-align: end; }
.id { display: block; max-width: 43ch; overflow-wrap: anywhere; }
.branch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.branch-grid .card { text-align: start; cursor: pointer; color: var(--text); }
.branch-grid .card[aria-pressed="true"] { border-color: var(--accent); background: var(--hero); }
.branch-grid .card strong, .branch-grid .card span { display: block; }
.branch-grid .card .meta { margin-top: 5px; }
.comparison { min-width: 480px; }
.comparison small { color: var(--quiet); font-size: .75rem; }
.table-number { white-space: nowrap; }
.table-unit { opacity: .88; }
.short-label { display: none; }
.parameters summary { min-height: 44px; cursor: pointer; font-weight: 670; }
.parameters[open] summary { margin-bottom: 10px; }
.parameter-controls label { color: var(--quiet); }
.parameter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.error, .empty { padding: 17px; color: var(--quiet); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }

@media (max-width: 800px) {
  .shell { display: block; }
  .topbar { min-height: 63px; padding-inline: max(14px, var(--safe-left)) max(14px, var(--safe-right)); }
  .navigation { position: fixed; z-index: 2; bottom: 0; left: 0; right: 0; min-height: 0; flex-direction: row; justify-content: space-around;
    border-inline-end: 0; border-top: 1px solid var(--line); padding: 5px max(8px, var(--safe-right)) calc(7px + var(--safe-bottom)) max(8px, var(--safe-left)); }
  .navigation a { flex: 1; justify-content: center; padding-inline: 4px; }
  main { padding: 22px max(14px, var(--safe-right)) calc(85px + var(--safe-bottom)) max(14px, var(--safe-left)); }
}

@media (max-width: 575px) {
  .overview-grid { grid-template-columns: 1fr; }
  .heading { margin-bottom: 16px; }
  .topbar .badge { display: none; }
  body[data-demo] .topbar .badge { display: inline-flex; }
  .brand { gap: 7px; }
  .brand small { display: block; font-size: .68rem; margin-inline-start: 0; }
  .comparison { min-width: 0; table-layout: fixed; font-size: .82rem; }
  .comparison th, .comparison td { padding: 9px 4px; overflow-wrap: anywhere; }
  .comparison th:first-child { width: 31%; padding-inline-start: 7px; }
  .comparison td:last-child { padding-inline-end: 7px; }
  .table-number { white-space: normal; }
  .table-unit { display: block; font-size: .72rem; }
  .long-label { display: none; }
  .short-label { display: inline; }
  .branch-grid .card { padding-inline: 11px; }
  .branch-grid { gap: 7px; }
  .table-wrap:has(.order-table) { overflow: visible; }
  .order-table { display: block; min-width: 0; }
  .order-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .order-table tbody, .order-table tr { display: block; }
  .order-table tr { padding: 11px; }
  .order-table td, .order-table tbody th { display: flex; padding: 3px 0; justify-content: space-between; gap: 8px; }
  .order-table td::before { content: attr(data-label); color: var(--quiet); text-align: start; }
}

@media (max-width: 380px) {
  .topbar, .top-actions { gap: 6px; }
  .topbar .badge, .refresh { padding-inline: 8px; }
  .table-wrap:has(.comparison) { overflow: visible; }
  .comparison, .comparison tbody, .comparison tr { display: block; }
  .comparison thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .comparison tbody tr { padding: 9px; }
  .comparison th:first-child { width: auto; padding: 4px 0; }
  .comparison td, .comparison td:last-child { display: flex; align-items: baseline; justify-content: space-between;
    gap: 8px; padding: 4px 0; text-align: end; }
  .comparison td::before { content: attr(data-label); color: var(--quiet); text-align: start; }
  .comparison .table-number { min-width: 0; }
  .comparison .table-unit { display: inline; }
}
