:root {
  color-scheme: light;
  --ink: #18221c;
  --ink-2: #33413a;
  --paper: #f4f1ea;
  --card: #fffefa;
  --line: #e5e0d7;
  --muted: #7d817d;
  --muted-2: #a5a49e;
  --coral: #d66a47;
  --coral-soft: #f5ded6;
  --green: #4e8067;
  --green-soft: #dcebe2;
  --sand: #c49c55;
  --sand-soft: #f0e6d0;
  --purple: #7770aa;
  --shadow: 0 14px 40px rgba(30, 34, 29, .055);
  --radius: 22px;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(214, 106, 71, .24); outline-offset: 2px; }

.hidden { display: none !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  background: var(--paper);
  color: var(--muted);
  transition: opacity .25s ease;
}

.loading-screen p { margin-top: 18px; font-size: 13px; letter-spacing: .08em; }
.loading-screen .brand-mark { animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.9); opacity: .58; } }

.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 750; letter-spacing: .08em; }
.brand-light { color: #fff; }
.brand-mark { position: relative; display: inline-flex; align-items: end; justify-content: center; gap: 3px; width: 34px; height: 34px; padding: 8px 7px; flex: 0 0 auto; border-radius: 10px; color: white; background: var(--ink); }
.brand-light .brand-mark { color: var(--ink); background: #f6f1e6; }
.brand-mark span { display: block; width: 4px; border-radius: 4px; background: currentColor; }
.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 13px; }

.eyebrow { margin: 0 0 12px; color: #c8d3cc; font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow.dark { color: var(--coral); }
.muted { color: var(--muted); }

/* Authentication */
.auth-screen { display: grid; grid-template-columns: minmax(420px, 1.08fr) minmax(430px, .92fr); min-height: 100vh; }
.auth-story { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 48px 7vw 56px; overflow: hidden; color: white; background: var(--ink); }
.auth-story::before { content: ""; position: absolute; width: 560px; height: 560px; right: -270px; top: 10%; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; box-shadow: 0 0 0 80px rgba(255,255,255,.025), 0 0 0 160px rgba(255,255,255,.018); }
.auth-story::after { content: ""; position: absolute; width: 170px; height: 240px; right: 10%; bottom: 12%; border: 1px solid rgba(255,255,255,.07); transform: rotate(33deg); }
.auth-story > * { position: relative; z-index: 1; }
.auth-story-copy { max-width: 580px; margin: auto 0; padding: 80px 0; }
.auth-story-copy h1 { max-width: 540px; margin: 0 0 26px; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(48px, 5.2vw, 82px); font-weight: 500; line-height: 1.15; letter-spacing: -.04em; }
.auth-story-copy > p:last-child { max-width: 430px; margin: 0; color: #b8c1bb; font-size: 17px; line-height: 1.9; }
.auth-quote { color: #929e97; font-family: Georgia, "Noto Serif SC", serif; font-size: 14px; line-height: 1.8; }
.auth-quote span { display: inline-block; margin-right: 8px; color: var(--coral); font-size: 36px; vertical-align: -15px; }
.auth-panel { display: grid; place-items: center; padding: 42px; background: #f8f6f1; }
.auth-box { width: min(420px, 100%); }
.auth-box h2 { margin: 0 0 12px; font-family: Georgia, "Noto Serif SC", serif; font-size: 38px; font-weight: 500; }
.auth-box > .muted { margin: 0 0 38px; font-size: 14px; }
.auth-form { display: grid; gap: 20px; }
label { display: grid; gap: 9px; color: var(--ink-2); font-size: 13px; font-weight: 650; }
input, select { width: 100%; min-height: 46px; padding: 0 14px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover { border-color: #cfc8bc; }
input:focus, select:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(214,106,71,.09); }
input::placeholder { color: #b6b6b1; }
.form-error { min-height: 18px; margin: -6px 0 0; color: #b44037; font-size: 12px; line-height: 1.5; }
.privacy-note { margin: 26px 0 0; color: var(--muted-2); font-size: 11px; line-height: 1.7; text-align: center; }
.mobile-auth-brand { display: none; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; font-size: 13px; font-weight: 700; cursor: pointer; transition: transform .15s ease, background .15s ease, opacity .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-primary { color: #fff; background: var(--ink); box-shadow: 0 7px 18px rgba(24,34,28,.12); }
.button-primary:hover { background: #27362d; }
.button-secondary { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.button-danger { color: #fff; background: #b94c3e; }
.button-block { width: 100%; min-height: 50px; margin-top: 2px; }
.button-small { min-height: 38px; padding: 0 13px; }
.button svg { width: 17px; height: 17px; }

/* Shell */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; justify-content: space-between; width: 244px; padding: 36px 26px 28px; background: #eeece6; border-right: 1px solid var(--line); }
.sidebar .brand { margin: 0 12px 54px; }
.main-nav { display: grid; gap: 8px; }
.nav-item { display: flex; align-items: center; gap: 14px; width: 100%; height: 48px; padding: 0 15px; color: #747a75; background: transparent; border: 0; border-radius: 12px; font-size: 14px; cursor: pointer; text-align: left; }
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.45); }
.nav-item.active { color: white; background: var(--ink); box-shadow: 0 10px 20px rgba(24,34,28,.1); }
.nav-item svg { width: 19px; height: 19px; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 19px 4px 0; border-top: 1px solid #ddd8cf; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip > span { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; color: white; background: var(--coral); border-radius: 50%; font-size: 13px; font-weight: 750; }
.user-chip div { min-width: 0; }
.user-chip b, .user-chip small { display: block; max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip b { font-size: 12px; }
.user-chip small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: rgba(255,255,255,.7); }
.icon-button svg { width: 18px; height: 18px; }

.content { min-height: 100vh; margin-left: 244px; padding: 44px clamp(32px, 4vw, 66px) 70px; }
.view { display: none; max-width: 1500px; margin: 0 auto; }
.view.active-view { display: block; animation: viewIn .28s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 34px; }
.page-header h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(30px, 3vw, 43px); font-weight: 500; line-height: 1.2; letter-spacing: -.03em; }
.page-header .eyebrow { margin-bottom: 9px; }
.page-description { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 12px; }
.month-control { position: relative; display: flex; grid-template: none; align-items: center; min-width: 160px; }
.month-control svg { position: absolute; left: 13px; z-index: 1; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.month-control input { min-height: 44px; padding-left: 40px; font-size: 13px; font-weight: 600; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.summary-card { position: relative; min-height: 172px; padding: 23px 25px; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-card.dark-card { color: white; background: var(--ink); border-color: var(--ink); }
.summary-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 650; }
.dark-card .summary-top { color: #abb4ae; }
.summary-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.summary-icon svg { width: 16px; height: 16px; }
.summary-icon.coral { color: #fff; background: var(--coral); }
.summary-icon.green { color: var(--green); background: var(--green-soft); }
.summary-icon.sand { color: #9a7536; background: var(--sand-soft); }
.summary-card strong { position: relative; z-index: 1; display: block; margin-top: 15px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(25px, 2.2vw, 36px); font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary-card p { position: relative; z-index: 1; margin: 12px 0 0; color: var(--muted-2); font-size: 11px; }
.dark-card p { color: #98a29c; }
.card-decoration { position: absolute; right: -28px; bottom: -56px; width: 155px; height: 155px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; box-shadow: 0 0 0 25px rgba(255,255,255,.022), 0 0 0 50px rgba(255,255,255,.012); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, 1fr); gap: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.daily-panel, .category-panel, .monthly-panel, .recent-panel { min-height: 340px; padding: 25px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.panel-heading h2 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 18px; font-weight: 550; }
.panel-heading p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.legend-group { display: flex; gap: 15px; }
.legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.coral-dot { background: var(--coral); }
.green-dot { background: var(--green); }
.chart-wrap { position: relative; width: 100%; min-height: 245px; }
.chart-wrap svg { display: block; width: 100%; height: 245px; overflow: visible; }
.chart-grid-line { stroke: #e9e5dd; stroke-width: 1; stroke-dasharray: 3 5; }
.chart-label { fill: #94968f; font-family: "Segoe UI", sans-serif; font-size: 9px; }
.chart-area { fill: url(#daily-gradient); stroke: none; }
.chart-line { fill: none; stroke: var(--coral); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { fill: var(--card); stroke: var(--coral); stroke-width: 2; }
.chart-point:hover { r: 5; }
.monthly-expense-line { fill: none; stroke: var(--coral); stroke-width: 2.3; }
.monthly-income-line { fill: none; stroke: var(--green); stroke-width: 2.3; }
.chart-tooltip { position: absolute; z-index: 4; padding: 8px 10px; color: white; background: var(--ink); border-radius: 8px; font-size: 10px; pointer-events: none; transform: translate(-50%, -120%); white-space: nowrap; box-shadow: 0 5px 14px rgba(0,0,0,.15); }
.empty-state { display: grid; place-items: center; min-height: 210px; color: var(--muted); text-align: center; }
.empty-state div { max-width: 220px; }
.empty-state .empty-symbol { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 14px; color: #a8aaa5; background: #f2efe9; border-radius: 18px; font-size: 26px; }
.empty-state b { display: block; margin-bottom: 7px; color: var(--ink-2); font-size: 13px; }
.empty-state p { margin: 0; font-size: 11px; line-height: 1.6; }

.category-chart { display: grid; grid-template-columns: minmax(128px, .85fr) minmax(145px, 1.15fr); align-items: center; gap: 22px; min-height: 235px; }
.donut-wrap { position: relative; width: min(170px, 100%); aspect-ratio: 1; margin: auto; }
.donut { position: absolute; inset: 0; border-radius: 50%; }
.donut::after { content: ""; position: absolute; inset: 21%; background: var(--card); border-radius: 50%; }
.donut-center { position: absolute; z-index: 2; inset: 29%; display: grid; place-content: center; text-align: center; }
.donut-center small { color: var(--muted); font-size: 9px; }
.donut-center b { margin-top: 3px; font-family: Georgia, serif; font-size: 15px; font-weight: 550; }
.category-legend { display: grid; gap: 12px; }
.category-legend-row { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 8px; font-size: 11px; }
.category-legend-row i { width: 7px; height: 7px; border-radius: 50%; }
.category-legend-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.category-legend-row b { font-size: 10px; font-weight: 650; }

.monthly-panel { min-height: 350px; }
.recent-panel { min-height: 350px; }
.text-button { display: inline-flex; align-items: center; gap: 3px; padding: 5px; color: var(--coral); background: transparent; border: 0; font-size: 10px; font-weight: 650; cursor: pointer; }
.text-button svg { width: 13px; height: 13px; }
.transaction-list { display: grid; }
.transaction-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; min-height: 55px; border-bottom: 1px solid #eeeae3; }
.transaction-row:last-child { border-bottom: 0; }
.category-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; font-size: 15px; }
.transaction-main { min-width: 0; }
.transaction-main b, .transaction-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-main b { font-size: 11px; }
.transaction-main small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.transaction-amount { font-family: Georgia, serif; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transaction-amount.expense { color: var(--ink); }
.transaction-amount.income { color: var(--green); }

/* Transactions */
.filter-panel { margin-bottom: 17px; padding: 15px; }
.filter-row { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(130px, .55fr) minmax(140px, .65fr) minmax(160px, .7fr) auto; gap: 10px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 14px; width: 17px; height: 17px; color: var(--muted); }
.search-box input { padding-left: 42px; }
.select-control select { appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237d817d' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center; }
.transactions-panel { overflow: hidden; }
.table-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; padding: 0 24px; background: #faf8f3; border-bottom: 1px solid var(--line); }
.table-summary p { font-size: 12px; font-weight: 700; }
.table-summary div { display: flex; gap: 25px; color: var(--muted); font-size: 11px; }
.table-summary b { margin-left: 5px; }
.income-text { color: var(--green); }
.expense-text { color: var(--coral); }
.transactions-table { min-height: 300px; }
.table-head, .table-row { display: grid; grid-template-columns: 115px minmax(150px,1fr) minmax(120px,.7fr) minmax(150px,1.2fr) 125px 86px; align-items: center; gap: 15px; padding: 0 24px; }
.table-head { min-height: 47px; color: var(--muted); background: #fdfcf9; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 650; }
.table-row { min-height: 66px; border-bottom: 1px solid #efebe4; font-size: 11px; }
.table-row:last-child { border-bottom: 0; }
.table-row:hover { background: #fdfbf7; }
.table-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.table-category { display: flex; align-items: center; gap: 9px; min-width: 0; }
.table-category .category-icon { width: 31px; height: 31px; border-radius: 9px; font-size: 13px; }
.table-category span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.table-note { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.table-actions { display: flex; justify-content: flex-end; }
.table-actions .icon-button { width: 32px; height: 32px; }
.table-actions .delete-button:hover { color: #b94c3e; background: #f8e7e2; }
.mobile-transaction-card { display: none; }

/* Categories */
.category-manage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.category-manage-panel { padding: 25px; }
.count-badge { padding: 6px 9px; color: var(--muted); background: #f0ede7; border-radius: 999px; font-size: 10px; }
.category-manage-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.category-manage-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 64px; padding: 10px; background: #faf8f4; border: 1px solid #eeeae2; border-radius: 14px; }
.category-manage-item .category-icon { width: 37px; height: 37px; }
.category-manage-item b, .category-manage-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-manage-item b { font-size: 11px; }
.category-manage-item small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.category-manage-item .icon-button { width: 30px; height: 30px; }
.category-manage-item .icon-button:hover { color: #b94c3e; background: #f8e7e2; }

/* Modals */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(21, 29, 24, .58); backdrop-filter: blur(4px); }
.modal { width: min(540px, calc(100vw - 32px)); padding: 0; background: var(--card); border: 0; border-radius: 24px; box-shadow: 0 25px 80px rgba(18,25,21,.25); }
.modal[open] { animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal form { display: grid; gap: 19px; padding: 28px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; }
.modal-header h2 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 26px; font-weight: 500; }
.modal-header .eyebrow { margin-bottom: 6px; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #eeebe5; border-radius: 12px; }
.type-switch button { height: 38px; color: var(--muted); background: transparent; border: 0; border-radius: 9px; font-size: 12px; font-weight: 700; cursor: pointer; }
.type-switch button.active { color: white; background: var(--ink); box-shadow: 0 4px 10px rgba(24,34,28,.12); }
.amount-field { gap: 4px; }
.amount-field > div { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.amount-field b { font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.amount-field input { height: 64px; padding: 0 12px; font-family: Georgia, serif; font-size: 37px; border: 0; border-radius: 0; box-shadow: none; }
.amount-field input:focus { box-shadow: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 3px; }
.small-modal { width: min(440px, calc(100vw - 32px)); }
.color-field { padding: 0; border: 0; }
.color-field legend { margin-bottom: 10px; color: var(--ink-2); font-size: 13px; font-weight: 650; }
.color-options { display: flex; flex-wrap: wrap; gap: 10px; }
.color-option { position: relative; width: 31px; height: 31px; padding: 0; border: 3px solid var(--card); border-radius: 50%; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.color-option.active::after { content: ""; position: absolute; inset: 8px; background: white; border-radius: 50%; }
.confirm-dialog { width: min(390px, calc(100vw - 32px)); padding: 30px; text-align: center; background: var(--card); border: 0; border-radius: 22px; box-shadow: 0 25px 80px rgba(18,25,21,.25); }
.confirm-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 16px; color: #b94c3e; background: #f6ded8; border-radius: 16px; }
.confirm-dialog h2 { margin: 0 0 10px; font-family: Georgia, "Noto Serif SC", serif; font-size: 23px; font-weight: 500; }
.confirm-dialog p { margin: 0 0 23px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.confirm-dialog .modal-actions { justify-content: center; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 30px; max-width: calc(100vw - 30px); padding: 11px 17px; color: white; background: var(--ink); border-radius: 10px; box-shadow: 0 10px 30px rgba(19,27,22,.2); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a94439; }
.mobile-header, .mobile-nav { display: none; }

@media (max-width: 1180px) {
  .sidebar { width: 214px; padding-left: 18px; padding-right: 18px; }
  .content { margin-left: 214px; padding-left: 28px; padding-right: 28px; }
  .dashboard-grid { grid-template-columns: 1.45fr 1fr; }
  .category-chart { gap: 12px; }
  .filter-row { grid-template-columns: minmax(180px,1fr) repeat(3,minmax(125px,.65fr)); }
  .filter-row .button { grid-column: 4; }
  .table-head, .table-row { grid-template-columns: 100px minmax(130px,1fr) 110px minmax(120px,1fr) 110px 74px; gap: 10px; padding-left: 18px; padding-right: 18px; }
  .category-manage-list { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-story { display: none; }
  .auth-panel { min-height: 100vh; padding: 32px 22px; }
  .mobile-auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 52px; font-size: 20px; }
  .sidebar { width: 82px; padding: 30px 14px; }
  .sidebar .brand { margin: 0 auto 48px; justify-content: center; }
  .sidebar .brand > span:last-child, .nav-item span, .user-chip div, .sidebar-footer .icon-button { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-footer { justify-content: center; }
  .content { margin-left: 82px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .category-panel { order: 2; }
  .monthly-panel { order: 3; }
  .recent-panel { order: 4; }
  .category-chart { grid-template-columns: 180px 1fr; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row .search-box { grid-column: 1 / -1; }
  .filter-row .button { grid-column: auto; }
  .table-head { display: none; }
  .table-row { grid-template-columns: 90px minmax(130px,1fr) minmax(100px,1fr) 110px 70px; }
  .table-row .table-note { display: none; }
}

@media (max-width: 680px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { display: none; }
  .mobile-header { position: sticky; z-index: 15; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 66px; padding: 10px 18px; background: rgba(244,241,234,.92); border-bottom: 1px solid rgba(229,224,215,.8); backdrop-filter: blur(16px); }
  .mobile-header .brand { font-size: 19px; }
  .mobile-header .brand-mark { width: 31px; height: 31px; }
  .mobile-nav { position: fixed; z-index: 30; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; display: grid; grid-template-columns: repeat(3,1fr); height: 62px; padding: 5px; background: rgba(24,34,28,.96); border: 1px solid rgba(255,255,255,.08); border-radius: 19px; box-shadow: 0 12px 35px rgba(18,26,21,.25); backdrop-filter: blur(16px); }
  .mobile-nav button { display: grid; place-content: center; justify-items: center; gap: 3px; color: #8f9b94; background: transparent; border: 0; border-radius: 14px; font-size: 9px; }
  .mobile-nav button.active { color: white; background: rgba(255,255,255,.1); }
  .mobile-nav svg { width: 19px; height: 19px; }
  .content { margin-left: 0; padding: 26px 15px 100px; }
  .page-header { align-items: flex-start; margin-bottom: 24px; }
  .page-header h1 { font-size: 30px; }
  .page-header .page-actions { display: block; }
  .page-header .page-actions .button { display: none; }
  .month-control { min-width: 148px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .summary-card { min-height: 145px; padding: 18px; border-radius: 18px; }
  .summary-card:first-child { grid-column: 1 / -1; min-height: 154px; }
  .summary-card strong { margin-top: 12px; font-size: 27px; }
  .summary-card p { margin-top: 9px; }
  .dashboard-grid { gap: 11px; }
  .daily-panel, .category-panel, .monthly-panel, .recent-panel { min-height: 320px; padding: 19px; border-radius: 18px; }
  .panel-heading { margin-bottom: 18px; }
  .chart-wrap, .chart-wrap svg { min-height: 230px; height: 230px; }
  .category-chart { grid-template-columns: 140px 1fr; gap: 11px; min-height: 235px; }
  .category-legend { gap: 10px; }
  .desktop-only { display: none; }
  #view-transactions .page-header, #view-categories .page-header { align-items: center; }
  #view-categories .page-header .button { min-width: 44px; padding: 0 12px; font-size: 0; }
  #view-categories .page-header .button svg { margin: 0; }
  .filter-panel { padding: 11px; border-radius: 17px; }
  .filter-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-row .search-box { grid-column: 1 / -1; }
  .filter-row .month-control { min-width: 0; }
  .filter-row .button { padding: 0 10px; }
  .transactions-panel { border-radius: 17px; }
  .table-summary { align-items: flex-start; min-height: 72px; padding: 14px 16px; }
  .table-summary p { margin: 2px 0; }
  .table-summary div { display: grid; justify-items: end; gap: 4px; }
  .table-row { display: none; }
  .mobile-transaction-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 78px; padding: 12px 14px; border-bottom: 1px solid #eeeae3; }
  .mobile-transaction-card:last-child { border-bottom: 0; }
  .mobile-transaction-card .mobile-card-end { display: grid; justify-items: end; gap: 6px; }
  .mobile-transaction-card .table-actions .icon-button { width: 27px; height: 27px; }
  .mobile-transaction-card .table-actions svg { width: 14px; height: 14px; }
  .category-manage-grid { grid-template-columns: 1fr; gap: 11px; }
  .category-manage-panel { padding: 19px; border-radius: 18px; }
  .category-manage-list { grid-template-columns: 1fr 1fr; gap: 8px; }
  .category-manage-item { min-height: 60px; padding: 8px; }
  .category-manage-item .category-icon { width: 34px; height: 34px; }
  .modal { margin-bottom: max(12px, env(safe-area-inset-bottom)); border-radius: 22px; }
  .modal form { padding: 23px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .amount-field input { height: 57px; font-size: 34px; }
  .toast { bottom: 88px; }
}

@media (max-width: 410px) {
  .page-header h1 { font-size: 27px; }
  .summary-card { padding: 16px; }
  .summary-card strong { font-size: 23px; }
  .month-control { min-width: 136px; }
  .month-control input { padding-left: 36px; padding-right: 7px; }
  .category-chart { grid-template-columns: 125px 1fr; }
  .category-manage-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
