/* Shared interface refinements. Keep financial charts and their data scales intact. */
:root {
  --accent: #bd491d;
  --dark: #9e3b16;
  --muted: #58677a;
}
[hidden] { display: none !important; }
html { scroll-behavior: auto; }
.app-shell { font-size: 15px; }
.app-shell h1 { font-size: 30px; letter-spacing: -.8px; }
.app-shell .page-heading { margin-bottom: 24px; }
.app-shell .page-heading h1 { margin: 0; }
.app-shell .page-heading .eyebrow { display: none; }
.app-shell button, .app-shell .button { font-size: 14px; }
.app-shell input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
.app-shell select, .app-shell textarea { font-size: 14px; }
.app-shell input, .app-shell select, .app-shell textarea { min-width: 0; }
.app-shell label { font-size: 13px; }
.app-shell .check { min-height: 44px; }
.app-shell input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.app-shell .small, .app-shell small, .app-shell .footnote { font-size: 12px; }
textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.app-shell .text-link { white-space: normal; min-height: 36px; }
.app-shell .panel { box-shadow: 0 2px 8px #24384b03; }

/* Navigation distinguishes frequent tasks, reports and occasional configuration. */
.sidebar { padding-top: 24px; }
.brand { padding-bottom: 20px; }
.brand img { width: 135px; }
.nav-caption { color: var(--muted); font-size: 10px; letter-spacing: 1px; margin: 10px 14px; }
.primary-nav { gap: 2px; margin-bottom: 12px; }
.primary-nav a { min-height: 44px; padding: 10px 12px; }
.nav-group { border-top: 1px solid var(--line); padding-top: 6px; margin-bottom: 16px; }
.nav-group > summary { min-height: 44px; padding: 12px; font-size: 13px; color: var(--muted); }
.nav-group[open] > summary { margin-bottom: 0; }
.nav-group:has([aria-current=page]) > summary { color: var(--ink); }
.sidebar-bottom { padding-top: 14px; }
.scope-bar { max-width: 1450px; margin: auto; padding: 20px 40px 0; display: flex; align-items: center; gap: 12px; }
.scope-switch { display: inline-flex; padding: 4px; gap: 3px; background: #e9edf1; border-radius: 10px; }
.scope-switch a { min-width: 72px; min-height: 36px; display: grid; place-items: center; padding: 5px 16px; border-radius: 7px; font-size: 13px; color: var(--muted); font-weight: 600; }
.scope-switch a:hover { background: #f8fafb; text-decoration: none; }
.scope-switch a[aria-current] { color: var(--dark); background: white; box-shadow: 0 1px 4px #24384b10; }
.scope-note, .environment-label { font-size: 12px; color: var(--muted); }
.environment-label { margin-left: auto; border: 1px solid #d9dfe5; border-radius: 6px; padding: 3px 8px; }

/* Help stays close to the relevant task, without occupying the main reading path. */
.help-details { font-size: 13px; color: var(--muted); margin-top: 12px; }
.help-details > summary { padding: 10px 0; font-size: 13px; min-height: 40px; color: var(--muted); }
.help-details[open] > summary { margin-bottom: 0; color: var(--ink); }
.help-details p { max-width: 75ch; margin: 8px 0 12px; }
.balance-summary { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.balance-summary > div { min-width: 0; }
.balance-summary > div:last-child { max-width: 52%; }
.balance-summary h2 { color: var(--muted); font-size: 13px; font-weight: 550; margin-bottom: 6px; }
.balance-summary .budget-amount { font-size: 28px; margin: 0; }
.balance-summary .help-details { margin-top: 0; }
.overview-history { margin-bottom: 16px; }
.overview-history > summary { min-height: 48px; padding: 13px 18px; background: white; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-size: 14px; }
.overview-history[open] > summary { margin-bottom: 16px; }
.overview-method { margin-bottom: 22px; }
.metric p, .metric p a { font-size: 12px; }
.metric .metric-label { font-size: 14px; }
.budget-panel .empty-inline { padding: 10px 0; }
.budget-panel .empty-inline h3 { margin-top: 0; }

/* Settings remain a single explicit save, with smaller visual sections. */
.settings-page { max-width: 1040px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.form-grid > div { min-width: 0; }
.field-hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; max-width: 75ch; }
.settings-page .section-heading h2 { margin: 0; }
.settings-page .settings-account { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; }
.settings-account > summary { padding: 16px; font-size: 14px; overflow-wrap: anywhere; }
.settings-account > summary > span:first-child { font-weight: 650; }
.account-purpose { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin: 3px 0 0 17px; }
.settings-account[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 0; }
.settings-account-fields { padding: 18px; }
.settings-account-fields > :last-child { margin-bottom: 0; }
.settings-save { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; background: #fffffff5; border: 1px solid var(--line); border-radius: 12px; position: sticky; bottom: 16px; z-index: 20; box-shadow: 0 4px 20px #24384b0a; }
.settings-save button { white-space: normal; }

/* Tables keep direct sorting, with the alternate controls available on demand. */
.table-sort-options { margin: -4px 0 14px; }
.table-sort-options > summary { font-size: 13px; color: var(--muted); padding: 10px 0; min-height: 40px; }
.table-sort-options .table-sort-form { margin: 8px 0 0; }
.app-shell table { font-size: 13px; }
.app-shell th, .app-shell .date-cell { font-size: 12px; }
.app-shell .merchant-link strong { font-size: 13px; }
.app-shell .merchant-link small, .app-shell .category-pill { font-size: 12px; }
.transaction-table tbody tr:hover { background: #fafbfc; }
.filter-reset { font-size: 13px; min-height: 44px; display: inline-flex; align-items: center; }
.filter-panel { row-gap: 16px; }
.filter-panel #search { min-width: 190px; }
.connection-options { text-align: left; }
.connection-options summary { min-height: 44px; display: flex; align-items: center; font-size: 13px; color: var(--muted); }
.connection-options summary::after { content: '⌄'; margin-left: 8px; }
.destructive-link { display: block; color: var(--red); font-size: 13px; padding: 10px 0; }
.scope-context { color: var(--muted); font-size: 13px; margin-top: -8px; }
.review-help > summary { min-height: 40px; padding: 10px 0; font-size: 13px; }
[data-partner-review] > form.panel label { display: block; white-space: nowrap; }
[data-partner-review] > form.panel { align-items: center; }
[data-partner-review] > .actions { gap: 12px; flex-wrap: wrap; }
[data-partner-review] > .actions > a:not(.button) { min-height: 44px; display: inline-flex; align-items: center; }

@media (min-width: 1550px) {
  .scope-bar { padding-inline: 55px; }
}
@media (max-width: 1200px) {
  .scope-bar { padding-inline: 24px; }
  [data-partner-review] > form.panel label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 900px) {
  .mobile-brand img { width: 72px; height: auto; }
  .mobile-brand { font-size: 15px; }
  .mobile-menu > summary { min-height: 44px; display: flex; align-items: center; }
  .mobile-menu:has([aria-current=page]) > summary { background: var(--accent-soft); color: var(--dark); }
  .mobile-menu nav { top: 64px; width: min(320px, calc(100vw - 32px)); max-height: calc(100dvh - 160px); overflow-y: auto; }
  .mobile-menu nav > a { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; }
  .mobile-menu nav > a.active { background: var(--accent-soft); color: var(--dark); font-weight: 600; }
  .mobile-nav a { font-size: 11px; min-height: 46px; }
  .mobile-nav a.active { background: var(--accent-soft); border-radius: 8px; }
  .settings-save { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .app-shell { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 650px) {
  .app-shell h1 { font-size: 27px; }
  .scope-bar { padding: 16px 16px 0; flex-wrap: wrap; }
  .scope-switch a { min-height: 40px; min-width: 68px; }
  .scope-note { order: 3; flex-basis: 100%; }
  .app-shell .dashboard { padding-top: 22px; }
  .app-shell .page-heading { gap: 14px; margin-bottom: 20px; }
  .app-shell input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
  .app-shell select, .app-shell textarea { font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .balance-summary { display: block; }
  .balance-summary > div:last-child { max-width: none; margin-top: 8px; }
  .balance-summary .budget-amount { font-size: 27px; }
  .metric .metric-label { font-size: 13px; }
  .metric .balance { font-size: clamp(20px, 6vw, 25px); }
  .app-shell .metric p { font-size: 12px; margin-left: 0; }
  .settings-page .section-heading { align-items: flex-start; flex-direction: column; }
  .settings-account-fields { padding: 14px; }
  .settings-save { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; }
  .settings-save [role=status] { font-size: 12px; }
  .filter-panel #search { min-width: 0; }
  .filter-reset { justify-content: center; width: 100%; }
  .app-shell .merchant-link strong, .app-shell .transaction-table td.number strong { font-size: 12px; }
  .app-shell .merchant-link small { font-size: 11px; }
  .app-shell .category-pill { font-size: 11px; }
  .app-shell .budget-panel .button-small { min-height: 44px; font-size: 12px; }
  .app-shell .transactions > .section-heading .small { font-size: 12px; }
  [data-partner-review] > form.panel { flex-wrap: wrap; }
  [data-partner-review] > form.panel input:not([type=hidden]) { min-width: 120px; }
  .connection .actions { align-items: flex-start; }
  .scope-bar .environment-label { font-size: 11px; }
  .app-shell .legal-footer { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
@media (max-width: 650px) {
  .transaction-table { table-layout: fixed; }
  .transaction-table th:first-child { width: 47%; }
  .transaction-table th:nth-child(2) { width: 26%; }
  .transaction-table th:last-child { width: 27%; }
  .app-shell .transaction-table th { font-size: 11px; white-space: normal; }
  .transaction-table .table-sort { gap: 4px; white-space: normal; overflow-wrap: anywhere; }
  .transaction-table .merchant-link { min-width: 0; max-width: 100%; }
  .transaction-table .merchant-link > span { min-width: 0; }
  .transaction-table .category-pill { max-width: 100%; }
  .settings-page input, .settings-page select, .settings-page summary { scroll-margin-bottom: 230px; }
}
@media (max-width: 370px) {
  .transaction-table th:first-child { width: 66%; }
  .transaction-table th:last-child { width: 34%; }
}
.settings-save { background: #fff; }
