:root {
  color-scheme: light;
  --canvas: #edf1f3;
  --surface: #ffffff;
  --surface-2: #f5f7f8;
  --surface-3: #e9eef1;
  --header: #25333e;
  --header-text: #eef2f4;
  --text: #26323c;
  --muted: #6d7983;
  --line: #dce3e7;
  --input: #ffffff;
  --hover: #f1f4f5;
  --primary: #4e748b;
  --primary-strong: #365c73;
  --primary-soft: #e6eef2;
  --green: #4f806f;
  --green-soft: #e8f1ed;
  --red: #a95e65;
  --red-soft: #f5e9eb;
  --amber: #987742;
  --amber-soft: #f4efe5;
  --shadow: 0 12px 30px rgba(31, 49, 62, .07);
  --radius: 12px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #11181e;
  --surface: #1b252e;
  --surface-2: #222e38;
  --surface-3: #2a3742;
  --header: #0d141a;
  --header-text: #e8edf1;
  --text: #dbe2e7;
  --muted: #94a0aa;
  --line: #34424d;
  --input: #202b35;
  --hover: #26333d;
  --primary: #779ab1;
  --primary-strong: #8eb1c6;
  --primary-soft: #283b49;
  --green: #78a392;
  --green-soft: #233a34;
  --red: #c67d83;
  --red-soft: #452e32;
  --amber: #bea16c;
  --amber-soft: #403728;
  --shadow: 0 14px 34px rgba(0, 0, 0, .23);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); }
body { min-width: 320px; min-height: 100%; margin: 0; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
button { color: inherit; }
input, select, textarea { color: var(--text); }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }
.app-shell.auth-hidden { display: none; }

