/* Touch layout shared by the iPhone, Android and phone browser builds. */
/* Prevent accidental double-tap zoom while retaining scrolling and pinch zoom. */
html, body { height: 100%; height: 100dvh; }
/* Inner scroll containers must opt out too: gesture handling stops at the
   nearest scrolling ancestor, before reaching html/body. Pinch stays usable. */
html, body, body * { touch-action: manipulation; }
:root { font-size: 14px; }
body { -webkit-tap-highlight-color: transparent; }
.topbar { height: auto; min-height: 72px; padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); gap: 10px; }
.brand { font-size: 16px; }
.brand-mark { width: 36px; height: 36px; }
.brand-name small { display: block; font-size: 10px; margin-top: 4px; }
.topbar .btn { height: 44px; padding: 0 12px; font-size: 12px; gap: 5px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(68px + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); z-index: 30; justify-content: space-around; box-shadow: 0 -3px 20px rgba(0,0,0,.04); }
.tabs button { color: var(--ink-2); height: 60px; flex: 1; padding: 6px 2px; border-radius: 10px; font-size: 11px; }
.tabs button:hover, .tabs button.active { color: var(--accent); }
.tabs button.active { background: var(--accent-wash); }
.tabs button.active::after { display: none; }
.tabs button::before { content: ''; display: block; width: 22px; height: 22px; margin: 0 auto 6px; background: currentColor; mask: var(--icon) center / contain no-repeat; -webkit-mask: var(--icon) center / contain no-repeat; }
[data-view="summary"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20V10h3v10zm6 0V4h3v16zm6 0v-7h3v7z'/%3E%3C/svg%3E"); }
[data-view="transactions"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v3H4zm0 6h16v3H4zm0 6h16v3H4z'/%3E%3C/svg%3E"); }
[data-view="rules"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6h18v2H3zm0 10h18v2H3z'/%3E%3Ccircle cx='8' cy='7' r='4'/%3E%3Ccircle cx='16' cy='17' r='4'/%3E%3C/svg%3E"); }
[data-view="imports"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 3h2v9l3-3 2 2-6 6-6-6 2-2 3 3zM3 17h2v3h14v-3h2v5H3z'/%3E%3C/svg%3E"); }
.subbar { flex-wrap: wrap; gap: 12px; padding: 16px; }
.subbar > .spacer { display: none; }
.page-title { width: 100%; }
.page-title h1 { font-size: 24px; }
#page-sub { line-height: 1.45; }
.filters { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
.filters > * { width: 100%; min-width: 0; }
#f-cats { grid-column: 1 / -1; max-width: none; }
.filters[style*="hidden"] { display: none; }
main { padding: 16px max(16px, env(safe-area-inset-right)) calc(90px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.wrap { gap: 14px; max-width: 900px; }
.card { padding: 16px; border-radius: 16px; }
.tiles { gap: 10px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.tile { flex-direction: column; gap: 10px; }
.tile .value { font-size: 25px; overflow-wrap: anywhere; }
.tile .label { font-size: 10px; }
.tile .note { font-size: 12px; line-height: 1.5; }
.grid-2 { grid-template-columns: 1fr; gap: 14px; }
.empty { margin: 12px auto; padding: 28px 18px; }
.empty h1 { font-size: 25px; line-height: 1.25; }
.empty .formats { flex-wrap: wrap; }
.empty .primary { width: 100%; justify-content: center; }
.drop-hint { padding: 20px 12px; line-height: 1.6; }
.statement-location-help { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--accent-wash); color: var(--ink-2); text-align: left; font-size: 13px; line-height: 1.6; }
.statement-location-help > strong { color: var(--ink); }
.statement-location-help p { margin: 8px 0 0; }
.statement-location-help details { margin-top: 8px; }
.statement-location-help summary { padding: 8px 0; cursor: pointer; color: var(--accent); min-height: 44px; display: list-item; }
.btn, .btn.small, select, input[type="text"], input[type="search"] { min-height: 44px; height: auto; }
input, select { font-size: 16px; }
.btn.link { min-height: 32px; }
td select { min-height: 44px; font-size: 16px; }
.row-actions input, .row-actions select { max-width: 100%; }
.hbar { grid-template-columns: minmax(0,1fr) 90px; padding: 10px 0; gap: 6px 10px; }
.hbar .track { grid-column: 1; grid-row: 2; height: 8px; }
.hbar .val { grid-column: 2; grid-row: 1 / 3; }
.hbar .pct { display: block; margin-top: 4px; }
.chart { overflow-x: auto; padding-bottom: 4px; }
.toolbar input[type="search"] { width: 100%; }
.toolbar select { max-width: 100%; flex: 1 1 130px; }
.toolbar .count { margin: 6px 0; width: 100%; line-height: 1.5; }
.transaction-table { max-height: none !important; overflow: visible; border: 0; }
.transaction-table thead { display: none; }
.transaction-table table, .transaction-table tbody { display: block; }
.transaction-table tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 10px; border-bottom: 1px solid var(--border); padding: 16px 0; }
.transaction-table td { padding: 0; border: 0; min-width: 0; }
.transaction-table td:nth-child(1) { grid-row: 2; grid-column: 1; color: var(--muted); font-size: 12px; }
.transaction-table td:nth-child(2) { grid-row: 1; grid-column: 1; white-space: normal; overflow-wrap: anywhere; font-weight: 600; line-height: 1.5; }
.transaction-table td:nth-child(3) { grid-row: 3; grid-column: 1; white-space: normal !important; font-size: 12px; }
.transaction-table td:nth-child(4) { grid-row: 4; grid-column: 1 / -1; }
.transaction-table td:nth-child(4) select { width: 100%; max-width: none; }
.transaction-table td:nth-child(5) { grid-row: 1 / 3; grid-column: 2; font-weight: 600; padding-top: 2px; }
.modal-bg { padding: env(safe-area-inset-top) 0 0; align-items: flex-end; }
.modal, .modal.narrow { width: 100%; max-height: 94%; border-radius: 22px 22px 0 0; }
.modal header { padding: 20px 18px 0; }
.modal .body { padding: 16px 18px; }
.modal footer { flex-wrap: wrap; padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); }
.modal footer .left { width: 100%; line-height: 1.5; }
.form-grid { grid-template-columns: 1fr; }
.check { min-height: 44px; line-height: 1.5; }
.check input { width: 20px; height: 20px; flex: none; }
#toast { bottom: calc(84px + env(safe-area-inset-bottom)); flex-wrap: wrap; width: calc(100% - 32px); max-width: 540px; }
#toast span { white-space: normal; line-height: 1.45; }
#toast input { flex: 1; min-height: 44px; }
#toast .btn { min-height: 44px; }
.pop-list .only { visibility: visible; }
.site-foot { padding-bottom: 0; line-height: 1.5; }
/* iPad retains touch targets while making use of the wider canvas. */
@media (min-width: 768px) {
  .wrap { max-width: 1180px; margin-left: auto; margin-right: auto; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  #f-cats { grid-column: auto; }
  .empty { max-width: 650px; padding: 40px; }
  .modal-bg { padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); align-items: center; }
  .modal { max-width: 1040px; max-height: 100%; border-radius: 18px; }
  .modal.narrow { max-width: 560px; }
  .modal footer { padding-bottom: 18px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .transaction-table table { display: table; }
  .transaction-table thead { display: table-header-group; }
  .transaction-table tbody { display: table-row-group; }
  .transaction-table tr { display: table-row; }
  .transaction-table td { display: table-cell; padding: 12px 10px; border-bottom: 1px solid var(--border); }
  .transaction-table td:nth-child(4) select { min-width: 140px; }
  .transaction-table td:nth-child(5) { padding-top: 12px; }
}
@media (max-width: 360px) {
  .brand { font-size: 14px; gap: 6px; }
  .brand-mark { width: 28px; height: 28px; }
  .topbar { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .topbar #btn-import { font-size: 11px; padding: 0 8px; }
}

[data-view="statements"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='M6 2h12v20l-3-2-3 2-3-2-3 2V2zm3 5h6m-6 5h6'/%3E%3C/svg%3E"); }
