/* Phone and iPad layout. Loaded last. static/mobile.js sets html.mobile (window up to 1000px: iPad upright and phones: the sidebar becomes a drawer) and html.phone (up to
   700px: lists become cards). On a wider window none of this applies, so the desktop looks as it always did. Touch sizes apply to every touch screen. The ten designs are
   overridden where they differ (the top-bar design makes the sidebar a bar). */
#topbar, #scrim, #tabbar { display: none; }

/* ---------- touch: finger-sized controls, text of 16px so iPhone Safari does not zoom into a field ---------- */
@media (pointer: coarse) {
  button, .btn, select, input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea { min-height: 44px; font-size: 16px; }
  button.link, a.link { min-height: 0; font-size: inherit; }
  input[type=checkbox], input[type=radio] { width: 26px; height: 26px; }
  .man-toc a, .subnav a { display: flex; align-items: center; min-height: 44px; }
  td button.link, td a.link, .sub a, .tsbadge a { display: inline-flex; align-items: center; min-height: 40px; }
  #new-txn { min-width: 44px; }
  label.f input, label.f select, label.f textarea, label.f button.picker { font-size: 16px; }
  #nav a, .acc, .ent, .grp, #acc-head, #side > .side-actions :is(button.link, a.link) { min-height: 44px; display: flex; align-items: center; }
  #add-account, #add-group, #collapse-all { min-width: 44px; min-height: 44px; }
  .side-actions button.link, .side-actions a.link { display: inline-flex; align-items: center; min-height: 40px; }
  .kebab, .caret { min-width: 44px; min-height: 44px; }
  th a.sortlink { display: inline-block; padding: 10px 0; }
  .pitem { padding: 12px 12px; }
}
/* the same sizes in a narrow window, touch or not (a phone-width browser window, the simulator) */
html.mobile button, html.mobile .btn, html.mobile select, html.mobile input:not([type=checkbox]):not([type=radio]):not([type=range]), html.mobile textarea { min-height: 44px; font-size: 16px; }
html.mobile button.link, html.mobile a.link { min-height: 0; font-size: inherit; }
html.mobile input[type=checkbox], html.mobile input[type=radio] { width: 26px; height: 26px; }
html.mobile .man-toc a, html.mobile .subnav a { display: flex; align-items: center; min-height: 44px; }
html.mobile td button.link, html.mobile td a.link, html.mobile .sub a, html.mobile .tsbadge a { display: inline-flex; align-items: center; min-height: 40px; }
html.mobile #new-txn { min-width: 44px; }
html.mobile label.f input, html.mobile label.f select, html.mobile label.f textarea, html.mobile label.f button.picker { font-size: 16px; }
html.mobile #nav a, html.mobile .acc, html.mobile .ent, html.mobile .grp { min-height: 44px; display: flex; align-items: center; }
html.mobile .side-actions button.link, html.mobile .side-actions a.link { display: inline-flex; align-items: center; min-height: 40px; }
html.mobile #acc-head, html.mobile #side > .side-actions :is(button.link, a.link) { min-height: 44px; }
html.mobile #add-account, html.mobile #add-group, html.mobile #collapse-all { min-width: 44px; min-height: 44px; }
html.mobile .kebab, html.mobile .caret { min-width: 44px; min-height: 44px; }
html.mobile th a.sortlink { display: inline-block; padding: 10px 0; }
html.mobile .pitem { padding: 12px 12px; }

/* ---------- the shell: a top bar, and the sidebar as a drawer ---------- */
html.mobile body { overscroll-behavior-y: none; }
html.mobile #app { flex-direction: column; min-height: 100dvh; }
html.mobile #resizer, html.mobile #siderail { display: none !important; }
html.mobile #topbar { display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 9; box-sizing: border-box; min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); background: var(--panel); border-bottom: 1px solid var(--line); color: var(--ink); }
html.mobile #topbar button { border: 0; background: none; min-width: 44px; min-height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: inherit; border-radius: 10px; }
html.mobile #topbar button:disabled { opacity: .35; }
html.mobile #topbar button svg { width: 22px; height: 22px; }
html.mobile #topbar-title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
html.mobile #topbar-actions { display: flex; }
html.mobile body #side, html.mobile[data-design] body #side { position: fixed; top: 0; bottom: 0; left: 0; right: auto; z-index: 40; width: min(88vw, 340px); height: auto; margin: 0; display: block; box-sizing: border-box;
  border-radius: 0; border: 0; border-right: 1px solid var(--line); box-shadow: 0 0 40px rgba(0,0,0,.35); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
html.mobile.drawer-open body #side { transform: none; visibility: visible; transition: transform .22s ease; }
html.mobile.nosidebar body #side { display: block; }
html.mobile #scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.45); }
html.mobile #scrim[hidden] { display: none; }
html.mobile.drawer-open, html.mobile.drawer-open body { overflow: hidden; }
html.mobile #side-hide { display: none; }
/* the top-bar design turns the sidebar into a bar: inside the drawer it is the ordinary list again */
html.mobile[data-design=topnav] body #side .sidehead { display: block; }
html.mobile[data-design=topnav] body #side #nav, html.mobile[data-design=topnav] body #side #accounts { display: block; order: 0; flex: none; overflow: visible; border: 0; padding: 0; }
html.mobile[data-design=topnav] body #side #nav a { border-bottom: 0; border-radius: 6px; padding: 8px 10px; }
html.mobile[data-design=topnav] body #side #networth { text-align: left; margin: 8px 0; } html.mobile[data-design=topnav] body #side #networth b { display: block; margin: 0; }
html.mobile[data-design=topnav] body #side .side-actions { margin: 12px 0 0; flex-wrap: wrap; order: 0; }
html.mobile[data-design=topnav] body #side #accounts > * { flex: none; } html.mobile[data-design=topnav] body #side #accounts .acc { border: 0; border-radius: 6px; background: none; padding: 6px 8px !important; }
html.mobile[data-design=topnav] body #side #accounts > div { display: block; }
html.mobile #main, html.mobile[data-design] #main { padding: 12px max(12px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
html.mobile #main.fixed, html.mobile[data-design] #main.fixed { height: auto; display: block; overflow: visible; }
html.mobile .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
html.mobile #toast { bottom: calc(18px + env(safe-area-inset-bottom)); }
html.mobile #networth { word-break: break-word; }
html.mobile h1 { font-size: 19px; }
html.mobile .bar { gap: 8px; } html.mobile .bar input:not([type=checkbox]):not([type=radio]) { width: 100%; max-width: none; }
html.mobile .bar > * { flex: 1 1 140px; }
html.mobile .bar > .seg { flex: 0 0 auto; }
html.mobile .bar > button, html.mobile .bar > .btn, html.mobile .bar > label:not(.datewrap) { flex: 0 0 auto; }
html.mobile .bar > label.datewrap { flex: 1 1 140px; }
html.mobile .rv-bar > * { flex: 0 0 auto; } html.mobile .rv-bar > .rv-actions { margin-left: auto; }   /* the report bar: back link on the left, Save and the menu on the right */
html.mobile .grid2 { grid-template-columns: 1fr; }
html.mobile .bar label:not(.f) { display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; }