.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: max(28px,env(safe-area-inset-top)) 20px max(28px,env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 0,#dfe8ed 0,transparent 44%),var(--canvas); }
html[data-theme="dark"] .auth-gate { background: radial-gradient(circle at 50% 0,#243641 0,transparent 44%),var(--canvas); }
.auth-card { width: min(440px,100%); padding: 38px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 24px 70px rgba(31,49,62,.13); text-align: center; }
.auth-brand { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 13px; color: #fff; background: var(--header); font-size: 13px; font-weight: 900; letter-spacing: .06em; }
.auth-card > small { color: var(--primary); font-size: 9px; font-weight: 850; letter-spacing: .13em; }
.auth-card h1 { margin: 12px 0 10px; font-size: clamp(25px,5vw,34px); line-height: 1.08; letter-spacing: -.045em; }
.auth-card > p { margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.6; }
.auth-sign-in { width: 100%; min-height: 48px; display: grid; place-items: center; margin-top: 25px; }
.google-identity-sign-in { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.google-identity-sign-in > div, .google-identity-sign-in iframe { max-width: 100% !important; }
.google-identity-sign-in.is-busy { opacity: .58; pointer-events: none; }
.google-sign-in { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface); font-size: 12px; font-weight: 800; box-shadow: 0 6px 18px rgba(31,49,62,.06); }
.google-sign-in:hover { background: var(--hover); }
.google-sign-in:disabled { opacity: .58; cursor: wait; }
.google-sign-in span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #4e748b; font-size: 10px; }
.auth-install { margin-top: 11px; padding: 8px 12px; border: 0; color: var(--primary); background: transparent; font-size: 9px; font-weight: 800; }
.auth-install:hover { text-decoration: underline; }
.auth-message { min-height: 19px; margin-top: 11px !important; color: var(--red) !important; font-size: 10px !important; }
.auth-security { display: grid; gap: 4px; margin-top: 18px; padding: 13px; border-radius: 9px; color: var(--muted); background: var(--surface-2); text-align: left; }
.auth-security b { color: var(--text); font-size: 9px; }
.auth-security span { font-size: 8px; line-height: 1.5; }

.app-header { position: sticky; top: 0; z-index: 50; padding-top: env(safe-area-inset-top); border-bottom: 1px solid rgba(255,255,255,.08); background: var(--header); box-shadow: 0 3px 12px rgba(0,0,0,.08); }
.header-inner { min-height: 64px; display: flex; align-items: stretch; padding: 0 24px; }
.brand { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 0 22px 0 0; border: 0; border-right: 1px solid rgba(255,255,255,.09); color: var(--header-text); background: transparent; text-align: left; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: #607d8d; font-size: 10px; font-weight: 850; letter-spacing: .05em; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: 13px; }
.brand small { margin-top: 1px; color: #9db0bc; font-size: 8px; }
.desktop-nav { min-width: 0; display: flex; align-items: stretch; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.desktop-nav::-webkit-scrollbar { display: none; }
.nav-item { flex: 0 0 auto; position: relative; min-width: 0; border: 0; padding: 0 13px; color: #afbdc6; background: transparent; font-size: 10px; font-weight: 700; white-space: nowrap; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.045); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active::after { content: ""; position: absolute; right: 13px; bottom: 0; left: 13px; height: 3px; border-radius: 3px 3px 0 0; background: #8aa9ba; }
.header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; margin-left: auto; padding-left: 12px; }
.sync-state { display: flex; align-items: center; gap: 7px; color: #b9c6ce; font-size: 9px; }
.sync-state i { width: 7px; height: 7px; border-radius: 50%; background: #7fb19d; box-shadow: 0 0 0 3px rgba(127,177,157,.13); }
.sync-state.offline i { background: #c19153; }
.sync-state.syncing i { background: #7f9eb1; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
.icon-action, .data-menu summary { min-height: 36px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 0 10px; color: #cad4da; background: rgba(255,255,255,.04); font-size: 10px; font-weight: 750; }
.icon-action { width: 38px; }
.icon-action:hover, .data-menu summary:hover { color: #fff; background: rgba(255,255,255,.08); }
.data-menu { position: relative; }
.data-menu summary { list-style: none; }
.data-menu summary::-webkit-details-marker { display: none; }
.data-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 70; width: 238px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.data-popover a, .data-popover button { width: 100%; display: block; padding: 10px; border: 0; border-radius: 7px; color: var(--text); background: transparent; text-align: left; text-decoration: none; }
.data-popover a:hover, .data-popover button:hover { background: var(--hover); }
.data-popover b, .data-popover small { display: block; }
.data-popover b { font-size: 10px; }
.data-popover small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.primary-button, .secondary-button, .ghost-button, .strip-button, .apply-button { min-height: 42px; border: 0; border-radius: 9px; padding: 0 16px; font-size: 11px; font-weight: 800; transition: .15s ease; }
.primary-button { color: #fff; background: var(--primary); box-shadow: 0 7px 18px rgba(53,89,111,.16); }
.primary-button:hover, .apply-button:hover { filter: brightness(.93); }
.secondary-button { border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.secondary-button:hover { background: var(--hover); }
.ghost-button { color: var(--muted); background: transparent; }
.header-create { min-height: 36px; padding: 0 14px; border-radius: 8px; background: #527f70; box-shadow: none; }
.full { width: 100%; }

.page-bar { position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 40; min-height: 70px; display: flex; align-items: center; gap: 20px; padding: 10px 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }
.page-bar > div:first-child { min-width: 0; }
.page-bar span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 700; }
.page-bar h1 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.page-controls { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.month-field { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.month-field span { margin: 0; text-transform: uppercase; font-size: 7px; letter-spacing: .05em; }
.month-field input { width: 155px; border: 0; outline: 0; background: transparent; font-size: 10px; font-weight: 800; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip > span { width: 31px; height: 31px; display: grid; place-items: center; margin: 0; border-radius: 50%; color: #fff; background: #687d89; font-size: 10px; }
.user-chip b, .user-chip small { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip b { font-size: 9px; }
.user-chip small { margin-top: 2px; color: var(--muted); font-size: 7px; }
.offline-banner { position: sticky; top: calc(134px + env(safe-area-inset-top)); z-index: 35; padding: 10px 28px; color: #795d2d; background: var(--amber-soft); font-size: 10px; }

.content { width: min(1760px, 100%); margin: 0 auto; padding: 24px 28px calc(48px + env(safe-area-inset-bottom)); }
.view { display: none; animation: enter .18s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.section-heading, .subheading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2, .subheading h3 { margin: 0; letter-spacing: -.025em; }
.section-heading h2 { font-size: 19px; }
.subheading { margin-top: 28px; }
.subheading h3 { font-size: 15px; }
.section-heading p, .subheading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.button-row { display: flex; gap: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.metric { min-height: 118px; display: flex; align-items: flex-start; gap: 13px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 18px rgba(20,35,46,.025); }
.metric-icon { flex: 0 0 35px; height: 35px; display: grid; place-items: center; border-radius: 9px; font-weight: 900; }
.metric.income .metric-icon { color: var(--green); background: var(--green-soft); }
.metric.expense .metric-icon { color: var(--red); background: var(--red-soft); }
.metric.result .metric-icon { color: var(--primary); background: var(--primary-soft); }
.metric.pending .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric small, .metric strong, .metric em { display: block; }
.metric small { color: var(--muted); font-size: 9px; font-weight: 750; }
.metric strong { margin: 8px 0 4px; font-size: clamp(18px,1.8vw,24px); letter-spacing: -.04em; }
.metric em { color: var(--muted); font-size: 8px; font-style: normal; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 20px rgba(20,35,46,.025); }
.dashboard-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 13px; margin-top: 13px; }
.trend-panel, .category-panel { min-height: 305px; padding: 20px; }
.balances-panel, .attention-panel { min-height: 235px; padding: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.panel-head h3 { margin: 0; font-size: 13px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 8px; }
.text-button { border: 0; padding: 4px; color: var(--primary); background: transparent; font-size: 9px; font-weight: 800; }
.legend { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.legend i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.legend .income-dot { background: var(--green); }
.legend .expense-dot { margin-left: 5px; background: var(--red); }
.trend-chart { min-height: 225px; }
.trend-chart svg { width: 100%; height: 225px; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 8px; }
.category-bars { display: grid; gap: 14px; }
.category-row { display: grid; grid-template-columns: minmax(88px,1fr) 1.7fr auto; gap: 9px; align-items: center; }
.category-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 700; }
.category-row strong { font-size: 9px; }
.bar-track { height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.bar-track i { display: block; min-width: 3px; height: 100%; border-radius: inherit; }
.compact-list { display: grid; gap: 2px; }
.compact-row { min-height: 47px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.compact-row:last-child { border-bottom: 0; }
.compact-row > i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 3px; }
.compact-row div { min-width: 0; flex: 1; }
.compact-row b, .compact-row small { display: block; }
.compact-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.compact-row small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.compact-row strong { font-size: 9px; }
.compact-action { width: 100%; border: 0; color: var(--text); background: transparent; text-align: left; }
.compact-action:hover { background: var(--hover); }
.pending-badge { flex: 0 0 auto; border-radius: 5px; padding: 4px 6px; color: var(--amber); background: var(--amber-soft); font-size: 7px; font-weight: 850; }
.wealth-strip { min-height: 92px; display: flex; align-items: center; gap: 24px; margin-top: 13px; padding: 20px 24px; border-radius: var(--radius); color: #fff; background: linear-gradient(115deg,#263d4c,#36545e); box-shadow: var(--shadow); }
.wealth-strip small, .wealth-strip strong { display: block; }
.wealth-strip small { color: #bbcad1; font-size: 8px; }
.wealth-strip strong { margin-top: 4px; font-size: 20px; }
.wealth-strip p { flex: 1; color: #b9c8cf; font-size: 9px; }
.strip-button { border: 1px solid rgba(255,255,255,.17); color: #fff; background: rgba(255,255,255,.07); }
.empty { min-height: 130px; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 9px; }
.empty.compact { min-height: 100px; }

.query-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin-bottom: 10px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.query-summary > div { position: relative; min-height: 62px; padding: 12px 16px 10px 19px; border-right: 1px solid var(--line); }
.query-summary > div:last-child { border-right: 0; }
.query-summary > div::before { content: ""; position: absolute; top: 12px; bottom: 12px; left: 0; width: 3px; background: var(--muted); }
.query-summary .out::before { background: var(--red); }
.query-summary .in::before { background: var(--green); }
.query-summary .net::before { background: var(--primary); }
.query-summary small, .query-summary strong { display: block; }
.query-summary small { color: var(--muted); font-size: 8px; font-weight: 750; }
.query-summary strong { margin-top: 4px; font-size: 15px; }
.filter-panel { margin-bottom: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.filter-primary { display: grid; grid-template-columns: minmax(250px,1.8fr) 128px 128px minmax(150px,.75fr) minmax(130px,.65fr) auto 36px; gap: 8px; align-items: end; }
.filter-secondary { display: grid; grid-template-columns: minmax(170px,1fr) minmax(140px,.7fr) minmax(130px,.65fr) minmax(125px,.55fr) minmax(125px,.55fr); gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.filter-panel label { min-width: 0; display: grid; gap: 4px; }
.filter-panel label > span { color: var(--muted); font-size: 7px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.filter-panel input, .filter-panel select, .search-field { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--input); font-size: 9px; }
.filter-panel input, .filter-panel select { padding: 0 9px; }
.search-field { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 7px !important; margin-top: 11px; padding: 0 10px; }
.search-field > span { font-size: 15px !important; }
.search-field input { height: 34px; padding: 0; border: 0; background: transparent; }
.apply-button { height: 38px; min-height: 38px; color: #fff; background: var(--green); }
.clear-button { width: 36px; height: 38px; border: 0; border-radius: 7px; color: var(--red); background: var(--red-soft); font-size: 18px; }
.advanced-toggle { display: none; min-height: 38px; border: 1px solid var(--line); border-radius: 7px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 800; }
.table-panel { overflow: hidden; }
.table-scroll { overflow: auto; }
.data-table { width: 100%; min-width: 920px; border-collapse: collapse; }
.data-table th { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-2); text-align: left; font-size: 7px; letter-spacing: .04em; text-transform: uppercase; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 9px; vertical-align: middle; }
.data-table tbody tr:hover { background: var(--hover); }
.align-right { text-align: right !important; }
.transaction-desc { max-width: 320px; }
.transaction-desc b, .transaction-desc small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-desc small { margin-top: 3px; color: var(--muted); font-size: 7px; }
.type-pill, .status-pill { display: inline-flex; justify-content: center; border-radius: 5px; padding: 4px 7px; font-size: 7px; font-weight: 850; }
.type-pill { min-width: 62px; }
.type-pill.expense { color: var(--red); background: var(--red-soft); }
.type-pill.income { color: var(--green); background: var(--green-soft); }
.type-pill.transfer { color: var(--primary); background: var(--primary-soft); }
.status-pill.pending { color: var(--amber); background: var(--amber-soft); }
.status-pill.confirmed { color: var(--green); background: var(--green-soft); }
.category-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 8px; font-weight: 750; }
.category-pill i { width: 7px; height: 7px; border-radius: 3px; }
.classify-button { border: 0; border-radius: 5px; padding: 5px 8px; color: var(--amber); background: var(--amber-soft); font-size: 8px; font-weight: 800; }
.amount.expense { color: var(--red); }
.amount.income { color: var(--green); }
.amount.transfer { color: var(--primary); }
.row-actions { display: flex; justify-content: flex-end; gap: 3px; }
.mini-button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px; color: var(--muted); background: transparent; }
.mini-button:hover { color: var(--primary); background: var(--primary-soft); }
.mini-button.danger:hover { color: var(--red); background: var(--red-soft); }
.table-footer { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 14px; color: var(--muted); background: var(--surface-2); font-size: 8px; }
.pagination { display: flex; align-items: center; gap: 7px; }
.pagination label { display: flex; align-items: center; gap: 5px; }
.pagination select, .pagination button { height: 30px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: var(--input); font-size: 8px; }
.pagination select { padding: 0 6px; }
.pagination button { padding: 0 9px; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.account-card, .asset-card, .category-card { position: relative; min-height: 150px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 20px rgba(20,35,46,.025); }
.account-card::before { content: ""; position: absolute; top: 0; right: 18px; left: 18px; height: 3px; border-radius: 0 0 4px 4px; background: var(--card-color); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.account-card h3, .asset-card h3, .category-card h3 { margin: 0; font-size: 12px; }
.account-card p, .asset-card p, .category-card p { margin: 4px 0 0; color: var(--muted); font-size: 8px; }
.account-card .balance-label { display: block; margin-top: 22px; color: var(--muted); font-size: 7px; text-transform: uppercase; letter-spacing: .04em; }
.account-card .balance { display: block; margin-top: 4px; font-size: 21px; letter-spacing: -.04em; }
.tip { display: flex; gap: 10px; margin-top: 14px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface); font-size: 9px; }
.tip span { color: var(--muted); }
.category-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.category-card { min-height: 108px; }
.category-action { color: var(--text); text-align: left; }
.category-action:hover { border-color: var(--primary); transform: translateY(-1px); }
.category-swatch { width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 8px; color: #fff; }
.internal-mark { position: absolute; right: 13px; bottom: 13px; border-radius: 99px; padding: 4px 6px; color: var(--muted); background: var(--surface-2); font-size: 6px; font-weight: 850; }
.import-grid { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(300px,.9fr); gap: 13px; }
.import-card, .import-explainer { padding: 23px; }
.import-card h3 { margin: 6px 0 12px; font-size: 14px; }
.import-card > select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--input); }
.step { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 850; }
.step.second { margin-top: 22px; }
.drop-zone { min-height: 152px; display: grid; place-items: center; align-content: center; gap: 6px; margin: 0 0 13px; border: 1.5px dashed var(--line); border-radius: 11px; color: var(--muted); background: var(--surface-2); text-align: center; }
.drop-zone input { display: none; }
.drop-zone > span { color: var(--primary); font-size: 24px; }
.drop-zone b { color: var(--text); font-size: 10px; }
.drop-zone small { font-size: 8px; }
.import-explainer > small { color: var(--primary); font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.import-explainer h3 { max-width: 300px; margin: 8px 0 22px; font-size: 20px; letter-spacing: -.035em; }
.import-explainer ol { list-style: none; display: grid; gap: 17px; margin: 0; padding: 0; counter-reset: steps; }
.import-explainer li { position: relative; padding-left: 39px; counter-increment: steps; }
.import-explainer li::before { content: counter(steps); position: absolute; top: 0; left: 0; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 850; }
.import-explainer li b, .import-explainer li span { display: block; }
.import-explainer li b { font-size: 10px; }
.import-explainer li span { margin-top: 3px; color: var(--muted); font-size: 8px; }
.import-preview { margin-top: 13px; padding-top: 19px; overflow: hidden; }
.preview-head { padding: 0 19px; }
.import-preview select { min-width: 145px; height: 34px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: var(--input); font-size: 8px; }
.asset-hero { min-height: 155px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; padding: 28px 34px; border-radius: var(--radius); color: #fff; background: linear-gradient(120deg,#2b4657,#3e665f); box-shadow: var(--shadow); }
.asset-hero small, .asset-hero strong { display: block; }
.asset-hero small { color: #bdd0d2; font-size: 8px; }
.asset-hero strong { margin: 7px 0; font-size: 29px; letter-spacing: -.045em; }
.asset-hero p { margin: 0; color: #b8cbcd; font-size: 8px; }
.asset-hero > span { width: 78px; height: 78px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.15); border-radius: 24px; color: #9bd0c3; background: rgba(255,255,255,.06); font-size: 29px; }
.asset-value { display: block; margin-top: 20px; font-size: 19px; }

.modal { width: min(610px,calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--surface); box-shadow: 0 30px 80px rgba(8,22,39,.28); }
.modal.small { width: min(490px,calc(100vw - 24px)); }
.modal::backdrop { background: rgba(8,20,30,.58); backdrop-filter: blur(3px); }
.modal form { padding: 23px; }
.install-dialog { padding: 23px; }
.install-guide { display: grid; gap: 13px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.install-guide > p { margin: 0; }
.install-guide ol { display: grid; gap: 10px; margin: 0; padding-left: 23px; }
.install-guide li { padding-left: 3px; }
.install-guide b { color: var(--text); }
.install-state { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.install-state i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head small { color: var(--primary); font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.modal-head h2 { margin: 3px 0 0; font-size: 19px; letter-spacing: -.03em; }
.close-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface-2); font-size: 19px; }
.modal label { display: block; margin-bottom: 13px; }
.modal label > span:first-child { display: block; margin-bottom: 6px; font-size: 9px; font-weight: 800; }
.modal label small { color: var(--muted); font-weight: 500; }
.modal input:not([type="radio"]):not([type="checkbox"]):not([type="color"]), .modal select, .modal textarea { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--text); background: var(--input); font-size: 10px; }
.modal input:focus, .modal select:focus, .modal textarea:focus, .filter-panel input:focus, .filter-panel select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.modal input[type="color"] { width: 100%; height: 43px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.form-grid { display: grid; gap: 11px; }
.form-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.money-field { height: 43px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--input); }
.money-field b { padding-left: 11px; color: var(--muted); font-size: 9px; }
.money-field input { border: 0 !important; box-shadow: none !important; }
.type-switch { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-bottom: 17px; padding: 4px; border-radius: 10px; background: var(--surface-2); }
.type-switch label { margin: 0; }
.type-switch input { position: absolute; opacity: 0; }
.type-switch span { min-height: 38px; display: grid !important; place-items: center; margin: 0 !important; border-radius: 7px; color: var(--muted); font-size: 9px; }
.type-switch input:checked + span { color: var(--text); background: var(--surface); box-shadow: 0 2px 8px rgba(16,36,62,.08); }
.check-line { display: flex !important; align-items: flex-start; gap: 9px; }
.check-line input { margin-top: 3px; accent-color: var(--primary); }
.check-line span { margin: 0 !important; }
.check-line b, .check-line small { display: block; }
.check-line b { font-size: 9px; }
.check-line small { margin-top: 2px; font-size: 8px; }
.learn-box { margin-bottom: 13px; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.learn-box > label { margin: 0; }
.learn-fields { display: grid; grid-template-columns: 1.4fr 1fr; gap: 9px; margin-top: 11px; }
.learn-fields label { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.toast { position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 100; max-width: min(360px,calc(100vw - 30px)); padding: 12px 15px; border-radius: 9px; color: #fff; background: #253b49; box-shadow: 0 18px 45px rgba(16,36,62,.24); font-size: 10px; font-weight: 700; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #8f454d; }
.app-update { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 90; width: min(390px,calc(100vw - 28px)); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; color: #fff; background: #253b49; box-shadow: 0 20px 48px rgba(10,25,35,.28); }
.app-update div { display: grid; gap: 3px; }
.app-update b { font-size: 10px; }
.app-update span { color: #cfdae0; font-size: 8px; }
.app-update button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 8px; color: #1a322c; background: #a9d5c5; font-size: 9px; font-weight: 850; }
.mobile-nav { display: none; }

@media (max-width: 1180px) {
  .header-inner { padding: 0 16px; }
  .brand > span:last-child { display: none; }
  .brand { padding-right: 14px; }
  .nav-item { padding: 0 9px; }
  .sync-state b { display: none; }
  .filter-primary { grid-template-columns: minmax(220px,1.5fr) 120px 120px minmax(140px,.7fr) auto 36px; }
  .filter-primary label:nth-of-type(5) { grid-column: 1 / 2; }
  .card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .category-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 860px) {
  .app-header { position: sticky; }
  .header-inner { min-height: 58px; }
  .desktop-nav, .sync-state, .data-menu, .header-create { display: none; }
  .brand { border: 0; }
  .brand > span:last-child { display: block; }
  .header-actions { padding: 0; }
  .page-bar { top: calc(58px + env(safe-area-inset-top)); min-height: 64px; padding: 8px 18px; }
  .page-bar > div:first-child span { display: none; }
  .page-bar h1 { font-size: 17px; }
  .user-chip div { display: none; }
  .offline-banner { top: calc(122px + env(safe-area-inset-top)); padding: 9px 18px; }
  .content { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .dashboard-grid, .import-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .query-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .query-summary > div:nth-child(2) { border-right: 0; }
  .query-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .filter-primary, .filter-secondary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filter-primary .search-field { grid-column: 1 / -1; }
  .filter-primary label:nth-of-type(5) { grid-column: auto; }
  .apply-button { width: 100%; }
  .mobile-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 60; min-height: calc(66px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5,1fr); padding: 5px 8px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: color-mix(in srgb,var(--surface) 96%,transparent); backdrop-filter: blur(16px); box-shadow: 0 -6px 22px rgba(22,36,47,.08); }
  .mobile-nav button { min-width: 0; display: grid; place-items: center; align-content: center; gap: 2px; border: 0; color: var(--muted); background: transparent; font-size: 7px; font-weight: 750; }
  .mobile-nav button > span { font-size: 17px; }
  .mobile-nav button.active { color: var(--primary); }
  .mobile-nav .mobile-add span { width: 39px; height: 39px; display: grid; place-items: center; margin-top: -22px; border-radius: 50%; color: #fff; background: var(--green); box-shadow: 0 7px 18px rgba(39,82,68,.25); font-size: 24px; }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

@media (max-width: 590px) {
  .month-field span, .secondary-button[data-view="import"] { display: none; }
  .month-field { padding: 0 8px; }
  .month-field input { width: 118px; }
  .user-chip { display: none; }
  .section-heading, .subheading { align-items: flex-start; }
  .section-heading > div:first-child { min-width: 0; }
  .section-heading p { max-width: 260px; }
  .section-heading .primary-button { flex: 0 0 auto; min-height: 40px; padding: 0 11px; font-size: 9px; }
  .metric { min-height: 106px; padding: 15px; }
  .metric-icon { width: 31px; height: 31px; flex-basis: 31px; }
  .metric strong { font-size: 17px; }
  .metric em { display: none; }
  .trend-panel, .category-panel, .balances-panel, .attention-panel { padding: 16px; }
  .wealth-strip { align-items: flex-start; flex-direction: column; gap: 10px; }
  .wealth-strip p { margin: 0; }
  .filter-primary, .filter-secondary { grid-template-columns: 1fr; }
  .filter-primary .search-field, .filter-primary label:nth-of-type(5) { grid-column: auto; }
  .filter-secondary { display: none; }
  .filter-panel.advanced-open .filter-secondary { display: grid; }
  .advanced-toggle { display: block; }
  .data-table { min-width: 0; }
  .data-table thead { display: none; }
  .data-table tbody { display: grid; }
  .data-table tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
  .data-table td { display: block; padding: 0; border: 0; }
  .data-table td:nth-child(1) { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 8px; }
  .data-table td:nth-child(2) { grid-column: 2; grid-row: 1; }
  .data-table td:nth-child(3) { grid-column: 1; grid-row: 2; }
  .data-table td:nth-child(4) { grid-column: 1; grid-row: 3; color: var(--muted); font-size: 8px; }
  .data-table td:nth-child(5) { grid-column: 1; grid-row: 4; }
  .data-table td:nth-child(6) { grid-column: 2; grid-row: 3; text-align: right; }
  .data-table td:nth-child(7) { grid-column: 2; grid-row: 2; align-self: center; }
  .data-table td:nth-child(8) { grid-column: 2; grid-row: 4; }
  .transaction-desc { max-width: 230px; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .pagination { width: 100%; flex-wrap: wrap; }
  .card-grid, .category-grid, .form-grid.two { grid-template-columns: 1fr; }
  .button-row { flex-wrap: wrap; }
  .tip { flex-direction: column; }
  .asset-hero { padding: 24px; }
  .asset-hero > span { width: 61px; height: 61px; border-radius: 18px; }
  .modal { width: 100%; max-height: calc(100dvh - 8px); margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .modal form { padding: 20px 17px calc(20px + env(safe-area-inset-bottom)); }
  .install-dialog { padding: 20px 17px calc(20px + env(safe-area-inset-bottom)); }
  .app-update { right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); }
  .type-switch span { font-size: 8px; }
  .learn-fields { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .metric-grid { gap: 9px; }
  .metric { gap: 9px; padding: 13px; }
  .metric small { font-size: 8px; }
  .metric strong { font-size: 15px; }
  .section-heading h2 { font-size: 17px; }
  .page-bar { padding-right: 12px; padding-left: 12px; }
  .content { padding-right: 12px; padding-left: 12px; }
}

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