/* Design polish follows unslop by Damir Sokolovsky (@heydamir), CC BY 4.0. */
:root {
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --bg: #f6f5f1;
  --surface: #fffefb;
  --raised: #eeede7;
  --ink: #1f1b16;
  --secondary: #5e554a;
  --muted: #7b7266;
  --line: rgba(31, 27, 22, 0.085);
  --accent: #2d5c4c;
  --green: #2f6e52;
  --red: #b2453f;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
}

html[lang="zh-CN"] { --sans: "Noto Sans SC", "IBM Plex Sans", sans-serif; }
html[lang="ja"] { --sans: "Noto Sans JP", "IBM Plex Sans", sans-serif; }
html[lang="ar"] { --sans: "Noto Sans Arabic", "IBM Plex Sans", sans-serif; }
html[lang="hi"] { --sans: "Noto Sans Devanagari", "IBM Plex Sans", sans-serif; }

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
option { font-family: var(--sans); }
button { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; background: #f1ede5; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 28px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 600; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; color: var(--accent); }
.brand-mark svg { width: 22px; height: 22px; }
nav { display: grid; gap: 4px; }
.nav-item { height: 36px; padding: 0 12px; display: flex; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--secondary); font-size: 14px; font-weight: 400; text-align: left; cursor: pointer; transition: color 140ms var(--ease), background 140ms var(--ease), border-color 140ms var(--ease); }
.nav-item > span { width: 18px; height: 18px; display: grid; place-items: center; color: var(--muted); }
.nav-item:hover { color: var(--ink); background: rgba(253, 251, 247, 0.65); }
.nav-item.active { color: var(--ink); background: var(--surface); border-color: var(--line); font-weight: 500; box-shadow: 0 1px 2px rgba(31, 27, 22, 0.04); }
.nav-item.active > span { color: var(--accent); }
.user { width: 100%; margin-top: auto; padding: 20px 8px 0; display: flex; align-items: center; gap: 10px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--accent); font-size: 13px; font-weight: 500; }
.user strong, .user small { display: block; }
.user strong { font-size: 13px; font-weight: 500; }
.user small { margin-top: 2px; color: var(--muted); font-size: 12px; }

main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px 32px 64px; }
.topbar { min-height: 64px; margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 400; letter-spacing: 0; }
.topbar h1, .section-title h2 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.month-switch { height: 40px; padding: 3px; display: grid; grid-template-columns: 32px minmax(112px, auto) 32px; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.month-switch button { width: 32px; height: 32px; padding: 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.month-switch button:hover { background: var(--raised); color: var(--ink); }
.month-switch button:disabled { opacity: .34; cursor: default; }
.month-switch strong { padding: 0 8px; font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 500; text-align: center; }
.primary-btn, .secondary-btn { min-height: 40px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: color 140ms var(--ease), background 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease); }
.primary-btn { border: 1px solid var(--ink); background: var(--ink); color: #fff; }
.primary-btn:hover { background: #342e27; border-color: #342e27; }
.primary-btn:active, .secondary-btn:active { transform: scale(0.98); }
.secondary-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.secondary-btn:hover { background: var(--raised); }
.view { display: none; }
.view.active { display: block; }

.summary-card { min-height: 144px; padding: 24px; display: grid; grid-template-columns: 1.6fr 1fr 1fr; align-items: center; gap: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.summary-card p { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 16px; }
.summary-card h2 { margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 36px; line-height: 1; font-weight: 500; letter-spacing: -0.02em; }
.trend { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 16px; }
.summary-stat { min-height: 72px; padding-left: 24px; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); }
.summary-stat strong { display: block; font-family: "IBM Plex Mono", monospace; font-size: 28px; line-height: 1; font-weight: 500; letter-spacing: -0.02em; }
.summary-stat:nth-child(2) strong { color: var(--green); }
.summary-stat:nth-child(3) strong { color: var(--red); }
.summary-stat small { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 16px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(300px, 0.82fr) minmax(440px, 1.18fr); gap: 16px; margin-top: 16px; }
.card { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card h3 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 500; }
.text-btn { min-height: 32px; padding: 0 4px; border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; transition: color 140ms var(--ease); }
.text-btn:hover { color: var(--ink); }
.month-label { color: var(--muted); font-size: 12px; line-height: 16px; }

.progress, .budget-meter-track, .distribution-rule { position: relative; overflow: hidden; background: var(--raised); }
.progress { height: 8px; margin: 32px 0 12px; border-radius: 4px; }
.progress i { display: block; height: 100%; border-radius: inherit; }
.progress::after, .budget-meter-track::after, .distribution-rule::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(31, 27, 22, 0.12) calc(10% - 1px), rgba(31, 27, 22, 0.12) 10%); }
.budget-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; line-height: 16px; }
.budget-message { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--secondary); font-size: 13px; line-height: 20px; }

