/* GrandMa Fin — ledger screens on top of base.css tokens. */

/* Top navigation (same as Раціон). */
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav-item { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500; transition: background 150ms var(--ease-out), color 150ms var(--ease-out); }
.nav-item .icon { width: 15px; height: 15px; }
.nav-item:hover { color: var(--text-primary); background: var(--bg-elevated); }
.nav-item.is-active { color: var(--text-primary); background: var(--bg-elevated); box-shadow: inset 0 -2px 0 0 var(--accent); }

/* Ledger fills the whole screen width; type scales with the viewport so data reads larger on big monitors. */
main:has(.ledger) { max-width: none; padding: 24px clamp(16px, 2vw, 40px) 32px; }
.ledger { --fs: clamp(13.5px, 0.3vw + 9px, 18px); --fs-meta: clamp(10.5px, 0.16vw + 8.5px, 13.5px);
  display: grid; grid-template-columns: clamp(280px, 17vw, 440px) minmax(0, 1fr); gap: clamp(16px, 1.4vw, 32px);
  align-items: start; font-size: var(--fs); }
.ledger .meta { font-size: var(--fs-meta); }
.serif { font-weight: 500; letter-spacing: -0.02em; }
.neg { color: var(--danger); }
.pos { color: var(--success); }
.warn { color: var(--warning); }

.accounts { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; }
.accounts-total { display: flex; flex-direction: column; gap: 2px; padding: 0 6px; }
.total-num { font-family: 'JetBrains Mono', monospace; font-size: clamp(22px, 0.6vw + 16px, 32px); line-height: 1.25;
  font-weight: 600; color: var(--accent-ink); letter-spacing: -0.02em; }

.total-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cur-switch { display: inline-flex; gap: 1px; padding: 2px; background: var(--bg-base); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); }
.cur-btn { background: none; border: 0; color: var(--text-secondary); font: inherit; font-size: 12px; min-width: 26px;
  padding: 2px 6px; border-radius: var(--radius-xs); cursor: pointer; }
.cur-btn:hover { color: var(--text-primary); }
.cur-btn.is-active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--accent); }
.cur-list { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 3px; }
.cur-list li { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: baseline; font-size: calc(var(--fs) - 1px); }
.cur-code { color: var(--text-tertiary); font-size: var(--fs-meta); }
.cur-list li > span:nth-child(2) { text-align: right; }

.scope-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px;
  background: var(--bg-base); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.scope { text-align: center; font-size: calc(var(--fs) - 0.5px); padding: 7px 4px; border-radius: var(--radius-sm);
  color: var(--text-secondary); transition: background .15s var(--ease-out), color .15s var(--ease-out); }
.scope:hover { color: var(--text-primary); }
.scope.is-active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--accent); }

.acc-group > summary { list-style: none; cursor: pointer; }
.acc-group > summary::-webkit-details-marker { display: none; }
.acc-group-title { display: flex; justify-content: space-between; padding: 4px 6px; font-size: var(--fs-meta);
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-tertiary); }
.acc-list { list-style: none; margin: 2px 0 0; padding: 0; }
.acc { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 6px;
  border-radius: var(--radius-sm); border-left: 2px solid transparent; line-height: 1.35;
  transition: background .15s var(--ease-out); }
.acc:hover { background: var(--bg-elevated); }
.acc.is-active { background: var(--bg-elevated); border-left-color: var(--accent); }
.acc.is-hidden { opacity: .55; }
.acc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-bal { font-size: calc(var(--fs) - 1px); white-space: nowrap; color: var(--text-secondary); }
.acc-bal.neg { color: var(--danger); }
.acc-hidden-toggle { padding: 0 6px; }
.acc-hidden-toggle:hover { color: var(--text-primary); }
.empty-side { color: var(--text-secondary); padding: 8px 6px; }

