@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600&display=swap');

:root {
  --bg: #f2efe9; --surface: #f2efe9; --surface-soft: #f8f6f1;
  --ink: #2b2b2b; --muted: #74746f; --muted-readable: #6d6d69; --line: #d4d0c7;
  --brand: #2b2b2b; --accent: #9b7e56; --accent-soft: #eee7dc;
  --warning: #9b7e56; --warning-soft: #eee7dc;
  --income: #326a50; --danger: #985047;
  --shadow: 0 18px 48px rgba(22, 23, 23, .16);
}
html, body, button, input { font-family: 'Onest', system-ui, sans-serif; }
html, body, .app, main { background: var(--bg); color: var(--ink); }
.screen-heading small, .screen-heading p, .welcome small, .operation-copy small,
.operation-value small, .prototype-state p, .placeholder-screen p, .label,
.panel-row small, .profile p, .detail-field > span, .category-level-head strong,
.calendar-weekdays span, .filter-row small, .filter-field small,
.notification-item small, .notification-empty small, .operations-aside p,
.operations-aside dt { color: var(--muted-readable); }

.app > header { border-bottom-color: #2b2b2b; background: #2b2b2b; backdrop-filter: none; }
.logo { background: transparent; color: #f3efe7; box-shadow: none; font-size: 15px; font-weight: 600; letter-spacing: .11em; }
.header-back { color: #f3efe7; }
.header-actions button { color: #f3efe7; }
.avatar { color: #f3efe7; background: transparent; }
.avatar::before { background: rgba(255, 255, 255, .09); }
.notification-button b, #bottomNav b { border-color: #2b2b2b; background: #a4865b; color: #fff; }
.operations-search { border-color: var(--line); border-radius: 7px; background: var(--surface-soft); box-shadow: none; }

.day-heading { margin-bottom: 7px; color: var(--ink); letter-spacing: .035em; }
.day-heading h2 { color: var(--ink); font-weight: 600; }
.day-totals, .operation-value { font-variant-numeric: tabular-nums; }
.day-totals .expense { color: #626260; }
.day-totals .income, .type-income .operation-value strong { color: var(--income); }
.operation-list { overflow: visible; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.operation-swipe { border-color: var(--line); background: var(--danger); }
.operation-row { grid-template-columns: 42px minmax(0, 1fr) auto; padding: 10px 2px; background: var(--bg); color: var(--ink); }
.operation-row:hover { background: var(--bg); }
.operation-mark { width: 42px; height: 42px; border: 0; border-radius: 0; background: transparent; color: #555654; font-weight: 400; }
.type-expense .operation-mark, .type-income .operation-mark, .type-transfer .operation-mark { background: transparent; color: #555654; }
.operation-mark svg { width: 24px; height: 24px; stroke-width: 1.65; }
.operation-copy strong { font-weight: 600; letter-spacing: -.012em; }
.operation-copy small { color: var(--muted-readable); }
.operation-value strong, .type-expense .operation-value strong, .type-transfer .operation-value strong { color: var(--ink); font-weight: 600; }
.review-dot { background: var(--accent); }

#bottomNav { border-top-color: #2b2b2b; background: rgba(43, 43, 43, .985); box-shadow: none; }
#bottomNav button { color: #aaa9a4; }
#bottomNav button.active { color: #f4f0e8; }
#bottomNav button.active::before { content: ''; position: absolute; top: -5px; left: calc(50% - 13px); width: 26px; height: 2px; background: #a4865b; }

.overlay { background: rgba(22, 23, 23, .48); backdrop-filter: blur(2px); }
.scrim { background: rgba(16, 24, 20, .58); }
#panel { border-left: 1px solid var(--line); border-radius: 24px 0 0 24px; background: var(--bg); box-shadow: -16px 0 44px rgba(25, 25, 25, .12); }
.panel-head { min-height: 60px; border-bottom: 1px solid var(--line); }
.panel-head strong { color: var(--ink); font-size: 21px; font-weight: 600; }
.panel-head [data-action="close"]:not(.panel-back) { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); }
.panel-head [data-action="close"]:focus-visible { outline: 0; color: var(--accent); font-weight: 600; }
.panel-head .panel-back { width: auto; height: 44px; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--accent); font-size: var(--type-control); font-weight: 600; }

.filters-panel { background: var(--bg); }
.filter-rows, .filter-row, .filter-field-shell { background: transparent; }
.filter-rows > .filter-row, .filter-row-block { border-color: var(--line); }
.filter-row small, .filter-field small { color: var(--muted-readable); }
.filter-row strong, .filter-field strong { color: var(--ink); }
.amount-input { border-color: #c9c4ba; border-radius: 8px; background: var(--surface-soft); }
.amount-range input::placeholder { color: var(--muted-readable); }
.filter-review input { accent-color: var(--ink); }
.filter-actions { border-top: 1px solid var(--line); background: var(--bg); }
.filter-actions button { border-radius: var(--action-radius); }
.filter-actions [data-action="reset-filters"] { border-color: #c9c4ba; background: transparent; color: var(--ink); }
.filter-actions .primary { border-color: var(--ink); background: var(--ink); color: #f6f2ea; }

.operation-detail { border: 0; border-radius: 22px 22px 0 0; background: var(--bg); box-shadow: 0 -18px 48px rgba(22, 23, 23, .16); }
.operation-detail .panel-head { height: 60px; min-height: 60px; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; margin: 0; padding: 0 16px 0 24px; }
.operation-detail .panel-head strong { line-height: 1; transform: none; }
.operation-detail .panel-head [data-action="close"] { width: 44px; height: 44px; place-self: center; transform: none; }
.operation-detail .detail-hero { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 22px 0; border-bottom: 1px solid var(--line); text-align: left; }
.detail-pictogram { display: grid; place-items: center; width: 32px; height: 32px; color: #555654; }
.detail-pictogram svg { width: 24px; height: 24px; stroke-width: 1.65; }
.operation-detail .detail-hero h2 { grid-column: 2; margin: 0; font-size: 15px; font-weight: 600; }
.operation-detail .amount-editor { grid-column: 3; margin: 0; color: var(--ink); font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-hero.type-expense .amount-editor, .detail-hero.type-transfer .amount-editor { color: var(--ink); }
.operation-detail .detail-hero > .inline-editor { grid-column: 2 / -1; }
.operation-detail .detail-fields { border: 0; border-radius: 0; background: transparent; }
.operation-detail .detail-field-wrap { border-color: var(--line); }
.operation-detail .detail-field { padding: 16px 0; background: transparent; }
.operation-detail .detail-field > span { color: var(--muted-readable); }
.operation-detail .detail-field > strong { color: var(--ink); }
.operation-detail .source-details { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.operation-detail .source-details summary { display: flex; align-items: center; gap: 9px; padding: 17px 0; color: #5f605d; list-style: none; }
.operation-detail .source-details summary::-webkit-details-marker { display: none; }
.operation-detail .source-details summary::before { content: ''; width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 6px solid #5f605d; transition: transform .16s ease; }
.operation-detail .source-details[open] summary::before { transform: rotate(90deg); }
.operation-detail .delete-from-card { background: transparent; color: var(--danger); }

.anchored-popover, .category-popover { border-color: #cfcac0; border-radius: 10px; background: var(--surface-soft); box-shadow: 0 14px 36px rgba(25, 25, 25, .12); }
.anchored-popover button, .category-popover button { border-color: var(--line); background: transparent; color: var(--ink); }
.anchored-popover svg, .category-popover svg { color: #5d5e5b; }
.anchored-popover [aria-pressed="true"], .category-popover [aria-pressed="true"] { background: #ebe6dc; color: var(--ink); }
.anchored-popover [data-action*="add"], .category-popover [data-action*="add"] { color: #7b6243; }
.detail-field-wrap:has([data-edit-field="category"][aria-expanded="true"]) .detail-field > span { color: #7b6243; font-weight: 600; }
.detail-field-wrap:has([data-edit-field="category"][aria-expanded="true"]) .detail-field > svg { color: var(--accent); }

.notification-panel { border-radius: 24px 0 0 24px; background: var(--bg); }
.notification-tabs { display: flex; gap: 24px; padding: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.notification-tabs button { flex: 0 0 auto; padding: 16px 0 13px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted-readable); }
.notification-tabs button.active { border-bottom-color: var(--accent); background: transparent; color: var(--ink); box-shadow: none; }
.notification-list { margin-top: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.notification-item { padding: 18px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.notification-item.unread { background: transparent; }
.notification-item i { width: 7px; height: 7px; background: transparent; }
.notification-item.unread i { background: var(--accent); }
.notification-item strong { color: var(--ink); }
.notification-item.read strong { color: var(--muted-readable); }
.notification-item small { color: var(--muted-readable); }
.toast { background: var(--ink); color: #f6f2ea; }

@media (orientation: landscape) {
  .app > header { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .operations-route .app > header { padding-left: max(17px, env(safe-area-inset-left)); padding-right: max(17px, env(safe-area-inset-right)); }
  #panel { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  main { padding-left: max(17px, env(safe-area-inset-left)); padding-right: max(17px, env(safe-area-inset-right)); }
  #bottomNav { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); }
}


/* Final shared FFO role system — keep before screen overrides. */
:root {
  --type-display-size: 30px; --type-display-line: 33px; --type-display-weight: 600;
  --type-screen-title-size: 21px; --type-screen-title-line: 25px; --type-screen-title-weight: 600;
  --type-detail-title-size: 25px; --type-detail-title-line: 30px; --type-detail-title-weight: 500;
  --type-detail-total-size: 21px; --type-detail-total-line: 25px; --type-detail-total-weight: 500;
  --type-section-title-size: 15px; --type-section-title-line: 19px; --type-section-title-weight: 600;
  --type-row-title-size: 12px; --type-row-title-line: 16px; --type-row-title-weight: 600;
  --type-body-size: 11px; --type-body-line: 16px; --type-body-weight: 400;
  --type-meta-size: 10px; --type-meta-line: 14px; --type-meta-weight: 500;
  --type-control-size: 11px; --type-control-line: 11px; --type-control-weight: 600;
  --type-display: var(--type-display-size); --type-screen-title: var(--type-screen-title-size);
  --type-detail-title: var(--type-detail-title-size); --type-detail-total: var(--type-detail-total-size);
  --type-section-title: var(--type-section-title-size); --type-row-title: var(--type-row-title-size);
  --type-body: var(--type-body-size); --type-meta: var(--type-meta-size); --type-control: var(--type-control-size);
  --type-field-native: 16px; --muted: #6d6d69;
}
html, body, button, input, select, textarea { font-family: 'Onest', system-ui, sans-serif; }
body { font-size: var(--type-body-size); line-height: var(--type-body-line); font-weight: var(--type-body-weight); }
input, select, textarea { font-size: 16px; font-weight: 400; }
.screen-heading h1, .panel-head strong, .review-editor-hero h2, .review-confirmation h2 { font-size: var(--type-screen-title-size); line-height: var(--type-screen-title-line); font-weight: var(--type-screen-title-weight); }
.section-head h2, .overview-section-head h2, .reference-section-head h2 { font-size: var(--type-section-title-size); line-height: var(--type-section-title-line); font-weight: var(--type-section-title-weight); }
.operation-copy strong, .settings-row strong, .reference-row strong, .panel-row span, .review-group-copy strong, .rule-main strong { font-size: var(--type-row-title-size); line-height: var(--type-row-title-line); font-weight: var(--type-row-title-weight); }
.operation-copy small, .settings-row small, .reference-row small, .rule-main small, .review-group-copy small, .review-assignment-field small { font-size: var(--type-meta-size); line-height: var(--type-meta-line); font-weight: var(--type-meta-weight); color: var(--muted); }
button, .label, .settings-section > h2, .overview-caption, .overview-eyebrow { font-size: var(--type-control-size); line-height: var(--type-control-line); font-weight: var(--type-control-weight); }
.summary strong, .overview-balance-main strong, .overview-expense-total strong, .overview-all-total strong, .overview-category-summary strong { font-size: var(--type-display-size); line-height: var(--type-display-line); font-weight: var(--type-display-weight); font-variant-numeric: tabular-nums; }

.logo { width: 44px; height: 44px; padding: 0; border-radius: 0; }
.header-logo-mark { display: block; width: 28px; height: 28px; }
.settings-route .location { display: block; min-width: 0; color: #f2efe9; }
.settings-route .location small { color: #b9b6b0; font-size: var(--type-meta-size); line-height: var(--type-meta-line); font-weight: var(--type-meta-weight); }
.settings-route .location strong { color: #f2efe9; font-size: var(--type-row-title-size); line-height: var(--type-row-title-line); font-weight: var(--type-row-title-weight); }
.panel-head { height: 60px; min-height: 60px; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; margin: 0 0 12px; padding: 0; }
.panel-head [data-action="close"]:not(.panel-back) { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); box-shadow: none; outline: 0; }
.panel-head [data-action="close"]:not(.panel-back) svg { width: 18px; height: 18px; }
.panel-head [data-action="close"]:focus-visible { outline: 0; color: var(--accent); font-weight: 600; }


/* Flat panel, menu, profile, review, rules, and integration surfaces. */
.panel-list, .family, .integration-status-card { overflow: visible; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); box-shadow: none; }
.family { padding: 14px 0; border-bottom: 1px solid var(--line); }
.family small, .family strong { color: inherit; }
.panel-row { min-height: 60px; padding: 8px 0; border-bottom: 1px solid var(--line); background: transparent; }
.panel-row i { width: 36px; height: 36px; border-radius: 0; background: transparent; color: var(--ink); }
.profile { display: grid; grid-template-columns: 52px minmax(0,1fr); column-gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); text-align: left; }
.profile-avatar { grid-row: 1 / 3; width: 52px; height: 52px; margin: 0; background: transparent; border: 1px solid var(--line); font-weight: 600; }
.profile h2 { align-self: end; margin: 0; font-size: var(--type-row-title-size); line-height: var(--type-row-title-line); font-weight: var(--type-row-title-weight); }
.profile p { align-self: start; margin: 2px 0 0; font-size: var(--type-meta-size); line-height: var(--type-meta-line); font-weight: var(--type-meta-weight); }
.review-groups { gap: 0; }
.review-groups.is-list { gap: 0; }
.review-group { padding: 0; background: transparent; }
.review-group-toggle { min-height: 54px; }
.review-assignment-grid { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.review-assignment-field { border-bottom: 1px solid var(--line); }
.review-assignment-field + .review-assignment-field { border-left: 0; }
.review-assignment-field > button { min-height: 30px; padding: 0 7px; background: transparent; }
.review-assignment-actions { border-bottom: 1px solid var(--line); }
.review-apply:not(:disabled) { background: var(--ink); color: #f2efe9; opacity: 1; }
.review-operation-main strong { font-size: var(--type-row-title-size); line-height: var(--type-row-title-line); }
.review-operation-main small, .review-bank-label { font-size: var(--type-meta-size); line-height: var(--type-meta-line); }
.rule-toggle input:checked + span { background: var(--ink); }
.rule-main small { color: var(--muted); }
.integration-status-card { gap: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0 16px; }
.integration-status-card > span { min-height: 28px; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: var(--ink); }
.integration-status-card > span i { background: var(--accent); }
.integration-status-card > span i { width: 8px; height: 8px; flex: 0 0 8px; }
.integration-status-card > span strong { font-size: var(--type-row-title-size); line-height: var(--type-row-title-line); }
.integration-status-card > button { width: 100%; height: 55px; padding: 0 18px; border: 0; border-radius: var(--action-radius); background: #9b7e56; color: var(--ink); text-align: center; box-shadow: none; }
.integration-status-card > button:disabled { opacity: .72; cursor: wait; }
.reference-screen { gap: 16px; }
.settings-section { margin-top: 16px; }
.settings-row, .reference-row, .category-tree-main { min-height: 60px; }
.secondary-reference-action, .reference-section-head button, .category-tree-add-row { color: var(--accent); font-size: var(--type-control-size); line-height: var(--type-control-line); font-weight: var(--type-control-weight); }
.overview-progress i { background: var(--ink); }
.overview-month button, .overview-sort-controls button { color: var(--ink); }
.overview-sort-controls button[aria-pressed="true"] { border-bottom-color: var(--ink); color: var(--ink); }
.overview-category-row { min-height: 64px; }


/* Desktop keeps the graphite frame and ledger geometry. */
@media (min-width: 760px) {
  main { max-width: 1240px; padding-right: 30px; padding-left: 30px; }
  .operations-route main, .finance-work-route main { max-width: 1240px; }
  .settings-route main { max-width: 960px; }
  .overview-screen { max-width: 1180px; }
  .operations-layout { grid-template-columns: minmax(0,1fr) 280px; gap: 32px; }
  .operations-aside { padding: 0; border: 0; border-radius: 0; background: transparent; }
  .operations-aside h2 { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .operations-aside dl { margin-top: 0; }
  .operations-aside div { min-height: 44px; align-items: center; margin: 0; border-bottom: 1px solid var(--line); }
  .operation-swipe:hover .operation-row { transform: none; }
  .review-group { padding: 0; background: transparent; }
  .overview-category-row { min-height: 60px; padding: 10px 0; }
  #bottomNav { right: 0; bottom: 0; left: 0; height: 72px; padding: 5px 4px env(safe-area-inset-bottom); border: 0; border-top: 1px solid #2b2b2b; border-radius: 0; box-shadow: none; }
}
