/* ============================================================ design tokens */
:root {
  --bg:        #f2f3f7;
  --surface:   #ffffff;
  --surface-2: #f3f4f8;
  --surface-3: #e7e9ef;
  --border:    #e5e7ee;
  --border-strong: #cfd4de;
  --text:      #0f1420;
  --text-2:    #4a5364;
  --muted:     #7b8493;
  --accent:    #3b5bdb;
  --accent-hover: #2f4cc4;
  --accent-soft: #e9edfc;
  --accent-ink: #ffffff;
  --warn:      #a86500;
  --warn-bg:   #fff4dd;
  --warn-border: #f3d9a4;
  --ok:        #147a48;
  --ok-bg:     #e4f5ec;
  --danger:    #c62f27;
  --danger-bg: #fdecea;

  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --sh-1: 0 1px 2px rgba(16,24,40,.04), 0 1px 1px rgba(16,24,40,.03);
  --sh-2: 0 4px 14px rgba(16,24,40,.08);
  --sh-3: 0 -2px 12px rgba(16,24,40,.06), 0 24px 56px rgba(16,24,40,.22);
  --sh-fab: 0 8px 20px rgba(59,91,219,.36), 0 2px 4px rgba(16,24,40,.14);
  --nav-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8493' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0c0f14;
    --surface:   #151920;
    --surface-2: #1d222b;
    --surface-3: #262c37;
    --border:    #262d38;
    --border-strong: #38414e;
    --text:      #eceff4;
    --text-2:    #b4bcc8;
    --muted:     #8b95a3;
    --accent:    #7391ff;
    --accent-hover: #8ea6ff;
    --accent-soft: #1d2540;
    --accent-ink: #0a0e17;
    --warn:      #ecb964;
    --warn-bg:   #2a2313;
    --warn-border: #4d4020;
    --ok:        #55cf92;
    --ok-bg:     #10291d;
    --danger:    #ff7f77;
    --danger-bg: #2d1614;
    --sh-1: 0 1px 2px rgba(0,0,0,.35);
    --sh-2: 0 4px 14px rgba(0,0,0,.4);
    --sh-3: 0 -2px 12px rgba(0,0,0,.3), 0 24px 56px rgba(0,0,0,.55);
    --sh-fab: 0 8px 20px rgba(115,145,255,.3), 0 2px 4px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

/* The browser's own `[hidden] { display: none }` is a user-agent rule, so ANY
   author rule that sets `display` beats it. A class like `.strip { display:flex }`
   or `.row { display:flex }` then leaves `el.hidden = true` doing nothing, and
   an element that should not exist stays on the page -- as an empty, clickable
   card. Stating it here, with !important, makes `hidden` mean hidden. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1,h2,h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--mono); }
svg { flex: none; }

/* ================================================================== buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .06s, opacity .13s;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: transparent; background: var(--danger-bg); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, var(--danger-bg)); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ================================================================ app shell */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 650;
  letter-spacing: -.015em; margin-right: auto; min-width: 0; }
.brand .mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand .mark svg { width: 17px; height: 17px; }
.brand .org { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* On a phone the org name is what matters; the product name lives on the sign-in page. */
.brand .app { display: none; }
@media (min-width: 700px) {
  .brand .app { display: inline; }
  .brand .org { color: var(--muted); font-weight: 500; }
  .brand .org::before { content: "/"; margin: 0 7px; color: var(--border-strong); }
}

.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid transparent;
}
.avatar:hover { border-color: var(--accent); }

main { max-width: 760px; margin: 0 auto; padding: 4px 16px 48px; }
@media (max-width: 699px) {
  main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 92px); }
}

/* --- page title + actions --------------------------------------------------- */
.page { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 6px 0 14px; min-height: 40px; }
.page h1 { font-size: 27px; font-weight: 720; letter-spacing: -.028em; line-height: 1.1; }
.page-actions { display: flex; gap: 2px; flex: none; }
.page-actions .btn { min-height: 44px; padding: 0 11px; font-size: 13.5px; }

/* --- primary navigation ----------------------------------------------------- */
/* A tab bar within thumb reach on a phone; a segmented row under the header on
   a desktop. Same markup, same handlers, only the placement changes. */
.viewnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.viewnav button {
  position: relative; flex: 1 1 0; min-width: 0; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 4px 2px 2px; border: 0; background: none; cursor: pointer; border-radius: 12px;
  color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: 0;
  white-space: nowrap;
}
.viewnav button svg { width: 24px; height: 24px; }
.viewnav button[aria-selected="true"] { color: var(--accent); }
.viewnav button:active { background: var(--surface-2); }
.viewnav .count {
  position: absolute; top: 3px; left: calc(50% + 5px);
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  line-height: 17px; text-align: center; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}
.viewnav .count:empty { display: none; }