.payments { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.payments-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.payments-title .page-title { display: flex; align-items: center; gap: 6px; font-size: clamp(26px, 0.8vw + 18px, 40px); line-height: 1.15; }
.crumb { display: inline-flex; color: var(--text-tertiary); border-radius: var(--radius-sm); }
.crumb:hover { color: var(--text-primary); background: var(--bg-elevated); }
.crumb .icon { width: 26px; height: 26px; }
.add-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.add-actions .btn { height: 40px; font-size: var(--fs); }
.add-income .icon { color: var(--success); }
.add-expense .icon { color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters .input { height: 40px; font-size: var(--fs); }
.filter-period select { min-width: 170px; }
.filter-dates { display: inline-flex; gap: 6px; }
.filter-dates .input { width: 150px; }
.filter-q { flex: 1 1 280px; min-width: 200px; }
.filter-amount { display: inline-flex; align-items: center; gap: 6px; }
.filter-amount .input { width: 96px; }
.filters .btn { height: 40px; }

.table-wrap { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); }
.tx-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: var(--fs); line-height: 1.4; }
.tx-table .c-date { width: 9.5%; } .tx-table .c-amount { width: 11%; } .tx-table .c-acc { width: 21%; }
.tx-table .c-cp { width: 14%; } .tx-table .c-cat { width: 17%; } .tx-table .c-proj { width: 9%; } .tx-table .c-comment { width: auto; }
.tx-table th { position: sticky; top: 0; z-index: 1; background: var(--bg-surface); text-align: left; font-weight: 500;
  font-family: 'JetBrains Mono', monospace; font-size: var(--fs-meta); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-tertiary); padding: 12px 14px; border-bottom: 1px solid var(--border-default); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tx-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-subtle); vertical-align: top;
  overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.tx-table tr:last-child td { border-bottom: 0; }
.tx-table tbody tr { cursor: pointer; transition: background .12s var(--ease-out); }
.tx-table tbody tr:hover td { background: var(--bg-elevated); }
.tx-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tx-table td > span { display: block; }
.tx-table .num { text-align: right; white-space: nowrap; }
.tx-amount .mono { font-weight: 500; }
.tx-date { white-space: nowrap; }
.tx-comment { color: var(--text-secondary); }
.tx.is-plan td { background: color-mix(in srgb, var(--info-bg) 60%, transparent); }
.badge-transit { display: inline-block !important; margin-top: 3px; font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; padding: 1px 6px; border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong); color: var(--text-secondary); }

.pager { display: flex; justify-content: center; align-items: center; gap: 16px; }
.empty { padding: 56px 24px; text-align: center; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); }
.empty h2 { font-size: 24px; line-height: 30px; font-weight: 600; margin-bottom: 6px; }

.settings { max-width: 640px; display: flex; flex-direction: column; gap: 16px; }

/* ── Transaction dialog ── */
.tx-dialog, .confirm-dialog { border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: 0;
  background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-lg); }
.tx-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.tx-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(5, 5, 10, .62); backdrop-filter: blur(2px); }
.tx-dialog[open] { animation: rise .22s var(--ease-spring); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.tx-form { display: flex; flex-direction: column; gap: 16px; padding: 22px 24px 20px; }
.tx-head { display: flex; justify-content: space-between; align-items: center; }
.tx-title { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -0.02em; }
.kind-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--bg-base);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.kind-switch label { position: relative; }
.kind-switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.kind-switch span { display: block; text-align: center; padding: 8px; border-radius: var(--radius-sm); font-weight: 500;
  color: var(--text-secondary); transition: background .15s var(--ease-out), color .15s var(--ease-out); }
.kind-switch input:checked + span { background: var(--bg-elevated); color: var(--text-primary); }
.kind-switch input[value=income]:checked + span { box-shadow: inset 0 -2px 0 var(--success); }
.kind-switch input[value=expense]:checked + span { box-shadow: inset 0 -2px 0 var(--danger); }
.kind-switch input[value=transfer]:checked + span { box-shadow: inset 0 -2px 0 var(--info); }
.kind-switch input:focus-visible + span { outline: 2px solid var(--accent); }
.tx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tx-grid .span-2 { grid-column: 1 / -1; }
.tx-grid [hidden] { display: none !important; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tx-form .input { height: 44px; font-size: 15px; }
.tx-form textarea.input { height: auto; min-height: 64px; padding-top: 10px; resize: vertical; }
.tx-form input[data-amount] { font-size: 18px; font-weight: 600; }
.input-with-icon { position: relative; display: block; }
.amount-row { display: grid; grid-template-columns: 1fr 120px; gap: 8px; }
.cur-select { font-weight: 500; }
.conv-hint { margin-top: -4px; }
.input-with-icon .input { padding-right: 38px; }
.input-icon { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); display: flex; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.tx-more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text-secondary);
  padding: 4px 0; }
