:root {
  --ink: #17231e;
  --ink-soft: #405148;
  --muted: #75827b;
  --line: #dfe5df;
  --line-strong: #cbd5cd;
  --canvas: #f3f5f1;
  --paper: #ffffff;
  --green: #1d5c45;
  --green-dark: #143e30;
  --green-light: #e5f2ea;
  --lime: #ceef86;
  --income: #25835c;
  --income-soft: #e7f5ed;
  --expense: #c85b43;
  --expense-soft: #fbede9;
  --gold: #b7862e;
  --gold-soft: #f8f0df;
  --blue: #3e6f97;
  --shadow: 0 12px 30px rgba(24, 48, 36, .07);
  --shadow-sm: 0 4px 14px rgba(24, 48, 36, .06);
  --radius: 18px;
  --radius-sm: 12px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
svg { display: block; }
[hidden] { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#i-grid path, #i-wallet path, #i-bank path, #i-cash path, #i-phone path { fill: none; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: #8a9c91; font-size: 11px; line-height: 1; font-weight: 750; letter-spacing: .16em; }
.align-right { text-align: right !important; }

.button {
  min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 650; text-decoration: none; white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button .icon { width: 17px; height: 17px; }
.button-primary { color: white; background: var(--green); box-shadow: 0 5px 14px rgba(29, 92, 69, .18); }
.button-primary:hover { background: var(--green-dark); box-shadow: 0 8px 20px rgba(29, 92, 69, .22); }
.button-secondary { border-color: var(--line-strong); background: var(--paper); color: var(--ink-soft); }
.button-secondary:hover { border-color: #aebeb2; background: #fbfcfa; }
.button-ghost { background: var(--green-light); color: var(--green); }
.button-ghost:hover { background: #d9ebdf; }
.button-block { width: 100%; }
.button-compact { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.icon-button { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.icon-button:hover { background: #edf1ec; color: var(--ink); }
.text-button { display: inline-flex; align-items: center; gap: 2px; border: 0; padding: 5px 0; background: transparent; color: var(--green); font-size: 13px; font-weight: 650; }
.text-button .icon { width: 16px; height: 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 20px; font-weight: 760; letter-spacing: -.03em; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: inline-grid; place-items: center; color: var(--green-dark); background: var(--lime); font-size: 18px; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(20, 62, 48, .08); }
.brand-light { color: white; }
.brand-light .brand-mark { color: var(--green-dark); }

/* Login */
.login-view { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: #fff; }
.login-art { position: relative; overflow: hidden; color: white; background: #143e30; display: flex; align-items: stretch; padding: clamp(34px, 5vw, 76px); }
.login-art::before { content: ""; position: absolute; width: 620px; height: 620px; border: 1px solid rgba(206, 239, 134, .17); border-radius: 50%; right: -230px; top: -250px; box-shadow: 0 0 0 78px rgba(206, 239, 134, .025), 0 0 0 160px rgba(206, 239, 134, .02); }
.login-art::after { content: ""; position: absolute; inset: 0; opacity: .28; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 54px 54px; mask-image: linear-gradient(to bottom right, black, transparent 75%); }
.login-art-inner { position: relative; z-index: 1; width: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 48px; }
.login-copy { max-width: 620px; }
.login-copy h1 { margin: 14px 0 24px; font-size: clamp(40px, 4.6vw, 70px); line-height: 1.13; letter-spacing: -.055em; font-weight: 680; }
.login-copy > p:last-child { max-width: 480px; margin: 0; color: rgba(255,255,255,.65); font-size: 16px; line-height: 1.8; }
.login-art .eyebrow { color: var(--lime); }
.login-points { display: flex; gap: 22px; flex-wrap: wrap; color: rgba(255,255,255,.73); font-size: 13px; }
.login-points span { display: inline-flex; align-items: center; gap: 7px; }
.login-points .icon { width: 15px; height: 15px; color: var(--lime); stroke-width: 2.3; }
.login-panel { display: grid; place-items: center; padding: clamp(24px, 5vw, 72px); background: #fbfcfa; }
.login-card { width: min(100%, 410px); }
.login-card h2 { margin: 0 0 10px; font-size: 31px; line-height: 1.2; letter-spacing: -.04em; }
.login-card > .muted { margin: 0 0 32px; font-size: 14px; }
.login-card .field { margin-bottom: 19px; }
.login-card .button { margin-top: 4px; min-height: 48px; border-radius: 12px; }
.login-mobile-brand { display: none; align-items: center; gap: 11px; margin-bottom: 48px; font-size: 20px; font-weight: 760; }
.secure-note { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.secure-note .icon { width: 15px; height: 15px; margin-top: 1px; }

/* Form controls */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span, .amount-field > span { color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.field small { color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; outline: 0; transition: border-color .15s, box-shadow .15s, background .15s; }
input, select { height: 44px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #a5aea8; }
input:focus, select:focus, textarea:focus { border-color: #6a9b83; box-shadow: 0 0 0 3px rgba(54, 122, 91, .11); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7d8a82 50%), linear-gradient(135deg, #7d8a82 50%, transparent 50%); background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.form-error { min-height: 18px; margin: 8px 0 10px; color: #b54434; font-size: 12px; line-height: 1.5; }
input[type="color"] { width: 62px; height: 40px; padding: 4px; cursor: pointer; }
input[type="date"], input[type="month"] { color-scheme: light; }

/* App layout */
.app-shell { min-height: 100dvh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 232px; padding: 28px 18px 20px; background: #163b2d; color: white; display: flex; flex-direction: column; }
.sidebar .brand { padding: 0 10px 36px; }
.side-nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item { width: 100%; height: 48px; padding: 0 13px; border: 0; border-radius: 11px; background: transparent; color: rgba(255,255,255,.61); display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 570; text-align: left; transition: background .16s, color .16s; }
.nav-item .icon { width: 19px; height: 19px; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active { color: var(--green-dark); background: var(--lime); font-weight: 680; }
.sidebar-foot { margin-top: auto; padding: 18px 5px 0 7px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.user-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.user-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user-meta small { color: rgba(255,255,255,.44); font-size: 10px; }
.avatar { width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; background: rgba(206,239,134,.14); color: var(--lime); font-size: 13px; font-weight: 700; }
.avatar-small { width: 34px; height: 34px; background: var(--green-light); color: var(--green); }
.sidebar .icon-button { color: rgba(255,255,255,.5); }
.sidebar .icon-button:hover { color: #fff; background: rgba(255,255,255,.08); }
.main { min-height: 100vh; margin-left: 232px; }
.topbar { position: sticky; z-index: 20; top: 0; height: 76px; padding: 0 clamp(22px, 3vw, 46px); border-bottom: 1px solid rgba(216,224,217,.8); background: rgba(243,245,241,.86); backdrop-filter: blur(16px); display: flex; align-items: center; justify-content: flex-end; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.month-control { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.8); display: flex; align-items: center; gap: 8px; }
.month-control-label { color: var(--muted); font-size: 12px; }
.month-control input { width: 132px; height: 30px; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 13px; font-weight: 650; }
.mobile-brand { display: none; }
.page-container { width: min(100%, 1420px); margin: 0 auto; padding: 35px clamp(22px, 3vw, 46px) 70px; }
.page { animation: page-in .24s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-heading { min-height: 67px; margin-bottom: 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; }
.page-heading h1 { margin: 0; font-size: clamp(27px, 2.6vw, 38px); line-height: 1.15; letter-spacing: -.045em; font-weight: 720; }
.page-heading .muted { margin: 8px 0 0; font-size: 13px; }
.heading-actions { display: flex; align-items: center; gap: 9px; }

/* Cards and panels */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { position: relative; min-height: 148px; padding: 20px 20px 18px; overflow: hidden; border: 1px solid rgba(217,225,218,.95); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; justify-content: space-between; }
.stat-card::after { content: ""; position: absolute; width: 105px; height: 105px; top: -58px; right: -43px; border-radius: 50%; background: currentColor; opacity: .045; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { color: var(--ink-soft); font-size: 13px; font-weight: 570; }
.stat-icon { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center; background: #f2f5f2; color: var(--muted); }
.stat-icon .icon { width: 16px; height: 16px; }
.stat-value { margin: 18px 0 10px; color: var(--ink); font-size: clamp(23px, 2.1vw, 30px); line-height: 1; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.stat-hint { color: #8a958e; font-size: 11px; }
.income-card .stat-icon { color: var(--income); background: var(--income-soft); }
.expense-card .stat-icon { color: var(--expense); background: var(--expense-soft); }
.profit-card .stat-icon { color: var(--gold); background: var(--gold-soft); }
.balance-card .stat-icon { color: var(--blue); background: #eaf1f7; }
.stat-value.negative { color: var(--expense); }
.panel { border: 1px solid rgba(217,225,218,.96); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow-sm); }
.panel-head { min-height: 67px; padding: 18px 20px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-head h2, .data-panel h2 { margin: 0; font-size: 15px; line-height: 1.4; font-weight: 700; letter-spacing: -.015em; }
.panel-head p, .data-panel p { margin: 4px 0 0; font-size: 11px; }
.panel-icon { width: 18px; height: 18px; color: #a0ada5; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(290px, .85fr); gap: 16px; margin-bottom: 16px; }
.chart-panel, .breakdown-panel { min-height: 345px; }
.legend { display: flex; align-items: center; gap: 14px; padding-top: 6px; color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.income-dot { background: var(--income); }
.expense-dot { background: var(--expense); }
.chart-wrap { position: relative; height: 255px; padding: 2px 14px 12px 6px; }
#trendChart { width: 100%; height: 100%; display: block; }
.empty-inline { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.breakdown-list { padding: 2px 20px 20px; display: flex; flex-direction: column; gap: 15px; }
.breakdown-empty { padding: 36px 8px; color: var(--muted); font-size: 12px; text-align: center; }
.breakdown-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 12px; align-items: center; }
.breakdown-name { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-soft); font-size: 12px; }
.breakdown-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-color { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.breakdown-amount { color: var(--ink); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.breakdown-track { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 10px; background: #f0f3ef; }
.breakdown-fill { height: 100%; min-width: 2px; border-radius: inherit; }
.recent-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 40px; padding: 0 18px; border-top: 1px solid #edf0ec; border-bottom: 1px solid #edf0ec; background: #fafbf9; color: #89958d; font-size: 10px; font-weight: 620; text-align: left; letter-spacing: .03em; white-space: nowrap; }
td { height: 58px; padding: 8px 18px; border-bottom: 1px solid #eff2ee; color: var(--ink-soft); font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: #fafcf9; }
.date-cell { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-category { display: flex; align-items: center; gap: 9px; min-width: 130px; }
.category-mark { width: 29px; height: 29px; flex: none; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.category-copy { display: flex; flex-direction: column; gap: 2px; }
.category-copy strong { color: var(--ink); font-size: 12px; font-weight: 620; }
.category-copy small { font-size: 9px; }
.type-income { color: var(--income); }
.type-expense { color: var(--expense); }
.counterparty { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.amount-cell { font-size: 13px; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-income { color: var(--income); }
.amount-expense { color: var(--ink); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: .2; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.row-actions .icon-button { width: 30px; height: 30px; }
.row-actions .icon { width: 15px; height: 15px; }
.mobile-transactions { display: none; }

/* Ledger */
.ledger-panel { overflow: hidden; }
.filter-bar { padding: 18px 20px 12px; display: grid; grid-template-columns: minmax(230px, 1fr) 150px 150px 150px; gap: 9px; }
.filter-bar select { height: 40px; font-size: 12px; }
.search-box { position: relative; }
.search-box .icon { position: absolute; z-index: 1; width: 17px; height: 17px; left: 13px; top: 12px; color: #91a097; }
.search-box input { height: 40px; padding-left: 40px; font-size: 12px; background: #fafbf9; }
.ledger-summary { padding: 2px 20px 12px; color: var(--muted); font-size: 11px; }
.ledger-panel .table-wrap { border-top: 1px solid #edf0ec; }
.pagination { min-height: 58px; padding: 10px 18px; display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.pagination button { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-soft); background: #fff; font-size: 11px; }
.pagination button:hover:not(:disabled) { background: var(--green-light); border-color: #b9d3c3; }
.pagination button.active { border-color: var(--green); background: var(--green); color: #fff; }
.pagination .page-info { margin-right: auto; color: var(--muted); font-size: 11px; }
.empty-state { padding: 58px 20px; text-align: center; }
.empty-icon { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; background: #eff4ef; color: #8aa093; display: grid; place-items: center; }
.empty-icon .icon { width: 23px; height: 23px; }
.empty-state h3 { margin: 0 0 7px; font-size: 15px; }
.empty-state p { margin: 0 0 20px; color: var(--muted); font-size: 12px; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.settings-panel { overflow: hidden; }
.settings-list { border-top: 1px solid #edf0ec; }
.setting-item { min-height: 68px; padding: 11px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #eff2ee; }
.setting-item:last-child { border-bottom: 0; }
.setting-mark { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--mark) 12%, white); color: var(--mark); }
.setting-mark .icon { width: 17px; height: 17px; }
.setting-copy { min-width: 0; flex: 1; }
.setting-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12px; font-weight: 640; }
.setting-copy small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.setting-balance { padding-right: 4px; color: var(--ink-soft); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.category-tabs { padding: 0 18px 12px; display: flex; gap: 7px; }
.category-tabs button { height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff; color: var(--muted); font-size: 11px; }
.category-tabs button.active { border-color: #b9d3c3; background: var(--green-light); color: var(--green); font-weight: 650; }
.data-panel { padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.data-actions { display: flex; gap: 8px; }

/* Dialogs */
.dialog { width: min(calc(100% - 30px), 640px); max-height: calc(100dvh - 30px); margin: auto; padding: 0; overflow: auto; border: 0; border-radius: 22px; background: transparent; box-shadow: 0 30px 90px rgba(10, 35, 23, .3); }
.dialog::backdrop { background: rgba(11, 27, 19, .55); backdrop-filter: blur(4px); }
.dialog[open] { animation: dialog-in .2s ease both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.dialog-card { padding: 25px; background: #fff; }
.dialog-card-small { max-width: 470px; }
.dialog-head { margin-bottom: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog-head h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.type-switch { height: 45px; padding: 4px; margin-bottom: 20px; border-radius: 11px; background: #f0f3ef; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.type-switch button { border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 13px; font-weight: 620; }
.type-switch button .icon { width: 16px; height: 16px; }
.type-switch button.active.expense { color: var(--expense); background: #fff; box-shadow: 0 2px 8px rgba(30,50,40,.08); }
.type-switch button.active.income { color: var(--income); background: #fff; box-shadow: 0 2px 8px rgba(30,50,40,.08); }
.amount-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 19px; }
.amount-input { height: 67px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fbfcfb; display: flex; align-items: center; gap: 7px; }
.amount-input:focus-within { border-color: #6a9b83; box-shadow: 0 0 0 3px rgba(54,122,91,.11); }
.amount-input span { color: var(--muted); font-size: 23px; }
.amount-input input { height: auto; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 34px; font-weight: 680; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dialog-actions { margin-top: 7px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 30px; padding: 11px 17px; border-radius: 10px; background: #1b2d24; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.22); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline-banner { position: fixed; z-index: 80; top: 0; left: 0; right: 0; padding: 7px 16px; background: #a84b38; color: #fff; text-align: center; font-size: 11px; }
.mobile-fab, .mobile-nav { display: none; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(55, 123, 91, .22); outline-offset: 2px; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .breakdown-panel { min-height: 0; }
  .breakdown-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
  .settings-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: minmax(220px, 1fr) repeat(3, 130px); }
}

@media (max-width: 880px) {
  .login-view { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-panel { min-height: 100dvh; background: radial-gradient(circle at 85% 8%, #e9f1e9 0, transparent 32%), #fbfcfa; }
  .login-mobile-brand { display: flex; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: 72px; }
  .topbar { height: 65px; padding: 0 18px; justify-content: space-between; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 16px; font-weight: 760; }
  .mobile-brand .brand-mark { width: 31px; height: 31px; border-radius: 9px; font-size: 14px; }
  .month-control-label, #topAvatar { display: none; }
  .month-control { padding: 0 8px; background: #fff; }
  .month-control input { width: 120px; }
  .page-container { padding: 27px 18px 40px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 29px; }
  .page-heading .heading-actions .button-secondary { display: none; }
  .mobile-fab { position: fixed; z-index: 35; right: 20px; bottom: 82px; width: 50px; height: 50px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--green); box-shadow: 0 10px 25px rgba(29,92,69,.3); }
  .mobile-fab .icon { width: 23px; height: 23px; stroke-width: 2.2; }
  .mobile-nav { position: fixed; z-index: 34; left: 0; right: 0; bottom: 0; height: calc(66px + env(safe-area-inset-bottom)); padding: 7px 16px env(safe-area-inset-bottom); border-top: 1px solid #dde5de; background: rgba(255,255,255,.95); backdrop-filter: blur(18px); display: grid; grid-template-columns: repeat(3, 1fr); }
  .mobile-nav button { border: 0; background: transparent; color: #89958d; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; }
  .mobile-nav button .icon { width: 21px; height: 21px; }
  .mobile-nav button.active { color: var(--green); font-weight: 650; }
  .mobile-nav button.active .icon { stroke-width: 2.2; }
  .toast { bottom: 85px; }
}

@media (max-width: 680px) {
  .topbar { padding: 0 14px; }
  .topbar-actions { gap: 8px; }
  #quickAddTop { display: none; }
  .month-control { height: 36px; }
  .month-control input { width: 112px; font-size: 12px; }
  .page-container { padding: 22px 14px 35px; }
  .page-heading { min-height: 0; margin-bottom: 20px; }
  .page-heading h1 { font-size: 26px; }
  .page-heading .muted { font-size: 11px; }
  .page-heading > .button { display: none; }
  .page-heading .heading-actions .button-primary { min-height: 37px; padding: 0 12px; font-size: 12px; }
  .stat-grid { gap: 9px; margin-bottom: 10px; }
  .stat-card { min-height: 125px; padding: 15px 14px; border-radius: 15px; }
  .stat-label { font-size: 11px; }
  .stat-icon { width: 27px; height: 27px; border-radius: 8px; }
  .stat-icon .icon { width: 14px; height: 14px; }
  .stat-value { margin: 14px 0 8px; font-size: 22px; }
  .stat-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
  .dashboard-grid { gap: 10px; margin-bottom: 10px; }
  .panel { border-radius: 15px; }
  .panel-head { min-height: 60px; padding: 15px 15px 11px; }
  .panel-head h2 { font-size: 14px; }
  .chart-panel { min-height: 305px; }
  .chart-wrap { height: 225px; padding-right: 8px; }
  .legend { gap: 9px; }
  .breakdown-list { padding: 0 15px 16px; grid-template-columns: 1fr; gap: 13px; }
  .recent-panel { margin-bottom: 0; }
  .desktop-table { display: none !important; }
  .mobile-transactions { display: flex; flex-direction: column; }
  .mobile-tx { min-height: 68px; padding: 11px 15px; border-top: 1px solid #eff2ee; display: flex; align-items: center; gap: 10px; }
  .mobile-tx-main { flex: 1; min-width: 0; }
  .mobile-tx-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
  .mobile-tx-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .mobile-tx-meta { margin-top: 5px; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-tx-amount { font-size: 13px; font-weight: 680; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .mobile-tx-more { width: 27px; height: 27px; padding: 0; border: 0; border-radius: 7px; background: #f3f6f2; color: #87948c; display: grid; place-items: center; }
  .mobile-tx-more .icon { width: 14px; height: 14px; }
  .mobile-empty { padding: 35px 15px; text-align: center; color: var(--muted); font-size: 11px; }
  .filter-bar { padding: 13px 14px 9px; grid-template-columns: 1fr 1fr; gap: 8px; }
  .search-box { grid-column: 1 / -1; }
  .filter-bar select { font-size: 11px; }
  .ledger-summary { padding: 3px 14px 10px; }
  .pagination { padding: 9px 13px; }
  .pagination .page-info { display: none; }
  .settings-grid { gap: 10px; margin-bottom: 10px; }
  .setting-item { padding-left: 14px; padding-right: 14px; }
  .data-panel { padding: 17px 15px; align-items: flex-start; flex-direction: column; }
  .data-actions { width: 100%; }
  .data-actions .button { width: 100%; }
  .dialog { width: 100%; max-height: calc(100dvh - 20px); margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .dialog-card { padding: 21px 17px calc(20px + env(safe-area-inset-bottom)); }
  .dialog-head h2 { font-size: 21px; }
  .form-grid { grid-template-columns: 1fr; gap: 13px; }
  .amount-input { height: 61px; }
  .amount-input input { font-size: 31px; }
  .dialog-actions .button { flex: 1; }
}

@media (max-width: 390px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 112px; }
  .stat-value { font-size: 24px; }
  .page-heading h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.button-danger { border-color: #efd2cb; background: #fff; color: #b64d39; }
.button-danger:hover { border-color: #deaa9f; background: #fff8f6; }
.dialog-spacer { flex: 1; }
@media (max-width: 680px) { .dialog-actions { flex-wrap: wrap; } .dialog-actions .dialog-spacer { display: none; } .dialog-actions .button-danger { flex: 0 0 100%; order: 3; } }
.breakdown-meta, .page-ellipsis { display: none; }
.settings-empty { position: static; padding: 32px 16px; }
.setting-actions { display: flex; gap: 1px; margin-left: 3px; }
.setting-actions .icon-button { width: 30px; height: 30px; }
.setting-actions .icon { width: 15px; height: 15px; }
.category-setting-mark { font-size: 13px; font-weight: 750; }
.pagination .icon { width: 15px; height: 15px; }
.pagination button { display: inline-flex; align-items: center; justify-content: center; }
.panel, .dashboard-grid > *, .chart-wrap { min-width: 0; }
#trendChart { width: 100% !important; height: 100% !important; }
.setting-item.inactive { background: #fbfcfb; }
.setting-item.inactive .setting-mark, .setting-item.inactive .setting-copy strong, .setting-item.inactive .setting-balance { opacity: .52; }
@supports (padding-top: env(safe-area-inset-top)) {
  @media (max-width: 880px) {
    .topbar { height: calc(65px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
    .login-panel { padding-top: calc(clamp(24px, 5vw, 72px) + env(safe-area-inset-top)); }
  }
}