@media (min-width: 700px) {
  .viewnav {
    position: static; display: flex; gap: 2px; padding: 3px; margin: 8px 0 18px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .viewnav button { flex-direction: row; gap: 7px; min-height: 40px; padding: 0 14px;
    border-radius: 9px; font-size: 14px; color: var(--text-2); }
  .viewnav button svg { width: 18px; height: 18px; }
  .viewnav button[aria-selected="true"] { background: var(--surface); color: var(--text);
    box-shadow: var(--sh-1); }
  .viewnav .count { position: static; box-shadow: none; margin-left: 2px;
    background: var(--warn-bg); color: var(--warn); }
}

/* ==================================================================== stats */
/* One card, three figures, hairlines between: reads as a single summary line
   rather than three competing tiles. */
.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 14px; box-shadow: var(--sh-1);
  overflow: hidden;
}
.stat { padding: 12px 13px 11px; min-width: 0; }
@media (max-width: 560px) { .stat { padding: 11px 10px 10px; } }
.stat + .stat { border-left: 1px solid var(--border); }
.stat b { display: block; font-size: 20px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500;
  margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.attention b { color: var(--warn); }

/* =================================================================== upload */
/* The primary action of each view. It floats above the list on a phone so the
   camera is one tap away however far down you have scrolled; on a desktop it is
   an ordinary block button at the top of the view. */
.capture {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; min-height: 48px; padding: 0 18px; margin-bottom: 14px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 12px; box-shadow: var(--sh-1);
  font-size: 15px; font-weight: 650; cursor: pointer; letter-spacing: -.005em;
  transition: background .13s, transform .06s, box-shadow .13s;
}
.capture:hover { background: var(--accent-hover); }
.capture:active { transform: scale(.985); }
.capture:disabled { opacity: .6; cursor: progress; }
.capture svg { width: 20px; height: 20px; }
@media (max-width: 699px) {
  .capture {
    position: fixed; right: 16px; z-index: 25;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
    width: auto; height: 52px; padding: 0 20px 0 17px; margin: 0;
    border-radius: 999px; box-shadow: var(--sh-fab);
  }
  .capture:active { transform: scale(.96); }
}

.row { display: flex; gap: 8px; margin-bottom: 16px; }
.row > * { flex: 1; }

.dropzone.dragging {
  outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: var(--r-lg);
}

/* ================================================================= messages */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px;
  line-height: 1.45;
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn);
}
.banner.error { background: var(--danger-bg); color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.banner.ok { background: var(--ok-bg); color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.banner b { font-weight: 650; }

.progress {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 14px; box-shadow: var(--sh-1);
}
.spinner {
  width: 17px; height: 17px; flex: none; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner.sm { width: 11px; height: 11px; border-width: 1.5px; }

.joblist { display: flex; flex-direction: column; gap: 2px;
  max-height: 210px; overflow-y: auto; }
.job { display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  padding: 3px 0; min-width: 0; }
.job .mark { width: 14px; flex: none; text-align: center; color: var(--muted); }
.job .name { flex: none; max-width: 40%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.job .note { flex: 1; min-width: 0; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job.done .mark      { color: var(--ok); }
.job.duplicate .mark { color: var(--muted); }
.job.failed .mark    { color: var(--danger); }
.job.failed .note    { color: var(--danger); }
.job.queued          { opacity: .5; }

/* ================================================================== filters */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.search { flex: 1; position: relative; min-width: 0; }
.search input {
  width: 100%; height: 44px; padding: 0 12px 0 38px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  -webkit-appearance: none; appearance: none; font-size: 15px;
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none; }

.toolbar select, .toolbar .select {
  flex: none; max-width: 44%; height: 44px; padding: 0 30px 0 13px; border-radius: 12px;
  background: var(--surface) var(--chev) no-repeat right 9px center / 16px;
  border: 1px solid var(--border); color: var(--text);
  font-size: 13.5px; font-weight: 550; -webkit-appearance: none; appearance: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.segmented {
  display: flex; padding: 3px; gap: 2px; background: var(--surface-3);
  border-radius: 12px; margin-bottom: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 1 0 auto; min-height: 38px; padding: 0 13px; border: none; background: none;
  cursor: pointer; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  color: var(--text-2); white-space: nowrap;
}
.segmented button[aria-selected="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--sh-1);
}
.segmented .count { opacity: .6; font-variant-numeric: tabular-nums; margin-left: 2px; }

/* ==================================================================== cards */
/* Rows live in one grouped container with hairlines between them, rather than a
   stack of separate boxes: denser on a phone, and the eye reads it as a list. */
.list {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-1); overflow: hidden;
}
.list:empty { display: none; }
.list > .quiet, .list > .empty { margin: 0; }
.list > .quiet { padding: 14px 16px; }
.card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: none; border: none; border-radius: 0;
  color: inherit; cursor: pointer; font: inherit;
  transition: background .12s;
  position: relative;
}
.card + .card, .card + .quiet { border-top: 1px solid var(--border); }
.card:hover { background: var(--surface-2); }
.card:active { background: var(--surface-3); }
.card.flagged::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--warn);
}

.card .icon {
  width: 40px; height: 40px; flex: none; border-radius: 11px;
  display: grid; place-items: center; font-size: 13.5px; font-weight: 700;
  letter-spacing: .01em;
  background: hsl(var(--hue, 226) 60% 93%); color: hsl(var(--hue, 226) 50% 38%);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .card .icon { background: hsl(var(--hue, 226) 32% 22%); color: hsl(var(--hue, 226) 80% 80%); }
}
.card .icon img { width: 100%; height: 100%; object-fit: cover; }

.card .who { flex: 1; min-width: 0; }
.card .who b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .who small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .amt { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.card .amt b { font-size: 15px; font-weight: 650; white-space: nowrap; letter-spacing: -.01em; }
.card .amt small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 650; line-height: 1.4; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.empty { text-align: center; padding: 52px 24px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 12px; }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* ================================================================== dialogs */
dialog {
  width: 100%; max-width: 100%; max-height: 94dvh; padding: 0; border: none;
  border-radius: 22px 22px 0 0; background: var(--surface);
  color: var(--text); box-shadow: var(--sh-3); margin: auto auto 0;
  overflow: hidden;
}
@media (min-width: 700px) {
  dialog { width: min(640px, 100%); max-height: 88dvh; border-radius: var(--r-lg); margin: auto; }
}
dialog::backdrop { background: rgba(8,12,18,.48); backdrop-filter: blur(2px); }

.sheet { display: flex; flex-direction: column; max-height: 94dvh; }
@media (min-width: 700px) { .sheet { max-height: 88dvh; } }
/* The grab handle a phone user expects on a sheet that slid up from the bottom. */
.sheet::before {
  content: ""; display: block; flex: none; width: 36px; height: 5px; border-radius: 3px;
  background: var(--border-strong); margin: 8px auto 0;
}
@media (min-width: 700px) { .sheet::before { display: none; } }
.sheet-head {
  display: flex; align-items: center; gap: 10px; flex: none; min-width: 0;
  padding: 8px 16px 12px; border-bottom: 1px solid var(--border);
}
.sheet-head h2 { flex: 1; font-size: 17px; font-weight: 680; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { min-width: 0; }
.icon-btn {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: none; border-radius: 50%; cursor: pointer;
  color: var(--text-2); font-size: 19px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
/* overflow-x must be stated explicitly: CSS promotes a `visible` axis to `auto`
   when the other axis scrolls, which silently made this pane scroll sideways. */
.sheet-body { padding: 16px; overflow-y: auto; overflow-x: hidden; flex: 1;
  -webkit-overflow-scrolling: touch; min-width: 0; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 8px; flex: none;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn-danger { flex: 0 0 auto; }

.thumb {
  display: block; width: 100%; max-height: 220px; object-fit: contain;
  border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); margin-bottom: 16px; cursor: zoom-in;
}

/* =================================================================== forms */
/* min-width:0 is load-bearing: grid items default to min-width:auto, and a date
   input's intrinsic width (dd/mm/yyyy + picker icon) then refuses to shrink,
   pushing the second column off narrow screens. */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 600; padding-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid transparent;
  border-radius: 12px; color: var(--text); font-size: 15px;
  -webkit-appearance: none; appearance: none;
}
.field select { padding-right: 32px;
  background-image: var(--chev); background-repeat: no-repeat;
  background-position: right 10px center; background-size: 16px; }
.field textarea {
  resize: vertical; min-height: 76px; line-height: 1.45;
  font-family: inherit;      /* textareas default to monospace in some browsers */
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field input:disabled, .field select:disabled, .field textarea:disabled { opacity: .6; }
.field input[type=number], .field input[type=date] { font-variant-numeric: tabular-nums; }
.field .hint { font-size: 12px; color: var(--muted); }
/* Date inputs, the hard way.
   iOS Safari gives input[type=date] an intrinsic content width and renders it
   as an inline-block that ignores `width:100%`, so it spills out of whatever
   box it is in. `appearance:none` drops that native sizing, and `display:block`
   plus an explicit width/min-width makes it behave like any other field.
   They also get a full row unconditionally -- two-up looked fine in Chromium
   twice and still overflowed on a real phone, so no breakpoint is trusted. */
.field input[type=date] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;          /* iOS renders these shorter without a native box */
  text-align: left;
}
.field:has(input[type=date]) { grid-column: 1 / -1; }

/* Nothing inside the form may be wider than the column it sits in. */
.grid, .field, .field > * { max-width: 100%; }

.section { margin-bottom: 22px; }
.section > h3 {
  font-size: 13px; color: var(--text-2); font-weight: 650; letter-spacing: -.005em;
  margin-bottom: 8px; padding-left: 2px;
}
/* Inside a sheet the section title has to stand clear of the field labels
   under it, or "Document" and "Vendor" read as the same kind of thing. */
.sheet-body .section > h3 { font-size: 16px; font-weight: 700; color: var(--text);
  letter-spacing: -.02em; margin: 4px 0 10px; }
.sheet-body .section + .section { margin-top: 26px; }
.meta-line { color: var(--muted); font-size: 12.5px; margin-top: 14px; line-height: 1.5; }

/* The seldom-edited fields of a document sit behind one row, not in the way. */
.more { border-top: 1px solid var(--border); margin-top: 4px; }
.more summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  min-height: 48px; font-size: 14px; font-weight: 600; color: var(--text-2);
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ""; margin-left: auto; width: 18px; height: 18px;
  background: var(--chev) no-repeat center / 18px; transition: transform .15s; }
.more[open] summary::after { transform: rotate(180deg); }
.more .grid { padding-bottom: 6px; }

/* Choices in the export sheet: a title with a line of explanation under it. */
.choice { flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px;
  min-height: 0; text-align: left; white-space: normal; }
.choice b { font-weight: 600; }
.choice small { color: var(--muted); font-weight: 400; font-size: 12.5px; line-height: 1.4; }
.divider { height: 1px; background: var(--border); }

/* ==================================================================== table */
.items { min-width: 0; }
/* table-layout:fixed stops a long product code from setting the table's width. */
.items table { width: 100%; table-layout: fixed; border-collapse: collapse;
  font-size: 13.5px; }
.items th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600;
  padding: 0 4px 6px; }
.items td { padding: 8px 4px; border-top: 1px solid var(--border);
  overflow-wrap: anywhere; }
.items td:last-child, .items th:last-child { text-align: right;
  font-variant-numeric: tabular-nums; }
.items .code { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.items col.qty { width: 52px; }
.items col.amt { width: 84px; }
/* A sub-item is a breakdown of the line above, so it is indented and quieter
   and carries no top border of its own. */
.items tr.sub td { border-top: none; padding-top: 0; padding-bottom: 6px;
  color: var(--muted); font-size: 12.5px; }
.items tr.sub td:first-child { padding-left: 16px; position: relative; }
.items tr.sub td:first-child::before {
  content: "\21B3"; position: absolute; left: 3px; opacity: .55;
}

/* ================================================================ member row */
.member {
  display: flex; align-items: center; gap: 11px; padding: 11px 0;
  border-top: 1px solid var(--border);
}
.member:first-of-type { border-top: none; }
.member .who { flex: 1; min-width: 0; }
.member .who b { display: block; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .who small { color: var(--muted); font-size: 12.5px;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member select { padding: 0 26px 0 10px; min-height: 36px; border-radius: 10px;
  background: var(--surface-2) var(--chev) no-repeat right 7px center / 14px;
  border: 1px solid transparent; font-size: 13px; -webkit-appearance: none; appearance: none; }

/* ==================================================================== tabs */
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border);
  overflow-x: auto; flex: none; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  padding: 12px 12px; background: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ================================================================== auth page */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 28px; box-shadow: var(--sh-2);
}
.auth-card .brand { justify-content: center; margin: 0 0 6px; font-size: 20px;
  flex-direction: column; gap: 12px; }
.auth-card .brand .mark { width: 48px; height: 48px; border-radius: 14px; }
.auth-card .brand .mark svg { width: 26px; height: 26px; }
.auth-card > form > p.sub { text-align: center; color: var(--muted); font-size: 14px;
  margin: 0 0 22px; }
.auth-card .field { margin-bottom: 13px; }
.auth-card .btn { margin-top: 8px; }
@media (max-width: 560px) {
  .auth-wrap { align-items: start; padding-top: 12vh; }
  .auth-card { background: none; border: none; box-shadow: none; padding: 8px 4px; }
  .auth-card .field input { background: var(--surface); border-color: var(--border); }
}

.code-display {
  font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: .08em;
  text-align: center; padding: 18px; border-radius: var(--r);
  background: var(--accent-soft); color: var(--accent);
  border: 1px dashed var(--accent); user-select: all;
}

.menu {
  position: absolute; right: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 44px);
  z-index: 40; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-2), 0 12px 40px rgba(16,24,40,.18);
  padding: 6px; overflow: hidden;
}
.menu .who { padding: 9px 11px 10px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.menu .who b { display: block; font-size: 14px; }
.menu .who small { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 11px;
  background: none; border: none; border-radius: 9px; cursor: pointer;
  font-size: 14.5px; text-align: left; color: var(--text); text-decoration: none;
}
.menu button:hover { background: var(--surface-2); }
.menu .divider { margin: 5px 0; }
.menu .label { padding: 7px 11px 4px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.menu .check { margin-left: auto; color: var(--accent); font-weight: 700; }

/* ============================================================== statements */
.bar { height: 5px; border-radius: 999px; background: var(--surface-3);
  overflow: hidden; display: flex; margin-top: 8px; }
.bar i { display: block; height: 100%; }
.bar .ok { background: var(--ok); }
.bar .ig { background: var(--border-strong); }
.bar .no { background: var(--warn); }

/* one statement line */
.txn { display: flex; align-items: flex-start; gap: 11px; padding: 12px 0;
  border-top: 1px solid var(--border); }
.txn:first-of-type { border-top: none; }
.txn .body { flex: 1; min-width: 0; }
.txn .body b { display: block; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn .body small { display: block; color: var(--muted); font-size: 12.5px; }
.txn .money { flex: none; text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 650; font-size: 14px; white-space: nowrap; }
.txn .money.credit { color: var(--ok); }
.txn.is-missing { border-left: 3px solid var(--warn); padding-left: 10px;
  margin-left: -13px; }
.txn.is-ignored { opacity: .55; }
.txn .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.chip.matched { background: var(--ok-bg); color: var(--ok); }
.chip.missing { background: var(--warn-bg); color: var(--warn); }
.chip.ignored { background: var(--surface-2); color: var(--muted); }
.chip.credit  { background: var(--accent-soft); color: var(--accent); }

.pick { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 12px; margin-bottom: 6px; background: var(--surface-2);
  border: 1px solid transparent; border-radius: 12px; cursor: pointer; }
.pick:hover { border-color: var(--accent); }
.pick .who { flex: 1; min-width: 0; }
.pick .who b { display: block; font-size: 14px; }
.pick .who small { color: var(--muted); font-size: 12px; }
.pick .score { font-variant-numeric: tabular-nums; font-size: 12px;
  color: var(--muted); flex: none; }

/* ====================================================== reports & owed views */
.quiet { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* --- active filter chip (arrived at by clicking a figure in a report) ------ */
#active-filter { margin-bottom: 10px; }
#active-filter .chip {
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; padding: 6px 6px 6px 12px; gap: 2px;
}
#active-filter .chip button {
  border: none; background: none; cursor: pointer; color: inherit;
  font-size: 17px; line-height: 1; padding: 0 6px; opacity: .7;
}
#active-filter .chip button:hover { opacity: 1; }

/* --- period summary -------------------------------------------------------- */
.totals-line {
  display: flex; gap: 18px; margin-bottom: 10px; flex-wrap: wrap;
  font-size: 13.5px; color: var(--muted);
}
.totals-line b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

.cat-list { display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-1); overflow: hidden; }
.cat-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 64px auto;
  align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 14px; border: none; border-radius: 0;
  background: none; cursor: pointer; font: inherit; color: var(--text);
}
.cat-row + .cat-row { border-top: 1px solid var(--border); }
.cat-row:hover { background: var(--surface-2); }
.cat-name { font-size: 14.5px; font-weight: 550; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-name .code { margin-left: 6px; }
.cat-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.cat-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.cat-amt { text-align: right; font-variant-numeric: tabular-nums;
  font-size: 14.5px; font-weight: 650; white-space: nowrap; }
.cat-amt small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }

/* --- owed / suppliers rows ------------------------------------------------- */
/* These carry an action button, so the card must not itself look clickable. */
.owed-row, .supplier, .merge-row { cursor: default; }
.owed-row:hover, .supplier:hover, .merge-row:hover { background: none; }
.owed-row:active, .supplier:active, .merge-row:active { background: none; }
.owed-row .btn, .merge-row .btn { flex: none; }

.supplier select {
  flex: none; max-width: 42%; min-height: 36px; padding: 0 26px 0 10px; font-size: 13px;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--surface-2) var(--chev) no-repeat right 7px center / 14px;
  color: var(--text); -webkit-appearance: none; appearance: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dup-group > h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  font-size: 13.5px; color: var(--text-2); }