.tx-more > summary::-webkit-details-marker { display: none; }
.tx-more > summary .icon { transition: transform .15s var(--ease-out); }
.tx-more[open] > summary .icon { transform: rotate(180deg); }
.tx-more > .tx-grid { margin-top: 12px; }
.tx-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tx-foot .btn-primary { flex: 1 1 100%; height: 48px; font-size: 15px; }
.tx-dialog[data-kind=income] .btn-primary { background: color-mix(in srgb, var(--success) 22%, var(--bg-elevated)); color: var(--text-primary); border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.tx-foot-edit { display: flex; gap: 8px; margin-left: auto; }
.tx-source { margin: -6px 0 0; }

.combo { position: relative; }
.combo-list { position: absolute; z-index: var(--z-dropdown); left: 0; right: 0; top: calc(100% + 4px); max-height: 280px;
  overflow-y: auto; list-style: none; margin: 0; padding: 4px; background: var(--bg-elevated);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.combo-opt { padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.combo-opt:not(.is-child) { font-weight: 600; }
.combo-opt.is-child { padding-left: 26px; }
.combo-opt.is-active { background: var(--bg-overlay); }
.combo-opt.is-selected { color: var(--accent-ink); }
.combo-opt.is-create { color: var(--accent-ink); font-weight: 500; }
.combo-empty { padding: 8px 10px; }

.receipt-busy { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center;
  background: rgba(5, 5, 10, .6); backdrop-filter: blur(3px); }
.receipt-busy[hidden] { display: none; }
.receipt-busy-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  padding: 28px 32px; max-width: 360px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.receipt-busy-title { font-size: 20px; font-weight: 600; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.payments.is-drop { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: var(--radius-lg); }

.confirm-dialog { width: min(420px, calc(100vw - 32px)); padding: 22px 24px; }
.confirm-title { font-size: 20px; line-height: 26px; font-weight: 600; margin-bottom: 6px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.acc-all > summary { display: none; }
@media (max-width: 960px) {
  .ledger { grid-template-columns: minmax(0, 1fr); }
  .accounts { position: static; max-height: none; }
  /* Phone: total and scope stay visible, the account list folds away under one tap. */
  .acc-all > summary { display: flex; justify-content: space-between; align-items: center; list-style: none; cursor: pointer;
    padding: 8px 6px; color: var(--text-secondary); font-weight: 500; }
  .acc-all > summary::-webkit-details-marker { display: none; }
  .acc-all > summary .icon { transition: transform .15s var(--ease-out); }
  .acc-all[open] > summary .icon { transform: rotate(180deg); }
}
@media (max-width: 640px) {
  .search { flex-basis: 100%; min-width: 0; }
  /* Mobile: table becomes stacked rows; columns beyond the essentials are dropped. */
  .tx-table thead { display: none; }
  .tx-table, .tx-table tbody, .tx-table tr, .tx-table td { display: block; width: 100%; }
  .tx-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle); }
  .tx-table td { padding: 0; border: 0; }
  .tx-table td:nth-child(n+4) { grid-column: 1 / -1; }
  .tx-table td:empty { display: none; }
  .tx-acc { min-width: 0; grid-column: 1 / -1; }
  .tx-table colgroup { display: none; }
  .add-actions { width: 100%; }
  .add-actions .btn { flex: 1; }
  .filter-amount { flex: 1 1 100%; }
  .filter-amount .input { flex: 1; width: auto; }
  .tx-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .tx-form { min-height: 100%; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .tx-grid, .field-pair { grid-template-columns: 1fr; }
  .tx-foot-edit { margin-left: 0; width: 100%; }
  .tx-foot-edit .btn { flex: 1; }
}

/* ── Calendar ── */
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.kpi { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi-num { font-family: 'JetBrains Mono', monospace; font-size: clamp(17px, 0.45vw + 12px, 24px); font-weight: 600; letter-spacing: -0.02em; }
.kpi-num.accent { color: var(--accent-ink); }
.kpi-num.plan, .cal-moves .plan { color: var(--info); }
.kpi-num.is-zero, .kpi-num.muted-num { color: var(--text-secondary); }
.cal { min-width: 0; }
.cal-day { min-width: 0; overflow: hidden; }
.cal-grid { display: flex; flex-direction: column; background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); overflow: hidden; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top: 1px solid var(--border-subtle); }
.cal-wd { padding: 10px 12px; font-size: var(--fs-meta); letter-spacing: .08em; color: var(--text-tertiary); text-transform: uppercase; }
.cal-day { min-height: clamp(96px, 8vw, 150px); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
  border-left: 1px solid var(--border-subtle); transition: background .12s var(--ease-out); }
.cal-day:first-child { border-left: 0; }
.cal-day:hover { background: var(--bg-elevated); }
.cal-day.is-out { opacity: .35; }
.cal-day.is-future { background: color-mix(in srgb, var(--bg-base) 50%, transparent); }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.is-today .cal-num { background: var(--accent); color: #fff; }
.cal-day.is-gap .cal-bal { color: var(--danger); }
.cal-num { align-self: flex-start; font-weight: 600; min-width: 26px; height: 26px; padding: 0 6px; border-radius: var(--radius-full);
  display: inline-grid; place-items: center; font-size: calc(var(--fs) - 0.5px); }
.cal-moves { display: flex; flex-direction: column; gap: 1px; font-size: calc(var(--fs) - 1px); line-height: 1.35; flex: 1; }
.cal-moves span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-moves .transit { color: var(--text-secondary); }
.cal-bal { font-size: var(--fs-meta); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-legend { max-width: 900px; }
@media (max-width: 760px) {
  .cal-day { min-height: 64px; padding: 6px; }
  .cal-moves { font-size: 10.5px; }
  .cal-bal { display: none; }
  .cal-day.has-moves .cal-num { box-shadow: 0 2px 0 -0px var(--accent-ink); }
}
@media (max-width: 480px) {
  .cal-moves span:not(.pos):not(.neg) { display: none; }
  .cal-moves span { font-size: 9.5px; }
}

/* ── Report «Гроші» ── colors validated (dataviz validator): dark #27A69A/#E5604D on #111118, light #0E9384/#C9452F. */
:root { --c-income: #27A69A; --c-expense: #E5604D; --c-net: #ECECEF; }
html[data-theme="light"] { --c-income: #0E9384; --c-expense: #C9452F; --c-net: #16141A; }
.c-income { color: var(--c-income); }
.c-expense { color: var(--c-expense); }
.report .filters select { min-width: 180px; }
.chart-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 16px 18px; margin: 0; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 8px; }
.chart-title { font-size: calc(var(--fs) + 1px); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-meta); color: var(--text-secondary); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.sw-income { background: var(--c-income); }
.sw-expense { background: var(--c-expense); }
.sw-transit { background: repeating-linear-gradient(45deg, var(--c-income) 0 2px, var(--bg-surface) 2px 4px); outline: 1px solid var(--c-income); outline-offset: -1px; }
.sw-net { height: 3px; border-radius: 2px; background: var(--c-net); }
.chart-box { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border-default); stroke-width: 1; }
.chart .grid-zero { stroke: var(--border-strong); }
.chart .axis { fill: var(--text-tertiary); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.chart .bar-income { fill: var(--c-income); }
.chart .bar-expense { fill: var(--c-expense); }
.chart .bar-transit { fill: url(#hatch); }
.chart .hatch-bg { fill: var(--c-income); }
.chart .hatch-line { stroke: var(--bg-surface); stroke-width: 2.5; }
.chart .col { transition: opacity .12s var(--ease-out); }
.chart:has(.col.is-hover) .col:not(.is-hover) { opacity: .45; }
.chart .net-line { fill: none; stroke: var(--c-net); stroke-width: 2; stroke-linejoin: round; }
.chart .net-dot { fill: var(--c-net); stroke: var(--bg-surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--text-tertiary); stroke-dasharray: 3 3; }
.chart .crosshair[hidden] { display: none; }
.chart .hit { fill: transparent; cursor: pointer; }
.tip { position: absolute; top: 8px; z-index: 5; pointer-events: none; min-width: 210px; background: var(--bg-overlay);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 10px 12px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.tip strong { font-weight: 600; margin-bottom: 2px; }
.tip > span { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; color: var(--text-secondary); }
.tip b { color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.chart-table { margin-top: 10px; }
.chart-table > summary { cursor: pointer; color: var(--text-secondary); font-size: var(--fs-meta); }
.chart-table .table-wrap { margin-top: 8px; max-height: 420px; overflow: auto; }
.num-table { table-layout: auto; }
.num-table tbody tr { cursor: default; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.rank { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rank-row > details > summary, .rank-row:not(:has(details)) { display: grid; grid-template-columns: minmax(120px, 1.3fr) 2fr auto 52px;
  gap: 10px; align-items: center; padding: 6px 4px; border-radius: var(--radius-sm); }
.rank-row > details > summary { list-style: none; cursor: pointer; }
.rank-row > details > summary::-webkit-details-marker { display: none; }
.rank-row > details > summary:hover, .rank-row:not(:has(details)):hover { background: var(--bg-elevated); }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 10px; background: var(--bg-base); border-radius: 3px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 3px; width: 0; }
.rank-bar i.c-income { background: var(--c-income); }
.rank-bar i.c-expense { background: var(--c-expense); }
.rank-bar i.is-transit { background: repeating-linear-gradient(45deg, var(--c-income) 0 3px, var(--bg-base) 3px 6px); }
.rank-val { text-align: right; white-space: nowrap; }
.rank-share { text-align: right; color: var(--text-tertiary); font-size: var(--fs-meta); }
.rank-children { list-style: none; margin: 2px 0 6px; padding: 0 4px 0 18px; display: flex; flex-direction: column; gap: 2px;
  font-size: calc(var(--fs) - 1px); color: var(--text-secondary); }
.rank-children li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--border-subtle); }
@media (max-width: 640px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .rank-row > details > summary, .rank-row:not(:has(details)) { grid-template-columns: minmax(0, 1fr) auto; }
  .rank-bar, .rank-share { display: none; }
  .chart .axis { font-size: 16px; }
}

/* Filters keep their natural width instead of stretching (base .input is width:100%). */
.filters select.input { width: auto; }

/* ── Phone: bottom navigation (as in Раціон) ── */
@media (max-width: 760px) {
  /* backdrop-filter makes the header a containing block for fixed — the bottom nav would stick to the header. */
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg-surface); }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky); margin: 0; justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--border-subtle); }
  .nav-item { flex: 1; flex-direction: column; gap: 3px; height: 50px; padding: 0 2px; justify-content: center; font-size: 10.5px; }
  .nav-item .icon { width: 19px; height: 19px; }
  .nav-item.is-active { box-shadow: none; color: var(--accent-ink); background: transparent; }
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .filters { gap: 6px; }
  .filters select.input { flex: 1 1 100%; width: 100%; }
  .filter-dates { flex: 1 1 100%; flex-wrap: wrap; }
  .filter-dates .input { flex: 1 1 40%; width: auto; min-width: 0; }
  .filter-dates .btn { flex: 1 1 100%; }
  .cal-kpis { grid-template-columns: 1fr 1fr; }
  .tx-dialog { padding-bottom: 0; }
}
@media (max-width: 640px) {
  .filter-amount { display: flex; min-width: 0; }
  .filter-amount .input { min-width: 0; flex: 1 1 0; }
  .filter-q { flex-basis: 100%; min-width: 0; }
}

/* ── Events / trips ── */
main:has(.events-page) { max-width: 1680px; }
.events-page { --fs: clamp(13.5px, 0.3vw + 9px, 18px); --fs-meta: clamp(10.5px, 0.16vw + 8.5px, 13.5px);
  display: flex; flex-direction: column; gap: 14px; font-size: var(--fs); }
.events-page .meta { font-size: var(--fs-meta); }
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.event-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s var(--ease-out), transform .2s var(--ease-spring); }
.event-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.event-name { font-size: calc(var(--fs) + 3px); font-weight: 600; letter-spacing: -0.01em; }
.event-top { display: flex; flex-direction: column; gap: 2px; }
.event-cost { font-size: clamp(22px, 0.6vw + 16px, 30px); font-weight: 600; color: var(--accent-ink); letter-spacing: -0.02em; }
.budget { height: 6px; background: var(--bg-base); border-radius: 3px; overflow: hidden; }
.budget-bar { display: block; height: 100%; width: 0; background: var(--c-income); border-radius: 3px; }
.budget-bar.over { background: var(--c-expense); }
.event-cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; color: var(--text-secondary); }
.event-cats li { display: flex; justify-content: space-between; gap: 10px; }
.event-cats li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-actions { display: flex; gap: 8px; }
.pick-table { table-layout: auto; }
.pick-table td.pick { width: 44px; }
.pick-table td.pick input { width: 18px; height: 18px; accent-color: var(--accent); }
@media (max-width: 640px) {
  .pick-table td:nth-child(n+4) { grid-column: 2 / -1; }
  .pick-table tr { grid-template-columns: 32px 1fr auto; }
}
