/* West Coast Jalsa Salana USA — Expense Portal design system (Jalsa gold on cream). */
:root {
  --bg: #f6efe2;          /* page */
  --panel: #ffffff;       /* top bar */
  --card: #fffaf0;        /* cards & tables */
  --ink: #2b2b2b;
  --muted: #6b6256;
  --line: #e6d8bd;
  --accent: #eda038;      /* Jalsa gold (primary) */
  --accent-ink: #2b2b2b;  /* text on gold — gold is too light for white text */
  --accent-deep: #a86c12; /* gold as text/accent on cream */
  --good: #2e6b1e;
  --good-bg: #d3e5c9;
  --warn-bg: #f7e7bb;
  --warn-ink: #7a5d10;
  --bad: #b23030;
  --bad-bg: #f3d2cf;
  --shadow: 0 2px 8px rgba(0,0,0,.06), 0 10px 30px rgba(0,0,0,.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; line-height: 1.45;
}

/* Wider than a text column on purpose: the Finance check table carries a lot of columns. */
.wrap { max-width: 1500px; margin: 0 auto; padding: 22px 18px 64px; }
.center-narrow { max-width: 460px; margin: 48px auto; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand-left { display: flex; align-items: center; gap: 14px; }
.topbar .logo { height: 46px; width: auto; object-fit: contain; }
.topbar .brand-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; line-height: 1.15; pointer-events: none; }
.topbar #brandTitle { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; }
.topbar #brandSub { font-size: 12px; margin-top: 2px; }
.topbar .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }

/* Tabs — same height as a default button so the tab strip and the action rows below it line up. */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 16px; }
.tab { display: inline-flex; align-items: center; justify-content: center; height: 38px; padding: 0 18px;
  border: 1.5px solid var(--ink); border-radius: 999px; background: transparent; color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 600; letter-spacing: .2px; line-height: 1;
  white-space: nowrap; cursor: pointer; transition: background .18s, color .18s; }
.tab:hover { background: rgba(43,43,43,.07); }
.tab.active { background: var(--ink); color: #fff; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.section-count { font-size: 13px; font-weight: 700; color: var(--accent-deep); }

/* Forms */
label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin: 0 0 5px; }
label .req { color: var(--bad); }
input, select, textarea { width: 100%; padding: 10px 12px; font-size: 15px; color: var(--ink); font-family: inherit; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; }
input, select { height: 42px; line-height: 1.2; }
textarea { height: auto; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-deep); border-color: transparent; }
.field { flex: 1 1 220px; margin-bottom: 14px; }
.field.full { flex-basis: 100%; }