/* ---------- windows: a sheet that fills the phone ---------- */
html.phone #modal, html.phone #modal2 { padding: 0; align-items: stretch; background: var(--panel); }
html.phone #modal-box, html.phone #modal2-box { width: 100%; min-height: 100%; box-sizing: border-box; border-radius: 0; padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
html.phone :is(#modal-box, #modal2-box) .actions { position: sticky; bottom: 0; background: var(--panel); padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); margin-top: 12px; flex-wrap: wrap; }
html.phone :is(#modal-box, #modal2-box) .actions button { flex: 1 1 auto; }
/* a row of buttons in a page's own card (Settings) is just a row: left alone, not pinned to the bottom of the screen */
html.phone #main .actions { flex-wrap: wrap; gap: 8px; }
html.phone #main .actions button { flex: 0 0 auto; }
html.phone .split-line { grid-template-columns: 1fr 1fr; }
html.phone #pickpanel { left: 8px !important; right: 8px !important; width: auto !important; max-width: none !important; max-height: 60dvh !important; }

/* ---------- lists as cards (phones) ---------- */
html.phone .tablewrap { border: 0; background: none; overflow: visible; }
html.phone table.reflow, html.phone table.reflow tbody { display: block; width: 100%; border: 0; background: none; }
html.phone table.reflow thead { display: none; }
html.phone table.reflow tr { display: block; margin: 0 0 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
html.phone table.reflow td { display: flex; align-items: baseline; gap: 10px; padding: 3px 0; border: 0; text-align: left; justify-content: space-between; }
html.phone table.reflow td::before { content: attr(data-label); flex: none; font-size: 12px; color: var(--muted); min-width: 84px; }
html.phone table.reflow td:empty { display: none; }
html.phone table.reflow td.num { text-align: right; }
html.phone table.reflow tr.quick, html.phone table.reflow tr.splitrow { padding: 8px 12px; }
html.phone table.reflow td[data-label=""]::before, html.phone table.reflow td:not([data-label])::before { display: none; }
html.phone table.noreflow { display: table; }

/* the register and the inbox (rows are `tr.row`; the cells are found by the heading they got): payee and amount on top, then date, category, account, balance and actions */
html.phone tr.row { display: grid !important; grid-template-columns: 44px minmax(0, 1fr) auto 40px; grid-template-areas: "sel pay amt menu" "sel dt dt menu" "sel cat cat menu" "sel acc acc menu" "sel bal bal menu" "sel act act menu"; gap: 2px 8px; align-items: start; }
html.phone tr.row > td { display: block; padding: 0; min-width: 0; }
html.phone tr.row > td::before { display: none !important; }
html.phone tr.row > td:first-child { grid-area: sel; padding-top: 2px; }
html.phone tr.row > td[data-label^="Payee"] { grid-area: pay; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
html.phone tr.row > td.neg, html.phone tr.row > td.pos { grid-area: amt; text-align: right; font-weight: 600; font-size: 15px; white-space: nowrap; }
html.phone tr.row > td.neg:empty, html.phone tr.row > td.pos:empty { display: none; }
html.phone tr.row > td[data-label^="Date"] { grid-area: dt; color: var(--muted); font-size: 12px; }
html.phone tr.row > td[data-label^="Category"] { grid-area: cat; font-size: 13px; }
html.phone tr.row > td[data-label^="Account"] { grid-area: acc; font-size: 12px; color: var(--muted); }
html.phone tr.row > td[data-label^="Balance"] { grid-area: bal; font-size: 12px; color: var(--muted); }
html.phone tr.row > td[data-label^="Balance"]::before { content: "Balance "; display: inline !important; min-width: 0; }
html.phone tr.row > td.num:not(.neg):not(.pos):not([data-label]) { grid-area: act; text-align: left; }
html.phone tr.row > td.rowmenu { grid-area: menu; justify-self: end; }
html.phone tr.row > td:empty { display: none; }
html.phone tr.row > td.rowmenu:empty, html.phone tr.row > td:first-child:empty { display: block; }
/* Windows on a phone: no tap highlight on the blocks inside them. iOS paints a rounded blue frame around every block of a tapped clickable container, and a window is one (a tap outside the box closes it): the document window showed frames around its matches, headings and search row */
html.mobile #modal-box, html.mobile #modal-box *, html.mobile #modal2-box, html.mobile #modal2-box * { -webkit-tap-highlight-color: transparent; }
/* A statement's own page: the period and balances stack and fit the screen; each transaction is a card (tick box, payee and amount, posted and transaction dates, the running total) */
html.phone .recstmt { gap: 8px; }
html.phone .recsum { flex-direction: column; gap: 0; }
html.phone .recsum .rs-op { display: none; }
html.phone .recsum .rs-ccy { align-self: flex-start; margin-bottom: 2px; }
html.phone .recsum .rs-b { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: baseline; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 2px; min-width: 0; }
html.phone .recsum .rs-v { font-size: 16px; height: auto; line-height: 1.3; }
html.phone .recsum .rs-s { flex-basis: 100%; }
html.phone .recsum .rs-e { display: none; }
html.phone .recsum .rs-diff { margin: 6px 0 0; border: 2px solid; border-radius: 8px; padding: 10px 12px; }
html.phone .recsum .rs-diff .rs-v { font-size: 22px; line-height: 1.3; }
html.phone .recstmt > label { display: flex; flex-wrap: wrap; width: 100%; justify-content: space-between; align-items: center; gap: 6px 10px; }
html.phone .recstmt > label input[type=date] { flex: 1 1 140px; min-width: 0; }
html.phone .recstmt > label input.money { margin-left: auto; }
html.phone table.rectable tr.recrow { display: grid !important; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "sel pay amt" "sel posted run" "sel date run"; gap: 2px 10px; align-items: start; }
html.phone table.rectable tr.recrow > td { display: block; padding: 0; min-width: 0; }
html.phone table.rectable tr.recrow > td::before { display: none !important; }
html.phone table.rectable tr.recrow > td.selc { grid-area: sel; padding-top: 2px; }
html.phone table.rectable tr.recrow > td[data-label^="Payee"] { grid-area: pay; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
html.phone table.rectable tr.recrow > td[data-label^="Amount"] { grid-area: amt; text-align: right; font-weight: 600; font-size: 15px; white-space: nowrap; }
html.phone table.rectable tr.recrow > td[data-label^="Posted"] { grid-area: posted; font-size: 12px; }
html.phone table.rectable tr.recrow > td[data-label^="Posted"]::before { content: "Posted "; display: inline !important; min-width: 0; color: var(--muted); }
html.phone table.rectable tr.recrow > td[data-label^="Date"] { grid-area: date; font-size: 12px; }
html.phone table.rectable tr.recrow > td[data-label^="Date"]::before { content: "Date "; display: inline !important; min-width: 0; }
html.phone table.rectable tr.recrow > td[data-label^="Running"] { grid-area: run; align-self: end; text-align: right; font-size: 12px; color: var(--muted); }
html.phone table.rectable tr.recrow > td[data-label^="Running"]::before { content: "Running "; display: inline !important; min-width: 0; }
/* Any touch screen, a wide iPad included: everything you tap has a 44px target (the phone layout already did; a wide window did not). Tick boxes: the cell around them is the target (mobile.js); small links and twisties grow their tap area with padding and an equal negative margin, so nothing moves */
@media (pointer: coarse) {
  th.selc { width: 48px; min-width: 48px; height: 44px; padding: 0 0 0 11px; vertical-align: middle; }
  td.selc { width: 48px; min-width: 48px; height: 44px; padding: 0 0 0 11px; vertical-align: top; }
  a.sortlink { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  th.num a.sortlink { justify-content: flex-end; }
  .side-actions button.link, .side-actions a.link { min-height: 44px; }
  .bar label:not(.f) { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
  #undo-btn, #redo-btn, #side-hide, #tb-undo, #tb-redo, #tb-palette { min-width: 44px; }
  td button.link, .repkid button.link, .reptable button.link { padding: 14px 10px; margin: -14px 0; }          /* only the height grows beyond the text: side by side links (Rename, Merge, Archive, Delete) must not overlap */
  td.num button.link { display: inline-flex; justify-content: flex-end; margin-right: -10px; }          /* a count that is a link ends where a plain 0 ends (its tap padding is cancelled) */
  td.num:has(button.link ~ button.link):not(:has(.cat-all)) button.link { margin-right: 0; }          /* several links side by side (Edit · Re-apply · Delete, Rename · Archive) keep the room between them: the -10px above is for one link alone */
  td button.link.cat-own + button.link.cat-all { margin-left: -10px; }                                  /* a link next to a link: the number and its "(… in all)" sit side by side, not a padding apart (a plain 0 before it needs no pull) */
  main button.link, #main > .bar button.link, .sub button.link { min-height: 44px; min-width: 44px; }
  button.link.tw { width: 44px; margin-right: -24px; }
  a.tag.rec, a.tag.warn { padding: 15px 19px; margin: -15px -19px -15px -11px; background-clip: content-box; }          /* the tap area grows, the visible chip does not (it was a blob over the payee's labels) */
  .gp-rule { min-height: 44px; }
  #ib-rulehint a { display: inline-block; padding: 12px 6px; margin: -12px -6px; }
}
/* in a phone card the tick box column is the 44px target itself */
html.phone tr.row > td.selc, html.phone tr.recrow > td.selc { width: auto; min-width: 0; height: auto; min-height: 44px; padding-left: 0; }
/* Any touch screen, a wide iPad included: the arrow that opens a By payee group is big enough to see and to hit */
@media (pointer: coarse) { .gp-toggle { min-width: 44px; min-height: 44px; font-size: 34px; line-height: 1; color: var(--ink); } }
/* Inbox, By payee, on a computer or a wide iPad: every group has the same two lines. First the arrow, the payee (the whole width to wrap in) and its totals. Then, under the payee and always in the same place, the category box, the suggestion after it, and "make a rule" with its row count at the right edge */
@media (min-width: 701px) {
  .gp-head { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "tog name" ". act"; align-items: start; gap: 0 10px; }
  .gp-toggle { grid-area: tog; align-self: start; }
  .gp-name { grid-area: name; flex: none; padding-top: 3px; }
  .gp-do { grid-area: act; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px 10px; margin-top: 8px; max-width: none; width: auto; }
  .gp-do .picker, .gp-do select { order: 1; flex: 0 0 260px; width: 260px; min-width: 0; max-width: none; }
  .gp-do .gp-sug { order: 2; }
  .gp-do .gp-meta { order: 3; flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-left: auto; }
  .gp-do .gp-ok { order: 4; }
}
/* Inbox, By payee: a group is a card (a 44px arrow, the payee and its totals, the suggestion and the category as full-width buttons, "make a rule" with how many rows it sets) and its rows are small cards of their own */
html.phone .gp { padding: 10px 12px; }
html.phone .gp-toggle { min-width: 44px; min-height: 44px; margin: -10px 0 -10px -12px; padding: 0; font-size: 34px; line-height: 1; color: var(--ink); }
html.phone .gp-head { flex-wrap: nowrap; align-items: flex-start; gap: 0 4px; }
html.phone .gp-name { flex: 1 1 0; padding-top: 4px; }
html.phone .gp-do { flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 8px; }
html.phone .gp-head { flex-wrap: wrap; }
html.phone .gp-do { flex: 1 1 100%; }
html.phone .gp-sug { flex: 1 1 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; border-radius: 10px; padding: 6px 12px; text-align: left; }
html.phone .gp-sug .sugg-src { display: inline; margin: 0; white-space: nowrap; }
html.phone .gp-meta { flex: 1 1 100%; justify-content: space-between; gap: 10px; }
html.phone .gp-rule { min-height: 44px; font-size: 14px; }
html.phone .gp-ok { flex: 1 1 100%; min-height: 44px; }
html.phone .gp-rows tr.row { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "dt amt" "acc act" "memo memo" "cat cat"; gap: 1px 10px; padding: 8px 0 0; border-bottom: 1px solid var(--line); align-items: start; }
html.phone .gp-rows tr.row:last-child { border-bottom: 0; }
html.phone .gp-rows tr.row > td { display: block; padding: 0; border: 0; min-width: 0; }
html.phone .gp-rows tr.row > td:nth-child(1) { grid-area: dt; font-weight: 600; font-size: 14px; white-space: nowrap; }
html.phone .gp-rows tr.row > td:nth-child(2) { grid-area: acc; align-self: center; font-size: 12px; color: var(--muted); }
html.phone .gp-rows tr.row > td:nth-child(3) { grid-area: memo; font-size: 12px; overflow-wrap: anywhere; }
html.phone .gp-rows tr.row > td:nth-child(4) { grid-area: cat; font-size: 13px; }
html.phone .gp-rows tr.row > td:nth-child(5) { grid-area: amt; text-align: right; font-weight: 600; font-size: 15px; white-space: nowrap; }
html.phone .gp-rows tr.row > td:nth-child(6) { display: flex; justify-content: flex-end; align-items: center; }
html.phone .gp-rows tr.row > td:nth-child(6) button { min-height: 44px; padding: 0 0 0 12px; }
/* Statements: account and status, the period, starting and closing balance, transactions and difference, when it was reconciled, then Edit / Delete */
html.phone tr.row.stmt-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "per stat" "st cl" "tx diff" "done done" "act act"; gap: 3px 12px; }
html.phone tr.row.stmt-row > td[data-label^="Status"] { grid-area: stat; justify-self: end; text-align: right; }
html.phone tr.row.stmt-row > td[data-label^="Period"] { grid-area: per; white-space: normal; font-weight: 600; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
html.phone tr.row.stmt-row > td[data-label^="Starting"] { grid-area: st; text-align: left; font-size: 13px; }
html.phone tr.row.stmt-row > td[data-label^="Starting"]::before { content: "Starting "; display: inline !important; min-width: 0; color: var(--muted); }
html.phone tr.row.stmt-row > td[data-label^="Closing"] { grid-area: cl; text-align: right; font-size: 13px; }
html.phone tr.row.stmt-row > td[data-label^="Closing"]::before { content: "Closing "; display: inline !important; min-width: 0; color: var(--muted); }
html.phone tr.row.stmt-row > td[data-label^="Transactions"] { grid-area: tx; text-align: left; font-size: 12px; color: var(--muted); }
html.phone tr.row.stmt-row > td[data-label^="Transactions"]::after { content: " transactions"; }
html.phone tr.row.stmt-row > td[data-label^="Difference"] { grid-area: diff; text-align: right; font-size: 12px; }
html.phone tr.row.stmt-row > td[data-label^="Difference"]::before { content: "Difference "; display: inline !important; min-width: 0; color: var(--muted); }
html.phone tr.row.stmt-row > td[data-label^="Reconciled"] { grid-area: done; font-size: 12px; color: var(--muted); }
html.phone tr.row.stmt-row > td[data-label^="Reconciled"]::before { content: "Reconciled "; display: inline !important; min-width: 0; }
html.phone tr.row.stmt-row > td:last-child { grid-area: act; text-align: left; }
html.phone tr.row.sum-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "acct" "since" "until" "last"; gap: 4px 12px; }
html.phone tr.row.sum-row > td[data-label^="Account"] { grid-area: acct; font-weight: 600; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
html.phone .sum-n { min-width: 0; }
html.phone tr.row.sum-row > td[data-label^="Account"] .sum-how { font-weight: 400; }
html.phone tr.row.sum-row > td[data-label^="Transactions"] { grid-area: since; white-space: normal; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
html.phone tr.row.sum-row > td[data-label^="Transactions"]::before { content: none !important; display: none !important; }
html.phone tr.row.sum-row > td[data-label^="Reconciled"] { grid-area: until; white-space: normal; font-size: 13px; }
html.phone tr.row.sum-row > td[data-label^="Reconciled"]::before { content: "Reconciled until "; display: inline !important; min-width: 0; color: var(--muted); }
html.phone tr.row.sum-row > td[data-label^="Last"] { grid-area: last; font-size: 13px; }
html.phone tr.row.sum-row > td[data-label^="Last"]::before { content: "Last transaction "; display: inline !important; min-width: 0; color: var(--muted); }
html.phone .sum-wrap { max-width: none; }
html.phone .sum-bar { width: 100%; }
html.phone .sum-sync { display: inline; }          /* a phone has no tooltip: the last sync shows in the line itself */
/* Documents: a row is a card of its own (file and status, supplier and amount, the document's date, when it was added, the transaction), not the register's: its columns have other names */
html.phone tr.row.doc-row { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "sel file stat" "sel sup amt" "sel dt dt" "sel add add" "sel txn txn"; }
html.phone tr.doc-row > td[data-label^="File"] { grid-area: file; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
html.phone tr.doc-row > td[data-label^="Status"] { grid-area: stat; justify-self: end; }
html.phone tr.doc-row > td[data-label^="Supplier"] { grid-area: sup; font-size: 13px; overflow-wrap: anywhere; }
html.phone tr.doc-row > td[data-label^="Amount"] { grid-area: amt; text-align: right; font-weight: 600; font-size: 14px; white-space: nowrap; }
html.phone tr.doc-row > td[data-label^="Date"] { grid-area: dt; color: var(--muted); font-size: 12px; }
html.phone tr.doc-row > td[data-label^="Date"]::before { content: "Document date "; display: inline !important; min-width: 0; }
html.phone tr.doc-row > td[data-label^="Added"] { grid-area: add; color: var(--muted); font-size: 12px; }
html.phone tr.doc-row > td[data-label^="Added"]::before { content: "Added "; display: inline !important; min-width: 0; }
html.phone tr.doc-row > td[data-label^="Transaction"] { grid-area: txn; font-size: 12px; overflow-wrap: anywhere; }
html.phone tr.row > td[data-label^="Category"] > * { max-width: 100%; box-sizing: border-box; }
html.phone tr.row > td[data-label^="Category"] button.picker { width: 100%; min-width: 140px; }
html.phone tr.row > td[data-label^="Category"] select { width: 100%; }
html.phone tr.splitrow { display: block; margin: -6px 0 10px 16px; padding: 4px 12px; border-radius: 8px; }
html.phone tr.splitrow > td { display: inline; padding: 0 6px 0 0; } html.phone tr.splitrow > td::before { display: none; }

/* a table that is truly a grid of numbers (reports, statements to tick) keeps its columns and scrolls inside its own box */
html.phone .keepgrid { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
html.phone .keepgrid table { display: table; min-width: 560px; }
html.phone .keepgrid table thead { display: table-header-group; } html.phone .keepgrid table tbody { display: table-row-group; } html.phone .keepgrid table tr { display: table-row; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; }
html.phone .keepgrid table td { display: table-cell; padding: 7px 10px; border-bottom: 1px solid var(--line); } html.phone .keepgrid table td::before { display: none; }

/* iPhone Safari gives a date field a width of its own that can push the page sideways: it takes the width of its box, and an empty one still has its height */
html.mobile input[type=date] { display: block; box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; min-height: 44px; -webkit-appearance: none; appearance: none; }
html.mobile .bar > label.datewrap { min-width: 0; }
html.mobile tr.row, html.mobile .acc, html.mobile #nav a { -webkit-tap-highlight-color: transparent; }
html.phone tr.row:active { background: var(--hover); }
html.mobile .bar label:not(.f) input[type=checkbox] { margin: 0; flex: none; width: 26px; height: 26px; }

/* Inbox on a phone: the account filter, Import and the bulk actions open from one button */
html.phone #main:not(.ib-open) :is(#ib-acc, #ib-import, .ib-actions) { display: none; }

/* the top bar already names the screen: its own heading is hidden, and a bar that held only the heading goes with it */
html.mobile #main h1 { display: none; }
html.mobile #main .bar:has(> h1:only-child) { display: none; }
html.mobile #main .bar:has(> h1:first-child) { justify-content: flex-end; }

/* a long press on an account or group in the drawer should lift it for dragging, not open Safari's link preview */
html.mobile #side :is(a, .acc, .grp) { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* the document viewer: a file over the whole screen with its own Close button */
#docview { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--bg, #fff); }
#docview[hidden] { display: none; }
#docview .dv-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; border-bottom: 1px solid var(--line, #ddd); background: var(--panel, #fff); }
#docview .dv-bar a { font-size: 14px; }
#docview iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* The drawer's groups and accounts: everything further left, and the group names stand out. --d is how deep a row is (groups.js) */
html.mobile #side .grp { margin: 6px 0 0; padding: 2px 8px 2px calc(4px + var(--d, 0) * 12px) !important; font-size: 14px; font-weight: 700; letter-spacing: .04em; color: var(--ink); border-bottom: 1px solid var(--line); border-radius: 0; }
html.mobile #side .grp.sel { color: var(--accent); }
html.mobile #side .grp .caret { width: 28px; min-width: 28px; padding: 0; text-align: center; }
html.mobile #side .grp .gtot { font-size: 13px; font-weight: 600; color: var(--muted); }
html.mobile #side .grp.ungrouped { margin-top: 8px; }
html.mobile #side #accounts > .grp:first-child { margin-top: 0; }
html.mobile #side #accounts .acc { padding-left: calc(24px + var(--d, 0) * 12px) !important; }

/* The From / To names above the date boxes are only for small screens (an empty date box is blank on iOS); on a computer the boxes line up with the other filters, named by their tooltips */
.bar > label.f.datewrap { display: contents; }
.bar > label.f.datewrap > span { display: none; }
html.mobile .bar > label.f.datewrap { display: block; }
html.mobile .bar > label.f.datewrap > span { display: block; }
html:not(.mobile) .bar > label.f.datewrap > input[type=date] { box-sizing: border-box; height: 34px; }
/* Every box in a filter bar is the same height and sits on the same line: on a computer a select was 33px next to 34px inputs; on an iPad or a narrow window the From / To names above the date boxes made those labels taller, so the date boxes sat lower than their neighbours (the row now lines them up by their bottoms) */
html:not(.mobile) .bar :is(select, input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), button.picker) { box-sizing: border-box; height: 34px; }
html.mobile .bar:has(> label.datewrap) { align-items: flex-end; }
/* A touch screen of any width: an empty date box is blank on iOS, so From / To are named above the boxes (a wide iPad too, not only a narrow window) */
@media (pointer: coarse) {
  .bar > label.f.datewrap { display: block; flex: 0 1 170px; }
  .bar > label.f.datewrap > span { display: block; }
  .bar:has(> label.datewrap) { align-items: flex-end; }
}
/* A date box is as high as its neighbours on an iPad too (Safari gives a date input its own taller minimum) */
@media (pointer: coarse) {
  .bar > label.f.datewrap > input[type=date] { box-sizing: border-box; width: 100%; height: 44px !important; min-height: 44px; max-height: 44px; -webkit-appearance: none; appearance: none; text-align: left; }
  .bar :is(select, input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), button.picker) { height: 44px !important; }   /* Safari ignores min-height on a select, so the computer's 34px height must not apply */
  tr.row > td.rowmenu { padding-top: 0; padding-bottom: 0; }                                       /* the ⋮ button is 44 high like the tick box: its centre is on the first line of the row */
}
/* The category box in a filter bar is a field, not a whole row; a phone still gives it the full width */
html:not(.phone) .bar > button.picker { width: auto; flex: 0 1 280px; min-width: 200px; }
html:not(.mobile) .bar > .seg button { box-sizing: border-box; height: 34px; }

/* The keyboard-selected row (a click or tap also selects it, for the arrow keys) is tinted in the register and Inbox; on a touch screen that shows as stray coloured blocks inside the cards and never goes away */
@media (hover: none) {
  tr.ksel td { background: none; }
  tr.ksel td:first-child { box-shadow: none; }
  tr.ksel button.kebab { background: none; color: inherit; }
}
html.phone .scroll { max-height: none !important; overflow: visible; }

/* The Tags box is a box around a little input: with the finger-sized input inside its padding it came out taller than the other fields. Now the empty box is exactly one field high, and it grows only when tags wrap */
html.mobile .tagbox { box-sizing: border-box; min-height: 44px; padding-top: 0; padding-bottom: 0; }
html.mobile .tagbox input.tagtype { min-height: 42px !important; }
@media (pointer: coarse) {
  .tagbox { box-sizing: border-box; min-height: 44px; padding-top: 0; padding-bottom: 0; }
  .tagbox input.tagtype { min-height: 42px !important; }
}

/* a photo in the document viewer fits the screen; a tap shows it at full size */
#docview iframe[hidden] { display: none; }
#docview #dv-img { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; background: #111; -webkit-overflow-scrolling: touch; }
#docview #dv-img[hidden] { display: none; }
#docview #dv-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
#docview #dv-img.full { display: block; }
#docview #dv-img.full img { max-width: none; max-height: none; }

/* An account's, group's or list's actions: buttons in the header; on a phone they fold into one "Actions ▾" button that opens the same list */

/* Calendar on a phone: the days that have transactions, as a list */
html.phone .cal-grid { display: none; }
html.phone .cal-list { display: block; }
html.phone .cal-lday { margin: 0 0 12px; }
html.phone .cal-lday h3 { margin: 0 0 4px; font-size: 14px; display: flex; justify-content: space-between; }
html.phone .cal-lday.today h3 { color: var(--accent, #2f6fed); }
html.phone .cal-tx { font-size: 15px; padding: 8px 6px; min-height: 44px; align-items: center; }
html.phone .cal-nav { width: 100%; justify-content: space-between; }
@media (pointer: coarse) { .cal-tx, .cal-more { min-height: 44px; display: flex; align-items: center; font-size: 13px; } }          /* 13px, not the 16px of every touch button: the grid is narrow and shows payees */

html.phone tr.payee-row > td:nth-child(5) { grid-area: act; justify-self: end; }

/* Categories page: a card per category (name and menu, amount and change, the chart and the share) */
@media (pointer: coarse), (max-width: 1000px) { .ovtw { min-width: 44px; min-height: 44px; } .co-chip { min-height: 44px; align-items: center; } }
html.phone .ovtbl thead { display: none; }
html.phone .ovtbl, html.phone .ovtbl tbody { display: block; }
html.phone .ovtbl tr.kindhead { display: block; } html.phone .ovtbl tr.kindhead td { display: block; padding: 14px 0 6px; }
html.phone .ovtbl tr.ovrow { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name menu" "amt chg" "spark share"; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
html.phone .ovtbl tr.ovrow > td { display: block; padding: 0; border: 0; min-width: 0; }
html.phone .ovtbl tr.ovrow > td::before { display: none !important; }
html.phone .ovtbl tr.ovrow > td.ovname { grid-area: name; white-space: normal; padding: 0 !important; } html.phone .ovtbl tr.ovsub > td.ovname { padding-left: 24px !important; }
html.phone .ovtbl tr.ovrow > td.ovamt { grid-area: amt; text-align: left; font-weight: 600; font-size: 16px; }
html.phone .ovtbl tr.ovrow > td.ovchg { grid-area: chg; text-align: right; }
html.phone .ovtbl tr.ovrow > td.ovspark { grid-area: spark; } html.phone .ovtbl tr.ovrow > td.ovshare { grid-area: share; text-align: right; font-size: 12px; }
html.phone .ovtbl tr.ovrow > td.rowmenu { grid-area: menu; display: flex; justify-content: flex-end; min-width: 44px; }          /* the 44px menu button has its own column: the name ends where it begins */
html.phone .ovtbl tr.ovsub .ovtw.ovno { display: none; }
/* Payees: a card per payee (name and menu, usual category, amount and change, chart and when it was last seen) */
html.phone .ovtbl tr.ovrow.pyrow { grid-template-areas: "name menu" "cat cat" "amt chg" "spark share"; }
html.phone .ovtbl tr.ovrow.pyrow > td.ovcat { grid-area: cat; font-size: 12px; max-width: none; }
html.phone .ovtbl tr.pymore, html.phone .ovtbl tr.pymore > td { display: block; }

/* printing or saving as PDF from a phone: the page still carries html.phone, so put the table layout back (the cards are for the screen) */
@media print {
  html.phone table.reflow { display: table !important; width: 100% !important; }
  html.phone table.reflow tbody { display: table-row-group !important; width: auto !important; }
  html.phone table.reflow thead { display: table-header-group !important; }
  html.phone table.reflow tr { display: table-row !important; margin: 0 !important; padding: 0 !important; background: none !important; border: 0 !important; border-radius: 0 !important; }
  html.phone table.reflow td, html.phone table.reflow th { display: table-cell !important; padding: 3px 6px !important; text-align: left; vertical-align: middle !important; }
  html.phone table.reflow td.num, html.phone table.reflow th.num { text-align: right; }
  html.phone table.reflow td::before { display: none !important; }
  html.phone table.reflow td:empty { display: table-cell !important; }
  html.phone .tablewrap { overflow: visible !important; }
}

/* Categories (all three tabs) on a phone: the tabs take a full row, Manage's actions sit under them; a category is a small card: name and ⋮ on one line, the counts under it */
html.phone .bar:has(> .co-tabs) { flex-wrap: wrap; }
html.phone .bar > .co-tabs { flex: 1 1 100%; order: -1; }
html.phone .bar:has(> .co-tabs) { justify-content: flex-start; }
html.phone .cat-tools { flex: 1 1 100%; margin-left: 0; }
html.phone table.cattbl.reflow tr.catrow > td.cn { justify-content: flex-start; gap: 8px; }
html.phone .co-tabs button { flex: 1 1 0; white-space: nowrap; }
html.phone table.cattbl.reflow tr.catrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; column-gap: 8px; padding: 6px 12px; margin-bottom: 8px; }
html.phone table.cattbl.reflow tr.catrow > td { padding: 2px 0; }
html.phone table.cattbl.reflow tr.catrow > td::before { content: none; }
html.phone table.cattbl.reflow tr.catrow > td.selc { grid-row: 1; grid-column: 1; }
html.phone table.cattbl.reflow tr.catrow > td.cn { grid-row: 1; grid-column: 2 / 4; padding-left: 0 !important; }
html.phone table.cattbl.reflow tr.catrow > td.rowmenu { grid-row: 1; grid-column: 4; }
html.phone table.cattbl.reflow tr.catrow > td.num { font-size: 13px; color: var(--muted); display: flex; gap: 5px; justify-content: flex-start; }
html.phone table.cattbl.reflow tr.catrow > td.c-tx { grid-row: 2; grid-column: 2; }
html.phone table.cattbl.reflow tr.catrow > td.c-rules { grid-row: 2; grid-column: 3 / 5; justify-self: end; }
html.phone table.cattbl.reflow tr.catrow > td.c-tx::before { content: "Transactions"; min-width: 0; }
html.phone table.cattbl.reflow tr.catrow > td.c-rules::before { content: "Rules"; min-width: 0; }
html.phone table.cattbl.reflow tr.catrow[data-pid]:not([data-pid=""]) { margin-left: 14px; }
html.phone table.cattbl.reflow tr.kindhead { background: none; border: 0; padding: 10px 2px 2px; margin: 0; }

/* Tidy up page on a phone: the name box and the Merge button take a full row each, the button's text wraps */
html.phone .tidy-go .tidy-rename, html.phone .tidy-go [data-tgo] { flex: 1 1 100%; }
html.phone .tidy-acts select { flex: 1 1 100%; }

/* the "··· More" button of the Transactions box lines up with the search box: in a narrow window the From / To names stand above the date boxes and the row aligns by its bottoms, so the button drops by the height of a name */
html.mobile:not(.phone) button.kebab.tx-menu { top: 32px; }

/* ---------- phone: the bottom tab bar ---------- */
html.phone #tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
html.phone #tabbar > * { flex: 1 1 0; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; padding: 6px 2px 4px;
  border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 11px; text-decoration: none; }
html.phone #tabbar > .on { color: var(--accent); font-weight: 600; }
html.phone #tabbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
html.phone #tabbar b { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 8px; background: var(--neg); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
html.phone #tabbar b[hidden] { display: none; }
html.phone #main, html.phone[data-design] #main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
html.phone.drawer-open #tabbar { z-index: 20; }
/* what floats at the bottom rides above the bar */
html.phone #toast { bottom: calc(66px + env(safe-area-inset-bottom)); }
html.phone.has-statusbar #toast { bottom: calc(122px + env(safe-area-inset-bottom)); }
html.phone #statusbar, html.phone #samplebar, html.phone #announce { bottom: calc(66px + env(safe-area-inset-bottom)); }
html.phone #updatebar { bottom: calc(66px + env(safe-area-inset-bottom)); }
html.phone #demobadge { bottom: calc(60px + env(safe-area-inset-bottom)); }

/* ---------- phone: the register ---------- */
html.mobile .tx-box:has(#rows) { padding: 14px 0 0; border-radius: 12px; }
html.mobile .tx-box:has(#rows) > .bar { align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 10px; }
html.phone .tx-box:has(#rows) > .bar > .cx, html.phone .tx-box:has(#rows) > .bar > #q { flex: 0 0 calc(100% - 100px); min-width: 0; margin-right: 0; }   /* one line of its own, clear of the page's ⋮ */
html.phone .tx-box:has(#rows) > .bar > .cx { display: block; } html.phone .tx-box:has(#rows) > .bar > .cx > input { width: 100%; }   /* clear of the page's ⋮ in the corner */
html.phone .tx-box:has(#rows) > .bar > #txf-btn, html.phone .tx-box:has(#rows) > .bar > #txs-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 10px; }
html.mobile #txf-btn.on { border-color: var(--accent); color: var(--accent); }
html.mobile #txf-btn b { background: var(--accent); color: var(--accent-ink, #fff); border-radius: 9px; min-width: 18px; height: 18px; line-height: 18px; font-size: 11px; text-align: center; padding: 0 4px; box-sizing: border-box; }
html.mobile #txf-chips { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 6px; }
html.mobile #txf-chips:empty { display: none; }
html.mobile .tx-box:has(#rows) #reset-filters { display: none; }
html.phone .tx-box:has(#rows) > .bar > #txs-btn { margin-left: auto; min-height: 36px; border: 0; background: none; color: var(--accent); padding: 0 6px; }
html.mobile .txf-chip { min-height: 32px !important; font-size: 13px !important; padding: 0 10px; border-radius: 16px; border: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
html.phone .tx-box:has(#rows) > .bar > #new-txn { margin: 0; position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 25; width: 52px; height: 52px; border-radius: 50%; font-size: 26px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
html.mobile #txf-scrim { display: none; }
html.mobile #main.txf-open #txf-scrim { display: block; position: fixed; inset: 0; z-index: 69; background: rgba(0,0,0,.45); }
html.mobile #txf-sheet { display: none; }
html.mobile #main.txf-open #txf-sheet { display: flex; flex-direction: column; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; max-height: 82dvh; box-sizing: border-box; background: var(--panel);
  border-radius: 16px 16px 0 0; border-top: 1px solid var(--line); padding: 14px max(14px, env(safe-area-inset-left)) calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
html.mobile .txf-head { display: flex; align-items: center; justify-content: space-between; font-size: 17px; }
html.mobile #txf-body { display: flex; flex-wrap: wrap; gap: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; padding-bottom: 4px; }
html.mobile #txf-body > * { flex: 1 1 100%; min-width: 0; margin: 0; }
html.mobile #txf-body > label.datewrap { flex: 1 1 calc(50% - 5px); }
html.mobile #txf-body > label:not(.datewrap):has(> input[type=checkbox]) { flex: 0 0 auto; }
html.mobile #txf-body > #cat-summary[hidden] { display: none; }
html.phone .tx-box:has(#rows) .selc { display: none; }
html.phone #main.tx-select .tx-box .selc { display: block; }
html.phone .tx-box:has(#rows) .pager { display: none; }
html.phone .tx-box:has(#rows) #more { display: block; width: calc(100% - 20px); margin: 10px; }
html.phone .tx-box:has(#rows) #more[hidden] { display: none; }
/* compact rows: payee and amount, then date · category · account on one line; the badges shrink to a dot for an unconfirmed row and the recurring mark */
html.phone .tx-box:has(#rows) table.reflow tr.row { grid-template-columns: auto auto minmax(0, 1fr) auto 36px; grid-template-areas: "sel pay pay amt menu" "sel dt cat acc menu" "sel bal bal bal menu" "sel act act act menu"; gap: 0 8px; margin: 0; padding: 8px 4px 8px 12px; border-radius: 0; border-width: 1px 0 0; }
html.phone .tx-box:has(#rows) tr.row > td[data-label^="Payee"] { font-size: 15px; font-weight: 500; }
html.phone .tx-box:has(#rows) tr.row > td[data-label^="Date"] { align-self: center; }
html.phone .tx-box:has(#rows) tr.row > td[data-label^="Date"]::after { content: " ·"; }
html.phone .tx-box:has(#rows) tr.row > td[data-label^="Category"] { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: center; }
html.phone .tx-box:has(#rows) tr.row > td[data-label^="Account"] { text-align: right; align-self: center; }
html.phone .tx-box:has(#rows) tr.row > td.neg, html.phone .tx-box:has(#rows) tr.row > td.pos { font-weight: 500; }
html.phone .tx-box:has(#rows) tr.row > td.neg { color: var(--neg); }
html.phone .tx-box:has(#rows) .c-pay .src, html.phone .tx-box:has(#rows) .c-pay .tag:not(.unconf):not(.rc-tag):not(.rec):not(.warn), html.phone .tx-box:has(#rows) .c-pay .muted { display: none; }
html.phone .tx-box:has(#rows) .c-pay .tag.unconf { display: inline-block; width: 8px; height: 8px; padding: 0; margin-left: 6px; border-radius: 50%; background: var(--warn, #d97706); color: transparent; font-size: 0; border: 0; vertical-align: middle; overflow: hidden; }
html.phone #txf-body > .ms, html.phone #txf-body > #acc-ms { max-width: none; width: 100%; }
html.phone #txf-body > .ms > button, html.phone #txf-body .ms-btn { width: 100%; }
html.phone #txf-body > #src, html.phone #txf-body > #docs { flex: 1 1 calc(50% - 5px); }
html.phone .tx-box:has(#rows) table.reflow tr.splitrow { margin: 0; padding: 4px 12px 4px 28px; border-radius: 0; border-width: 1px 0 0; background: var(--bg); font-size: 13px; }

/* ---------- phone: the Inbox list ---------- */
.ib-ok { display: none; }
html.phone .ib-actions ~ .tablewrap table.reflow tr.row { grid-template-columns: auto minmax(0, 1fr) auto 36px; grid-template-areas: "sel pay amt menu" "sel dt acc menu" "sel cat cat menu" "sel act act menu"; gap: 2px 8px; margin: 0; padding: 10px 4px 10px 8px; border-radius: 0; border-width: 1px 0 0; }
html.phone .ib-actions ~ .tablewrap tr.row > td.selc { min-height: 0; padding: 0; }
html.phone .ib-actions ~ .tablewrap tr.row > td[data-label^="Date"] { align-self: center; }
html.phone .ib-actions ~ .tablewrap tr.row > td[data-label^="Account"] { text-align: right; align-self: center; }
html.phone .ib-actions ~ .tablewrap tr.row > td[data-label^="Payee"] { font-size: 15px; font-weight: 500; }
html.phone .ib-actions ~ .tablewrap tr.row > td.neg { color: var(--neg); }
html.phone .ib-actions ~ .tablewrap .src, html.phone .ib-actions ~ .tablewrap td .muted[title], html.phone .ib-actions ~ .tablewrap td[data-label^="Payee"] .tag:not(.warn) { display: none; }
html.phone .ib-actions ~ .tablewrap td:has(.sugg[data-sug]) :is(.ib-cat, .picker) { display: none; }       /* a suggestion stands in for the empty box: ✓ takes it, a tap on the row opens the full editor */
html.phone .ib-actions ~ .tablewrap tr.row > td.num:not(.neg):not(.pos):not([data-label]) { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
html.phone .ib-ok { display: inline-flex; align-items: center; justify-content: center; flex: 1 1 auto; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--pos, #15803d) 16%, transparent); color: var(--pos, #15803d); font-weight: 600; }
html.phone #ib-cta { position: fixed; left: 12px; right: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 28; min-height: 48px; border-radius: 12px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
html.phone #ib-cta[hidden] { display: none; }
html.phone #main:has(#ib-cta:not([hidden])) { padding-bottom: calc(136px + env(safe-area-inset-bottom)); }
/* a window (a full-screen sheet on a phone) covers the tab bar, so its Save button is never underneath it */
html.phone:has(#modal:not(.hidden)) #tabbar, html.phone:has(#modal2:not(.hidden)) #tabbar, html.phone:has(#palette:not([hidden])) #tabbar { display: none; }
html.phone:has(#modal:not(.hidden)) #ib-cta, html.phone:has(#modal:not(.hidden)) #new-txn { display: none; }
/* the Inbox's top bar on a phone: the List / By payee / Cards switch has its own line, then the search box and the Filters & actions button share the next one */
html.phone .bar:has(> #ib-fold) > .seg { flex: 1 0 100%; display: flex; }
html.phone .bar:has(> #ib-fold) > .seg > button { flex: 1 1 0; }
html.phone .bar:has(> #ib-fold) > .cx, html.phone .bar:has(> #ib-fold) > input[type=search] { flex: 1 1 0; min-width: 0; }
html.phone .bar:has(> #ib-fold) > .cx > input { width: 100%; }
html.phone .bar:has(> #ib-fold) > #ib-fold { flex: 0 0 auto; white-space: nowrap; }

/* ---------- phone: Home, Payees, Rules, Manage categories ---------- */
html.phone .home .home-card:not(.home-slim) > h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; min-height: 44px; margin: 0; }
html.phone .home .home-card:not(.home-slim) > h2::after { content: ""; flex: none; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; margin-right: 4px; }
html.phone .home .home-card.folded > h2::after { transform: rotate(-45deg); }
html.phone .home .home-card.folded > :not(h2):not(.home-ctl) { display: none; }
html.phone .home .home-card.folded { padding-top: 0; padding-bottom: 0; }
html.phone .ovtbl tr.ovrow.pyrow { grid-template-columns: minmax(0, 1fr) auto 44px; grid-template-areas: "name amt menu" "cat chg menu"; padding: 6px 0; gap: 0 10px; }
html.phone .ovtbl tr.ovrow.pyrow > td.ovamt { font-size: 15px; text-align: right; }
html.phone .ovtbl tr.ovrow.pyrow > td.ovspark, html.phone .ovtbl tr.ovrow.pyrow > td.ovshare { display: none; }
html.phone .ovtbl tr.ovrow.pyrow > td.ovname { font-weight: 500; }
html.phone table.reflow tr.rurow { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when when" "then then" "acc act"; gap: 2px 8px; padding: 8px 12px; margin: 0; border-radius: 0; border-width: 1px 0 0; }
html.phone table.reflow tr.rurow > td { display: block; padding: 0; min-width: 0; }
html.phone table.reflow tr.rurow > td::before { display: none; }
html.phone table.reflow tr.rurow > td:nth-child(1), html.phone table.reflow tr.rurow > td:nth-child(5) { display: none; }
html.phone table.reflow tr.rurow > td:nth-child(2) { grid-area: when; font-weight: 500; overflow-wrap: anywhere; }
html.phone table.reflow tr.rurow > td:nth-child(3) { grid-area: then; font-size: 13px; overflow-wrap: anywhere; }
html.phone table.reflow tr.rurow > td:nth-child(3)::before { content: "→ "; display: inline; color: var(--muted); min-width: 0; }
html.phone table.reflow tr.rurow > td:nth-child(4) { grid-area: acc; font-size: 12px; color: var(--muted); align-self: center; }
html.phone table.reflow tr.rurow > td:nth-child(6) { grid-area: act; justify-self: end; }
html.phone #ru-sugg:not(.open) .ru-extra { display: none; }
html.phone #ru-sugg > .bar { flex-wrap: nowrap; align-items: center; }
html.phone #ru-sugg > .bar > span { flex: 1 1 0; min-width: 0; font-size: 14px; }
html.phone #ru-sugg #ru-more { min-height: 44px; }
html.phone table.cattbl.reflow tr.catrow { padding: 2px 8px; margin: 0; border-radius: 0; border-width: 1px 0 0; }
html.phone table.cattbl.reflow tr.catrow[data-pid]:not([data-pid=""]) { margin-left: 12px; }
html.phone .txf-sortrow { display: flex; gap: 10px; }
html.phone .txf-sortrow > label { flex: 1 1 0; min-width: 0; }
/* the ⋮ menu on a phone: a sheet from the bottom with a Cancel, and a dimmed area that closes it when tapped */
html.phone #rowmenu-scrim { position: fixed; inset: 0; z-index: 58; background: rgba(0,0,0,.4); }
html.phone #rowmenu { left: 0 !important; right: 0; top: auto !important; bottom: 0; z-index: 59; max-height: 80dvh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
html.phone #rowmenu button { min-height: 48px; width: 100%; font-size: 16px; }
html.phone #rowmenu button.menu-cancel { margin-top: 6px; border-top: 1px solid var(--line); font-weight: 600; justify-content: center; text-align: center; }
html.phone .m-sort { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
html.phone .m-sort label { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
html.phone .m-sort select { flex: 1 1 0; min-width: 0; }
html.phone .m-sort button { flex: 0 0 auto; }
html.phone .m-sort button[hidden] { display: none; }
/* the Payees toolbar on a phone: the search box, then Period, then the tick box, each on its own full line; the Sort by line below it lines up with Period */
html.phone .bar:has(#py-q) > .cx, html.phone .bar:has(> #py-q) > #py-q { flex: 1 1 100%; order: 0; }
html.phone .bar:has(#py-q) > .cx > input { width: 100%; }
html.phone .bar:has(#py-q) > .sum-pick { flex: 1 1 100%; margin-left: 0 !important; order: 1; }
html.phone .bar:has(#py-q) > label.nowrap { flex: 1 1 100%; order: 2; white-space: normal; }
html.phone .bar > .sum-pick, html.phone .m-sort > label { display: flex; align-items: center; gap: 8px; }
html.phone .bar > .sum-pick > span, html.phone .m-sort > label > span { flex: 0 0 64px; font-size: 13px; color: var(--muted); }
html.phone .bar > .sum-pick > select { flex: 1 1 0; min-width: 0; }

/* Categories > Manage on a phone: the new-category name on a line, where it goes and its type side by side, Add on a line, then Select / Tidy up / ⋮ */
html.phone .cat-addbar { gap: 8px; }
html.phone .cat-addbar > #cat-new, html.phone .cat-addbar > .cx { flex: 1 1 100%; width: 100%; }
html.phone .cat-addbar > .cx > input { width: 100%; }
html.phone .cat-addbar > #cat-parent { flex: 1 1 55%; min-width: 0; }
html.phone .cat-addbar > #cat-kind { flex: 1 1 30%; min-width: 0; }
html.phone .cat-addbar > #cat-add { flex: 1 1 100%; }
html.phone .cat-addbar > .cat-tools { flex: 1 1 100%; display: flex; gap: 8px; align-items: center; }
html.phone .cat-addbar > .cat-tools > button:not(.kebab) { flex: 1 1 0; }

/* the Budget tab on a phone: Budget picker on a line, New budget and ⋮ below, and each category's Allowance, Spent and Left on one line under its name with the pace bar below */
html.phone .bg-tools > .sum-pick { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; margin: 0; }
html.phone .bg-tools > .sum-pick > span { flex: 0 0 64px; font-size: 13px; color: var(--muted); }
html.phone .bg-tools > .sum-pick > select { flex: 1 1 0; min-width: 0; }
html.phone .bg-tools > #bg-new { flex: 1 1 0; }
html.phone .bg-tools > .bg-nav { margin-left: 0; flex: 1 1 100%; justify-content: space-between; }
html.phone .bg-row { grid-template-columns: 1.4fr 1fr 1fr; gap: 6px 10px; align-items: start; }
html.phone .bg-row > .bg-name, html.phone .bg-row > .bg-pc { grid-column: 1 / -1; }
html.phone .bg-row > .bg-cell { display: grid; grid-template-rows: auto 44px; align-items: center; text-align: left; min-width: 0; font-size: 15px; }
html.phone .bg-row > .bg-cell > .bg-lab { align-self: end; }
html.phone .bg-row > .bg-pc { display: block; }
html.phone .bg-amt { text-align: left; }
/* the Categories (Spending) toolbar on a phone: search and Period each on a full line, like Payees */
html.phone .bar:has(#co-q) > .cx, html.phone .bar:has(> #co-q) > #co-q { flex: 1 1 100%; order: 0; }
html.phone .bar:has(#co-q) > .cx > input { width: 100%; }
html.phone .bar:has(#co-q) > .sum-pick { flex: 1 1 100%; margin-left: 0 !important; order: 1; }
html.phone .bar.bg-tools > label.sum-pick { flex: 1 1 100%; }
html.phone .bar.bg-tools > #bg-new { flex: 1 1 0; white-space: nowrap; }
html.phone .bar.bg-tools > .bg-nav { flex: 1 1 100%; }
/* Home on a phone or an upright iPad: one column, every card as wide as the page (the desktop grid's align-items: start made each card only as wide as its content) */
html.mobile #home.home { align-items: stretch; }
html.mobile #home .home-card { align-self: stretch; width: auto; box-sizing: border-box; }
/* Home on a phone: Customise sits at the right of the greeting line instead of taking a line of its own (while customising, the bar comes back so its hint has room) */
html.phone #main > .bar:has(> #home-custom):not(:has(#home-edit-tools:not(:empty))) { position: relative; height: 0; min-height: 0; margin: 0; padding: 0; overflow: visible; }
html.phone #main > .bar:has(> #home-custom):not(:has(#home-edit-tools:not(:empty))) > #home-custom { position: absolute; right: 0; top: 0; z-index: 2; border: 0; background: none; color: var(--accent); padding: 0 6px; }
html.phone #main > #home-sub { min-height: 44px; display: flex; align-items: center; padding-right: 100px; margin-top: 0; }
html.phone #home-foldall { display: none; }
html.phone #main > .bar:has(> #home-custom):not(:has(#home-edit-tools:not(:empty))) > #home-foldall { display: inline-flex; align-items: center; justify-content: center; position: absolute; right: 92px; top: 0; z-index: 2; border: 0; background: none; color: var(--muted); min-width: 44px; padding: 0; }
html.phone #home-foldall .fa-fold, html.phone #home-foldall.is-open .fa-open { display: none; }
html.phone #home-foldall.is-open .fa-fold { display: inline; }
html.phone #main > #home-sub { padding-right: 150px; }

/* ---------- phone: Imports (a card of three lines and a row of figures), and the "Show more" row under a long list ---------- */
html.phone table.reflow tr.more-row { display: block; border: 0; background: none; padding: 0; margin: 0; }
html.phone table.reflow tr.more-row > td { display: block; padding: 0; }
html.phone table.reflow tr.more-row > td::before { display: none; }
html.phone table.reflow tr.more-row button { width: 100%; min-height: 48px; }
html.phone table.reflow tr.improw { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "file file act" "acc acc imp" "per per per" "new skp clo"; gap: 2px 10px; padding: 10px 12px; margin: 0 0 8px; }
html.phone table.reflow tr.improw > td { display: block; padding: 0; min-width: 0; text-align: left; }
html.phone table.reflow tr.improw > td::before { display: none; }
html.phone table.reflow tr.improw > td:nth-child(1) { grid-area: imp; justify-self: end; font-size: 12px; color: var(--muted); white-space: nowrap; }
html.phone table.reflow tr.improw > td:nth-child(2) { grid-area: file; font-weight: 500; overflow-wrap: anywhere; }
html.phone table.reflow tr.improw > td:nth-child(3) { grid-area: acc; font-size: 13px; color: var(--muted); }
html.phone table.reflow tr.improw > td:nth-child(4) { grid-area: per; font-size: 12px; color: var(--muted); }
html.phone table.reflow tr.improw > td:nth-child(5) { grid-area: new; } html.phone table.reflow tr.improw > td:nth-child(6) { grid-area: skp; } html.phone table.reflow tr.improw > td:nth-child(7) { grid-area: clo; text-align: right; }
html.phone table.reflow tr.improw > td:nth-child(n+5):nth-child(-n+7)::before { display: block; content: attr(data-label); font-size: 11px; color: var(--muted); min-width: 0; }
html.phone table.reflow tr.improw > td:nth-child(8) { grid-area: act; justify-self: end; }
/* Categories (Spending) rows: name and amount, then the share bar and the change; the twelve-month bars are left out on a phone */
html.phone .ovtbl tr.ovrow:not(.pyrow) { grid-template-columns: minmax(0, 1fr) auto 44px; grid-template-areas: "name amt menu" "share chg menu"; padding: 6px 0; gap: 0 10px; }
html.phone .ovtbl tr.ovrow:not(.pyrow) > td.ovspark { display: none; }
html.phone .ovtbl tr.ovrow:not(.pyrow) > td.ovamt { text-align: right; font-size: 15px; }
html.phone .ovtbl tr.ovrow:not(.pyrow) > td.ovshare { text-align: left; }

/* the same filter sheet on an iPad held upright: a wide search box and one button, with the table kept; Select is a phone's way to show tick boxes */
html.mobile:not(.phone) .tx-box:has(#rows) > .bar > .cx { flex: 1 1 280px; min-width: 0; display: block; }
html.mobile:not(.phone) .tx-box:has(#rows) > .bar > .cx > input { width: 100%; }
html.mobile:not(.phone) .tx-box:has(#rows) > .bar > #txs-btn { display: none; }
html.mobile:not(.phone) .tx-box:has(#rows) > .bar > #txf-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; }
html.mobile:not(.phone) #txf-sheet, html.mobile:not(.phone) #main.txf-open #txf-sheet { left: 50%; right: auto; width: min(560px, 100%); transform: translateX(-50%); }
html.mobile:not(.phone) .tx-box:has(#rows) > .bar { padding-right: 114px; flex-wrap: wrap; }          /* clear of the page's ⋮ in the corner */
html.mobile:not(.phone) #txf-chips { flex: 1 0 100%; }
html.mobile:not(.phone) .tx-box:has(#rows) { padding-top: 32px; }                                  /* the search box lines up with the page's ⋮ */

/* Summary pages on a phone: one button opens or folds every card */
#sum-foldall { display: none; }
html.phone #sum-foldall { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; margin-left: auto; border: 0; background: none; color: var(--muted); min-width: 44px; min-height: 44px; padding: 0; }
html.phone #sum-foldall .fa-fold, html.phone #sum-foldall.is-open .fa-open { display: none; }
html.phone #sum-foldall.is-open .fa-fold { display: inline; }

/* Payee and category Summaries on a phone: the buttons share one row, equal and centred; the pickers take a full line */
html.phone .bar:has(> .pgsum) { gap: 8px; }
html.phone .bar:has(> .pgsum) > .pgsum { flex: 1 1 0; justify-content: center; min-width: 0; padding: 6px 8px; border-radius: 999px; }
html.phone .bar.bar:has(> .pgsum) > label.sum-pick { flex: 1 1 100%; margin: 0 !important; }
html.phone .bar.bar:has(> .pgsum) > label.sum-pick.sum-last { flex: 0 0 calc(100% - 52px); min-width: 0; }

/* The category picker opens above the Sort & filter sheet, not behind it */
html.mobile #pickpanel { z-index: 95; }
/* every field in the sheet fills its line; the source and documents selects share one */
html.mobile #txf-body > :not(label):not(.datewrap) { flex: 1 1 100%; width: 100%; box-sizing: border-box; }
html.mobile #txf-body > select { flex: 1 1 calc(50% - 5px); width: auto; }
html.mobile #txf-body > button { justify-content: space-between; text-align: left; }

/* The multi-select action bar on a phone wraps inside the screen (it was one long nowrap row that widened the page and made iOS zoom out) */
html.mobile .batchbar:not([hidden]) { display: flex; flex-wrap: wrap; width: 100%; max-width: 100%; box-sizing: border-box; padding: 8px 10px; gap: 6px; }
html.mobile .batchbar > b, html.mobile .batchbar > .bb-total { flex: 0 1 auto; }
html.mobile .batchbar > button { flex: 0 1 auto; white-space: nowrap; }
