/* Breadbox Approvals, "Ocean slate" (DESIGN.md). Tokens first; dark is the primary scene. */
@font-face {
  font-family: "Space Grotesk";
  src: url("vendor/fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 300 700; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("vendor/fonts/space-grotesk-latin-ext.woff2") format("woff2");
  font-weight: 300 700; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;
  --bg: #F4F1EC; --surface: #FFFFFF; --surface-2: #F8F5F1; --sunken: #EFEAE3;
  --line: #E4DDD3; --line-strong: #D3C9BC;
  --text: #1B2228; --muted: #5B6770;
  --accent: #F5A052; --accent-strong: #EE8F3B; --on-accent: #1B2228; --accent-ink: #9A5312;
  --accent-soft: #FCEBDB; --row-on: #FDF2E7; --row-hover: #FAF7F3;
  --danger: #B42318; --danger-soft: #FCEAE8; --ok: #17704A; --ok-soft: #E2F3EA; --warn: #855300; --warn-soft: #FBEFD6;
  --logo-ink: #1B2228; --logo-shadow: #A08E78;
  --shadow-1: 0 1px 2px rgba(27, 34, 40, .07), 0 1px 1px rgba(27, 34, 40, .04);
  --shadow-2: 0 12px 32px -12px rgba(27, 34, 40, .28), 0 2px 8px rgba(27, 34, 40, .08);
  --r-s: 10px; --r: 12px; --r-l: 16px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Space Grotesk", var(--font-ui);
  --ease: cubic-bezier(.16, 1, .3, 1);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181D; --surface: #1B2228; --surface-2: #202A31; --sunken: #161D22;
    --line: #2B3740; --line-strong: #3B4954;
    --text: #EEF1F3; --muted: #A3B0BA;
    --accent: #F5A052; --accent-strong: #F8B474; --on-accent: #1B2228; --accent-ink: #F5A052;
    --accent-soft: rgba(245, 160, 82, .15); --row-on: rgba(245, 160, 82, .09); --row-hover: #1F282E;
    --danger: #FF8C7A; --danger-soft: rgba(255, 140, 122, .13); --ok: #6DD3A0; --ok-soft: rgba(109, 211, 160, .12);
    --warn: #F3C46E; --warn-soft: rgba(243, 196, 110, .12);
    --logo-ink: #EEF1F3; --logo-shadow: #8C7B66;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 16px 40px -12px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .35);
  }
}

/* ---------- base and browser surfaces ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; caret-color: var(--accent); scrollbar-color: var(--line-strong) transparent; }
::selection { background: color-mix(in srgb, var(--accent) 38%, transparent); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
h2, h3 { text-wrap: balance; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 9px 12px; max-width: 100%; transition: border-color .15s, background-color .15s; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- buttons ---------- */
button { font: 600 14px/1.2 var(--font-ui); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease), box-shadow .15s; }
button:hover { background: var(--surface-2); border-color: var(--line-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(27, 34, 40, .18); }
button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: transparent; }
button.danger:hover { background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--sunken); border-color: transparent; }
button.icon-btn { width: 40px; padding: 0; }
button.mini { min-height: 30px; padding: 0 10px; font-size: 13px; color: var(--accent-ink); }
button.mini .i { width: 15px; height: 15px; }
button.big { width: 100%; min-height: 48px; font-size: 16px; border-radius: 12px; }
.chip { min-height: 34px; padding: 0 14px; border-radius: 999px; font-size: 13px; background: transparent; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.on:hover { background: var(--text); }

/* ---------- header ---------- */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 8px 20px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); }
/* Brand signature: an orange segment under the logo, on the header's hairline. */
.bar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, var(--accent) 0 148px, var(--line) 148px); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.logo { height: 30px; width: auto; display: block; }
.logo .lg-ink { fill: var(--logo-ink); } .logo .lg-a { fill: #F79D59; } .logo .lg-b { fill: var(--logo-shadow); } .logo .lg-c { fill: #F5A052; }
.brand-app { font: 500 15px/1 var(--font-brand); color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line-strong); letter-spacing: .01em; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--muted); font-size: 13px; }
.updated { white-space: nowrap; font-variant-numeric: tabular-nums; }
.me { position: relative; }
.avatar { width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--surface); font: 600 13px/1 var(--font-brand); letter-spacing: .02em; color: var(--text); }
.avatar[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 248px; padding: 6px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); display: grid; gap: 2px;
  transform-origin: top right; animation: pop .16s var(--ease); }
