@layer reset, layout, components, responsive;

@layer reset {
  :root {
    color-scheme: light;
    font-family: Inter, 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    font-size: 14px; -webkit-font-smoothing: antialiased;
    --ink: #18243c; --muted: #60708b; --soft: #718098; --surface: #fff;
    --bg: #f5f7fb; --line: #e3e8f0; --line-soft: #edf0f5;
    --brand: #285de2; --brand-dark: #204abd; --brand-pale: #eaf0ff;
    --nav: #172041; --nav-muted: #a7b4d2;
    --good: #147450; --good-bg: #e3f5e9; --warn: #8b5410; --warn-bg: #fff0d3;
    --bad: #b62742; --bad-bg: #ffebef; --radius: 15px;
  }
  *, *::before, *::after { box-sizing: border-box; }
  body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100dvh; }
  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; }
  button:disabled { cursor: default; opacity: .5; }
  button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
  button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid #628cff; outline-offset: 2px;
  }
  a { color: var(--brand-dark); }
  h1, h2, h3, p { margin: 0; }
  h1, h2, h3 { line-height: 1.18; letter-spacing: -.025em; }
  .icon { vertical-align: middle; flex: 0 0 auto; }
  .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .muted { color: var(--muted); }
  .good-text { color: var(--good); }
  .bad-text { color: var(--bad); }
  .warn-text { color: var(--warn); }
  .strong { font-weight: 670; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  [hidden] { display: none !important; }
}

@layer layout {
  .shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100dvh; }
  .sidebar {
    position: sticky; top: 0; height: 100dvh; min-height: 0; display: flex; flex-direction: column; padding: 24px 17px 14px;
    background: radial-gradient(ellipse at 3% 1%, #242f58 0, transparent 47%), linear-gradient(168deg, #1a2549 0%, #151e3c 65%, #121b36 100%);
    color: #f3f6ff; overflow-y: auto; isolation: isolate;
  }
  .main { min-width: 0; }
  .topbar {
    min-height: 65px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4;
  }
  .crumb, .top-actions, .actions, .month-heading, .date-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .crumb { font-size: .93rem; color: var(--muted); gap: 8px; }
  .crumb button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crumb .current { color: var(--ink); font-weight: 680; white-space: nowrap; }
  .body { max-width: 1610px; margin: 0 auto; padding: 29px 34px 38px; }
  .page-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 19px; min-height: 43px; }
  .page-heading h1 { font-size: clamp(1.75rem, 2.4vw, 2.28rem); font-weight: 750; }
  .columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 306px); align-items: start; gap: 20px; }
  .budget-col { min-width: 0; }
  .inspector { position: sticky; top: 84px; min-width: 0; display: grid; gap: 13px; max-height: calc(100dvh - 100px); overflow-y: auto; scrollbar-width: thin; }
  .ledger { min-width: 0; }
}

