:root {
  color-scheme: light;
  --canvas: #eeeae1;
  --surface: #faf8f3;
  --surface-2: #f2eee5;
  --ink: #1e1d1a;
  --muted: #57554f;
  --line: #d9d2c4;
  --accent: #33594f;
  --accent-ink: #fff;
  --accent-soft: #dfe7e2;
  --positive: #176a42;
  --negative: #a63832;
  --cost: #8f5a1c;
  --warn: #85570e;
  --warn-soft: #f5e7c8;
  --ok-soft: #e1eee5;
  --track: #e4ded1;
  --focus: #33594f;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sector-1: #3b7766;
  --sector-2: #66739e;
  --sector-3: #bc8546;
  --sector-4: #bc6660;
  --sector-5: #806d9a;
  --sector-6: #5d92a4;
  --sector-7: #8a9453;
  --sector-unassigned: #777268;
  --sector-cash: #c4b9a6;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f0f0f;
  --surface: #181818;
  --surface-2: #20201e;
  --ink: #ece8e1;
  --muted: #b7b2a8;
  --line: #35332f;
  --accent: #dfb943;
  --accent-ink: #17130a;
  --accent-soft: #37301a;
  --positive: #70ce95;
  --negative: #f18174;
  --cost: #d6a871;
  --warn: #e6bc65;
  --warn-soft: #352a16;
  --ok-soft: #1a3022;
  --track: #343027;
  --focus: #eac866;
  --sector-1: #6cbba1;
  --sector-2: #9ba9e0;
  --sector-3: #e6ad63;
  --sector-4: #e88780;
  --sector-5: #b29bd4;
  --sector-6: #84bfd2;
  --sector-7: #b8c475;
  --sector-unassigned: #ada79e;
  --sector-cash: #655d50;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--ink); }
* { scrollbar-color: var(--line) transparent; scrollbar-width: thin; }

.skip-link { position: fixed; z-index: 30; top: 8px; left: 8px; padding: 8px 12px; background: var(--accent); color: var(--accent-ink); transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.app { min-height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 15px; height: 52px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 232px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand strong { font-size: 13px; font-weight: 690; letter-spacing: -.01em; }
.brand-mark { display: block; width: 29px; height: 29px; flex: none; }
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.breadcrumb strong { color: var(--ink); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.freshness { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.freshness strong { color: var(--ink); font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); }
.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-decoration: none; white-space: nowrap; }
.button { padding: 0 12px; font-size: 13px; font-weight: 600; }
.icon-button { width: 36px; padding: 0; }
.button-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.menu-button { display: none; }
@media (hover: hover) and (pointer: fine) {
  .button:not(:disabled), .icon-button:not(:disabled) { transition: background-color 140ms ease, color 140ms ease; }
  .button:not(:disabled):hover, .icon-button:not(:disabled):hover { background: var(--surface-2); }
  .button-primary:not(:disabled):hover { background: var(--accent); filter: brightness(1.1); }
}

.workspace { display: grid; grid-template-columns: 254px minmax(0, 1fr); min-height: calc(100dvh - 52px); }
.sidebar { display: flex; flex-direction: column; gap: 18px; min-width: 0; padding: 12px 9px 0; border-right: 1px solid var(--line); background: var(--surface-2); }
.side-heading { display: block; margin: 6px 10px 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
.side-section { padding: 13px 5px 0; border-top: 1px solid var(--line); }
.side-section .side-heading { margin: 0 5px 7px; }
.side-section select { width: 100%; height: 36px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.side-section .app-select { width: 100%; }
.side-note { margin: 9px 5px 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.side-foot { display: flex; align-items: center; gap: 9px; margin: auto -9px 0; padding: 11px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.scrim { display: none; }

main { min-width: 0; padding: 19px 22px 30px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 13px; }
.page-heading h1 { margin: 0 0 3px; font-size: 23px; line-height: 1.2; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12.5px; }
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.panel-grid > .panel { margin: 0; }
.portfolio-jump { display: inline-block; margin-top: 7px; color: var(--accent); font-size: 12.5px; font-weight: 650; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; min-height: 46px; padding: 13px 15px 10px; }
.panel-head h2 { margin: 0; font-size: 15px; line-height: 1.25; font-weight: 660; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.panel-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.big-number { display: block; font-size: 27px; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; font-variant-numeric: tabular-nums; }
dt { color: var(--muted); }

.positions-panel { margin-top: 14px; scroll-margin-top: 66px; }
.positions-panel .panel-head { min-height: 59px; }
.positions-panel .form-message { margin: 0 15px 12px; }
.position-sector-filter { display: flex; align-items: center; gap: 12px; padding: 0 15px 11px; color: var(--muted); font-size: 12.5px; }
.position-sector-filter strong { color: var(--ink); }
.position-sector-filter a { color: var(--accent); font-weight: 650; }
.table-toolbar { display: grid; grid-template-columns: minmax(210px, .9fr) minmax(0, 2.1fr); align-items: end; gap: 12px; padding: 12px 15px 16px; }
.table-toolbar .panel-meta { margin-left: auto; }
.position-search-field { min-width: 0; }
.search-field { display: flex; align-items: center; gap: 7px; width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); }
.search-field svg { width: 16px; height: 16px; }
.search-field:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 13px; }
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.period-hint { margin: 0; padding: 0 15px 12px; font-size: 12.5px; }
.period-hint { color: var(--muted); }
.positions-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.positions-table thead { background: var(--surface-2); }
.positions-table thead th { padding: 7px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: right; white-space: nowrap; }
.positions-table thead th:first-child { text-align: left; padding-left: 15px; }
.positions-table tbody tr + tr.position-row { border-top: 1px solid var(--line); }
.positions-table > tbody > tr > td, .positions-table > tbody > tr > th { padding: 8px 10px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.positions-table > tbody > tr > th { padding-left: 15px; text-align: left; font-weight: 400; }
.position-button { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); text-align: left; }
.position-button strong { display: block; font-size: 13px; line-height: 1.2; }
.position-button small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.position-button svg { width: 14px; height: 14px; margin-left: 3px; color: var(--muted); }
.position-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.ticker-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; font-size: 13px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; padding: 3px 6px; border-radius: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--positive); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.detail-row:not([hidden]) { background: var(--surface-2); }
.positions-table > tbody > .detail-row > td { padding: 0; text-align: left; white-space: normal; }
.detail-reveal { overflow: hidden; }
.position-detail { padding: 15px; border-top: 1px solid var(--line); }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.detail-heading h3 { margin: 0; font-size: 15px; line-height: 1.25; }
.detail-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.detail-layout { display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); gap: 22px; padding-top: 14px; }
.detail-layout h4 { margin: 0 0 10px; font-size: 12.5px; }
.detail-ledger { padding-right: 20px; border-right: 1px solid var(--line); }
.detail-ledger dl { margin: 0; }
.detail-ledger dl div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.detail-ledger dt { color: var(--ink); }
.detail-ledger dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-ledger .detail-gross { border-top: 1px solid var(--line); font-weight: 650; }
.detail-ledger .detail-total { padding: 9px 0; border-bottom: 0; font-weight: 700; }
.detail-ledger .detail-total dt { color: var(--ink); font-weight: 750; }
.detail-ledger .detail-total dd { color: var(--ink); font-weight: 750; }
.detail-ledger .detail-total.positive dd { color: var(--positive); }
.detail-ledger .detail-total.negative dd { color: var(--negative); }
.detail-note, .detail-warning { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.detail-warning .badge { margin-right: 5px; }
.detail-operations { min-width: 0; }
.detail-operations-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.detail-operations-head span { color: var(--muted); font-size: 12px; }
.operation-kind { color: var(--ink); font-weight: 600; }
.operation-amount { color: var(--ink); font-weight: 650; }
.op-child { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; color: var(--cost); font-size: 11.5px; }
.empty-state { margin: 0; padding: 18px 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

.quality-popover { position: fixed; inset: 58px 12px auto auto; width: min(380px, calc(100vw - 24px)); max-height: calc(100dvh - 70px); margin: 0; padding: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.quality-popover .panel-head { border-bottom: 1px solid var(--line); }
.quality-popover .panel-meta { display: block; margin-top: 4px; }
.quality-body { padding: 3px 15px 14px; }
.quality-note { display: block; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.text-button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--accent); font-size: 12.5px; font-weight: 650; }
.text-button svg { width: 14px; height: 14px; }

@media (max-width: 1180px) {
  .freshness { display: none; }
  .panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid > .sector-panel { grid-column: 1 / -1; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-ledger { padding: 0 0 16px; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .menu-button { display: inline-flex; }
  .brand { min-width: 0; }
  .brand strong { display: none; }
  .breadcrumb { gap: 5px; font-size: 12.5px; }
  .breadcrumb span:first-child { display: none; }
  .breadcrumb span:nth-child(2) { display: none; }
  .top-actions { gap: 5px; }
  .top-actions .button { width: 36px; padding: 0; }
  .top-actions .button span { display: none; }
  .workspace { display: block; }
  .sidebar { position: fixed; z-index: 20; top: 52px; bottom: 0; left: 0; width: min(280px, 86vw); transform: translateX(-100%); transition: transform 220ms var(--ease-drawer); box-shadow: 8px 0 24px rgba(0,0,0,.18); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; z-index: 19; inset: 52px 0 0; width: 100%; border: 0; background: rgba(0,0,0,.35); }
  main { padding: 17px 12px 28px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 21px; }
  .panel-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .positions-panel .panel-head { align-items: center; }
  .table-toolbar { grid-template-columns: minmax(0, 1fr); }
  .table-toolbar .panel-meta { margin-left: 0; }
  .search-field { width: 100%; }
  .positions-table, .positions-table > tbody, .position-row, .detail-row { display: block; width: 100%; }
  .positions-table > thead { display: none; }
  .position-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 10px 13px; }
  .position-row + .position-row { border-top: 1px solid var(--line); }
  .position-row th { grid-column: 1 / -1; }
  .positions-table > tbody > .position-row > th, .positions-table > tbody > .position-row > td { display: block; padding: 0; text-align: left; }
  .position-row td::before { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; content: attr(data-label); }
  .positions-table > tbody > .detail-row > td { display: block; }
  .position-detail { padding: 13px; }
  .quality-note .badge { margin-bottom: 7px; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 760px) {
  .sidebar { opacity: 0; transition: opacity 100ms var(--ease-out); }
  .app.nav-open .sidebar { opacity: 1; }
}

/* Production components built on the approved palette and spacing. */
a { color: var(--accent); }
a:hover { text-decoration: underline; }
input, select, textarea { font: inherit; }
.app-main { min-width: 0; }
.app-nav-links .nav-link { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: 6px; color: var(--ink); font-size: 13.5px; text-decoration: none; }
.app-nav-links .nav-link[aria-current="page"] { background: var(--accent-soft); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .app-nav-links .nav-link { transition: background-color 140ms ease; } .app-nav-links .nav-link:hover:not([aria-current="page"]) { background: var(--line); text-decoration: none; } }
.side-foot { justify-content: space-between; }
.logout-link { border: 0; background: transparent; color: var(--accent); font-weight: 600; }
.theme-toggle { width: 36px; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle [data-theme-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.page-content { width: 100%; min-width: 0; padding: 19px 22px 36px; }
.page-heading { margin-bottom: 16px; flex-wrap: wrap; }
.page-heading h1 { font-size: 24px; }
.page-heading form { flex: none; }
.snapshot-form, .heading-action { display: flex; align-items: center; gap: 8px; }
.snapshot-form input { width: 195px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.btn-outline-danger { color: var(--negative); }
.btn-sm { min-height: 28px; padding: 4px 8px; }
@media (hover: hover) and (pointer: fine) { .btn { transition: background-color 140ms ease, color 140ms ease; } .btn:hover { background: var(--surface-2); text-decoration: none; } .btn-primary:hover { background: var(--accent); filter: brightness(1.1); } }
.form-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.form-control, .form-select, input[type="file"] { min-width: 0; min-height: 36px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 13px; }
.app-select { position: relative; display: block; min-width: 0; }
.app-select__native { position: absolute; width: 1px !important; height: 1px !important; min-height: 0 !important; margin: -1px; padding: 0 !important; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0 !important; white-space: nowrap; opacity: 0; pointer-events: none; }
.app-select__trigger { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 36px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; line-height: 1.25; text-align: left; }
.app-select__trigger svg { width: 16px; height: 16px; color: var(--muted); transition: transform 140ms var(--ease-out); }
.app-select__trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.app-select__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-select__trigger.is-placeholder .app-select__value { color: var(--muted); }
.app-select__popup { position: fixed; z-index: 40; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 28px rgba(0,0,0,.22); }
.app-select__search { flex: none; width: auto; min-height: 36px; margin: 8px 8px 6px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 13px; }
.app-select__options { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.app-select__group + .app-select__group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.app-select__group-label { display: block; padding: 5px 8px 3px; color: var(--muted); font-size: 11px; font-weight: 650; }
.app-select__option { display: block; width: 100%; min-height: 32px; padding: 6px 8px; border: 0; border-radius: 5px; background: transparent; color: var(--ink); font: inherit; font-size: 13px; line-height: 1.3; text-align: left; }
.app-select__option[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.app-select__option:disabled { color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .app-select__trigger:not(:disabled):hover { border-color: var(--muted); }
  .app-select__option:not(:disabled):hover { background: var(--surface-2); }
  .app-select__option[aria-selected="true"]:hover { background: var(--accent); filter: brightness(1.08); }
}
.form-control { width: 100%; }
.form-text { margin-top: 6px; color: var(--muted); font-size: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.text-secondary, .mb-0.text-secondary, .panel p, .section-header p, .card-header p { color: var(--muted); }
.mb-0 { margin-bottom: 0 !important; }
.panel { margin-bottom: 14px; }
.section-header, .card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.section-header h2, .card-header h2, .panel h2 { margin: 0; font-size: 15px; line-height: 1.3; }
.section-header p, .card-header p { margin: 4px 0 0; font-size: 12.5px; }
.quiet-badge { padding: 3px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.table-responsive { position: relative; width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.table .number-cell, .number-cell { text-align: right; font-variant-numeric: tabular-nums; }
.table small { display: block; color: var(--muted); font-size: 11px; }
.empty-cell, .empty-list { padding: 16px !important; color: var(--muted); text-align: left !important; white-space: normal !important; }
.list-group { margin: 0; padding: 0; list-style: none; }
.list-group-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 15px; border-bottom: 1px solid var(--line); }
.list-group-item:last-child { border-bottom: 0; }
.list-group-item small, .empty-list span { display: block; color: var(--muted); font-size: 12px; }
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }
.cost { color: var(--cost) !important; }
.period-note { margin: 8px 15px 14px; font-size: 12px; }
.positions-panel .panel-head { border-bottom: 1px solid var(--line); }
.position-filters { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) auto; align-items: end; gap: 10px; min-width: 0; }
.operations-filters { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.position-filter-field { min-width: 0; }
.position-filter-field .form-select, .position-filter-field .app-select { width: 100%; max-width: none; height: 38px; }
.position-filters > .btn { height: 38px; }
.period-control { min-width: 150px; }
.period-custom { display: flex; gap: 8px; }
.period-custom > div { max-width: 160px; }
.position-button .chevron { margin-left: 7px; color: var(--muted); }
.position-button[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.instrument-logo { width: 26px; height: 26px; object-fit: contain; border-radius: 5px; }
.ticker-icon { background: var(--brand-bg, var(--accent)); color: var(--brand-fg, var(--accent-ink)); }
.positions-table > tbody > .position-row > td, .positions-table > tbody > .position-row > th { border-bottom: 1px solid var(--line); }
.detail-row .position-detail { white-space: normal; }
.detail-heading a { white-space: nowrap; }
.detail-operations-head { align-items: flex-start; }
.detail-operations-head h4 { margin: 0; }
.instrument-ops-placeholder { color: var(--muted); font-size: 12px; }
.instrument-ops-table td:nth-child(3), .instrument-ops-table th:nth-child(3) { text-align: right; }
.op-load-more { margin: 6px; }
.quality-popover { z-index: 25; }
.quality-close { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.quality-body strong { font-variant-numeric: tabular-nums; }
.workflow-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px; }
.workflow-copy h2 { margin: 0 0 4px; }
.workflow-copy p { margin: 0; font-size: 12px; }
.reconciliation-form, .import-form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.reconciliation-form > div { min-width: 200px; }
.report-job { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 15px; border-bottom: 1px solid var(--line); }
.report-job:last-child { border-bottom: 0; }
.job-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.job-copy small { color: var(--muted); }
.job-status { padding: 3px 6px; border-radius: 4px; background: var(--surface-2); font-size: 11px; }
.operations-filters { padding: 13px 15px; }
.operation-kind { display: inline-flex; align-items: center; gap: 7px; }
.operation-kind small { font-weight: 400; }
.op-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.op-badge--cost { background: var(--warn-soft); color: var(--warn); }
.op-badge--income { background: var(--ok-soft); color: var(--positive); }
.snapshot-list a { font-weight: 600; }
.snapshot-list time { color: var(--muted); font-size: 12px; }
.import-zone { display: flex; justify-content: space-between; gap: 20px; padding: 15px; border-top: 1px solid var(--line); }
.import-zone h3 { margin: 0; font-size: 13px; }
.import-zone p { margin: 4px 0 0; font-size: 12px; }
.settings-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, 1fr); gap: 14px; }
.settings-panel .settings-fields { display: grid; gap: 14px; padding: 15px; }
.settings-panel .settings-fields > div { max-width: 520px; }
.form-footer { display: flex; align-items: center; gap: 12px; padding: 0 15px 15px; }
.form-footer span { color: var(--muted); font-size: 12px; }
/* A form with only an action: no fields above to space the footer from the header rule. */
.form-footer--solo { padding-top: 15px; }
.security-panel { padding: 15px; }
.security-panel p { font-size: 12.5px; }
.auth-shell { min-height: 100dvh; }
.auth-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.auth-brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.auth-brand img { display: block; width: 29px; height: 29px; }
.auth-wrap { display: grid; place-items: center; padding: 40px 15px; }
.auth-card { width: min(430px, 100%); padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.auth-card h1 { margin: 0 0 5px; font-size: 22px; }
.auth-card p { color: var(--muted); }
.auth-form { display: grid; gap: 14px; }
.auth-note { margin-bottom: 0; font-size: 12px; }
.alert-danger { padding: 9px; border: 1px solid var(--negative); border-radius: 6px; color: var(--negative) !important; }
.w-100 { width: 100%; }
@media (max-width: 1320px) {
  .table-toolbar { grid-template-columns: minmax(0, 1fr); }
  .position-search-field { max-width: 360px; }
}
@media (max-width: 900px) and (min-width: 761px) {
  .position-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .position-filters > .btn { grid-column: 1 / -1; width: 100%; }
}
@media (max-width: 760px) {
  .page-content { padding: 17px 12px 28px; }
  .portfolio-heading { display: block; }
  .portfolio-heading .snapshot-form { margin-top: 12px; }
  .snapshot-form input { flex: 1; width: auto; }
  .snapshot-form .btn { font-size: 11px; }
  .workflow-panel, .import-zone { align-items: stretch; flex-direction: column; }
  .settings-layout { grid-template-columns: 1fr; }
  .position-search-field { max-width: none; }
  .position-filters { grid-template-columns: minmax(0, 1fr); }
  .position-filters > .btn { grid-column: auto; width: 100%; }
  .period-custom > div { flex: 1 1 120px; min-width: 0; max-width: none; }
  .period-custom .form-control { width: 100%; }
  .positions-table > tbody > .position-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .positions-table > tbody > .position-row > th { grid-column: 1 / -1; }
  .position-row td { overflow-wrap: anywhere; }
  .detail-operations-head { display: block; }
  .report-job { align-items: flex-start; flex-direction: column; }
  .table-responsive .table { min-width: 580px; }
}

.trade-buy, .trade-sell { color: var(--ink); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.detail-card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.detail-card > header p { margin: 4px 0 0; font-size: 12px; }
.detail-card dl { margin: 0; padding: 4px 15px 12px; }
.detail-card dl div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.detail-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.detail-card .detail-total { font-weight: 700; }
.quality-badge { padding: 3px 6px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); font-size: 11px; }
.back-link { display: inline-block; margin-bottom: 7px; font-size: 12px; text-decoration: none; }
.ticker-pill { font-weight: 700; }

.app-nav-links .nav-link svg { width: 16px; height: 16px; color: var(--muted); }
.app-nav-links .nav-link[aria-current="page"] svg { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .button, .icon-button, .btn, .app-nav-links .nav-link { transition-duration: 80ms; }
}

/* Sector classification and allocation share the existing panel vocabulary. */
.sectors-admin .sector-create-form { display: flex; align-items: end; gap: 9px; padding: 15px; }
.sector-create-form > div { width: min(340px, 100%); }
.sector-admin-list { border-top: 1px solid var(--line); }
.sector-admin-row { justify-content: flex-start; flex-wrap: wrap; }
.sector-rename-form { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; max-width: 500px; }
.sector-rename-form .form-control { max-width: 300px; }
.sector-count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sector-admin-note { margin: 0; padding: 10px 15px 14px; color: var(--muted); font-size: 12px; }
.form-message { margin: 0 0 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--accent-soft); color: var(--ink); font-size: 12.5px; }
.sectors-admin .form-message { margin: 12px 15px 0; }
.form-message--error { border-color: var(--negative); background: var(--surface); color: var(--negative); }
.sector-assign-form { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sector-assign-form .form-label { margin: 0; }
.sector-assign-form .form-select, .sector-assign-form .app-select { flex: 0 1 220px; min-width: 150px; max-width: 240px; }
.sector-assign-form a, .sector-assign-empty { font-size: 12px; }
.sector-assign-empty { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sector-panel { margin-top: 14px; }
.panel-grid .sector-panel { margin-top: 0; }
.sector-panel .panel-head { align-items: center; border-bottom: 1px solid var(--line); }
.sector-panel .panel-head .text-button { white-space: nowrap; }
.sector-chart-content { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 20px; max-width: 840px; padding: 12px 20px; }
.sector-chart-plot { position: relative; width: 166px; height: 166px; margin: auto; }
.sector-chart-plot svg { width: 100%; height: 100%; overflow: visible; }
.sector-chart-track, .sector-chart-slice { fill: none; stroke-width: 16; }
.sector-chart-track { stroke: var(--track); }
.sector-chart-slice { stroke: var(--sector-color); stroke-linecap: butt; transform: rotate(-90deg); transform-origin: 50% 50%; }
.sector-chart-center { position: absolute; inset: 18%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.sector-chart-center span { color: var(--muted); font-size: 11px; }
.sector-chart-center strong { margin-top: 4px; font-size: 14px; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.sector-legend { margin: 0; padding: 0; list-style: none; }
.sector-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.sector-legend li:last-child { border-bottom: 0; }
.sector-swatch { width: 11px; height: 11px; border-radius: 3px; background: var(--sector-color); }
.sector-legend-name { overflow-wrap: anywhere; }
.sector-legend a.sector-legend-name { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.sector-legend strong, .sector-legend-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sector-legend-value { min-width: 95px; color: var(--muted); text-align: right; }
.sector-color-1 { --sector-color: var(--sector-1); }
.sector-color-2 { --sector-color: var(--sector-2); }
.sector-color-3 { --sector-color: var(--sector-3); }
.sector-color-4 { --sector-color: var(--sector-4); }
.sector-color-5 { --sector-color: var(--sector-5); }
.sector-color-6 { --sector-color: var(--sector-6); }
.sector-color-7 { --sector-color: var(--sector-7); }
.sector-color-8 { --sector-color: var(--sector-unassigned); }
.sector-color-9 { --sector-color: var(--sector-cash); }
@media (max-width: 760px) {
  .sectors-admin .sector-create-form { align-items: stretch; flex-direction: column; }
  .sector-create-form > div { width: 100%; }
  .sector-admin-row { align-items: flex-start; }
  .sector-rename-form { flex-wrap: wrap; }
  .sector-rename-form .form-control { flex: 1; min-width: 150px; }
  .sector-count { margin-left: 0; }
  .sector-chart-content { grid-template-columns: 1fr; gap: 12px; padding: 16px 14px; }
  .sector-panel .panel-head { align-items: flex-start; flex-direction: column; }
  .sector-legend li { grid-template-columns: 12px minmax(0, 1fr) auto; gap: 8px; }
  .sector-legend-value { grid-column: 2 / -1; min-width: 0; text-align: left; }
}

/* Portfolio summary: three panels share one frame (head, figure, ruled rows) */
.portfolio-period { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.portfolio-period .period-control { width: 210px; }
.portfolio-period .period-control .app-select, .portfolio-period .btn, .portfolio-period .period-custom .form-control { height: 38px; }
.portfolio-period-hint { flex: 1 1 220px; margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.summary-panel, .panel-grid > .sector-panel { display: flex; flex-direction: column; }
.summary-main { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding: 4px 15px 14px; }
.summary-main span { color: var(--muted); font-size: 12.5px; }
.summary-rows { margin: auto 0 0; border-top: 1px solid var(--line); }
.summary-rows div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 15px; font-size: 12.5px; }
.summary-rows dd { margin: 0; font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-total { background: var(--surface-2); border-top: 1px solid var(--line); }
.summary-total dt, .summary-total dd { color: var(--ink); font-weight: 700; }
.summary-panel .period-note { margin-top: 0; }
.panel-grid > .sector-panel .panel-head { border-bottom: 0; }
.panel-grid .sector-chart-content { flex: 1; grid-template-columns: 124px minmax(0, 1fr); gap: 16px; max-width: none; padding: 4px 15px 14px; }
.panel-grid .sector-chart-plot { width: 124px; height: 124px; }
.panel-grid .sector-chart-center strong { font-size: 12px; }
.panel-grid .sector-legend li { grid-template-columns: 11px minmax(0, 1fr) auto; gap: 2px 8px; padding: 5px 0; }
.panel-grid .sector-legend-value { grid-column: 2 / -1; min-width: 0; font-size: 12px; text-align: left; }
.sector-color-other { --sector-color: var(--track); }

/* Period dynamics */
.history-panel { margin-top: 14px; scroll-margin-top: 66px; }
.history-panel .panel-head { flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.segmented-links { display: inline-grid; grid-auto-flow: column; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.segmented-links a { display: flex; align-items: center; min-height: 30px; padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.segmented-links a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.history-panel > .form-message { margin: 12px 15px 0; }
.history-panel > .empty-state { margin: 0; padding: 16px 15px; }
.history-confirm { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 16px 15px; }
.history-confirm > div:first-child { flex: 1 1 420px; max-width: 760px; }
.history-confirm h3 { margin: 0 0 6px; font-size: 14px; }
.history-confirm p { margin: 0 0 6px; font-size: 12.5px; line-height: 1.45; }
.history-confirm p strong { color: var(--ink); }
.history-confirm-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; padding: 12px 15px 4px; }
.metric-switch { display: flex; flex-wrap: wrap; margin: 0; padding: 0; border: 0; }
.metric-switch label { position: relative; display: flex; align-items: center; min-height: 32px; margin-left: -1px; padding: 0 11px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.metric-switch label:first-of-type { margin-left: 0; border-radius: 6px 0 0 6px; }
.metric-switch label:last-of-type { border-radius: 0 6px 6px 0; }
.metric-switch input { position: absolute; opacity: 0; pointer-events: none; }
.metric-switch label:has(input:checked) { z-index: 1; border-color: var(--accent); background: var(--accent-soft); }
.metric-switch label:has(input:focus-visible) { z-index: 2; outline: 2px solid var(--focus); outline-offset: 1px; }
.history-summary { margin: 0; color: var(--ink); font-size: 13px; font-weight: 620; font-variant-numeric: tabular-nums; }
.history-chart { position: relative; margin: 6px 15px 4px; border-radius: 6px; }
.history-chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.history-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.history-grid line { stroke: var(--line); stroke-width: 1; }
.history-grid line.history-zero { stroke: var(--muted); }
.history-grid text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.history-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.history-area { fill: var(--accent); opacity: .08; }
.history-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.history-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.history-tooltip { position: absolute; top: 8px; display: grid; gap: 2px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 6px 18px rgba(0,0,0,.14); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.history-tooltip span { color: var(--muted); }
.history-body > .period-note { margin: 4px 15px 8px; }
.history-table { border-top: 1px solid var(--line); }
.history-table summary { padding: 10px 15px; color: var(--accent); font-size: 12.5px; font-weight: 650; cursor: pointer; }
.history-table .table-responsive { max-height: 360px; overflow-y: auto; }

/* Loaded data popover */
.data-section + .data-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.data-section h3 { margin: 10px 0 4px; font-size: 13px; }
.data-section > p { margin: 0 0 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.data-section > .quality-note { margin-bottom: 10px; }
.data-list { max-height: 180px; margin: 0 0 10px; padding: 0; overflow-y: auto; list-style: none; border: 1px solid var(--line); border-radius: 6px; }
.data-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.data-list li + li { border-top: 1px solid var(--line); }
.data-list form { flex: none; }
@media (max-width: 760px) {
  .portfolio-period .period-control { flex: 1 1 100%; width: auto; }
  .portfolio-period .btn { flex: 1; }
  .portfolio-period-hint { flex-basis: 100%; margin: 0; }
  .panel-grid .sector-chart-content { grid-template-columns: 104px minmax(0, 1fr); }
  .panel-grid .sector-chart-plot { width: 104px; height: 104px; }
  .history-confirm-actions, .history-confirm-actions form, .history-confirm-actions .btn { width: 100%; }
  .segmented-links { width: 100%; grid-auto-columns: 1fr; }
  .segmented-links a { justify-content: center; }
  .metric-switch { width: 100%; }
  .metric-switch label { flex: 1 1 auto; justify-content: center; padding: 0 8px; }
  .history-chart { margin: 6px 10px 4px; }
}

/* Module switch, account and user administration */
.module-switch { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 2px; margin: 0 1px 12px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.module-switch a { display: flex; align-items: center; justify-content: center; min-height: 30px; padding: 4px 6px; border-radius: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.module-switch a[aria-current="true"] { background: var(--accent-soft); color: var(--ink); }
.module-switch a:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { .module-switch a:hover:not([aria-current="true"]) { color: var(--ink); text-decoration: none; } }
.side-user { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); text-decoration: none; }
.side-user svg { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user:hover { color: var(--ink); }
.account-message { margin: 14px 15px 0; }
.check-label { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; font-size: 13px; cursor: pointer; }
.check-label input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check-label input:disabled + span { color: var(--muted); }
.check-label small { color: var(--muted); font-size: 11.5px; }
.module-checks { display: flex; flex-wrap: wrap; gap: 2px 14px; min-width: 0; margin: 0; padding: 0; border: 0; }
.user-create-form { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto; align-items: start; gap: 10px 12px; padding: 15px; }
.user-create-form .form-action { padding-top: 22px; }
.user-create-form .form-text { margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.user-create-form .module-checks { padding-top: 0; }
.user-create-form .module-checks legend { margin-bottom: 9px; }
.user-list { margin: 0; padding: 0; list-style: none; }
.user-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(330px, auto) minmax(330px, auto); align-items: center; gap: 12px 18px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row--inactive .user-identity strong { color: var(--muted); }
.user-identity { display: grid; gap: 2px; min-width: 0; }
.user-identity small { color: var(--muted); font-size: 12px; }
.user-modules-form, .user-actions, .user-reset-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.user-modules-form .module-checks { flex-wrap: nowrap; }
.user-actions { justify-content: flex-end; }
.user-reset-form .form-control { width: 170px; min-height: 28px; padding: 4px 8px; }
@media (max-width: 1180px) {
  .user-create-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .user-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .user-create-form { grid-template-columns: 1fr; }
  .user-create-form .btn { width: 100%; }
  .user-row { grid-template-columns: 1fr; }
  .user-reset-form .form-control { flex: 1; width: auto; min-width: 140px; }
}

/* Expenses module */
.period-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.period-nav svg, .page-heading .btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.year-select .form-select, .year-select .app-select { min-width: 92px; height: 36px; }
.metric-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.metric-strip div { padding: 11px 15px 12px; border-left: 1px solid var(--line); }
.metric-strip div:first-child { border-left: 0; }
.metric-strip dt { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.metric-strip dd { margin: 4px 0 0; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-strip dd small { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.metric-strip--panel { margin: 0; border: 0; border-radius: 0; }
.expense-entry-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, 1fr); gap: 14px; align-items: start; }
.expense-saved a { margin-left: 4px; font-weight: 600; }
.expense-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto minmax(200px, 1.4fr) minmax(150px, .8fr); align-items: start; gap: 14px 12px; padding: 15px; }
.expense-form-wide { grid-column: 1 / -1; }
.expense-form .form-message { margin: 0; }
.amount-input { height: 44px; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.expense-form .form-select, .expense-form .app-select, .expense-form input[type="date"] { width: 100%; height: 44px; }
.expense-form .app-select__trigger { min-height: 44px; }
.label-hint { color: var(--muted); font-weight: 400; }
.kind-switch { display: grid; grid-auto-flow: column; margin: 0; padding: 0; border: 0; }
.kind-switch legend { padding: 0; }
.kind-switch label { position: relative; display: flex; align-items: center; height: 44px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.kind-switch label:first-of-type { border-radius: 6px 0 0 6px; }
.kind-switch label:last-of-type { margin-left: -1px; border-radius: 0 6px 6px 0; }
.kind-switch input { position: absolute; opacity: 0; pointer-events: none; }
.kind-switch label:has(input:checked) { z-index: 1; border-color: var(--accent); background: var(--accent-soft); }
.kind-switch label:has(input:focus-visible) { z-index: 2; outline: 2px solid var(--focus); outline-offset: 1px; }
.quick-categories { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 28px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; }
.chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { .chip { transition: background-color 140ms ease; } .chip:hover { background: var(--line); } }
.expense-form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.expense-form-actions .form-text { margin: 0; }
.expense-glance .glance-totals { display: grid; gap: 10px; margin: 0; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.glance-totals dt { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.glance-totals dd { margin: 2px 0 0; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.glance-groups { margin: 0; padding: 8px 15px; list-style: none; }
.glance-groups li { display: grid; grid-template-columns: 11px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; }
.glance-groups strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.text-link { display: inline-block; margin: 0 15px 14px; font-size: 12.5px; font-weight: 600; }
.expense-table td { vertical-align: middle; }
.expense-table .nowrap, .row-actions { white-space: nowrap; }
.expense-table small { display: block; color: var(--muted); font-size: 11px; }
.expense-description-cell { min-width: 160px; }
.category-tag { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.expense-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.expense-amount--refund { color: var(--positive); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.entries-filter { display: flex; align-items: center; gap: 8px; }
.entries-filter .form-label { margin: 0; }
.entries-filter .form-select, .entries-filter .app-select { max-width: 260px; }
/* Quick-entry link: management on the entry page and the phone form */
.quick-link-body { display: grid; gap: 12px; padding: 14px 15px 16px; }
.quick-link-body > .form-message { margin: 0; }
.quick-link-layout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 28px; align-items: start; max-width: 980px; }
.quick-link-main { display: grid; gap: 8px; min-width: 0; }
.quick-link-main .form-label { margin: 0; }
.quick-link-field { display: flex; gap: 8px; }
.quick-link-field .form-control { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.quick-link-status { min-height: 18px; margin: 0; color: var(--positive); font-size: 12.5px; }
.quick-link-main > .form-message { margin: 0; }
.quick-link-note, .quick-link-meta { max-width: 640px; margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.quick-link-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.quick-link-qr { display: grid; justify-items: center; gap: 6px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.quick-link-qr img { display: block; width: 168px; height: 168px; }
.quick-link-qr figcaption { color: #4a4740; font-size: 11.5px; }

.quick-body { min-height: 100dvh; }
.quick-page { display: grid; gap: 14px; width: min(100%, 480px); margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.quick-head { display: flex; align-items: center; gap: 10px; }
.quick-head h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.quick-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.quick-saved { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft); font-size: 13.5px; }
.quick-saved p { margin: 0; }
.quick-saved form { flex: none; }
.quick-form { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.quick-form .form-message { margin: 0; }
.quick-form .form-control, .quick-form .app-select__trigger { width: 100%; min-height: 48px; font-size: 16px; }
.quick-form .quick-amount { height: 56px; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.quick-form .kind-switch { grid-auto-columns: 1fr; }
.quick-form .kind-switch label { justify-content: center; height: 48px; font-size: 15px; }
.quick-form .chip { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.quick-form .chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.quick-submit { min-height: 52px; font-size: 16px; }
.quick-foot { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 760px) {
  .quick-link-layout { grid-template-columns: minmax(0, 1fr); }
  .quick-link-field { flex-wrap: wrap; }
  .quick-link-field .form-control { flex-basis: 100%; }
  .quick-link-qr { justify-self: start; }
}

/* Month ledger: one ruled table, single-line rows, numbers in columns.
   The share column pairs a short meter on a 100 % track with the printed
   percentage; both are relative to the section (spent or set aside). */
.month-ledger-wrap { max-width: 1040px; }
.month-ledger { table-layout: fixed; font-size: 13px; }
.month-ledger .month-ledger-sum { width: 140px; }
.month-ledger .month-ledger-share { width: 320px; }
.month-ledger th, .month-ledger td { padding: 7px 15px; vertical-align: middle; }
.month-ledger thead th { padding-top: 9px; padding-bottom: 9px; }
.month-ledger .number-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.month-ledger .share-head { padding-left: 15px; }
.share-cell { white-space: nowrap; }
.share-meter { display: inline-block; width: 220px; height: 8px; margin-right: 10px; overflow: hidden; border-radius: 4px; background: var(--track); vertical-align: middle; }
.share-meter > span { display: block; min-width: 3px; height: 100%; border-radius: 4px; background: var(--sector-color); }
.share-value { display: inline-block; min-width: 48px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; vertical-align: middle; }
.category-row .share-meter { height: 6px; }
.category-row .share-meter > span { opacity: .6; }
.group-row .share-value { color: var(--ink); font-weight: 650; }
.composition-bar { display: flex; gap: 2px; width: 280px; height: 16px; border-radius: 5px; vertical-align: middle; }
.composition-segment { flex: none; min-width: 6px; height: 100%; padding: 0; border: 0; border-radius: 3px; background: var(--sector-color); cursor: pointer; transition: opacity 160ms var(--ease-out); }
.composition-segment:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.month-ledger-focus { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0; padding: 10px 15px; border-bottom: 1px solid var(--line); background: var(--accent-soft); font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.has-focus .composition-segment:not(.is-active) { opacity: .28; }
.month-ledger [data-ledger-row] > tr > * { transition: opacity 160ms var(--ease-out); }
.has-focus [data-ledger-row]:not(.is-focused) > tr > * { opacity: .3; }
.has-focus .is-focused .group-row th { box-shadow: inset 3px 0 0 var(--sector-color); }
@media (hover: hover) and (pointer: fine) { .composition-segment:hover { opacity: .8; } .has-focus .composition-segment:not(.is-active):hover { opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .composition-segment, .month-ledger [data-ledger-row] > tr > * { transition: none; } }
.month-ledger .section-row > * { padding-top: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.month-ledger .section-row th { text-transform: uppercase; }
.month-ledger .is-aside .section-row > * { padding-top: 22px; }
.month-ledger .group-row > * { background: var(--surface-2); font-weight: 650; }
.month-ledger .category-row th { padding-left: 34px; font-weight: 400; }
.month-ledger .category-row > * { border-bottom-color: color-mix(in srgb, var(--line) 60%, transparent); }
.month-ledger tbody:not(.month-ledger-section) tr:last-child > * { border-bottom-color: var(--line); }
.month-ledger tfoot th, .month-ledger tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; background: var(--surface-2); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .month-ledger .category-row:hover > * { background: color-mix(in srgb, var(--surface-2) 60%, transparent); } }
@media (max-width: 760px) {
  .table-responsive .month-ledger { min-width: 0; }
  .month-ledger .month-ledger-sum { width: 104px; }
  .month-ledger .month-ledger-share { width: 64px; }
  .month-ledger th, .month-ledger td { padding-right: 10px; padding-left: 10px; }
  .month-ledger .category-row th { padding-left: 22px; }
  .share-meter, .composition-bar { display: none; }
  .share-value { min-width: 0; }
  .share-head-extra { display: none; }
}
.expense-zero-categories { padding: 11px 15px; border-top: 1px solid var(--line); font-size: 12.5px; }
.expense-zero-categories summary { width: max-content; max-width: 100%; color: var(--accent); font-weight: 600; cursor: pointer; }
.expense-zero-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px 22px; padding: 14px 0 2px; }
.expense-zero-groups strong { font-size: 12px; }
.expense-zero-groups ul { margin: 5px 0 0; padding-left: 16px; color: var(--muted); }
.expense-zero-groups li + li { margin-top: 3px; }
.expense-disclosure-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 15px; cursor: pointer; list-style: none; }
.expense-disclosure-head::-webkit-details-marker { display: none; }
.expense-disclosure-head::marker { content: ''; }
.expense-disclosure-copy { display: grid; gap: 3px; }
.expense-disclosure-copy strong { font-size: 15px; line-height: 1.3; }
.expense-disclosure-copy small { color: var(--muted); font-size: 12.5px; }
.expense-disclosure-meta { display: inline-flex; align-items: center; gap: 10px; flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.expense-disclosure-meta svg { width: 16px; height: 16px; transition: transform 140ms var(--ease-out); }
.expense-disclosure[open] .expense-disclosure-meta svg { transform: rotate(180deg); }
.expense-disclosure[open] .expense-disclosure-head { border-bottom: 1px solid var(--line); }
.expense-entries-toolbar { display: flex; justify-content: flex-end; padding: 12px 15px; border-bottom: 1px solid var(--line); }
#entries { scroll-margin-top: 66px; }
.year-matrix { font-variant-numeric: tabular-nums; }
.year-matrix th { font-weight: 500; }
.year-matrix tbody + tbody .group-row > * { border-top: 1px solid var(--line); }
.year-matrix .group-row > * { background: var(--surface-2); font-weight: 650; }
.group-row .sector-swatch { display: inline-block; margin-right: 8px; vertical-align: -1px; }
.category-row th { padding-left: 30px; }
.category-row a { color: var(--ink); text-decoration: none; }
.category-row a:hover { color: var(--accent); text-decoration: underline; }
.category-row small { display: inline; }
.is-zero { color: var(--muted); }
.year-matrix tfoot th, .year-matrix tfoot td { border-top: 1px solid var(--ink); font-weight: 700; }
.year-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.year-matrix { min-width: 1400px; table-layout: fixed; font-size: 12px; }
.year-matrix .year-category-col { width: 250px; }
.year-matrix .year-month-col { width: 76px; }
.year-matrix .year-total-col { width: 108px; }
.year-matrix .year-share-col { width: 74px; }
.year-matrix th, .year-matrix td { padding: 7px 6px; white-space: nowrap; }
.year-matrix .is-zero { text-align: right; }
.year-matrix thead a { color: var(--muted); text-decoration: none; }
.year-matrix thead a:hover { color: var(--accent); }
.year-matrix .sticky-col { position: sticky; left: 0; z-index: 1; min-width: 190px; padding-left: 10px; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.year-matrix thead .sticky-col, .year-matrix .group-row .sticky-col { background: var(--surface-2); }
.danger-zone { display: flex; justify-content: flex-end; padding: 12px 15px; border-top: 1px solid var(--line); }
.group-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 12px; padding: 15px; }
.group-form-name { flex: 1 1 220px; max-width: 360px; }
.group-form .check-label { min-height: 36px; }
.group-form--edit { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.group-form--edit > .sector-swatch { align-self: center; width: 14px; height: 14px; margin-top: 18px; }
.order-field { width: 90px; }
.category-list { margin: 0; padding: 0; list-style: none; }
.category-item { display: grid; grid-template-columns: minmax(0, 1fr) 96px 168px; align-items: center; gap: 8px 14px; padding: 9px 15px; border-bottom: 1px solid var(--line); }
.category-item.is-archived .category-form .form-control:first-of-type { color: var(--muted); }
.category-form { display: grid; grid-template-columns: minmax(140px, 1.3fr) minmax(130px, 1fr) 76px auto; gap: 8px; align-items: center; }
.category-form .form-control, .category-form .form-select, .category-form .app-select__trigger { min-height: 32px; padding: 4px 8px; }
.category-uses { color: var(--muted); font-size: 12px; white-space: nowrap; }
.category-actions { display: flex; justify-content: flex-end; gap: 6px; }
.group-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 11px 15px; }
.category-create { display: flex; gap: 8px; }
.category-create .form-control { width: 240px; min-height: 32px; padding: 4px 8px; }
.data-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 15px; }
.data-actions .form-text { margin: 0; }
.storage-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.usage-meter { height: 8px; margin: 0 15px 15px; border-radius: 4px; background: var(--track); overflow: hidden; }
.usage-meter span { display: block; height: 100%; background: var(--accent); }
.usage-meter--warn span { background: var(--negative); }
.statement-page > .panel { margin-top: 14px; }
.statement-page .page-heading { gap: 12px; }
.statement-steps { display: flex; gap: 0; margin: 5px 0 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; }
.statement-steps span { min-width: 115px; padding: 9px 14px; border-bottom: 2px solid transparent; }
.statement-steps .is-current { border-bottom-color: var(--accent); color: var(--ink); }
.statement-steps .is-complete { color: var(--accent); }
.statement-upload { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 14px; margin: 15px; padding: 18px; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface-2); }
.statement-upload.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.statement-upload > svg { width: 28px; height: 28px; color: var(--accent); }
.statement-upload-copy { display: grid; gap: 2px; min-width: 0; }
.statement-upload strong { font-size: 14px; }
.statement-upload span, .statement-upload small { color: var(--muted); font-size: 12px; }
.statement-mapping-fields { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 12px; max-width: 960px; padding: 15px; }
.statement-mapping-fields > div, .statement-optional-mapping [data-optional-mapping-fields] > div { display: grid; gap: 5px; min-width: 0; }
.statement-mapping-fields .form-select, .statement-mapping-fields .app-select { width: 100%; }
.statement-optional-mapping { margin: 0 15px 15px; max-width: 960px; }
.statement-optional-mapping summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
.statement-optional-mapping > p, .statement-extras > p { margin: 7px 0 10px; color: var(--muted); font-size: 12px; }
.statement-optional-mapping [data-optional-mapping-fields] { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 12px; margin-top: 12px; }
.statement-extras { margin: 0 15px 15px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.statement-optional-mapping .statement-extras { margin: 14px 0 0; }
.statement-extras legend { padding: 0 5px; }
.statement-extras > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 5px 15px; }
.statement-section-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 0 15px 15px; }
.statement-toolbar { display: flex; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.statement-toolbar > div { flex: 1 1 180px; }
.statement-toolbar .form-select, .statement-toolbar .app-select, .statement-toolbar .form-control { width: 100%; }
.statement-count { align-self: center; white-space: nowrap; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.statement-table-wrap { max-height: min(62vh, 740px); overflow: auto; }
.statement-table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.statement-table { min-width: 1050px; margin: 0; font-size: 12px; font-variant-numeric: tabular-nums; }
.statement-table th, .statement-table td { padding: 7px 8px; vertical-align: middle; }
.statement-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); white-space: nowrap; }
.statement-table td:first-child { width: 60px; text-align: center; }
.statement-table input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.statement-table tr.is-income td { background: var(--ok-soft); }
.statement-table tr.is-excluded td { background: var(--surface-2); }
.statement-table tr.is-excluded .statement-money strong { color: var(--muted); }
.statement-table .statement-date { white-space: nowrap; }
.statement-money { min-width: 145px; white-space: nowrap; }
.statement-money strong { display: block; font-weight: 650; }
.statement-money .badge, .statement-money .statement-kind { display: inline-flex; margin-top: 4px; }
.statement-money small { display: block; max-width: 170px; white-space: normal; color: var(--muted); }
.statement-kind { color: var(--muted); font-size: 11px; }
.statement-table .is-income .statement-money strong { color: var(--positive); }
.statement-description { min-width: 220px; }
.statement-description .form-control { min-width: 190px; }
.statement-source-cell { min-width: 90px; max-width: 230px; overflow-wrap: anywhere; }
.statement-category { min-width: 240px; }
.statement-category .form-select, .statement-category .app-select { width: 100%; }
.statement-apply-category { display: block; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 11px; font-weight: 600; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.statement-apply-category:disabled { color: var(--muted); text-decoration: none; }
.statement-no-results { margin: 0; padding: 18px 15px; }
.statement-pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.statement-commit-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; border-top: 1px solid var(--line); background: var(--surface); }
.statement-commit-bar p { margin: 0; font-size: 12px; }
@media (hover: hover) and (pointer: fine) {
  .statement-upload { transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out); }
}
@media (prefers-reduced-motion: reduce) {
  .statement-upload { transition-duration: 80ms; }
  .expense-disclosure-meta svg { transition-duration: 80ms; }
}
@media (max-width: 1180px) {
  .expense-entry-layout { grid-template-columns: 1fr; }
  .expense-form { grid-template-columns: minmax(0, 1fr) auto; }
  .expense-field-category { grid-column: 1 / -1; }
  .category-item { grid-template-columns: 1fr; }
  .category-actions { justify-content: flex-start; }
  .statement-mapping-fields, .statement-optional-mapping [data-optional-mapping-fields] { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 760px) {
  .expense-disclosure-head { align-items: flex-start; }
  .expense-disclosure-meta { padding-top: 2px; }
  .expense-entries-toolbar { justify-content: stretch; }
  .expense-form { grid-template-columns: 1fr; }
  .kind-switch { grid-auto-columns: 1fr; }
  .kind-switch label { justify-content: center; }
  .expense-form-actions .btn { width: 100%; }
  .section-header:has(.entries-filter) { flex-direction: column; }
  .entries-filter { width: 100%; }
  .entries-filter .form-select, .entries-filter .app-select { flex: 1; max-width: none; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip div:nth-child(odd) { border-left: 0; }
  .metric-strip div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .storage-layout { grid-template-columns: 1fr; }
  .category-form { grid-template-columns: 1fr 1fr; }
  .category-form .form-control:first-of-type { grid-column: 1 / -1; }
  .category-create { flex: 1; }
  .category-create .form-control { flex: 1; width: auto; }
  .year-matrix .sticky-col { min-width: 150px; max-width: 150px; white-space: normal; }
  .expense-table .row-actions { flex-direction: column; align-items: flex-end; }
  .statement-steps span { flex: 1; min-width: 0; padding: 8px; text-align: center; }
  .statement-upload { grid-template-columns: 30px minmax(0, 1fr); align-items: start; }
  .statement-upload .btn { grid-column: 1 / -1; width: 100%; }
  .statement-mapping-fields, .statement-optional-mapping [data-optional-mapping-fields] { grid-template-columns: 1fr; }
  .statement-toolbar { flex-direction: column; }
  .statement-commit-bar { position: sticky; bottom: 0; z-index: 3; flex-direction: column; align-items: stretch; }
  .statement-commit-bar .btn { width: 100%; }
}

/* Two-factor authentication (account security page) */
.two-factor-body { padding: 15px; border-top: 1px solid var(--line); }
.two-factor-body > p { margin: 0 0 12px; font-size: 12.5px; }
.two-factor-body .settings-fields { display: grid; gap: 14px; max-width: 520px; padding: 0; }
.two-factor-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start; }
.two-factor-setup ol { margin: 0 0 14px; padding-left: 18px; font-size: 12.5px; line-height: 1.6; }
.two-factor-qr { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.two-factor-qr svg { display: block; width: 168px; height: 168px; stroke: none; }
.two-factor-key { word-break: break-word; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px 14px; margin: 0; padding: 0; list-style: none; }
.recovery-codes code { font-size: 13px; letter-spacing: .04em; }
@media (max-width: 760px) {
  .two-factor-setup { grid-template-columns: 1fr; }
  .two-factor-qr { justify-self: start; }
}

/* Backup page */
.backup-tables { border-top: 1px solid var(--line); }
.backup-tables summary { padding: 12px 15px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.backup-tables .table { margin: 0; }