.menu-head { display: grid; gap: 2px; padding: 10px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head #user { color: var(--text); font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.menu-sub { font-size: 12px; color: var(--muted); }
.menu button { justify-content: flex-start; border-color: transparent; background: transparent; font-weight: 500; }
.menu button:hover { background: var(--sunken); }
.menu .toggle-item { justify-content: space-between; }
.switch { position: relative; width: 36px; height: 22px; flex: none; border-radius: 999px; background: var(--line-strong); transition: background-color .18s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .18s var(--ease); }
[aria-checked="true"] > .switch { background: var(--accent); }
[aria-checked="true"] > .switch::after { transform: translateX(14px); }
@keyframes pop { from { transform: scale(.97) translateY(-4px); opacity: 0; } }

.viewas { display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 14px; color: var(--text);
  background: var(--warn-soft); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); }
.viewas .i { color: var(--warn); }
.viewas span { flex: 1; min-width: 0; }

/* ---------- sign in ---------- */
.login { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 36px 28px 28px; box-shadow: var(--shadow-2); }
.login-logo { display: block; height: 45px; width: auto; margin: 0 0 28px; }
.login-card h2 { margin: 0 0 8px; font: 600 28px/1.15 var(--font-brand); letter-spacing: -.02em; }
.login-lead { margin: 0 0 20px; color: var(--muted); max-width: 34ch; }
.login-msg { min-height: 1.2em; margin: 0 0 8px; color: var(--danger); font-size: 14px; }
.login-msg:empty { display: none; }
.login-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.ms { width: 18px; height: 18px; }

/* ---------- app layout ---------- */
main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; padding: 20px; align-items: start;
  width: 100%; max-width: 1680px; margin: 0 auto; }
.list, .detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; min-width: 0; box-shadow: var(--shadow-1); }
main:has(> #detail[hidden]) { grid-template-columns: minmax(0, 1fr); }
/* With the detail open beside it, the list keeps what decides: type, vendor, amount, due. */
@media (min-width: 901px) {
  main:has(> #detail:not([hidden])) :is(th, td).c-date { display: none; }
}
.detail { position: sticky; top: 80px; max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); overflow: auto; overscroll-behavior: contain; }

/* tabs: a segmented control */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 13px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; min-height: 38px; gap: 8px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font: 600 14px/1 var(--font-brand); padding: 0 14px; }
.tab:hover { background: transparent; color: var(--text); }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.count { min-width: 22px; padding: 3px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink);
  font: 600 12px/1 var(--font-brand); font-variant-numeric: tabular-nums; }
.count:empty { display: none; }

/* summary: one quiet line of counts */
.summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 16px 4px 0; color: var(--muted); font-size: 14px; }
.summary:empty { display: none; }
.summary .dot { color: var(--line-strong); }
.stat b { font: 600 14px/1.2 var(--font-brand); color: var(--text); font-variant-numeric: tabular-nums; }
.stat.warn, .stat.warn b { color: var(--danger); }

/* filters and tools */
.list-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.list-head:not(:has(> :not([hidden]))) { display: none; }
.filters { display: flex; gap: 6px; }
.tools { display: flex; flex: 1 1 360px; gap: 8px; min-width: 0; justify-content: flex-end; }
.search { position: relative; flex: 1 1 200px; display: block; min-width: 0; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 40px; padding-left: 38px; }
.select { position: relative; display: block; flex: 0 1 200px; min-width: 0; }
.select select { width: 100%; min-height: 40px; appearance: none; -webkit-appearance: none; padding-right: 36px; text-overflow: ellipsis; }
.select .i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#refresh.busy .i { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bulk { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px;
  padding: 8px 8px 8px 16px; border-radius: var(--r); background: var(--text); color: var(--bg); box-shadow: var(--shadow-2); font-size: 14px; }