/* --- audit trail ----------------------------------------------------------- */
.history { margin-top: 12px; border-top: 1px solid var(--border); }
.history summary {
  cursor: pointer; font-size: 14px; color: var(--text-2); font-weight: 600;
  list-style: none; display: flex; align-items: center; min-height: 48px;
}
.history summary::-webkit-details-marker { display: none; }
.history summary::after { content: ""; margin-left: auto; width: 18px; height: 18px;
  background: var(--chev) no-repeat center / 18px; transition: transform .15s; }
.history[open] summary::after { transform: rotate(180deg); }

.trail { list-style: none; margin: 0 0 12px; padding: 0; display: flex;
  flex-direction: column; gap: 8px; }
.trail li { font-size: 13px; color: var(--text-2); line-height: 1.45;
  padding-left: 11px; border-left: 2px solid var(--border); }
.trail li b { color: var(--text); font-weight: 600; }
.trail li small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }

.settled-note { align-items: center; justify-content: space-between; }

/* On a phone the account name already needs every pixel, and a half-shown code
   ("Telecom & Internet 6…") reads worse than none. The name is what identifies
   the row; the code is reference detail that belongs to the wider layout. */
@media (max-width: 560px) {
  .cat-name .code { display: none; }
  .cat-row { grid-template-columns: minmax(0, 1fr) 46px auto; gap: 9px; }
}