.category-content { margin-top: 20px; }
.category-total { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.category-total span { color: var(--muted); font-size: 12px; }
.category-total strong { font-size: 28px; line-height: 1; font-weight: 500; }
.distribution-rule { height: 20px; margin-top: 16px; display: flex; border-radius: 6px; border: 1px solid var(--line); }
.distribution-rule > i { display: block; height: 100%; min-width: 0; }
.distribution-rule > i:first-child { border-radius: 5px 0 0 5px; }
.distribution-rule > i:last-child { border-radius: 0 5px 5px 0; }
.distribution-rule .empty-segment { width: 100%; background: var(--raised); border-radius: 5px; }
.legend { margin-top: 16px; display: grid; gap: 8px; }
.legend-row { min-height: 24px; display: grid; grid-template-columns: minmax(96px, 1fr) auto 40px; align-items: center; gap: 12px; color: var(--secondary); font-size: 12px; }
.legend-name { display: flex; align-items: center; gap: 8px; }
.legend-row strong { font-weight: 500; color: var(--ink); text-align: right; }
.legend-row > span:last-child { color: var(--muted); text-align: right; }
.dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 2px; }

.recent-card { margin-top: 16px; }
.transaction-list { margin-top: 16px; }
.transaction-wrap { border-bottom: 1px solid var(--line); }
.transaction-wrap:last-child { border-bottom: 0; }
.transaction { min-height: 64px; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.tx-icon { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); }
.tx-icon i { width: 8px; height: 8px; border-radius: 2px; }
.tx-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 20px; font-weight: 500; }
.tx-main small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 16px; }
.tx-amount { color: var(--ink); font-size: 14px; line-height: 20px; font-weight: 500; text-align: right; }
.tx-amount.income { color: var(--green); }
.tx-actions { height: 24px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.detail-toggle, .delete-btn { height: 24px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.detail-toggle { padding: 0 4px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.detail-toggle:hover { color: var(--accent); }
.chevron { width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-1px) rotate(45deg); transition: transform 160ms var(--ease); }
.transaction-wrap.open .chevron { transform: translateY(2px) rotate(225deg); }
.delete-btn { width: 24px; padding: 3px; opacity: 0; transition: color 140ms var(--ease), opacity 140ms var(--ease); }
.delete-btn svg { width: 16px; height: 16px; }
.transaction-wrap:hover .delete-btn, .delete-btn:focus-visible { opacity: 1; }
.delete-btn:hover { color: var(--red); }
.tx-details { display: none; margin: 0 0 16px 48px; padding: 16px; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; }
.transaction-wrap.open .tx-details { display: block; }
.item-row { min-height: 32px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.item-row:last-of-type { border-bottom: 0; }
.item-row span:nth-child(2) { color: var(--muted); }
.item-row strong { font-weight: 500; }
.no-items { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.add-details { min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 500; cursor: pointer; }
.empty { padding: 48px 24px; color: var(--muted); font-size: 13px; text-align: center; }
.empty b { display: block; margin-bottom: 8px; font-size: 24px; font-weight: 400; }

.section-title { margin: 8px 0 24px; }
.filterbar { display: grid; grid-template-columns: minmax(280px, 1fr) 160px 160px; gap: 8px; margin-bottom: 16px; }
.search { height: 40px; padding: 0 12px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.search > span { width: 18px; height: 18px; display: grid; place-items: center; color: var(--muted); }
.search input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.filterbar select, .form-row select { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--secondary); font-size: 14px; }

.budget-focus { min-height: 280px; display: grid; grid-template-columns: minmax(360px, 1.2fr) 1fr; align-items: center; gap: 48px; padding: 32px; }
.budget-focus h2 { margin: 4px 0 12px; font-size: 36px; line-height: 1; font-weight: 500; }
.budget-focus p:not(.eyebrow) { margin: 0 0 24px; color: var(--secondary); font-size: 13px; line-height: 20px; }
.budget-meter { padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); }
.budget-meter-head { display: flex; align-items: baseline; justify-content: space-between; color: var(--secondary); font-size: 13px; }
.budget-meter-head strong { color: var(--ink); font-size: 32px; line-height: 1; font-weight: 500; }
.budget-meter-track { height: 24px; margin: 20px 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.budget-meter-track i { display: block; height: 100%; border-radius: 5px; }
.budget-meter > small { color: var(--muted); font-size: 12px; }
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.insight-grid p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.insight-grid h3 { margin: 0; font-size: 28px; line-height: 1; font-weight: 500; }
.insight-grid small { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 16px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.conversion-card { grid-column: 1 / -1; }
.settings-heading { margin-bottom: 20px; padding-bottom: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.settings-heading > div { display: flex; align-items: center; gap: 12px; }
.settings-heading h3 { margin: 0; }
.settings-index, .currency-badge { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 400; }
.settings-card > p { min-height: 40px; margin: 0 0 24px; color: var(--secondary); font-size: 13px; line-height: 20px; }
.settings-card form { display: grid; gap: 16px; }
.settings-card form label { margin: 0; }
.settings-card select, .settings-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .settings-card textarea { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); outline: 0; }
.settings-card textarea { min-height: 88px; padding-block: 10px; resize: vertical; }
.conversion-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.conversion-preview { padding: 12px 16px; border-left: 2px solid var(--accent); background: var(--raised); color: var(--secondary); font-size: 13px; line-height: 20px; }
.confirm-row { display: flex !important; align-items: center; gap: 8px !important; color: var(--secondary) !important; font-size: 13px !important; }
.confirm-row input { margin: 0; }
.settings-note { margin: 16px 4px; color: var(--muted); font-size: 12px; line-height: 20px; }
.restore-btn { margin-left: 8px; }
.data-card { grid-column: 1 / -1; }
.account-sync-card { grid-column: 1 / -1; }
.sync-badge { padding: 4px 8px; border-radius: 999px; background: var(--raised); color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.sync-badge[data-status="synced"] { background: #e7f0ea; color: var(--green); }
.sync-badge[data-status="syncing"] { color: var(--accent); }
.sync-badge[data-status="error"], .sync-badge[data-status="offline"] { background: #f5ead8; color: #75511c; }
.sync-account { margin: -4px 0 20px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sync-account strong, .sync-account small { display: block; }
.sync-account strong { font-size: 14px; font-weight: 500; }
.sync-account small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.snapshot-section { margin-top: 24px; border-top: 1px solid var(--line); }
.snapshot-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--secondary); font-size: 13px; }
.snapshot-heading strong { color: var(--ink); font-weight: 500; }
.snapshot-heading span { color: var(--muted); font-size: 12px; }
.snapshot-row { min-height: 60px; padding: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); }
.snapshot-row > div { min-width: 0; }
.snapshot-row strong, .snapshot-row span { display: block; }
.snapshot-row strong { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.snapshot-row span { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 16px; }
.snapshot-row .text-btn { flex: 0 0 auto; }
.snapshot-empty { min-height: 60px; display: flex; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.modal { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; }
.modal.open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(31, 27, 22, 0.52); }
.modal-panel { position: relative; width: min(480px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); overflow: auto; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 24px rgba(31, 27, 22, 0.08); animation: panel-in 180ms var(--ease); }
.modal-panel.small { width: min(420px, calc(100vw - 32px)); }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }
.modal-panel h2 { margin: 0 0 20px; font-size: 24px; line-height: 32px; font-weight: 500; }
.auth-panel { width: min(440px, calc(100vw - 32px)); }
.auth-intro { margin: -8px 0 20px; color: var(--secondary); font-size: 13px; line-height: 20px; }
.auth-tabs { margin-bottom: 20px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 10px; background: var(--raised); }
.auth-tabs button { min-height: 34px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.auth-tabs button.active { border-color: var(--line); background: var(--surface); color: var(--ink); font-weight: 500; }
.form-message { min-height: 20px; margin: -4px 0 12px; color: var(--muted); font-size: 12px; line-height: 18px; }
.form-message[data-kind="error"] { color: var(--red); }
.form-message[data-kind="success"] { color: var(--green); }
.auth-reset { margin-top: 8px; }
.auth-divider { margin: 16px 0; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.device-only-btn { width: 100%; }
.close-btn { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--secondary); font-size: 20px; line-height: 1; cursor: pointer; }
.type-toggle { margin-bottom: 20px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--raised); border-radius: 10px; }
.type-toggle button { min-height: 32px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; }
.type-toggle button.active { background: var(--surface); border-color: var(--line); color: var(--accent); }
form label { display: grid; gap: 8px; margin-bottom: 16px; color: var(--secondary); font-size: 13px; line-height: 20px; }
.amount-field div { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.amount-field b { color: var(--ink); font-size: 24px; font-weight: 500; }
.amount-field input { width: 100%; padding: 8px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 32px; line-height: 40px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row input, .modal-panel label > input, .item-field textarea { width: 100%; min-height: 40px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); outline: 0; }
.category-custom { display: none; margin-top: -4px; padding: 12px; border-left: 2px solid var(--accent); background: var(--raised); border-radius: 0 8px 8px 0; }
.category-custom.show { display: grid; }
.category-custom input { background: var(--surface) !important; }
.item-field span { color: var(--muted); font-weight: 400; }
.item-field textarea { min-height: 96px; resize: vertical; font-size: 13px; line-height: 20px; }
.submit { width: 100%; margin-top: 4px; }
.detail-total div { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; }
.detail-total b { color: var(--ink); font-size: 18px; font-weight: 500; }
.detail-total input { width: 100%; padding: 8px; border: 0 !important; outline: 0; background: transparent; color: var(--ink); font-size: 20px; font-weight: 500; }
.detail-help, .sum-hint { margin: -4px 0 16px; padding: 12px; background: var(--raised); border-radius: 8px; color: var(--secondary); font-size: 12px; line-height: 18px; }
.sum-hint.mismatch { color: #75511c; background: #f5ead8; }
.import-summary { margin-bottom: 16px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; background: var(--raised); }
.import-summary > * { min-height: 64px; padding: 12px; display: flex; align-items: center; justify-content: center; color: var(--secondary); font-size: 12px; text-align: center; }
.import-summary > * + * { border-left: 1px solid var(--line); }
.import-summary strong { color: var(--accent); font-weight: 600; }
.import-preview { margin-bottom: 16px; border-top: 1px solid var(--line); }
.import-preview:empty { display: none; }
.import-preview > div { min-height: 44px; display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.import-preview strong { overflow: hidden; color: var(--ink); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.import-preview span { color: var(--muted); }
.import-mode { margin-bottom: 16px; display: grid; gap: 8px; }
.import-mode label { min-height: 44px; margin: 0; padding: 10px 12px; display: flex; grid-template-columns: none; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.import-mode input { width: auto !important; min-height: auto !important; margin: 0; padding: 0 !important; }
.import-mode.json-only label:last-child { opacity: .45; cursor: not-allowed; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; padding: 10px 16px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity 160ms var(--ease), transform 160ms var(--ease); }
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }

.subscription-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.subscription-summary { margin-bottom: 16px; display: grid; grid-template-columns: 1.2fr .8fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.subscription-summary > div { min-height: 128px; padding: 24px; display: flex; flex-direction: column; justify-content: center; }
.subscription-summary > div + div { border-left: 1px solid var(--line); }
.subscription-summary span, .subscription-summary small { color: var(--muted); font-size: 12px; line-height: 16px; }
.subscription-summary strong { margin: 8px 0; color: var(--ink); font-size: 28px; line-height: 32px; font-weight: 500; }
.subscription-summary > div:first-child strong { font-size: 36px; line-height: 40px; }
.subscription-ledger { padding: 0 24px; }
.subscription-ledger-head, .subscription-row { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(120px, .8fr) minmax(110px, .6fr) minmax(180px, .8fr); align-items: center; gap: 20px; }
.subscription-ledger-head { min-height: 48px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.subscription-row { min-height: 80px; border-bottom: 1px solid var(--line); }
.subscription-row:last-child { border-bottom: 0; }
.subscription-row.paused { opacity: .58; }
.subscription-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.subscription-name > i { width: 10px; height: 32px; flex: 0 0 auto; border-radius: 3px; }
.subscription-name div, .subscription-schedule, .subscription-price { min-width: 0; }
.subscription-name strong, .subscription-schedule strong, .subscription-price strong { display: block; overflow: hidden; color: var(--ink); font-size: 14px; line-height: 20px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.subscription-name span, .subscription-schedule span, .subscription-price span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 16px; }
.subscription-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.status-button { min-width: 64px; height: 28px; padding: 0 10px; border: 1px solid rgba(49, 95, 78, .22); border-radius: 999px; background: rgba(49, 95, 78, .08); color: var(--accent); font-size: 12px; cursor: pointer; }
.paused .status-button { border-color: var(--line); background: var(--raised); color: var(--muted); }
.icon-button { width: 32px; height: 32px; padding: 7px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--raised); color: var(--ink); }
.icon-button.danger:hover { color: var(--red); }
.subscription-empty { padding: 64px 24px; display: grid; gap: 8px; color: var(--muted); text-align: center; }
.subscription-empty strong { color: var(--secondary); font-size: 15px; font-weight: 500; }
.subscription-empty span { font-size: 13px; }
.subscription-note { margin: 16px 4px 0; color: var(--muted); font-size: 12px; line-height: 20px; }

/* Advanced ledger: typography, trends, accounts and recovery */
.section-title-actions, .account-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-title-actions .secondary-btn small { min-width: 20px; padding-left: 8px; border-left: 1px solid var(--line); color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.trend-grid { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .7fr); gap: 16px; }
.trend-card, .merchant-card { min-height: 320px; }
.trend-change { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12px; }
.trend-change.positive { color: var(--green); }
.trend-change.negative { color: var(--red); }
.trend-chart { height: 240px; margin-top: 16px; }
.trend-chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid line { stroke: var(--line); stroke-width: 1; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.trend-area { fill: rgba(45, 92, 76, .08); }
.trend-chart circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-labels text { fill: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.merchant-ranking { margin-top: 20px; }
.merchant-row { min-height: 48px; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.merchant-row:last-child { border-bottom: 0; }
.merchant-row > span { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.merchant-row div { min-width: 0; }
.merchant-row strong { display: block; overflow: hidden; margin-bottom: 6px; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.merchant-row i { position: relative; height: 2px; display: block; overflow: hidden; background: var(--raised); }
.merchant-row i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--merchant-width); background: var(--accent); }
.merchant-row b { font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 500; }
.pro-empty { min-height: 96px; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; }

.category-budget-card { margin-top: 16px; }
.category-budget-list { margin-top: 16px; }
.category-budget-row { min-height: 72px; display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.2fr) 72px; align-items: center; gap: 24px; border-top: 1px solid var(--line); }
.category-budget-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.category-budget-name > i { width: 4px; height: 32px; flex: 0 0 auto; border-radius: 2px; }
.category-budget-name strong, .category-budget-name span { display: block; }
.category-budget-name strong { font-size: 14px; font-weight: 500; }
.category-budget-name span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.category-budget-meter > div { height: 6px; overflow: hidden; border-radius: 3px; background: var(--raised); }
.category-budget-meter > div i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.category-budget-meter > span { display: block; margin-top: 8px; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.category-budget-actions { display: flex; justify-content: flex-end; gap: 4px; }

.account-title > div:last-child { display: flex; gap: 8px; }
.asset-summary { position: relative; min-height: 152px; padding: 24px 32px; display: grid; grid-template-columns: minmax(260px, 1fr) 1px minmax(180px, .45fr); align-items: center; gap: 32px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); border-radius: 16px; background: #1f2825; color: #f2f3ef; }
.asset-summary::before { content: ""; position: absolute; pointer-events: none; }
.asset-summary > div:not(.asset-rule) { display: flex; flex-direction: column; }
.asset-summary span, .asset-summary small { color: rgba(242,243,239,.62); font-size: 12px; }
.asset-summary strong { margin: 8px 0; font-family: "IBM Plex Mono", monospace; font-size: 36px; line-height: 1; font-weight: 500; letter-spacing: -0.025em; }
.asset-rule { width: 1px; height: 72px; background: rgba(255,255,255,.12); }
.account-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.account-card { min-height: 176px; padding: 20px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; color: #f7f7f4; box-shadow: 0 8px 24px rgba(31,27,22,.08); }
.account-tone-0 { background: linear-gradient(145deg, #485c54, #2d3d37); }
.account-tone-1 { background: linear-gradient(145deg, #4d515b, #30343d); }
.account-tone-2 { background: linear-gradient(145deg, #64594d, #3f3932); }
.account-card-head { display: flex; align-items: center; justify-content: space-between; }
.account-card-head > span, .account-card small { color: rgba(255,255,255,.66); font-family: "IBM Plex Mono", monospace; font-size: 11px; }
.account-edit { width: 28px; height: 28px; padding: 6px; border: 1px solid rgba(255,255,255,.16); border-radius: 7px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.78); cursor: pointer; }
.account-card > strong { margin-top: 20px; font-size: 14px; font-weight: 500; }
.account-card > b { margin: 12px 0 auto; font-family: "IBM Plex Mono", monospace; font-size: 26px; line-height: 1; font-weight: 500; letter-spacing: -0.02em; }
.transfer-ledger { margin-top: 16px; }
.transfer-row { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
.transfer-row strong, .transfer-row small { display: block; }
.transfer-row strong { font-size: 13px; font-weight: 500; }
.transfer-row strong span { padding: 0 4px; color: var(--muted); }
.transfer-row small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.transfer-row b { font-family: "IBM Plex Mono", monospace; font-size: 13px; font-weight: 500; }

.edit-panel { width: min(600px, calc(100vw - 32px)); }
#detailModal .detail-help { display: none; }
.trash-list { border-top: 1px solid var(--line); }
.trash-row { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.trash-row strong, .trash-row span { display: block; }
.trash-row strong { font-size: 13px; font-weight: 500; }
.trash-row span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.toast { display: flex; align-items: center; gap: 12px; }
.toast button { min-height: 28px; padding: 0 8px; border: 1px solid rgba(255,255,255,.24); border-radius: 6px; background: rgba(255,255,255,.08); color: #fff; font-size: 12px; cursor: pointer; }
.transaction .icon-button { width: 24px; height: 24px; padding: 4px; }
.tx-actions .icon-button { opacity: 0; }
.transaction-wrap:hover .tx-actions .icon-button, .tx-actions .icon-button:focus-visible { opacity: 1; }

[dir="rtl"] { text-align: right; }
[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] .summary-stat { border-left: 0; border-right: 1px solid var(--line); }
[dir="rtl"] .conversion-preview, [dir="rtl"] .category-custom { border-left: 0; border-right: 2px solid var(--accent); border-radius: 8px 0 0 8px; }
[dir="rtl"] .close-btn { right: auto; left: 16px; }
[dir="rtl"] .tx-amount, [dir="rtl"] .legend-row strong, [dir="rtl"] .legend-row > span:last-child, [dir="rtl"] .subscription-price { text-align: left; }
[dir="rtl"] .subscription-actions { justify-content: flex-start; }
[dir="rtl"] .restore-btn { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .merchant-row i::after { inset: 0 0 0 auto; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(49, 95, 78, 0.28); outline-offset: 2px; }
@media (hover: none) { .delete-btn { opacity: 1; } }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 80px minmax(0, 1fr); }
  .sidebar { padding: 24px 12px; }
  .brand { justify-content: center; padding: 4px 0 28px; }
  .brand > span:last-child, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item > span { width: 18px; }
  .user { justify-content: center; padding: 20px 0 0; }
  .user > div:last-child { display: none; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .conversion-card, .data-card, .account-sync-card { grid-column: auto; }
  .trend-grid { grid-template-columns: 1fr; }
  .merchant-card { min-height: auto; }
  .account-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subscription-ledger-head, .subscription-row { grid-template-columns: minmax(180px, 1.3fr) minmax(110px, .7fr) minmax(100px, .6fr) minmax(150px, .8fr); gap: 12px; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: auto; bottom: 0; z-index: 10; width: 100%; height: 72px; padding: 8px 12px; display: block; background: rgba(247, 244, 238, 0.98); border: 0; border-top: 1px solid var(--line); }
  .brand, .user { display: none; }
  .sidebar nav { grid-template-columns: repeat(6, 1fr); gap: 2px; }
  .nav-item, .nav-item.active { height: 56px; padding: 4px 0; flex-direction: column; justify-content: center; gap: 4px; border: 0; background: transparent; box-shadow: none; font-size: 11px; }
  main { padding: 20px 16px 96px; }
  .topbar { min-height: 56px; margin-bottom: 20px; align-items: flex-start; gap: 12px; }
  .top-actions { flex-direction: column-reverse; align-items: flex-end; }
  .month-switch { grid-template-columns: 28px minmax(92px, auto) 28px; height: 36px; }
  .month-switch button { width: 28px; height: 28px; padding: 5px; }
  .topbar h1, .section-title h2 { font-size: 26px; }
  .topbar .primary-btn { width: 40px; padding: 0; font-size: 0; }
  .summary-card { grid-template-columns: 1fr 1fr; gap: 0; padding: 20px; }
  .summary-card > div:first-child { grid-column: 1 / -1; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
  .summary-card h2 { font-size: 32px; }
  .summary-stat { min-height: 80px; padding: 20px 0 0; border-left: 0; }
  .summary-stat:last-child { padding-left: 20px; border-left: 1px solid var(--line); }
  [dir="rtl"] .summary-stat:last-child { padding-left: 0; padding-right: 20px; border-left: 0; border-right: 1px solid var(--line); }
  .summary-stat strong { font-size: 24px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .filterbar { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .filterbar select { width: 100%; }
  .budget-focus { grid-template-columns: 1fr; gap: 24px; padding: 20px; }
  .budget-meter { padding: 20px; }
  .insight-grid { grid-template-columns: 1fr; }
  .conversion-row, .form-row { grid-template-columns: 1fr; }
  .transaction { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; }
  .tx-details { margin-left: 0; }
  .delete-btn { opacity: 1; }
  .legend-row { grid-template-columns: minmax(80px, 1fr) auto 36px; gap: 8px; }
  .subscription-title { align-items: center; }
  .subscription-title .primary-btn { width: 40px; padding: 0; font-size: 0; }
  .subscription-summary { grid-template-columns: 1fr 1fr; }
  .subscription-summary > div { min-height: 104px; padding: 20px; }
  .subscription-summary > div:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
  .subscription-summary > div:nth-child(2) { border-left: 0; }
  .subscription-summary strong, .subscription-summary > div:first-child strong { font-size: 24px; line-height: 28px; }
  .subscription-ledger { padding: 0 20px; }
  .subscription-ledger-head { display: none; }
  .subscription-row { min-height: 0; padding: 20px 0; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .subscription-name { grid-column: 1; grid-row: 1; }
  .subscription-price { grid-column: 2; grid-row: 1; text-align: right; }
  .subscription-schedule { grid-column: 1; grid-row: 2; padding-left: 22px; }
  .subscription-actions { grid-column: 2; grid-row: 2; }
  .trend-card { min-height: 292px; }
  .trend-chart { height: 212px; }
  .section-title-actions, .account-title { align-items: flex-start; }
  .account-title > div:last-child { flex-direction: column-reverse; }
  .account-title > div:last-child button { width: 40px; padding: 0; font-size: 0; }
  .asset-summary { min-height: 132px; padding: 20px; grid-template-columns: 1fr 1px .5fr; gap: 20px; }
  .asset-summary strong { font-size: 28px; }
  .account-grid { grid-template-columns: 1fr; }
  .account-card { min-height: 160px; }
  .category-budget-row { padding: 16px 0; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .category-budget-meter { grid-column: 1 / -1; grid-row: 2; }
  .category-budget-actions { grid-column: 2; grid-row: 1; }
  .data-actions > button { flex: 1 1 calc(50% - 4px); }
  .data-actions > .primary-btn { flex-basis: 100%; }
  .import-summary { grid-template-columns: 1fr; }
  .import-summary > * { min-height: 44px; justify-content: flex-start; text-align: left; }
  .import-summary > * + * { border-left: 0; border-top: 1px solid var(--line); }
  .import-preview > div { grid-template-columns: 76px minmax(0, 1fr); }
  .import-preview > div span:last-child { grid-column: 2; }
  .tx-actions .icon-button { opacity: 1; }
}

@media (max-width: 440px) {
  main { padding-left: 12px; padding-right: 12px; }
  .sidebar { padding-left: 6px; padding-right: 6px; }
  .nav-item, .nav-item.active { font-size: 10px; }
  .summary-card { padding: 18px; }
  .month-switch strong { font-size: 11px; }
  .asset-summary { grid-template-columns: 1fr; gap: 12px; }
  .asset-rule { display: none; }
  .asset-summary > div:last-child { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
}

/* Planning, reminders and reports */
.power-nav em { font: inherit; font-style: normal; }
.reminder-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper, #fff); color: var(--ink); display: grid; place-items: center; position: relative; cursor: pointer; }
.reminder-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.reminder-button b { position: absolute; top: -5px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #b34b37; color: #fff; font: 600 10px/18px var(--mono); }
.power-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.power-card { min-height: 260px; }
.power-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto auto; align-items: center; gap: 10px; min-height: 66px; border-top: 1px solid var(--line); }
.power-row:first-child { border-top: 0; }
.power-row > div { min-width: 0; display: grid; gap: 5px; }
.power-row strong, .goal-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.power-row span, .goal-row span, .goal-row small { color: var(--muted); font-size: 12px; }
.power-empty { color: var(--muted); min-height: 120px; display: grid; place-items: center; text-align: center; padding: 24px; }
.switch { width: 34px; height: 20px; padding: 2px; border: 0; border-radius: 10px; background: #c8c4bc; cursor: pointer; }
.switch::before { content: ''; display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s ease; }
.switch.on { background: var(--accent); }
.switch.on::before { transform: translateX(14px); }
[dir="rtl"] .switch.on::before { transform: translateX(-14px); }
.goal-row { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 8px 12px; padding: 18px 0; border-top: 1px solid var(--line); }
.goal-row:first-child { border-top: 0; }
.goal-row > div:first-child { display: grid; gap: 5px; }
.goal-track { grid-column: 1 / 3; height: 7px; overflow: hidden; border-radius: 4px; background: #e6e1d8; }
.goal-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.goal-row small { grid-column: 1 / 3; }
.reconcile-result { margin: 14px 0; padding: 14px; border-radius: 8px; background: #f1eee7; display: flex; justify-content: space-between; gap: 16px; }
.reconcile-result:empty { display: none; }
.reconcile-result span { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.reconcile-result b { color: var(--ink); font: 500 18px var(--mono); }
.reconcile-result b.negative { color: #b34b37; }
.power-modal { position: fixed; inset: 0; z-index: 40; display: none; place-items: center; padding: 20px; }
.power-modal.open { display: grid; }
.power-modal .modal-backdrop { position: absolute; inset: 0; background: rgba(25,24,21,.48); backdrop-filter: blur(2px); }
.power-modal .modal-panel { position: relative; width: min(620px,100%); max-height: min(760px,calc(100vh - 40px)); overflow: auto; }
.power-modal .close-btn { font-size: 24px; line-height: 1; }
.reminder-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.reminder-row > div { display: grid; gap: 4px; }
.reminder-row span { color: var(--muted); font-size: 12px; }
.reminder-settings { margin: 16px 0 8px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.reminder-settings > div { display: grid; gap: 3px; }
.reminder-settings span { color: var(--muted); font-size: 12px; }
.report-view-active .month-switch, .report-view-active #openModal { display: none; }
.report-title { align-items: flex-end; margin-bottom: 20px; }
.report-title > div { display: grid; gap: 4px; }
.report-title h2 { margin: 0; }
.report-intro { max-width: 600px; margin: 4px 0 0; color: var(--secondary); line-height: 1.55; }
.report-title .secondary-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.report-kpis { display: grid; grid-template-columns: 1.25fr repeat(3,minmax(0,1fr)); gap: 1px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); }
.report-kpis article { min-height: 128px; padding: 20px; background: var(--surface); display: flex; flex-direction: column; justify-content: space-between; }
.report-kpis article.report-kpi-primary { box-shadow: inset 0 3px var(--accent); }
.report-kpis span, .report-kpis small { color: var(--muted); font-size: 12px; }
.report-kpis strong { margin: 16px 0 6px; font: 500 clamp(20px,2vw,28px) var(--mono); font-variant-numeric: tabular-nums; }
.report-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(280px,.85fr); gap: 16px; }
.report-grid .report-accounts { grid-column: 1 / -1; }
.cashflow-card, .report-merchants, .report-accounts { padding: 24px; }
.cashflow-card .card-head, .report-merchants .card-head, .report-accounts .card-head { margin-bottom: 16px; }
.report-legend { display: flex; justify-content: flex-end; gap: 16px; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.report-legend span { display: flex; align-items: center; gap: 6px; }
.report-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.report-legend i.expense { background: #9b6652; }
.cashflow-chart { height: 220px; display: flex; align-items: flex-end; gap: 8px; padding: 16px 4px 0; border-bottom: 1px solid var(--line); }
.report-month { flex: 1; height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 10px; }
.report-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.report-bars i { width: min(10px,38%); min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); }
.report-bars i.expense { background: #9b6652; }
.report-month span { padding-bottom: 8px; color: var(--muted); font: 10px var(--mono); white-space: nowrap; }
.report-month.current span { color: var(--ink); font-weight: 500; }
.report-rank { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: center; gap: 12px; min-height: 56px; border-top: 1px solid var(--line); }
.report-rank > span { color: var(--muted); font: 11px var(--mono); }
.report-rank > div { min-width: 0; display: grid; gap: 7px; }
.report-rank strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-rank i { height: 3px; overflow: hidden; border-radius: 2px; background: var(--soft); }
.report-rank i b { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.report-rank > b, .report-account-row > b { font: 500 13px var(--mono); font-variant-numeric: tabular-nums; }
.report-account-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 16px; min-height: 64px; border-top: 1px solid var(--line); }
.report-account-row > div { min-width: 0; display: grid; gap: 4px; }
.report-account-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-account-row small { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) { .power-grid, .report-grid { grid-template-columns: 1fr; } .report-kpis { grid-template-columns: repeat(2,1fr); } .report-grid .report-accounts { grid-column: auto; } }
@media (max-width: 720px) {
  .sidebar nav { display: flex; overflow-x: auto; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-item, .nav-item.active { min-width: 58px; flex: 0 0 58px; }
  .power-grid { grid-template-columns: 1fr; }
  .power-row { grid-template-columns: minmax(0,1fr) auto auto; }
  .power-row > b { grid-column: 1; }
  .report-kpis { grid-template-columns: 1fr 1fr; }
  .report-title { align-items: flex-start; }
  .report-title .secondary-btn { width: 100%; justify-content: center; }
  .cashflow-card, .report-merchants, .report-accounts { padding: 20px; }
  .cashflow-card .card-head { align-items: flex-start; }
  .cashflow-card .trend-change { max-width: 140px; text-align: right; }
  .cashflow-chart { gap: 4px; padding-inline: 0; }
  .report-bars { gap: 2px; }
}
@media (max-width: 440px) { .report-kpis { grid-template-columns: 1fr; } .cashflow-chart { overflow-x: auto; justify-content: flex-start; } .report-month { flex: 0 0 36px; } }
@media print { .sidebar,.topbar,.nav-item,.section-title button { display:none!important; } main { padding:0!important; } .view { display:none!important; } #reportsView { display:block!important; } .card,.report-kpis { break-inside:avoid; box-shadow:none!important; } }
.cloud-version-row,.shared-book-row { display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:8px;align-items:center;min-height:62px;border-top:1px solid var(--line); }
.cloud-version-row>div,.shared-book-row>div {display:grid;gap:4px;min-width:0}.cloud-version-row span,.shared-book-row span{color:var(--muted);font-size:12px}.shared-book-row{grid-template-columns:minmax(0,1fr) auto}.shared-book-row.active{box-shadow:inset 3px 0 var(--accent);padding-left:12px}.shared-book-row code{font:500 11px var(--mono);letter-spacing:.08em;color:var(--ink)}#sharedLedgerCard form+form{margin-top:18px;padding-top:18px;border-top:1px solid var(--line)}
[dir="rtl"] .shared-book-row.active { box-shadow: inset -3px 0 var(--accent); padding-left: 0; padding-right: 12px; }
@media (max-width: 720px) { .cloud-version-row { grid-template-columns: 1fr auto; padding-block: 10px; } .cloud-version-row > div { grid-column: 1 / -1; } }

/* Product guidance, feedback and the private owner dashboard. */
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--secondary); cursor: pointer; transition: border-color 140ms var(--ease), color 140ms var(--ease), background 140ms var(--ease); }
.icon-btn:hover { color: var(--ink); border-color: var(--muted); background: var(--soft); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.product-lead, .tutorial-intro { margin: -8px 0 20px; color: var(--secondary); line-height: 1.65; }
.product-choice-list { display: grid; gap: 8px; }
.product-choice { min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.product-choice:hover { border-color: var(--accent); background: var(--soft); }
#productPrivacyNote { margin-top: 18px; }
.privacy-note { color: var(--muted); font-size: 12px; line-height: 1.55; }
.tutorial-content { min-height: 230px; padding: 26px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.tutorial-number { margin-bottom: 36px; color: var(--accent); font-family: var(--mono); font-size: 13px; }
.tutorial-content h2 { max-width: 370px; margin-bottom: 12px; }
.tutorial-content p { max-width: 420px; margin: 0; color: var(--secondary); font-size: 15px; line-height: 1.65; }
.tutorial-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 18px 0; }
.tutorial-progress i { height: 3px; border-radius: 2px; background: var(--line); }
.tutorial-progress i.active, .tutorial-progress i.done { background: var(--accent); }
.tutorial-actions { display: flex; justify-content: space-between; gap: 10px; }
.feedback-auth-gate { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.feedback-auth-gate p { margin: 0 0 16px; color: var(--secondary); line-height: 1.6; }
#feedbackMessage { width: 100%; resize: vertical; min-height: 130px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; outline: 0; }
#feedbackMessage:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 92, 76, .1); }
.product-admin-title { align-items: flex-start; }
.product-admin-active .month-switch, .product-admin-active #openModal { display: none; }
.product-admin-title p:last-child { max-width: 680px; margin: 8px 0 0; color: var(--secondary); line-height: 1.55; }
.admin-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-kpis article { min-height: 126px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.admin-kpis span { display: block; color: var(--secondary); font-size: 13px; }
.admin-kpis strong { display: block; margin-top: 18px; font-family: var(--mono); font-size: 28px; font-weight: 500; }
.admin-kpis small { display: block; margin-top: 7px; color: var(--muted); }
.admin-feedback-card { padding: 22px; }
.admin-feedback-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; padding: 18px 0; border-top: 1px solid var(--line); }
.admin-feedback-row:first-child { border-top: 0; }
.admin-feedback-row > div { display: flex; align-items: center; gap: 10px; }
.admin-feedback-row p { grid-column: 1; margin: 0; color: var(--ink); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-feedback-row select { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 130px; }
.feedback-kind { padding: 3px 7px; border-radius: 5px; background: var(--soft); color: var(--secondary); font-size: 12px; }
.admin-feedback-row time { color: var(--muted); font-size: 12px; }
.admin-empty { padding: 34px 0; color: var(--muted); text-align: center; }

@media (max-width: 720px) {
  .product-help-btn { position: absolute; top: 0; right: 0; }
  .admin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-feedback-row { grid-template-columns: 1fr; }
  .admin-feedback-row select { grid-column: 1; grid-row: auto; width: 100%; }
  .tutorial-content { min-height: 260px; padding: 22px; }
}

@media (max-width: 440px) {
  .admin-kpis { grid-template-columns: 1fr; }
  .tutorial-actions .primary-btn, .tutorial-actions .secondary-btn { flex: 1; }
}
.sync-conflict{margin-top:16px;padding:14px;border:1px solid #c77763;background:#fff4ef;border-radius:8px;display:grid;gap:6px}.sync-conflict[hidden]{display:none}.sync-conflict span{font-size:12px;color:var(--muted)}.sync-conflict>div{display:flex;gap:8px;margin-top:6px}