/* Guest entry block on the sign-in gate */
.guest-block { border: 1px solid var(--line); background: #fffdf8; border-radius: 12px; padding: 16px 16px 14px; }

/* Submitter line items. Each line is its own expense: description + amount, then its department,
   sub-department and receipt on a second row. Shared by the public form and the "New expense" dialog. */
.li-row { position: relative; padding: 12px 12px 12px 38px; border: 1px solid var(--line);
  border-radius: 12px; background: #fffdf8; margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s; }
.li-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(237,160,56,.18); }
/* Line number, so "Line 3: enter a description" points at something visible */
.li-num { position: absolute; left: 11px; top: 17px; display: inline-flex; align-items: center;
  justify-content: center; height: 19px; min-width: 19px; padding: 0 4px; border-radius: 6px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; font-weight: 800; }
.li-row.has-file .li-num { background: var(--good-bg); color: var(--good); }
.li-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.li-line + .li-line { margin-top: 8px; }
.li-row .li-desc { flex: 1 1 200px; }
/* Amount, with a $ sign sitting inside the field */
.amt-wrap { position: relative; flex: 0 0 122px; }
.amt-wrap::before { content: '$'; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none; }
.amt-wrap .li-amt { width: 100%; padding-left: 23px; }
.li-row .li-dept { flex: 1 1 170px; }
.li-row .li-sub { flex: 1 1 170px; }
.li-row select.muted-select { color: var(--muted); }
.li-row .li-name { flex: 1 1 90px; font-size: 12px; overflow-wrap: anywhere; }
.li-row .li-name.ok { color: var(--good); font-weight: 600; }
/* The receipt picker turns green once a file is attached */
.li-row.has-file .li-file { border-color: var(--good); color: var(--good); }
.li-row.has-file .li-file::before { content: '✓ '; }
/* Round ✕ that removes a line — opts out of the button box, sized to sit level with the inputs. */
.li-row .li-remove { flex: 0 0 auto; height: 34px; width: 34px; padding: 0; border: none; border-radius: 50%;
  background: transparent; color: var(--bad); font-size: 18px; }
.li-row .li-remove:hover { filter: none; background: var(--bad-bg); }
.li-total { font-size: 14px; color: var(--muted); }
.li-total strong { color: var(--ink); }

/* Finance: check number + account entry inside the "check to be written" table */
input.ck-num { height: 34px; padding: 4px 8px; font-size: 13px; width: 100%; min-width: 90px; max-width: 130px; border-radius: 8px; }
select.ck-gl { height: 34px; padding: 4px 8px; font-size: 12.5px; width: 100%; min-width: 150px; max-width: 230px; border-radius: 8px; }

/* Accounts tab: sub-department grouping inside a department's expandable detail */
.acct-sub { font-size: 12.5px; margin: 4px 0 2px; }

/* Bulk action bar: "select all" sits beside the buttons, not in the table header — the phone breakpoint
   hides <thead> off-screen, which would leave a header checkbox untappable but still focusable. */
.bulk-bar { align-items: center; }
.sel-all { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; cursor: pointer; user-select: none; }

/* Budget: expandable per-department expense breakdown */
.acct-row { cursor: pointer; }
.acct-toggle { display: inline-block; color: var(--accent-deep); font-weight: 700; width: 14px; }
tr.acct-detail > td { background: #fdf7ea; }
.acct-detail-wrap { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 6px 18px; }
.acct-erow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }
.acct-e-name { flex: 1 1 200px; overflow-wrap: anywhere; }
.acct-e-meta { flex: 1 1 160px; font-size: 12px; }
.acct-e-amt { flex: 0 0 auto; font-weight: 700; white-space: nowrap; }
.acct-e-rcpt { flex: 0 0 auto; }

/* Budget: department row → sub-department rows → that sub-department's approved line items */
table.bd-table tr.bd-dept > td { background: #fbf6ec; }
.bd-indent { display: inline-block; padding-left: 18px; }

/* Admins tab: collapsible department / sub-department groups */
.ad-group { border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; overflow: hidden; }
.ad-group.ad-orphan { border-color: var(--bad); }
.ad-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px;
  background: #fbf6ec; cursor: pointer; user-select: none; }
.ad-group.ad-orphan > .ad-head { background: var(--bad-bg); }
.ad-head:hover { filter: brightness(.985); }
.ad-name { font-weight: 800; font-size: 14.5px; letter-spacing: .2px; }
.ad-count { flex: 0 0 auto; min-width: 22px; text-align: center; padding: 1px 8px; border-radius: 20px;
  background: var(--accent-deep); color: #fff; font-size: 11.5px; font-weight: 800; }
.ad-count.ad-zero { background: #cdbf9f; color: #3a3424; }
.ad-add { margin-left: auto; }
.ad-body { padding: 4px 12px 12px; }
.ad-subgroup { margin: 8px 0 0; }
.ad-subgroup > .ad-head { background: #fdfaf3; padding: 8px 10px; }
.ad-subgroup .ad-name { font-weight: 700; font-size: 13.5px; }
.ad-empty { margin: 6px 0; }
table.ad-table { font-size: 13.5px; }

/* Manager-only Delete link on an expense row — inline text, not a box. */
.ex-del { display: inline; height: auto; padding: 0 2px; border: none; border-radius: 0;
  background: transparent; color: var(--bad); font-size: 12px; font-weight: 700; text-decoration: underline;
  white-space: normal; }
.ex-del:hover { filter: none; opacity: .75; background: transparent; }
/* In-flight: the row says what is happening instead of looking untouched */
.ex-del.busy { text-decoration: none; cursor: default; font-style: italic; animation: delPulse 1.1s infinite; }
@keyframes delPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* Buttons — two sizes only, both with a FIXED height so no button is ever taller than its neighbour.
   Hierarchy is carried by fill (solid gold = primary, outline = secondary), never by size.
     default  38px — page- and card-level actions (anything sitting in a .row)
     .small   30px — actions inside a table row, a modal header, or a collapsible group header
   inline-flex + line-height:1 keeps the label optically centred at a fixed height, so swapping the text
   to "Saving…" can't resize the button. */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 18px; border: 1.5px solid var(--accent); border-radius: 999px;
  font-family: inherit; font-size: 14px; font-weight: 600; letter-spacing: .2px; line-height: 1;
  white-space: nowrap; cursor: pointer; background: var(--accent); color: var(--accent-ink);
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s, opacity .18s;
}
button:hover, .btn:hover { filter: brightness(.96); }
button:active, .btn:active { transform: translateY(.5px); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; transform: none; }
button:disabled:hover { filter: none; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
button.ghost:hover { background: rgba(43,43,43,.07); filter: none; }
button.subtle { background: transparent; color: var(--muted); border-color: var(--line); }
button.subtle:hover { background: rgba(43,43,43,.04); filter: none; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.small { height: 30px; padding: 0 13px; font-size: 12.5px; border-width: 1.5px; }
/* Full-width primary call to action (Submit expense, Continue as a guest) — taller on purpose, and
   every .block is the same height as every other. */
button.block { width: 100%; height: 46px; font-size: 15px; }
/* Text-only button that flows inside a sentence — opts out of the box entirely. */
button.link {
  display: inline; height: auto; padding: 0; border: none; border-radius: 0; background: transparent;
  color: var(--accent-deep); font-size: inherit; font-weight: 700; text-decoration: underline;
  white-space: normal;
}
button.link:hover { filter: none; opacity: .75; }
/* Card-style download button — its own look, but the same height as any other in-table action. */
button.dl {
  height: 30px; padding: 0 14px; min-width: 120px; border-radius: 9px; border-width: 1px;
  background: #fffdf8; border-color: var(--line); color: var(--ink); font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
button.dl:hover { background: #f6ecd9; filter: none; }
button.dl svg { flex: 0 0 auto; }
/* Icon-only variant for wide tables — a square tap target, no 120px minimum. */
button.dl.dl-icon { min-width: 0; width: 30px; padding: 0; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: #f8f0df; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Right-aligned numbers get extra right padding so an Amount never crowds the next column */
td.num, th.num { text-align: right; white-space: nowrap; padding-right: 26px; }
/* Center a checkbox within its column */
td.center, th.center { text-align: center; }
td.center .chk { display: inline-block; }
/* Nudge a text column to the right for even spacing */
td.pad-l, th.pad-l { padding-left: 22px; }
.chk { width: 20px; height: 20px; cursor: pointer; accent-color: var(--accent-deep); }
/* Compact budget-account dropdown inside tables */
select.acct { height: 34px; padding: 4px 8px; font-size: 13px; width: auto; min-width: 96px; border-radius: 8px; }
/* Selected-row tint (bulk select) */
table tbody tr.sel-row, table tbody tr.sel-row:hover { background: #fbe7c3; }
table.resp tr.sel-row { background: #fbe7c3; }
.empty { color: var(--muted); font-size: 14px; padding: 14px 0; }
table tfoot td { border-top: 2px solid var(--line); border-bottom: none; }

/* Pills / status */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.pill.role { background: #ecdfc4; color: #4a4334; }
.pill.role.manager { background: var(--accent-deep); color: #fff; }
.pill.role.edit { background: #1296d8; color: #fff; }
.pill.role.view { background: #cdbf9f; color: #3a3424; }
.pill.dept-central { background: var(--accent-deep); color: #fff; }
.pill.dept-finance { background: #5b2d8e; color: #fff; }
.pill.sub-yes { background: var(--good-bg); color: var(--good); }
.pill.sub-no { background: var(--bad-bg); color: var(--bad); }
/* Check lifecycle stages */
.pill.stage-check { background: var(--warn-bg); color: var(--warn-ink); }
.pill.stage-done { background: var(--good-bg); color: var(--good); }
/* Flags on an expense row */
.pill.dup { background: var(--warn-bg); color: var(--warn-ink); text-transform: none; letter-spacing: 0; font-weight: 700; }
.pill.over { background: var(--bad-bg); color: var(--bad); text-transform: none; letter-spacing: 0; }
.muted { color: var(--muted); }

/* Loading skeleton — keeping-warm.md §5: never a bare "Loading…" string. */
.skeleton { position: relative; overflow: hidden; }
.sk-line { height: 12px; border-radius: 6px; background: var(--line); margin: 0 0 12px; opacity: .65; }
.sk-line.sk-title { height: 18px; width: 45%; margin-bottom: 18px; }
.sk-line.short { width: 60%; }
.skeleton::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  transform: translateX(-100%); animation: skSheen 1.4s infinite; }
@keyframes skSheen { to { transform: translateX(100%); } }
.sk-label { position: relative; z-index: 1; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ── Dialogs ────────────────────────────────────────────────────────────────
   A modal is a flex column — pinned header, scrolling body, always-visible message slot, pinned footer
   — so a form with twenty line items keeps its title and its Submit button on screen. */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: rgba(40,31,14,.48); backdrop-filter: blur(3px);
  animation: mFade .16s ease-out;
}
.modal {
  display: flex; flex-direction: column; overflow: hidden;
  width: 100%; max-width: 560px; max-height: min(88vh, 940px);   /* dvh override below */
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 20px 52px rgba(0,0,0,.24), 0 2px 6px rgba(0,0,0,.08);
  animation: mRise .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes mFade { from { opacity: 0; } }
@keyframes mRise { from { opacity: 0; transform: translateY(10px) scale(.99); } }
/* `vh` on mobile Safari measures the viewport with the URL bar HIDDEN, so a 94vh sheet is taller than
   what you can actually see and its header ends up above the fold. `dvh` tracks the visible viewport. */
@supports (height: 100dvh) {
  .modal { max-height: min(88dvh, 940px); }
}

.modal-head { display: flex; align-items: flex-start; gap: 14px; flex: 0 0 auto;
  padding: 17px 22px 15px; border-bottom: 1px solid var(--line); background: #fffdf8; }
.modal-title { min-width: 0; }
.modal h3 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: .3px; }
.modal-sub { margin: 3px 0 0; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.modal-x { margin-left: auto; flex: 0 0 auto; height: 32px; width: 32px; min-width: 32px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 14px; }
.modal-x:hover { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad); filter: none; }

.modal-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding: 16px 22px 18px; }
.modal-body > .field:last-child, .modal-body > .row:last-child { margin-bottom: 0; }
.modal-msg { flex: 0 0 auto; padding: 0 22px; }
.modal-msg:empty { display: none; }
.modal-msg .notice { margin: 0 0 12px; }
.modal-foot { display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  padding: 13px 22px; border-top: 1px solid var(--line); background: #fffdf8; }
/* Running total, pinned beside the submit button so it is never scrolled out of sight */
.foot-total { margin-right: auto; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); }
.foot-total strong { display: block; margin-top: 1px; font-size: 20px; font-weight: 800;
  letter-spacing: 0; text-transform: none; color: var(--ink); line-height: 1.05; }

.modal input, .modal select, .modal textarea { width: 100%; }
body.modal-open { overflow: hidden; }

/* Section divider inside a form: a small gold caption with a rule running to the right edge */
.form-sec { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; color: var(--accent-deep); }
.form-sec::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--line); }
.modal-body > .form-sec:first-child { margin-top: 0; }
/* Explanatory line under a single input */
.field-hint { margin: 5px 0 0; font-size: 12px; line-height: 1.35; color: var(--muted); }

/* Budget: big total-remaining card */
.budget-total { text-align: center; }
.budget-total .big { font-size: 36px; font-weight: 900; color: var(--accent-deep); margin: 6px 0; letter-spacing: .3px; }

/* Dashboard load progress bar (shows while all tabs warm in the background) */
.loadbar { margin: 0 0 16px; transition: opacity .4s ease; }
.loadbar.fading { opacity: 0; }
.loadbar-track { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.loadbar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .35s ease; }
/* Indeterminate: the dashboard arrives in ONE request, so there is no honest percentage to show — a
   travelling stripe says "working" without inventing progress. */
.loadbar-track.indet .loadbar-fill { width: 38%; transition: none; animation: loadSlide 1.15s infinite ease-in-out; }
@keyframes loadSlide { 0% { margin-left: -40%; } 100% { margin-left: 102%; } }
.loadbar-cap { font-size: 12.5px; color: var(--muted); margin-top: 7px; font-weight: 600; letter-spacing: .2px; }

/* Notices */
.notice { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin: 10px 0; }
.notice.err { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--good-bg); color: var(--good); }
.notice.info { background: var(--warn-bg); color: var(--warn-ink); }
.hidden { display: none !important; }
.spinner { color: var(--muted); font-size: 14px; padding: 16px 0; text-align: center; }
.btn-loading { position: relative; overflow: hidden; }
.btn-loading::after { content: ''; position: absolute; left: -35%; bottom: 0; height: 3px; width: 35%; background: currentColor; opacity: .85; border-radius: 2px; animation: btnBar 1.1s infinite ease-in-out; }
@keyframes btnBar { 0% { left: -35%; } 100% { left: 100%; } }

/* Auth screen */
.auth-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-toggle button { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0; text-transform: uppercase; letter-spacing: .5px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
#googleBtn { display: flex; justify-content: center; margin: 4px 0; }

/* Indeterminate progress bar (signing-in) */
.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 18px 0 12px; }
.progress .bar { height: 100%; width: 40%; background: var(--accent); border-radius: 6px; animation: indet 1.15s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -42%; } 100% { margin-left: 102%; } }

/* Responsive */
@media (max-width: 760px) {
  .wrap { padding: 16px 12px 48px; }
  .topbar { position: static; flex-wrap: wrap; gap: 10px; padding: 12px 14px; justify-content: center; text-align: center; }
  .topbar .brand-left { width: 100%; justify-content: center; }
  .topbar .logo { height: 38px; }
  .topbar .brand-center { position: static; transform: none; left: auto; top: auto; width: 100%; pointer-events: auto; }
  .topbar .who { width: 100%; justify-content: center; flex-wrap: wrap; gap: 8px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin: 14px 0; padding-bottom: 6px; gap: 6px; }
  .tabs::-webkit-scrollbar { height: 0; }
  .tab { flex: 0 0 auto; height: 34px; padding: 0 14px; font-size: 13px; }
  /* Buttons shrink together so a row stays uniform on a narrow screen */
  button, .btn { height: 36px; padding: 0 15px; font-size: 13.5px; }
  button.small { height: 30px; padding: 0 12px; font-size: 12.5px; }
  button.block { height: 46px; font-size: 15px; }
  .card { padding: 16px; border-radius: 12px; }
  /* 16px inputs stop iOS Safari from zooming in on focus */
  input, select, textarea { font-size: 16px; }
  .table-scroll table { min-width: 560px; }   /* tablets/large phones still scroll horizontally */
  .row { gap: 8px; }
  /* Fields stack one per line — !important so inline flex-basis (e.g. the Admins form's
     Department/Access fields) is overridden and they stack too. */
  .field { flex-basis: 100% !important; }
  .center-narrow { margin: 20px auto; }   /* tighter than the desktop 48px so stacked cards sit closer */
}

/* Phones: turn data tables into stacked label/value cards (no horizontal scrolling). */
@media (max-width: 600px) {
  table.resp { min-width: 0; }
  table.resp thead { position: absolute; left: -9999px; }   /* visually hide the header row */
  table.resp tr { display: block; border: 1px solid var(--line); border-radius: 12px; background: #fffdf8; margin-bottom: 10px; padding: 4px 2px; }
  table.resp td { display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; border: none; border-bottom: 1px solid var(--line); padding: 9px 14px; overflow-wrap: anywhere; }
  table.resp tr td:last-child { border-bottom: none; }
  table.resp td::before { content: attr(data-label); font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 10.5px; letter-spacing: .05em; text-align: left; flex: 0 0 auto; }
  table.resp td:empty, table.resp td[data-label='']::before { display: none; }
  table.resp td.num { text-align: right; }
  /* `table.resp td` above out-specifies `table tfoot td`, which would silently drop the Budget totals
     row's divider and make it read as just another row. */
  table.resp tfoot td { border-top: 2px solid var(--line); font-weight: 800; }
  tbody tr:hover { background: #fffdf8; }       /* no hover highlight needed on touch */

  /* Two account dropdowns share the Department cell, and their 96px minimum plus the label overflows a
     360px screen — which brings back the horizontal scrolling this whole block exists to remove. Let the
     cell wrap and the selects take the full width, exactly as the submitter's line-item selects do. */
  table.resp td[data-label="Department"] { flex-wrap: wrap; justify-content: flex-end; }
  select.acct { min-width: 0; flex: 1 1 100%; height: 42px; font-size: 16px; }

  /* Bulk bars get the same full-width treatment as every other primary action on a phone */
  .bulk-bar { flex-wrap: wrap; }
  .bulk-bar .sel-all { flex: 1 1 100%; min-height: 34px; }
  .bulk-bar button { flex: 1 1 130px; }

  /* Submitter line items: everything stacks so a phone can still allocate each line */
  .li-row .li-desc { flex: 1 1 100%; }
  .amt-wrap { flex: 1 1 100px; }
  .li-row .li-dept, .li-row .li-sub { flex: 1 1 100%; }
  .li-row .li-name { flex: 1 1 100%; }
  .li-row .li-file { flex: 1 1 auto; }
  /* Check entry cells get full width in the stacked table. 16px keeps iOS from zooming the page on
     focus — the small font here was the one place that still triggered it. */
  input.ck-num, select.ck-gl { max-width: none; height: 42px; font-size: 16px; }
  /* Comfortable tap targets for the in-table icon buttons */
  button.dl.dl-icon { width: 36px; height: 36px; }
  .chk { width: 22px; height: 22px; }

  /* Budget per-department detail row spans full width as a block */
  table.resp tr.acct-detail td { display: block; text-align: left; }
  .acct-detail-wrap { padding-left: 4px; }
  .acct-erow { justify-content: space-between; }
  /* Stacked cards already read as a hierarchy — drop the desktop indent, keep sub rows tinted */
  .bd-indent { padding-left: 0; }
  table.bd-table tr.bd-sub { background: #fdfaf3; margin-left: 12px; }

  /* Budget create/edit form: stacked labelled rows with comfortable inputs on phones */
  #bTable td input { flex: 1 1 130px; width: auto; min-width: 0; text-align: right; }
  #bTable td .bDept, #bTable td .bSub, #bTable td .bOwner { text-align: left; }
  #bTable td[data-label=''] { justify-content: flex-end; }

  /* Admins tab groups */
  .ad-body { padding: 4px 8px 10px; }
  .ad-add { margin-left: 0; width: 100%; }

  /* Full-width primary actions on phones for comfortable tapping */
  .new-exp-btn { width: 100%; }

  /* Dialogs become a bottom sheet: full width, rounded top corners, rising from the bottom edge. The
     header and footer stay pinned, so Submit is always reachable without scrolling a long form. */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; max-height: 92vh; border: none; border-radius: 18px 18px 0 0;
    animation: mSheet .22s cubic-bezier(.2,.8,.3,1); }
  @supports (height: 100dvh) {
    /* leave a sliver of backdrop above the sheet so the header can never sit under the URL bar.
       --kb is the software keyboard's height, published by app.js from visualViewport: dvh tracks the
       URL bar but NOT the keyboard, so without it the pinned footer (Submit + running total) is laid
       out underneath the keyboard with no way to scroll to it. */
    .modal { max-height: calc(100dvh - 28px - var(--kb, 0px)); }
  }
  @keyframes mSheet { from { transform: translateY(16px); opacity: .6; } }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-body { padding: 14px 16px 16px; }
  .modal-msg { padding: 0 16px; }
  /* Total on its own line above full-width action buttons */
  .modal-foot { flex-wrap: wrap; padding-bottom: max(13px, env(safe-area-inset-bottom)); }
  .foot-total { flex: 1 1 100%; margin-right: 0; }
  .modal-foot button { flex: 1 1 130px; }
}