/* ===================================================================== approvals */
.switch { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0;
  font-size: 14px; cursor: pointer; line-height: 1.45; }
.switch input { flex: none; width: 18px; height: 18px; margin-top: 1px;
  accent-color: var(--accent); cursor: pointer; }
.switch input:disabled { cursor: not-allowed; opacity: .5; }
.switch input:disabled + span { color: var(--muted); }

.pill.ap-wait  { background: var(--accent-soft); color: var(--accent); }
.pill.ap-back  { background: var(--danger-bg);  color: var(--danger); }
.pill.ap-draft { background: var(--surface-2);  color: var(--muted); }

/* The row carries a checkbox and its own open button, so the card itself is
   not the click target. */
.approval-row { cursor: default; gap: 10px; }
.approval-row:hover, .approval-row:active { background: none; }
.approval-row .pick-box { flex: none; display: grid; place-items: center; cursor: pointer;
  width: 32px; height: 44px; margin: -6px -4px -6px -6px; }
.approval-row .pick-box input { width: 18px; height: 18px; accent-color: var(--accent);
  cursor: pointer; }
.approval-row .pick-box input:disabled { cursor: not-allowed; opacity: .45; }

.as-link { background: none; border: none; padding: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; }
/* Needs to out-specify `.card .who small`, which truncates to one line -- a
   rejection reason clipped to "you filed or paid for this ..." tells the reader
   nothing, and it is the whole point of the row. */