@layer components {
  .logo { display: flex; align-items: center; gap: 10px; padding: 1px 4px; margin-bottom: 27px; font-weight: 750; letter-spacing: -.025em; font-size: 1.22rem; }
  .logo-mark {
    display: grid; place-items: center; width: 35px; height: 35px; flex: none; color: #fff; border-radius: 10px;
    background: linear-gradient(140deg, #7392ff, #3e64ec 80%); box-shadow: inset 0 1px 1px #c8d7ff78, 0 4px 12px #0d164588;
  }
  .logo-mark .icon { stroke-width: 2; }
  .plan-switch {
    background: #ffffff0a; border: 1px solid #ffffff1b; color: inherit; border-radius: 11px; display: flex; align-items: center;
    gap: 9px; width: 100%; padding: 11px 10px; text-align: left; margin-bottom: 21px;
  }
  .plan-switch:hover { background: #ffffff16; }
  .plan-switch .plan-icon { display: grid; place-items: center; border-radius: 7px; padding: 6px; background: #7e94ff24; color: #c1d0ff; }
  .plan-text { flex: 1; min-width: 0; }
  .plan-text strong, .plan-text small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plan-text strong { font-size: .92rem; font-weight: 690; }
  .plan-text small { color: var(--nav-muted); margin-top: 3px; font-size: .77rem; }
  .nav-group { display: grid; gap: 3px; padding-bottom: 19px; }
  .nav-btn {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 10px; border-radius: 8px;
    background: none; border: 0; text-align: left; color: #d3ddf8; min-width: 0; line-height: 1.35; min-height: 39px;
  }
  .nav-btn .icon { color: #b4c0e5; }
  .nav-btn:hover { background: #ffffff0c; color: white; }
  .nav-btn.active { background: #3856aa57; color: #f5f8ff; font-weight: 680; box-shadow: inset 2px 0 #7da4ff; }
  .nav-btn.active .icon { color: #b3c7ff; }
  .nav-btn .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-btn .balance { color: #d9e3ff; font-size: .83rem; }
  .nav-btn .debt { color: #f9bcc7; }
  .nav-label {
    padding: 0 6px; color: #a6b4d9; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between;
    font-size: .73rem; text-transform: uppercase; letter-spacing: .085em; font-weight: 720;
  }
  .nav-label button { color: inherit; }
  .nav-label button:hover { color: white; }
  .nav-accounts { display: grid; gap: 2px; margin-bottom: 20px; }
  .nav-accounts .nav-btn { min-height: 36px; padding: 8px 6px; gap: 8px; font-size: .9rem; }
  .account-add {
    color: #c8d5ff; background: #ffffff07; border: 1px dashed #ffffff31; border-radius: 9px; padding: 9px 10px;
    width: 100%; text-align: left; display: flex; align-items: center; gap: 8px;
  }
  .account-add:hover { background: #ffffff13; }
  .sidebar-footer { margin-top: auto; padding-top: 24px; }
  .connection-line {
    border-top: 1px solid #ffffff18; margin-top: 10px; padding: 14px 6px 4px; display: flex; align-items: center;
    min-width: 0; gap: 7px; color: #aebbdc; font-size: .79rem; text-align: left; background: transparent; border-right: 0;
    border-left: 0; border-bottom: 0; width: 100%;
  }
  .connection-line:hover { color: white; }
  .connection-line .sync-copy { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .signal { width: 7px; height: 7px; border-radius: 50%; background: #b2bfd7; flex: none; }
  .signal.online { background: #51d8a4; box-shadow: 0 0 0 3px #51d8a423; }
  .signal.offline, .signal.auth, .signal.failed { background: #f4bf59; box-shadow: 0 0 0 3px #f4bf5928; }
  .topbar .btn.flat { padding-inline: 7px; }
  .local-chip { color: #405779; display: flex; align-items: center; gap: 7px; background: #f3f6fb; border-radius: 999px; border: 1px solid #edf1f8; padding: 6px 10px; white-space: nowrap; font-size: .83rem; }
  .local-chip .signal { width: 6px; height: 6px; box-shadow: none; }
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line);
    border-radius: 9px; min-height: 37px; padding: 7px 11px; color: #34445e; background: #fff; line-height: 1.25;
    font-weight: 640; white-space: nowrap; text-decoration: none;
  }
  .btn:hover { background: #f6f8fc; border-color: #ccd7e9; }
  .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 1px 2px #20397829; }
  .btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
  .btn.soft { color: var(--brand-dark); background: var(--brand-pale); border-color: transparent; }
  .btn.soft:hover { background: #dce7ff; }
  .btn.flat, .icon-btn { background: transparent; border-color: transparent; }
  .btn.flat:hover, .icon-btn:hover { background: #eaf0fa; border-color: transparent; }
  .btn.danger { color: var(--bad); background: #fff5f7; border-color: #f8dae1; }
  .btn.danger:hover { background: #ffe7ee; }
  .btn.small { font-size: .86rem; padding-inline: 9px; min-height: 32px; }
  .icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; color: inherit; border: 1px solid transparent; border-radius: 8px; flex: none; }
  .icon-btn.tiny { width: 27px; height: 27px; }
  .month-heading { gap: 13px; }
  .month-title { border: 0; background: none; display: flex; align-items: center; gap: 7px; padding: 0; color: inherit; text-align: left; }
  .month-title .icon { color: var(--muted); }
  .date-controls { gap: 0; background: white; border: 1px solid var(--line); border-radius: 9px; }
  .date-controls button { border-radius: 8px; }
  .date-controls button + button { border-left: 1px solid var(--line); border-radius: 0 8px 8px 0; }
  .ready-card {
    --ready-text: #123f34; --ready-soft: #2c6558; --ready-edge: #cce8dc;
    position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; gap: 15px; padding: 18px 19px; min-height: 100px;
    border: 1px solid var(--ready-edge); background: linear-gradient(110deg, #e7f7ed, #dcf3eb); border-radius: var(--radius);
    color: var(--ready-text); margin-bottom: 16px;
  }
  .ready-card::after {
    content: ''; position: absolute; z-index: -1; width: 270px; height: 270px; border: 1px solid #82bfad35; border-radius: 50%;
    right: -50px; top: -90px; box-shadow: inset 0 0 0 24px #badfce27, inset 0 0 0 48px #b3dbcb22, inset 0 0 0 72px #a5d5c320;
  }
  .ready-card.ready-danger { --ready-text: #7f1c33; --ready-soft: #923852; --ready-edge: #f5c3cc; background: #fff0f3; }
  .ready-card.ready-neutral { --ready-text: #27355a; --ready-soft: #546483; --ready-edge: #dce5f6; background: #edf2ff; }
  .ready-coin { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 13px; background: #ffffff88; border: 1px solid #ffffffb5; color: var(--ready-soft); }
  .ready-line { flex: 1; min-width: 0; }
  .ready-label { color: var(--ready-soft); display: flex; align-items: center; gap: 3px; font-weight: 660; font-size: .9rem; }
  .ready-label .icon-btn { height: 24px; width: 24px; }
  .ready-label .icon-btn:hover { background: #ffffffaf; }
  .ready-value { display: block; margin-top: 2px; font-size: clamp(1.75rem, 2.75vw, 2.4rem); font-weight: 760; line-height: 1.04; letter-spacing: -.042em; }
  .ready-cta { background: #155943; border-color: #155943; color: white; }
  .ready-cta:hover { background: #104732; border-color: #104732; }
  .ready-danger .ready-cta { background: #a42e48; border-color: #a42e48; }
  .panel { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); min-width: 0; box-shadow: 0 2px 4px #2c407104; }
  .panel-title { padding: 17px 17px 0; font-size: 1.04rem; font-weight: 730; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 17px; }
  .panel-head h2 { font-size: 1.04rem; }
  .toolbar {
    padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    flex-wrap: wrap; border-bottom: 1px solid var(--line);
  }
  .filters { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
  .chip {
    background: transparent; color: #526582; border: 1px solid transparent; border-radius: 8px; min-height: 31px;
    padding: 5px 9px; white-space: nowrap; font-weight: 610; font-size: .84rem;
  }
  .chip:hover { background: #f0f4fa; }
  .chip.active { background: var(--brand-pale); color: var(--brand-dark); }
  .chip .filter-count { display: inline-block; min-width: 16px; margin-left: 2px; color: #68572e; background: #fff0d4; padding: 1px 4px; border-radius: 5px; font-size: .72rem; }
  .table-wrap { min-width: 0; }
  table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: .92rem; }
  .budget-table col:first-child { width: 45%; }
  .budget-table col:not(:first-child) { width: 18.333%; }
  thead th {
    background: #f9fafd; color: #5d6d88; font-weight: 670; text-align: right; font-size: .78rem; white-space: nowrap;
    height: 35px; padding: 8px 13px; border-bottom: 1px solid var(--line);
  }
  thead th:first-child { text-align: left; padding-left: 15px; }
  .budget-table td { padding: 0 13px; min-width: 0; height: 46px; border-bottom: 1px solid var(--line-soft); text-align: right; }
  .budget-table td:first-child { padding-left: 15px; text-align: left; }
  .budget-table tbody:last-child tr:last-child td { border-bottom: 0; }
  .group-row td { height: 38px; font-weight: 710; font-size: .81rem; background: #f4f6fc; color: #405474; border-bottom-color: #e7ebf4; }
  .group-label, .category-name {
    display: flex; align-items: center; text-align: left; gap: 8px; border: 0; background: none; padding: 0;
    color: inherit; max-width: 100%; min-width: 0;
  }
  .group-label { min-height: 33px; font-weight: inherit; }
  .group-label:hover { color: var(--brand-dark); }
  .group-label .multi, .category-name .multi { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .category-row:hover td { background: #f9fbff; }
  .category-row.is-selected td { background: #eef3ff; }
  .category-row.is-selected td:first-child { box-shadow: inset 3px 0 var(--brand); }
  .category-name { font-weight: 650; }
  .category-name:hover { color: var(--brand-dark); }
  .category-dot { display: grid; place-items: center; flex: none; width: 25px; height: 25px; border-radius: 7px; background: #eef2fb; color: #506a9a; }
  .category-dot.g1 { background: #edf2ff; color: #4b66ba; }
  .category-dot.g2 { background: #e9f6f2; color: #327d6e; }
  .category-dot.g3 { background: #f0ecfc; color: #785aba; }
  .category-dot.g4 { background: #f7effa; color: #895b9a; }
  .amount-edit, .activity-btn, .pill, .status-btn {
    display: inline-flex; align-items: center; justify-content: flex-end; color: inherit; border: 1px solid transparent;
    background: none; padding: 5px 6px; min-height: 29px; border-radius: 7px; max-width: 100%;
  }
  .amount-edit:hover, .activity-btn:hover { color: var(--brand-dark); background: var(--brand-pale); border-color: #dce6ff; }
  .activity-btn { color: #566783; padding-inline: 0; }
  .activity-btn.zero { color: #8390a5; }
  .amount-edit.input-wrap { padding: 0; width: min(100%, 117px); }
  .amount-edit input { text-align: right; width: 100%; min-width: 0; background: white; color: var(--ink); padding: 4px 6px; border: 1px solid #83a2f8; border-radius: 7px; }
  .pill { display: inline-flex; gap: 4px; justify-content: center; font-weight: 710; font-size: .86rem; min-width: 56px; padding: 4px 8px; min-height: 26px; }
  button.pill:hover { filter: saturate(1.18) brightness(.97); }
  .pill.positive { background: var(--good-bg); color: var(--good); }
  .pill.warning { background: var(--warn-bg); color: var(--warn); }
  .pill.danger { background: var(--bad-bg); color: var(--bad); }
  .pill.neutral { background: #f0f3f8; color: #5f708d; }
  .table-footer { padding: 11px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
  .inspector-card { padding: 16px 16px 14px; }
  .inspector-card h2 { font-size: 1.07rem; font-weight: 730; }
  .inspector-card h3 { font-size: .91rem; font-weight: 710; }
  .inspector-subtitle { color: var(--muted); font-size: .83rem; margin: 6px 0 13px; line-height: 1.45; }
  .period-label { font-size: .81rem; color: var(--muted); margin-top: 5px; }
  .summary-list { margin: 13px 0 0; display: grid; gap: 0; }
  .stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 0; color: #4b5f80; font-size: .88rem; }
  .stat-row .stat-value { color: var(--ink); margin: 0; font-weight: 650; }
  .stat-row .stat-value.bad-text { color: var(--bad); }
  .stat-row .stat-value.good-text { color: var(--good); }
  .stat-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-weight: 690; color: var(--ink); }
  .summary-highlight { border: 1px solid #d6e7e1; background: #f0faf5; border-radius: 9px; padding: 9px 10px; margin-top: 7px; }
  .summary-highlight .stat-value { color: var(--good); }
  .goal-info { background: #f5f7fe; border: 1px solid #e6ebf8; border-radius: 10px; padding: 10px; margin-top: 12px; }
  .goal-info .goal-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .82rem; }
  .progress { height: 6px; border-radius: 999px; background: #e1e8f5; overflow: hidden; margin: 9px 0 6px; }
  .progress i { display: block; height: 100%; background: #2c65e4; border-radius: inherit; }
  .progress i.complete { background: #2a9d76; }
  .hint { font-size: .82rem; color: var(--muted); line-height: 1.45; }
  .inspector-actions { display: grid; gap: 7px; margin-top: 12px; }
  .inspector-actions .btn { justify-content: flex-start; white-space: normal; text-align: left; }
  .summary-button { display: flex; align-items: center; gap: 9px; color: #354c75; font-weight: 640; border: 1px solid var(--line); background: #f8faff; border-radius: 8px; padding: 8px 9px; width: 100%; text-align: left; min-height: 36px; font-size: .85rem; }
  .summary-button:hover { background: #edf3ff; }
  .summary-button .later { margin-left: auto; }
  .sync-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff5df; border: 1px solid #f2db9f; border-radius: 10px; padding: 10px 13px; margin-bottom: 14px; color: #72501c; }
  .demo-inline { border: 1px solid #dce6fd; background: #f3f7ff; color: #2f497c; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; margin-bottom: 13px; }
  .demo-inline p { flex: 1; line-height: 1.35; font-size: .84rem; }
  .empty { padding: 31px 18px; text-align: center; color: var(--muted); line-height: 1.5; }
  .empty .empty-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--brand-pale); color: var(--brand-dark); margin-bottom: 9px; }
  .empty h3 { color: var(--ink); font-size: 1.12rem; margin-bottom: 8px; }
  .empty .btn { margin-top: 12px; }
  .balances { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 17px; }
  .balance-tile { padding: 15px 17px; min-width: 0; }
  .balance-tile + .balance-tile { border-left: 1px solid var(--line); }
  .balance-tile .muted { font-size: .85rem; display: block; line-height: 1.4; }
  .balance-tile strong { display: block; margin-top: 4px; font-size: clamp(1.03rem, 2vw, 1.52rem); font-weight: 730; letter-spacing: -.03em; }
  .account-title { display: flex; align-items: center; gap: 9px; }
  .ledger .table-wrap { overflow: auto; }
  .ledger-table { min-width: 655px; }
  .ledger-table th:nth-child(2), .ledger-table th:nth-child(3), .ledger-table th:nth-child(4) { text-align: left; }
  .ledger-table th:first-child { width: 42px; }
  .ledger-table th:nth-child(2) { width: 90px; }
  .ledger-table th:nth-child(3) { width: 24%; }
  .ledger-table th:nth-child(4) { width: 25%; }
  .ledger-table th:last-child { width: 48px; }
  .ledger-table td { border-bottom: 1px solid var(--line-soft); padding: 8px 9px; height: 45px; }
  .ledger-table tr:hover td { background: #f8faff; }
  .ledger-table td:nth-last-child(2) { text-align: right; }
  .ledger-table td:first-child, .ledger-table td:last-child { text-align: center; }
  .ledger-table td:nth-child(3), .ledger-table td:nth-child(4) { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
  .ledger-table .activity-btn { color: var(--ink); font-weight: 650; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ledger-table .memo { color: var(--muted); display: block; font-size: .79rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
  .status-btn { border-radius: 50%; align-items: center; justify-content: center; min-height: 27px; width: 27px; padding: 0; }
  .status-btn.open { border-color: #e5eaf1; color: #8192a9; }
  .status-btn.cleared { background: #e6f6ec; color: #167453; }
  .status-btn.reconciled { background: #e9efff; color: #3e60ab; }
  .schedule-list { display: grid; margin-bottom: 15px; }
  .schedule-item { padding: 9px 13px; border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: 34px minmax(0,1fr) auto auto; align-items: center; gap: 8px; }
  .schedule-item .category-name small { display: block; color: var(--muted); }
  .schedule-item .due { color: var(--warn); font-weight: 620; }
  .search-box { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fafbfe; border-radius: 8px; padding: 0 8px; color: var(--muted); }
  .search-box input { border: 0; background: none; min-height: 32px; padding: 3px 0; color: var(--ink); width: min(170px, 34vw); }
  .search-box:focus-within { border-color: #7497f8; }
  .search-box input:focus { outline: none; }
  .filter-select { min-height: 33px; width: auto; }
  .report-toolbar { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 11px; background: white; }
  .report-grid { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr); gap: 16px; }
  .report-content { padding: 18px; min-width: 0; }
  .report-content h2 { font-size: 1.14rem; margin-bottom: 6px; }
  .metric { font-size: 1.8rem; font-weight: 750; letter-spacing: -.035em; margin-top: 4px; }
  .donut { width: min(220px, 65vw); aspect-ratio: 1; border-radius: 50%; margin: 19px auto; display: grid; place-items: center; }
  .donut-hole { width: 77%; height: 77%; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; }
  .donut-hole .metric { font-size: clamp(1.09rem, 2.1vw, 1.51rem); }
  .report-list { list-style: none; padding: 0; margin: 11px 0 0; }
  .report-list li { display: flex; align-items: baseline; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
  .report-list li:last-child { border-bottom: 0; }
  .chart-color { width: 8px; height: 8px; border-radius: 50%; flex: none; }
  .report-list .legend-name { flex: 1; overflow-wrap: anywhere; }
  .report-list .legend-share { color: var(--muted); min-width: 43px; text-align: right; font-size: .83rem; }
  .bar-chart { display: flex; align-items: stretch; justify-content: space-around; gap: 4px; min-height: 166px; margin: 13px 0 6px; }
  .bar-column { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; }
  .bar-space { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line); }
  .bar-space i { width: min(15px, 40%); background: #638bf4; border-radius: 4px 4px 0 0; }
  .bar-space i.expense { background: #6ac6aa; }
  .bar-space i.debt { background: #eb8698; }
  .bar-column small { color: var(--muted); font-size: .71rem; text-align: center; }
  .settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
  .setting-panel { padding: 17px; }
  .setting-panel h2 { display: flex; align-items: center; gap: 9px; font-size: 1.09rem; margin-bottom: 7px; }
  .setting-panel p { color: var(--muted); font-size: .88rem; line-height: 1.5; margin-bottom: 12px; }
  .setting-panel .actions { flex-wrap: wrap; }
  .startup { display: grid; align-content: center; justify-items: center; text-align: center; min-height: 100dvh; padding: 22px; gap: 9px; }
  .startup h1 { font-size: 1.7rem; }
  .startup p { color: var(--muted); }
  .pair-card { width: min(100%, 420px); padding: 26px; margin-top: 6px; text-align: left; }
  .pair-card .btn { margin-top: 11px; width: 100%; }
  .pair-card code { font-family: inherit; }
  form { margin: 0; }
  label.field { display: grid; gap: 5px; color: #344660; font-weight: 650; font-size: .88rem; min-width: 0; }
  label.field > small { color: var(--muted); font-size: .78rem; font-weight: 450; line-height: 1.3; }
  input:not([type="checkbox"], [type="radio"]), select, textarea { color: var(--ink); }
  .field input, .field select, .field textarea, .filter-select, .split-line input, .split-line select {
    min-width: 0; width: 100%; border: 1px solid #d9e1ee; border-radius: 8px; padding: 8px 9px; background: #fff; min-height: 38px;
  }
  .field textarea { resize: vertical; min-height: 80px; }
  .field input::placeholder, .search-box input::placeholder { color: #8291a8; }
  .field select, .filter-select { padding-right: 5px; }
  .filter-select { width: auto; font-size: .86rem; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .form-grid .full { grid-column: 1/-1; }
  .form-stack { display: grid; gap: 11px; }
  .field-check { display: flex; align-items: center; gap: 8px; font-weight: 580; color: #425570; }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }
  .form-error { min-height: 0; margin-top: 7px; font-size: .86rem; color: var(--bad); line-height: 1.4; }
  .form-error:empty { display: none; }
  .dialog-copy { color: var(--muted); line-height: 1.48; margin-bottom: 12px; }
  dialog {
    color: var(--ink); padding: 0; border-radius: 17px; border: 1px solid #dce4f0;
    width: min(520px, calc(100% - 27px)); max-width: none; max-height: min(86dvh, 780px); overflow: auto;
    box-shadow: 0 24px 70px #1b285445; overscroll-behavior: contain;
  }
  dialog.wide { width: min(680px, calc(100% - 27px)); }
  dialog::backdrop { background: #111b3980; backdrop-filter: blur(2px); }
  .dialog-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 13px 16px 13px 19px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; background: white; }
  .dialog-head h2 { font-size: 1.23rem; font-weight: 740; }
  .dialog-body { padding: 16px 19px 18px; }
  .dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; border-top: 1px solid var(--line); padding: 12px 19px; background: #fafbff; }
  .dialog-foot .spacer { margin-right: auto; }
  .dialog-card { border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: #f8faff; }
  .dialog-card + .dialog-card { margin-top: 7px; }
  .dialog-card .stat-row { padding: 4px 0; }
  .option-btn { display: flex; align-items: center; gap: 9px; padding: 9px; width: 100%; text-align: left; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; background: white; }
  .option-btn:hover { background: #f2f6ff; border-color: #d9e4fc; }
  .option-btn .option-main { flex: 1; }
  .option-btn .option-main small { display: block; color: var(--muted); margin-top: 2px; }
  .option-btn.active { border-color: #a3b9ff; background: #f0f5ff; }
  .split-line { display: grid; grid-template-columns: minmax(0, 1fr) 105px 32px; gap: 6px; align-items: center; margin-bottom: 5px; }
  .number-cell { text-align: right; }
  .pill-note { font-size: .81rem; color: var(--muted); }
  .import-preview { max-height: 185px; overflow-y: auto; margin-top: 9px; }
  .bank-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
  .bank-review { max-height: 46dvh; overflow: auto; padding: 2px; }
  .bank-review .stat-row { align-items: start; gap: 12px; }
  .bank-review .stat-row strong:first-child { overflow-wrap: anywhere; }
  .bank-review .field { margin-top: 8px; }
  .bank-review .num { white-space: nowrap; }
  .bank-pages { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
  .bank-opening { margin-top: 12px; line-height: 1.5; }
  [hidden] { display: none !important; }
  .pair-address { display: block; overflow-wrap: anywhere; font-size: .9rem; padding: 4px 0; }
  .key-display { color: var(--ink); font-size: 1.12rem; letter-spacing: .035em; overflow-wrap: anywhere; padding: 6px 0 2px; display: block; }
  .report-years { align-items: end; }
  #toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 16px); z-index: 20;
    padding: 11px 15px; border-radius: 10px; background: #172543; color: white; opacity: 0; pointer-events: none;
    transition: opacity .16s, transform .16s; max-width: calc(100vw - 30px); width: max-content; box-shadow: 0 4px 20px #17254340; line-height: 1.35;
  }
  #toast.visible { opacity: 1; transform: translate(-50%, 0); }
}

@layer responsive {
  .mobile-only, .mobile-nav, .scrim { display: none; }
  @media (max-width: 1250px) {
    .shell { grid-template-columns: 219px minmax(0, 1fr); }
    .sidebar { padding-inline: 13px; }
    .body { padding-inline: 23px; }
    .topbar { padding-inline: 23px; }
    .columns { grid-template-columns: minmax(0, 1fr) minmax(228px, 265px); gap: 14px; }
    .budget-table td, thead th { padding-inline: 8px; }
  }
  @media (max-width: 1000px) {
    .shell { grid-template-columns: 191px minmax(0, 1fr); }
    .columns { grid-template-columns: minmax(0, 1fr); }
    .inspector { position: static; max-height: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inspector .inspector-card:first-child:last-child { grid-column: 1 / -1; }
    .sidebar { padding-inline: 10px; }
    .nav-btn .balance { font-size: .75rem; }
    .body { padding-inline: 17px; }
    .topbar { padding-inline: 17px; }
    .mobile-summary { display: inline-flex !important; }
  }
  @media (min-width: 1001px) { .mobile-summary { display: none !important; } }
  @media (max-width: 720px) {
    .shell { display: block; }
    .sidebar { display: none; }
    .sidebar.is-open {
      display: flex; position: fixed; left: 0; top: 0; z-index: 12; width: min(278px, 87vw); padding: max(17px, env(safe-area-inset-top)) 14px 15px;
      box-shadow: 10px 0 35px #0e173552;
    }
    .scrim.is-open { display: block !important; position: fixed; inset: 0; z-index: 11; background: #151d488c; border: 0; width: 100%; height: 100%; }
    .topbar { min-height: 54px; padding: max(4px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left)); }
    .topbar .crumb { gap: 3px; }
    .topbar .desktop-label { display: none; }
    .topbar .local-chip { font-size: .77rem; padding: 5px 7px; }
    .body { padding: 14px max(10px, env(safe-area-inset-right)) calc(90px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
    .page-heading { margin-bottom: 11px; min-height: 39px; }
    .page-heading h1 { font-size: clamp(1.42rem, 5.3vw, 1.83rem); }
    .month-heading { gap: 7px; }
    .month-title { gap: 4px; }
    .date-controls .icon-btn { width: 30px; height: 31px; }
    .actions { gap: 6px; }
    .desktop-only { display: none !important; }
    .mobile-only { display: inline-flex !important; }
    .mobile-nav {
      display: grid !important; grid-template-columns: repeat(4,minmax(0,1fr)); position: fixed; bottom: 0; left: 0; right: 0; z-index: 8;
      border-top: 1px solid var(--line); background: #fffffffa; padding: 5px max(5px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left)); min-height: 59px;
    }
    .mobile-nav button { min-width: 0; display: grid; justify-items: center; align-content: center; gap: 3px; padding: 4px 2px; border: 0; border-radius: 9px; color: #687998; background: transparent; font-size: .73rem; font-weight: 650; }
    .mobile-nav button.active { color: var(--brand-dark); background: #eff4ff; }
    .mobile-nav .mobile-add span:first-child { display: grid; place-items: center; width: 30px; height: 26px; border-radius: 7px; color: #fff; background: var(--brand); }
    .ready-card { padding: 12px 11px; min-height: 76px; gap: 9px; margin-bottom: 11px; border-radius: 12px; }
    .ready-coin { width: 35px; height: 35px; border-radius: 10px; }
    .ready-coin .icon { width: 20px; height: 20px; }
    .ready-value { font-size: clamp(1.35rem, 6.4vw, 1.87rem); }
    .ready-label { font-size: .8rem; }
    .ready-cta { padding-inline: 7px; min-height: 32px; font-size: .82rem; }
    .panel { border-radius: 12px; }
    .toolbar { gap: 5px; padding: 8px; }
    .filters { gap: 2px; }
    .chip { font-size: .79rem; padding-inline: 6px; min-height: 29px; }
    .table-wrap { overflow-x: hidden; }
    .budget-table col:first-child { width: 50%; }
    .budget-table col:not(:first-child) { width: 25%; }
    .budget-table col.money-activity, .budget-table .money-activity { display: none; }
    .budget-table td, .budget-table th { padding-inline: 5px; }
    .budget-table td:first-child, .budget-table th:first-child { padding-left: 8px; }
    .budget-table td:last-child, .budget-table th:last-child { padding-right: 8px; }
    .category-row .category-name { gap: 5px; font-size: .89rem; }
    .category-name .multi { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.14; }
    .category-dot { width: 21px; height: 21px; border-radius: 6px; }
    .category-dot .icon { width: 13px; height: 13px; }
    .pill { font-size: .79rem; min-width: 46px; padding-inline: 5px; }
    .group-row td { font-size: .76rem; height: 35px; }
    .group-label { gap: 4px; }
    .amount-edit { font-size: .86rem; }
    .amount-edit input, .field input, .field select, .field textarea, .split-line input, .split-line select { font-size: 16px; }
    .inspector { display: none; }
    .mobile-detail .inspector-card { border: 0; padding: 0; box-shadow: none; }
    .mobile-detail .inspector-card + .inspector-card { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 12px; }
    .report-grid, .settings-grid { grid-template-columns: minmax(0,1fr); }
    .balance-tile { padding: 11px 7px; }
    .balance-tile .muted { font-size: .76rem; }
    .balance-tile strong { font-size: clamp(.88rem, 3.36vw, 1.18rem); white-space: normal; overflow-wrap: anywhere; }
    .ledger .table-wrap { overflow-x: hidden; }
    .ledger-table { min-width: 0; }
    .ledger-table th:first-child { width: 0; }
    .ledger-table td:first-child, .ledger-table th:first-child { display: none; }
    .ledger-table th:nth-child(2) { width: 54px; padding-left: 8px; }
    .ledger-table th:nth-child(3) { width: auto; }
    .ledger-table td:nth-child(4), .ledger-table th:nth-child(4) { display: none; }
    .ledger-table th:nth-last-child(2) { width: 84px; }
    .ledger-table th:last-child { width: 32px; font-size: 0; }
    .ledger-table td, .ledger-table th { padding-inline: 4px; }
    .ledger-table td:nth-child(2) { padding-left: 8px; font-size: .76rem; }
    .ledger-table .memo { font-size: .72rem; }
    .schedule-item { grid-template-columns: 21px minmax(0,1fr) auto auto; padding-inline: 7px; gap: 5px; }
    .schedule-item > .num { font-size: .78rem; }
    .schedule-item .btn { min-height: 30px; padding-inline: 5px; font-size: .77rem; }
    .demo-inline { padding: 8px; gap: 6px; }
    .demo-inline .btn { padding-inline: 6px; white-space: normal; }
    dialog { max-height: calc(100dvh - 25px); }
    .dialog-head { padding-inline: 12px; }
    .dialog-body { padding-inline: 12px; }
    .dialog-foot { padding-inline: 12px; }
    #toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  }
  @media (max-width: 360px) {
    .group-row .num { font-size: .7rem; }
    .ready-coin { display: none; }
    .ledger-table th:nth-last-child(2) { width: 74px; }
    .report-content { padding: 12px; }
    .form-grid { gap: 8px; }
  }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
}