.bulk span { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.bulk .ghost { color: var(--bg); }
.bulk .ghost:hover { background: color-mix(in srgb, var(--bg) 12%, transparent); }
.status { color: var(--muted); font-size: 13px; min-height: 1.2em; margin: 10px 2px; }
.status:empty { margin: 4px 0; }

/* ---------- the list ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
th.sortable { cursor: pointer; transition: color .15s; }
th.sortable:hover, th.sorted { color: var(--text); }
th.sorted::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
th.sorted.asc::after { transform: translateY(1px) rotate(-135deg); }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
tbody tr:last-child td { border-bottom: 0; }
td.check, th.check { width: 30px; padding-right: 0; }
td.check { padding-top: 13px; }
tbody tr.row { cursor: pointer; transition: background-color .15s; }
tbody tr.row:hover { background: var(--row-hover); }
tbody tr.row.on { background: var(--row-on); }
tbody tr.row:focus-visible { outline-offset: -2px; }
.c-vendor { font-weight: 600; }
.c-amount { font: 600 14.5px/1.4 var(--font-brand); width: 1%; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub2 { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 3px; }
.c-vendor .sub2 { max-width: 62ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-date { color: var(--muted); white-space: nowrap; width: 1%; }
.c-due { white-space: nowrap; width: 1%; }
.c-voyage { color: var(--muted); font-size: 13.5px; white-space: nowrap; width: 1%; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }
.quiet { color: var(--muted); font-size: 13px; }
.m-only { display: none; }
tbody tr.row td { vertical-align: middle; }

/* empty and loading */
.empty-row td { padding: 44px 16px; text-align: center; border: 0; }
.empty { display: grid; justify-items: center; gap: 6px; color: var(--muted); }
.empty .i { width: 30px; height: 30px; stroke-width: 1.5; color: var(--accent); margin-bottom: 6px; }
.empty b { font: 600 17px/1.3 var(--font-brand); color: var(--text); }
.empty span { max-width: 40ch; font-size: 14px; }
.skel-row td { border-bottom: 1px solid var(--line); }
.skel { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--sunken) 0%, var(--surface-2) 50%, var(--sunken) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.skel.w1 { width: 55%; height: 14px; margin-bottom: 8px; } .skel.w2 { width: 35%; } .skel.w3 { width: 70px; margin-left: auto; height: 14px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* tags: soft fills, state only */
.tag { display: inline-flex; align-items: center; font: 600 11.5px/1 var(--font-ui); padding: 5px 8px; border-radius: 999px;
  background: var(--sunken); color: var(--muted); white-space: nowrap; letter-spacing: .01em; }
.tag.hold, .tag.overdue { background: var(--danger-soft); color: var(--danger); }
.tag.soon, .tag.open { background: var(--warn-soft); color: var(--warn); }
.tag.paid { background: var(--ok-soft); color: var(--ok); }

/* ---------- detail ---------- */
.detail-top { display: flex; align-items: center; justify-content: space-between; margin: -6px -6px 6px; }
.back { display: none; padding-left: 6px; }
.detail-top .nav { display: flex; gap: 2px; margin-left: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.detail-title { min-width: 0; }
.detail h2 { margin: 0; font: 600 24px/1.2 var(--font-brand); letter-spacing: -.02em; overflow-wrap: anywhere; }
.d-sub { margin: 6px 0 0; color: var(--text); font-size: 14px; }
.meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.amount-wrap { text-align: right; display: grid; justify-items: end; gap: 8px; }
.amount { font: 600 26px/1.1 var(--font-brand); letter-spacing: -.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badges:empty { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; align-items: center; }
.actions #a-approve { order: -1; min-width: 132px; }
.actions .secondary { display: contents; }
.more-btn { display: none; }
/* Desktop, detail next to the list: when the panel is narrow the secondary actions keep one row as icon buttons. */
.detail { container: detail / inline-size; }
@media (min-width: 901px) {
  @container detail (max-width: 620px) {
    .actions .secondary button { width: 40px; padding: 0; }
    .actions .secondary button span { display: none; }
  }
}
/* The facts always keep 18px from the head, with or without the action row above them. */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 9px 20px; font-size: 14px; margin: 18px 0 0; padding: 16px 18px;
  background: var(--sunken); border-radius: var(--r); line-height: 1.4; }
.facts:empty { display: none; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sub { display: flex; align-items: center; gap: 8px; font: 600 15px/1.3 var(--font-brand); margin: 26px 0 10px; }
.sub .mini { margin-left: auto; }
.lines td { font-size: 13px; padding: 9px 8px; }
.lines th { padding: 6px 8px; }
.docs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; color: var(--muted); font-size: 14px; }
.docs .chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.docs > button.ghost { min-height: 34px; padding: 0 12px; font-size: 13px; border: 1px solid var(--line); }
.doc-label { font-size: 14px; font-weight: 600; margin-right: auto; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.pdf { width: 100%; max-height: 78vh; overflow: auto; border-radius: var(--r); background: var(--sunken); padding: 10px; color: var(--muted); font-size: 14px; }
.pdf canvas { display: block; margin: 0 auto 10px; background: #fff; border-radius: 4px; box-shadow: 0 2px 10px rgba(0, 0, 0, .18), 0 1px 2px rgba(0, 0, 0, .1); }
.pdf-bar { display: flex; gap: 2px; align-items: center; margin-bottom: 6px; }
.pdf-bar .meta { margin: 0 0 0 8px; font-variant-numeric: tabular-nums; }

.trail { list-style: none; margin: 0; padding: 0 0 0 4px; }
.trail li { position: relative; padding: 0 0 16px 22px; font-size: 13px; border-left: 1.5px solid var(--line); margin-left: 5px; }
.trail li:last-child { border-left-color: transparent; padding-bottom: 0; }
.trail li::before { content: ""; position: absolute; left: -6.5px; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong); }
.trail li[data-status="Open"]::before { border-color: var(--accent); background: var(--accent); }
.trail li[data-status="Approved"]::before { border-color: var(--ok); background: var(--ok); }
.trail li[data-status="Rejected"]::before { border-color: var(--danger); background: var(--danger); }
.trail li.comment::before { border-color: var(--muted); }
.trail .when { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.trail .what { display: block; font-weight: 600; margin-top: 1px; }
.trail .note { display: block; margin-top: 3px; overflow-wrap: anywhere; color: var(--muted); }

/* line editor */
.line-editor { display: grid; gap: 10px; }
.line-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); background: var(--surface-2); }
.line-card label { min-width: 0; font-size: 12px; }
.line-card input { width: 100%; min-width: 0; padding: 8px 10px; }
.line-card input.changed { border-color: var(--accent); background: var(--accent-soft); }
.line-card .wide { grid-column: 1 / -1; }
.line-card .line-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.line-card .line-head b { flex: 1; font-family: var(--font-brand); font-weight: 600; }
.line-card .line-head .danger { border-color: transparent; }
.line-editor .editor-bar { display: flex; gap: 8px; justify-content: flex-end; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); width: min(460px, 94vw);
  padding: 22px; box-shadow: var(--shadow-2); }
dialog[open] { animation: pop .18s var(--ease); }
dialog::backdrop { background: rgba(10, 14, 18, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 14px; }
dialog h3 { margin: 0; font: 600 19px/1.25 var(--font-brand); letter-spacing: -.01em; }
dialog .meta { margin-top: -8px; }
dialog textarea { resize: vertical; min-height: 84px; }
.people { display: grid; gap: 2px; max-height: min(46vh, 360px); overflow: auto; overscroll-behavior: contain; margin-top: 8px;
  padding: 4px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.person { justify-content: flex-start; gap: 12px; min-height: 48px; padding: 6px 10px; border-color: transparent; background: transparent;
  font-weight: 500; text-align: left; }
.person:hover { background: var(--sunken); border-color: transparent; }
.person.on { background: var(--accent-soft); }
.person .pname { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .pid { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.avatar.sm { width: 30px; height: 30px; min-height: 30px; flex: none; display: inline-grid; place-items: center; font-size: 11px; border-color: var(--line); }
.people-none { padding: 10px; margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-actions .primary { min-width: 120px; }

/* ---------- tablets and phones: one column, the item opens as a sheet ---------- */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 12px; }
  .detail { position: fixed; inset: 0; z-index: 40; max-height: none; border-radius: 0; border: 0; box-shadow: none;
    padding: 0 16px calc(92px + env(safe-area-inset-bottom)); padding-top: env(safe-area-inset-top); animation: sheet .24s var(--ease); }
  .detail-top { position: sticky; top: 0; z-index: 2; margin: 0 -16px 8px; padding: 8px 10px;
    background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line); }
  .back { display: inline-flex; }
  body.detail-open { overflow: hidden; }
  .pdf { max-height: none; }
  /* Approve and Reject under the thumb; the rest behind More. */
  .actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; margin: 0; flex-wrap: nowrap;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); }
  .actions button { min-height: 48px; font-size: 15px; }
  .actions #a-approve { order: 2; flex: 1 1 auto; }
  .actions #a-reject { order: 1; }
  .actions .more-btn { display: inline-flex; order: 3; width: 48px; border: 1px solid var(--line); }
  .actions .secondary { display: none; }
  .actions.more-open .secondary { display: grid; position: absolute; right: 16px; bottom: calc(100% + 8px); min-width: 220px; gap: 2px; padding: 6px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-2); animation: pop .16s var(--ease); }
  .actions.more-open .secondary button { justify-content: flex-start; border-color: transparent; background: transparent; min-height: 44px; }
  .actions.more-open .secondary button:hover { background: var(--sunken); }
  .actions.more-open .more-btn { border-color: var(--accent); }
}
@keyframes sheet { from { transform: translateY(28px); opacity: .5; } }

/* ---------- phones: the list becomes a grouped list on the page ---------- */
@media (max-width: 640px) {
  :root { font-size: 15px; }
  .bar { padding-left: 16px; padding-right: 12px; min-height: 56px; }
  .bar::after { background: linear-gradient(90deg, var(--accent) 0 122px, var(--line) 122px); }
  .logo { height: 26px; }
  .brand { gap: 10px; }
  .brand-app { font-size: 14px; padding-left: 10px; }
  .updated { display: none; }
  .viewas { padding: 10px 16px; font-size: 13px; }
  main { padding: 12px 12px 0; }
  .list { background: transparent; border: 0; box-shadow: none; padding: 4px 0 0; }
  .tab { font-size: 13px; padding: 0 12px; }
  .summary { margin: 14px 4px 12px; }
  .list-head { gap: 10px; }
  .filters { width: 100%; }
  .tools { flex: 1 1 100%; flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: 1; }
  .select { flex: 1 1 auto; order: 2; }
  #refresh { order: 3; border: 1px solid var(--line); }
  #export { order: 4; }
  .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); margin-bottom: 8px; }
  table.list-table thead { display: none; }
  table.list-table, table.list-table tbody { display: block; width: 100%; }
  /* Two lines, two columns: who and entity on the left, amount and state on the right, same edges in every row. */
  table.list-table tr.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "vendor amount" "vendor due";
    column-gap: 16px; row-gap: 4px; align-items: start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  table.list-table tr.row:has(> td.check) { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "check vendor amount" "check vendor due"; column-gap: 12px; }
  table.list-table tr.row:last-child { border-bottom: 0; }
  table.list-table td { display: block; border: 0; padding: 0; width: auto; }
  table.list-table td.check { grid-area: check; padding: 1px 2px 0 0; }
  table.list-table td.c-vendor { grid-area: vendor; min-width: 0; font-size: 15px; line-height: 1.35; }
  table.list-table td.c-vendor .sub2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: none; }
  table.list-table td.c-amount { grid-area: amount; font-size: 15px; line-height: 1.35; }
  table.list-table td.c-due { grid-area: due; justify-self: end; max-width: 44vw; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
  table.list-table td.c-due .quiet { font-size: 13px; }
  table.list-table td.c-date, table.list-table td.c-voyage { display: none; }
  .m-only { display: inline; }
  table.list-table tr.empty-row, table.list-table tr.skel-row { display: block; }
  table.list-table tr.empty-row td { display: block; padding: 40px 24px 44px; }
  table.list-table tr.skel-row td { display: block; padding: 16px; border-bottom: 1px solid var(--line); }
  .empty span { line-height: 1.5; }
  #export span { display: none; }
  #export { width: 40px; padding: 0; order: 4; border: 1px solid var(--line); }
  .detail-head { flex-direction: column; gap: 10px; }
  .amount-wrap { text-align: left; justify-items: start; }
  .badges { justify-content: flex-start; }
  .detail h2 { font-size: 22px; }
  .amount { font-size: 28px; }
  .facts { grid-template-columns: 96px minmax(0, 1fr); gap: 10px 14px; padding: 14px 16px; font-size: 14px; margin-top: 16px; }
  .facts dt { font-size: 13px; line-height: 1.45; }
  .doc-label { flex: 1 1 100%; }
  .docs > button.ghost { flex: 1 1 0; }
  .sub { margin-top: 28px; }
  .detail-title .meta { margin-top: 6px; }
  .amount-wrap { gap: 10px; }
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
  dialog[open] { animation: sheet .24s var(--ease); }
  .dlg-actions button { flex: 1; min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