.approval-row .who small.note {
  color: var(--muted); font-style: italic;
  white-space: normal; overflow: visible; text-overflow: clip; margin-top: 2px;
}

.approval-note { align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; }
.approval-actions { display: flex; gap: 6px; flex: none; }

#approval-bulk { flex-wrap: wrap; margin-bottom: 12px; }
#approval-bulk > * { flex: 1 1 auto; }

/* ============================================ statements on the receipts view */
/* Reconciliation used to be a tab. Statements now arrive through the same
   upload as everything else, so this one line carries the only thing worth
   knowing about them until you want the detail. */
.strip {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 14px; margin-bottom: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-1); font: inherit; color: var(--text);
  position: relative; overflow: hidden;
  transition: background .12s;
}
.strip::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--border-strong); }
.strip:hover { background: var(--surface-2); }
.strip.attention::before { background: var(--warn); }
.strip.ok::before        { background: var(--ok); }
.strip-main { flex: 1; min-width: 0; }
.strip-main b { display: block; font-size: 14.5px; font-weight: 600; }
.strip-main small { display: block; color: var(--muted); font-size: 12.5px; }
.strip.attention .strip-main small { color: var(--warn); }
.strip-go { flex: none; color: var(--accent); font-size: 13.5px; font-weight: 600; }

/* ========================================================== touch ergonomics */
/* A pointer is exact; a thumb is about 44px wide, and this app is used on a
   phone far more than on a desktop. Where a control has to stay visually small
   (an icon button, an avatar) the HIT area is grown with a pseudo-element
   instead, so the target gets bigger without the design getting heavier. */
@media (max-width: 560px) {
  .icon-btn, .avatar { position: relative; }
  .icon-btn::after, .avatar::after {
    content: ""; position: absolute;
    /* to 44px from whatever the visual size is */
    inset: calc((44px - 100%) / -2);
    min-width: 44px; min-height: 44px;
  }

  /* Controls that can simply be taller, without the layout minding. */
  .btn-sm { min-height: 42px; }
  .segmented button, .tabs button { min-height: 42px; }
  select, .supplier select, .field select, .member select { min-height: 42px; }
}

/* An owed row is name, amount and a button. On a phone the avatar tile is the
   thing that can go: without it "Mei Lin" fits, with it the row read "Mei …". */
@media (max-width: 560px) {
  .owed-row .icon { display: none; }
  .owed-row .btn-sm, .merge-row .btn-sm { padding: 0 11px; }
}

/* ============================================================ invoices & jobs */
.pill.inv-draft { background: var(--surface-2);  color: var(--muted); }
.pill.inv-sent  { background: var(--accent-soft); color: var(--accent); }
.pill.inv-paid  { background: var(--ok-bg);      color: var(--ok); }
.pill.inv-void  { background: var(--surface-2);  color: var(--muted);
                  text-decoration: line-through; }

.card .amt b.pos { color: var(--ok); }
.card .amt b.neg { color: var(--danger); }

/* One line of an invoice: description takes the room, the three figures stay
   narrow and aligned, and the delete sits at the end. */
.inv-line {
  display: grid; gap: 6px; margin-bottom: 6px; align-items: center;
  grid-template-columns: minmax(0, 1fr) 62px 72px 84px 36px;
}
.inv-line input {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; font-size: 14px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-variant-numeric: tabular-nums;
  -webkit-appearance: none; appearance: none;
}
.inv-line input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.inv-line .l-del { justify-self: center; }

/* On a phone there is no room for four across: the description takes a line of
   its own and the figures share the next. */
@media (max-width: 560px) {
  .inv-line {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 40px;
    padding-bottom: 8px; margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .inv-line .l-desc { grid-column: 1 / -1; }
  .inv-line input { min-height: 44px; }
}

/* The two figures ARE the point of a job row, so they wrap rather than being
   cut to "cost SGD 390.00 · billed SGD 1,..." on a narrow screen. */
.card .who small.figures {
  white-space: normal; overflow: visible; text-overflow: clip;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

#invoice-foot { display: flex; gap: 8px; flex-wrap: wrap; }
#invoice-foot .btn { flex: 1 1 auto; }

/* ================================================== statements in the list */
/* A statement row wears a bank glyph instead of vendor initials, and its
   right-hand figure is a status, not an amount. */
.card .icon.icon-stmt { background: var(--accent-soft); color: var(--accent); }
.card .icon.icon-stmt svg { width: 20px; height: 20px; }
.card .amt .chip { font-size: 11.5px; font-weight: 650; }

/* ============================================================ choice sheets */
/* "Ready to submit?" and "Possible duplicate": a summary of the record, then
   buttons whose labels are sentences, so they stack on a phone. */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0;
  font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.confirm-line { margin: 16px 0 0; padding: 12px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14.5px; }
.choice-foot { flex-wrap: wrap; }
.choice-foot .btn, .choice-foot .btn-danger { flex: 1 1 100%; white-space: normal; }
@media (min-width: 700px) { .choice-foot .btn, .choice-foot .btn-danger { flex: 1 1 auto; } }
.choice-h { font-size: 13px; color: var(--text-2); font-weight: 650; margin: 16px 0 8px; }

.twin { display: flex; gap: 12px; padding: 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.twin img, .twin-noimg { width: 64px; height: 64px; flex: none; border-radius: 10px;
  object-fit: cover; background: var(--surface-3); display: grid; place-items: center;
  color: var(--muted); font-weight: 700; font-size: 13px; }
.twin-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.twin-body b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.twin-body small { color: var(--muted); font-size: 12.5px; }
.twin-open { color: var(--accent); font-weight: 600; font-size: 13.5px; margin-top: 4px;
  min-height: 36px; align-self: flex-start; }

/* ============================================================ evidence */
.pill.proof { background: var(--surface-3); color: var(--text-2); }
/* An attached slip's amount is shown but not counted: quieter, so the eye
   does not add it to the column. */
.card .amt.muted b { color: var(--muted); font-weight: 600; }
.confirm-line.warn { background: var(--warn-bg); color: var(--warn); }

/* ===================================================================== home */
/* Cards on the home screen: one figure or one chart each. Charts are HTML
   where they can be, so the bars follow the column width and the text stays
   crisp; the donut alone is SVG. */
.quick-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px 14px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.quick-row::-webkit-scrollbar { display: none; }
.quick {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 42px;
  padding: 0 14px 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
  font-weight: 600; cursor: pointer; box-shadow: var(--sh-1); white-space: nowrap;
}
.quick svg { width: 18px; height: 18px; color: var(--accent); }
.quick:first-child { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.quick:first-child svg { color: inherit; }
.quick:active { transform: scale(.98); }
@media (min-width: 700px) { .quick-row { margin: 0 0 16px; padding: 0; } }

.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats.two .stat:nth-child(2n+1) { border-left: none; }
.stats.two .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
.stat small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 13px; }
.stat.attention small { color: var(--warn); }

.select-ghost {
  min-height: 44px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface) var(--chev) no-repeat right 8px center / 16px; color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600; -webkit-appearance: none; appearance: none;
}

.strips { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.strips .strip { margin: 0; }
.strip-n { flex: none; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px;
  display: grid; place-items: center; font-weight: 700; font-size: 13.5px;
  font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text-2); }
.strip.attention .strip-n { background: var(--warn-bg); color: var(--warn); }

.dcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--sh-1); padding: 14px 14px 12px; margin-bottom: 14px; min-width: 0;
}
.dcard > header { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; }
.dcard > header h3 { font-size: 14px; font-weight: 680; color: var(--text); letter-spacing: -.01em; }
.dcard-note { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
  font-weight: 600; white-space: nowrap; }
.dcard-note.pos { color: var(--ok); }
.dcard-note.neg { color: var(--danger); }
.dcard-foot { font-size: 11.5px; color: var(--muted); margin: 10px 0 0; }
/* A text link that is still a 44px thumb target: the padding grows the hit area
   and the negative margin keeps the header the same height. */
.dcard .as-link { color: var(--accent); font-weight: 600; font-size: 13.5px;
  background: none; border: 0; cursor: pointer; font-family: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px;
  margin: -13px -10px -13px 0; border-radius: 10px; }
.dcard .as-link:hover { background: var(--surface-2); }
.dcard .quiet { margin: 0; }

/* --- column charts --------------------------------------------------------- */
.bars { display: flex; gap: 8px; }
.bars-y { flex: none; display: flex; flex-direction: column; justify-content: space-between;
  height: 128px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  text-align: right; min-width: 28px; padding-bottom: 0; }
.bars-main { flex: 1; min-width: 0; }
.bars-plot {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  height: 128px; border-bottom: 1px solid var(--border-strong);
  background: linear-gradient(to top, transparent 49.6%, var(--border) 49.6%, var(--border) 50.4%, transparent 50.4%);
}
.bar-col { position: relative; height: 100%; min-width: 0; border: 0; background: none;
  padding: 0; pointer-events: none; }
/* One tap target for the whole plot: a 23px column is not something a thumb
   can aim at, so the plot works out which month was meant. */
.bars-plot[data-months] { cursor: pointer; }
.bar-col i { position: absolute; bottom: 0; left: 18%; right: 18%; min-height: 0;
  border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.bar-col.now i { background: var(--accent); }
.bar-col.pair i.in  { left: 12%; right: 52%; background: var(--ok); }
.bar-col.pair i.out { left: 52%; right: 12%; background: var(--accent); }
.bar-budget { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed var(--warn);
  pointer-events: none; }
.bar-budget small { position: absolute; right: 0; top: -16px; font-size: 11.5px; color: var(--warn);
  font-weight: 650; background: var(--surface); padding: 0 3px; }
.bars-x { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-top: 5px; }
.bars-x span { text-align: center; font-size: 11.5px; color: var(--muted); overflow: hidden;
  white-space: nowrap; }

.legend-row { display: flex; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.legend-row.wrap { flex-wrap: wrap; gap: 6px 14px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-row b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; }
.legend-row i, .stack i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legend-row i.in, .stack i.b0 { background: var(--ok); }
.legend-row i.out { background: var(--accent); }
.stack i.b1 { background: #e0b04c; }
.stack i.b2 { background: #e5843e; }
.stack i.b3 { background: #d95d4a; }
.stack i.b4 { background: var(--danger); }
.legend-row i.b1 { background: #e0b04c; }
.legend-row i.b2 { background: #e5843e; }
.legend-row i.b3 { background: #d95d4a; }
.legend-row i.b4 { background: var(--danger); }

/* --- stacked bar (invoice ageing) ------------------------------------------ */
.stack { display: flex; height: 16px; border-radius: 999px; overflow: hidden; gap: 2px;
  background: var(--surface-3); }
.stack i { height: 100%; width: auto; border-radius: 0; min-width: 3px; }

/* --- donut + legend --------------------------------------------------------- */
.donut-wrap { display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 14px; align-items: center; }
.donut { width: 124px; height: 124px; }
.donut-n { font-size: 15px; font-weight: 700; fill: var(--text); letter-spacing: -.02em; }
.donut-l { font-size: 8.5px; fill: var(--muted); font-weight: 600; }
.legend { display: flex; flex-direction: column; min-width: 0; }
.leg { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 9px;
  width: 100%; min-height: 44px; padding: 5px 2px; border: 0; background: none; text-align: left;
  cursor: pointer; font: inherit; color: var(--text); border-radius: 8px; }
.leg + .leg { border-top: 1px solid var(--border); }
.leg:hover { background: var(--surface-2); }
.leg i { width: 10px; height: 10px; border-radius: 3px; }
/* Account names are long ("Hardware & Equipment") and the column beside a
   donut is narrow: let the name take two lines rather than cutting it off. */
.leg-name { font-size: 12.5px; font-weight: 550; line-height: 1.25; min-width: 0;
  overflow-wrap: anywhere; }
.leg-amt { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right;
  white-space: nowrap; }
.leg-amt small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
@media (max-width: 380px) { .donut-wrap { grid-template-columns: 104px minmax(0, 1fr); }
  .donut { width: 104px; height: 104px; } }

/* --- budgets ------------------------------------------------------------------- */
.budgets { display: flex; flex-direction: column; gap: 12px; }
.budget-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 6px; }
.budget-name { font-size: 13.5px; font-weight: 600; min-width: 0; line-height: 1.2;
  overflow-wrap: anywhere; }
.budget-amt { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-amt small { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.budget-bar { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3);
  overflow: visible; }
.budget-bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok);
  max-width: 100%; }
.budget-bar em { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px;
  background: var(--text-2); opacity: .55; border-radius: 1px; }
.budget.warn .budget-bar i { background: var(--warn); }
.budget.over .budget-bar i { background: var(--danger); }
.budget-note { display: block; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.budget.warn .budget-note { color: var(--warn); }
.budget.over .budget-note { color: var(--danger); font-weight: 600; }

/* The editor: a label and a number per account. */
.brows { display: flex; flex-direction: column; }
.brow { display: flex; align-items: center; gap: 12px; padding: 9px 0; cursor: text; }
.brow + .brow { border-top: 1px solid var(--border); }
.brow.total { padding-bottom: 12px; margin-bottom: 4px; border-bottom: 2px solid var(--border-strong); }
.brow-name { flex: 1; min-width: 0; }
.brow-name b { display: block; font-size: 14px; font-weight: 600; }
.brow-name small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.brow input { flex: none; width: 118px; min-height: 42px; padding: 8px 10px; text-align: right;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
  color: var(--text); font: inherit; font-size: 15px; font-variant-numeric: tabular-nums;
  -webkit-appearance: none; appearance: none; -moz-appearance: textfield; }
.brow input::-webkit-outer-spin-button, .brow input::-webkit-inner-spin-button { -webkit-appearance: none; }
.brow input:focus { outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* --- horizontal bars (suppliers) ------------------------------------------------ */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 10px;
  align-items: center; }
.hbar-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; min-width: 0; }
.hbar-name small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.hbar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 999px; }
.hbar-amt { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Cards inside a home card: no second frame. */
.list.flat { border: 0; box-shadow: none; border-radius: 0; background: none; margin: -4px 0 0; }
.list.flat .card { padding-left: 0; padding-right: 0; }

/* --- roles (settings → people) -------------------------------------------------- */
.roles { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 10px; }
.role b { display: block; font-size: 14px; font-weight: 650; }
.role small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 1px; }
.roles-help { margin-top: 8px; }

/* ===================================================================== xero */
.brow select { flex: none; width: 168px; min-height: 42px; padding: 0 28px 0 10px;
  border-radius: 10px; border: 1px solid transparent; color: var(--text); font: inherit;
  font-size: 13.5px; background: var(--surface-2) var(--chev) no-repeat right 8px center / 15px;
  -webkit-appearance: none; appearance: none; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.brow select:focus { outline: none; border-color: var(--accent); }
@media (max-width: 400px) { .brow select { width: 148px; } }
.xres-list { display: flex; flex-direction: column; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; background: var(--surface); }
.xres { padding: 9px 12px; border-left: 3px solid var(--border); }
.xres + .xres { border-top: 1px solid var(--border); }
.xres b { display: block; font-size: 13.5px; font-weight: 600; }
.xres small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.xres.ok { border-left-color: var(--ok); }
.xres.fail { border-left-color: var(--danger); }
.xres.fail small { color: var(--danger); }
.xres.skip { border-left-color: var(--warn); }
.avatar.xero { background: #13b5ea; color: #fff; font-weight: 800; }

