/* Connect4Sure brand: cyan #13C2ED -> indigo #3943E8 (the "4"), grey #575757 (lettering) */
:root {
  --brand-cyan: #13c2ed;
  --brand-blue: #1aa7ee;
  --brand-indigo: #3943e8;
  --brand-grey: #575757;
  --brand-gradient: linear-gradient(120deg, #13c2ed 0%, #1aa7ee 45%, #3943e8 100%);
  --button-gradient: linear-gradient(120deg, #1584c9 0%, #3943e8 100%); /* deeper, so white text reads well */
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --text: #24272d;
  --muted: #646a73;
  --border: #dbe2ea;
  --primary: #2f4be0;
  --primary-text: #ffffff;
  --ok: #157a3b;
  --ok-bg: #e4f4e9;
  --warn: #8f5500;
  --warn-bg: #fff2d9;
  --info: #1d63d6;
  --info-bg: #e5f6fd;
  --err: #b42318;
  --err-bg: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141a; --surface: #192029; --surface-2: #1d2530; --text: #e6e9ee; --muted: #9aa3b0; --border: #2c3440;
    --primary: #4cc7f2; --ok: #5fd08a; --ok-bg: #173323; --warn: #f2b857; --warn-bg: #3a2c12;
    --info: #6fd2f4; --info-bg: #10303f; --err: #ff8a80; --err-bg: #3d1c1a; --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 20px; margin: 0; }
h2 { margin: 0 0 8px; font-size: 18px; }
h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
a { color: var(--primary); }
code { font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono, .uid-cell { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--brand-gradient); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-logo { height: 16px; width: auto; display: block; }
.brand span { font-weight: 500; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 6px 9px; border-radius: 8px; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.topbar nav a:hover { background: var(--surface-2); }
.topbar nav a.active { background: var(--info-bg); color: var(--info); font-weight: 600; }
.nav-count { background: var(--warn); color: var(--surface); border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.mode-badge { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.mode-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.mode-direct { background: var(--ok-bg); color: var(--ok); }
.mode-import { background: var(--warn-bg); color: var(--warn); }
.mode-unknown { background: var(--surface-2); color: var(--muted); }
.mode-banner { background: var(--warn-bg); color: var(--warn); padding: 9px 24px; border-bottom: 1px solid var(--border); font-size: 13px; }
.mode-banner a { color: inherit; font-weight: 600; }

main { padding: 20px 24px 60px; max-width: 1440px; margin: 0 auto; }
.page-head { margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.empty { text-align: center; color: var(--muted); padding: 28px 0 12px; }

/* ---------- buttons, pills ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--button-gradient); border-color: transparent; color: var(--primary-text); font-weight: 600; }
.btn-primary:hover:not(:disabled) { border-color: transparent; filter: brightness(1.06); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { padding: 5px 10px; font-size: 12px; }
.pill { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; display: inline-block; }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-err { background: var(--err-bg); color: var(--err); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-info { background: var(--info-bg); color: var(--info); }

/* ---------- upload ---------- */
.upload-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.upload-layout .upload-card { grid-row: span 2; }
.upload-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.step { display: flex; gap: 14px; }
.step-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--button-gradient); color: var(--primary-text); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.step-body { flex: 1; min-width: 0; }
.step-body h3 { margin: 5px 0 10px; }
.pick-entry { display: flex; gap: 8px; }
.pick-entry input { flex: 1; min-width: 0; font: inherit; font-size: 15px; font-weight: 600; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.pick-entry.invalid input { border-color: var(--err); }
.suggest-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.suggest li { padding: 8px 10px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.suggest li.active, .suggest li:hover { background: var(--ok-bg); }
.suggest li mark { background: none; color: inherit; font-weight: 700; text-decoration: underline; }
.suggest li.note { cursor: default; color: var(--muted); font-size: 13px; background: none; }
.pick-confirmed { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); }
.pick-confirmed span { min-width: 0; overflow-wrap: anywhere; }
.pick-confirmed strong { font-size: 16px; white-space: nowrap; }
.pick-confirmed small { font-weight: 400; opacity: .85; }
.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 4px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 150px; padding: 24px; border: 2px dashed var(--border); border-radius: var(--radius); cursor: pointer; text-align: center; background: var(--surface-2); }
.dropzone:not(.disabled):hover, .dropzone.over { border-color: var(--primary); background: var(--info-bg); }
.dropzone.disabled { opacity: .55; cursor: not-allowed; }
.dropzone small { color: var(--muted); }
.upload-msg { margin-top: 10px; white-space: pre-wrap; font-size: 13px; }
.upload-msg .rej { color: var(--err); }
.batch-card { border-color: var(--primary); }
.batch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.uid { font-size: 22px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.file-list, .recent-list { list-style: none; margin: 0; padding: 0; }
.file-list li, .recent-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.file-list li a, .recent-list li a { color: var(--text); text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list li a:hover, .recent-list li a:hover { color: var(--primary); }
.recent-list .meta { color: var(--muted); font-size: 12px; }

/* ---------- queue ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; font: inherit; color: var(--muted); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.tile .n { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.tile.active { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: -2px; }
.tile[data-status="needs_review"] .n { color: var(--warn); }
.tile[data-status="extraction_failed"] .n, .tile[data-status="post_failed"] .n { color: var(--err); }
.tile[data-status="done"] .n { color: var(--ok); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { flex: 1 1 260px; font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--info-bg); color: var(--info); border-radius: 99px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: 13px; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.inline-check.block { display: flex; align-items: flex-start; margin-top: 6px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: var(--surface-2); }
.table td.file { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tr.dim td { opacity: .55; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { display: flex; gap: 4px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- review ---------- */
.review-head { margin-bottom: 14px; }
.back { text-decoration: none; font-size: 13px; }
.review-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px; }
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.doc { position: sticky; top: 70px; padding: 10px; margin: 0; }
.doc-frame { height: calc(100vh - 170px); min-height: 420px; border-radius: 8px; overflow: auto; background: var(--surface-2); }
.doc-frame iframe { width: 100%; height: 100%; border: 0; }
.doc-frame img { width: 100%; display: block; }
.doc a { display: inline-block; margin-top: 8px; }
.form-section { padding: 16px 18px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.span2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field input, .field select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.field input.readonly { background: var(--surface-2); color: var(--muted); font-weight: 700; }
.field input.upper { text-transform: uppercase; }
.field.missing input, .field.missing select { border-color: var(--warn); background: var(--warn-bg); }
.field.invalid input { border-color: var(--err); }
.field.invalid .hint { color: var(--err); }
.field.disabled { opacity: .45; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }
.quick button { font: inherit; font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; }
.quick button:hover { color: var(--primary); border-color: var(--primary); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; }
.tag-found { background: var(--ok-bg); color: var(--ok); }
.tag-missing { background: var(--warn-bg); color: var(--warn); }
.tag-derived { background: var(--info-bg); color: var(--info); }
.tag-edited { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.amount-check { margin-top: 12px; font-size: 13px; padding: 8px 12px; border-radius: 8px; }
.amount-check:empty { display: none; }
.amount-check.ok { background: var(--ok-bg); color: var(--ok); }
.amount-check.bad { background: var(--err-bg); color: var(--err); }
.note-field { margin-top: 14px; }
.banner { padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-err { background: var(--err-bg); color: var(--err); }
.banner-ok { background: var(--ok-bg); color: var(--ok); }
.banner-info { background: var(--info-bg); color: var(--info); }
.banner .btn { margin-top: 8px; }
.voucher-preview table { width: 100%; border-collapse: collapse; font-size: 13px; }
.voucher-preview td, .voucher-preview th { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.voucher-preview .cc { display: block; font-size: 12px; color: var(--muted); }
.voucher-preview .narr { margin-top: 8px; font-size: 12px; color: var(--muted); }
.action-bar { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 -4px 16px rgba(16, 24, 40, .08); }
.checklist { margin: 0 0 8px; padding-left: 18px; color: var(--warn); font-size: 13px; }
.checklist:empty { display: none; }
.confirm { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 13px; }
.confirm input { margin-top: 2px; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.actions.left { justify-content: flex-start; }
.spacer { flex: 1; }
.error { color: var(--err); margin-top: 8px; white-space: pre-wrap; font-size: 13px; }
.error:empty { display: none; }

.doc-noview { padding: 40px 24px; text-align: center; display: grid; gap: 10px; justify-items: center; color: var(--muted); }
.doc-noview strong { color: var(--text); }

/* ---------- users: vendor ledgers ---------- */
.mono-ish { font-size: 13px; overflow-wrap: anywhere; }
.super-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 4px; color: var(--muted); cursor: pointer; }
.warn-text { color: var(--warn) !important; font-weight: 600; }
.ledger-picker { display: flex; gap: 8px; }
.ledger-picker input { flex: 1; }
.ledger-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ledger-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--info-bg); color: var(--info); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12px; font-weight: 600; }
.ledger-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.v-account { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; font-size: 13px; }
.v-account select { font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.v-acc { font-size: 11px; color: var(--muted); }

/* ---------- dashboard ---------- */
.dash-card { overflow-x: auto; background: #f5f7fa; color: #24272d; padding: 0; }

/* ---------- Tally payments ---------- */
.pay-table td { vertical-align: top; }
.pay-table td.small { max-width: 260px; }
.flag-box { margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--warn); background: var(--warn-bg); color: var(--text); border-radius: 4px; font-size: 12px; }
.flag-box .link, .pay-table .link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 12px; }
.hint-ok { margin-top: 4px; color: var(--info); font-weight: 600; }

/* ---------- activity ---------- */
.act-filters { padding: 10px 14px; }
.act-custom { display: inline-flex; gap: 10px; margin-left: 6px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.act-custom input { font: inherit; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.act-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.act-tile { cursor: default; }
.act-table th { white-space: normal; vertical-align: bottom; }
.act-table td .sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.link-num { font: inherit; background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; }
.link-num:hover strong { text-decoration: underline; }
@media (max-width: 900px) { .act-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- settings ---------- */
/* ---------- settings ---------- */
.settings-page { max-width: 1240px; margin: 0 auto; }
.settings-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav button { display: flex; align-items: center; gap: 8px; text-align: left; font: inherit; color: var(--muted); background: none; border: 0; border-left: 2px solid var(--border); padding: 8px 12px; cursor: pointer; }
.settings-nav button:hover { color: var(--text); background: var(--surface-2); }
.settings-nav button.active { color: var(--text); font-weight: 600; border-left-color: var(--brand-blue); background: var(--info-bg); }
.settings-nav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.settings-nav .dot.ok { background: var(--ok); }
.settings-nav .dot.bad { background: var(--err); }
.settings .set-card { padding: 22px 24px; margin-bottom: 18px; scroll-margin-top: 76px; }
.set-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.set-head h2 { font-size: 16px; margin: 0 0 4px; }
.set-head p { margin: 0; color: var(--muted); font-size: 13px; max-width: 640px; }
.set-head .pill { flex: none; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; margin-bottom: 16px; }
.set-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.set-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings .field { margin: 0; }
.settings .field .hint { margin-top: 2px; }
.req { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--warn); background: var(--warn-bg); padding: 1px 6px; border-radius: 99px; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.more { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.more summary { cursor: pointer; color: var(--primary); font-weight: 600; width: fit-content; }
.more ul, .more ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; }
.more p { margin: 8px 0 0; }
.settings .sub-head { margin: 18px 0 10px; font-size: 12px; }
.settings .field label.inline-check { display: flex; flex-direction: row; gap: 6px; align-items: center; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 4px; cursor: pointer; }
.settings .field label.inline-check input { width: auto; padding: 0; margin: 0; flex: none; }
.set-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.set-stats .stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-stats .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.set-stats .val { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.set-stats .sub { font-size: 12px; color: var(--muted); }
.set-stats .stat-wide { grid-column: 1 / -1; margin: 0; }
.conn-status .banner { margin: 0 0 12px; }
.choice-group { border: 0; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-group legend { font-size: 12px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--muted); }
.choice:has(input:checked) { border-color: var(--brand-blue); background: var(--info-bg); box-shadow: 0 0 0 1px var(--brand-blue) inset; }
.choice input { margin-top: 3px; accent-color: var(--brand-indigo); }
.choice small, .switch-row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 400; }
.choice .pill { font-size: 10px; padding: 1px 7px; margin-left: 4px; vertical-align: 1px; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.switch { appearance: none; flex: none; width: 36px; height: 20px; border-radius: 99px; background: var(--border); position: relative; cursor: pointer; margin: 1px 0 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch:checked { background: var(--button-gradient); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.gst-wrap { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }
.settings #set-gst { padding-left: 16px; padding-right: 16px; }
#set-gst .set-head, #set-gst .set-grid { padding-left: 8px; padding-right: 8px; }
.gst-wrap .table th { background: var(--surface-2); }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin: 0 0 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(16, 24, 40, .06); }
.save-bar .save-msg { color: var(--muted); font-size: 13px; }
.save-bar.dirty { border-color: var(--brand-blue); }
.save-bar.dirty .save-msg { color: var(--text); font-weight: 600; }
.save-bar.dirty .save-msg::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-right: 8px; vertical-align: 1px; }
.save-bar.error { border-color: var(--err); }
.save-bar.error .save-msg { color: var(--err); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-nav { position: sticky; top: 56px; z-index: 6; flex-direction: row; overflow-x: auto; background: var(--bg); padding: 6px 0; margin: 0 -4px; }
  .settings-nav button { border-left: 0; border-radius: 99px; white-space: nowrap; padding: 6px 12px; border: 1px solid var(--border); background: var(--surface); }
  .settings-nav button.active { border-color: var(--brand-blue); }
  .set-grid, .set-grid.cols-2, .set-grid.cols-3, .choice-group { grid-template-columns: minmax(0, 1fr); }
  .settings .set-card { padding: 18px 16px; }
  .set-head { flex-direction: column; }
}
.conn-status { margin-bottom: 12px; }
.conn-status:empty { display: none; }

/* ---------- dialog, toast ---------- */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 460px; width: calc(100% - 32px); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 15, 25, .45); }
.reasons { border: 0; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.reasons label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.reasons input[type="text"] { flex: 1; font: inherit; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); min-width: 0; }
dialog .actions { justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 30; max-width: calc(100% - 32px); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .doc { position: static; }
  .doc-frame { height: 60vh; }
  .upload-layout { grid-template-columns: minmax(0, 1fr); }
  .upload-layout .upload-card { grid-row: auto; }
}
@media (max-width: 640px) {
  main { padding: 14px 16px 60px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .topbar nav { order: 3; width: 100%; }
  .mode-banner { padding: 9px 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: span 1; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pick-entry { flex-wrap: wrap; }
  .pick-entry .btn { width: 100%; justify-content: center; }
  .actions .spacer { display: none; }
}

/* ---------- sign in ---------- */
.login-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 400px; padding: 28px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.login-logo { width: 190px; height: auto; display: block; }
.login-brand span { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.login-card { position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--brand-gradient); }
.login-card form { display: grid; gap: 12px; }
.login-card h2 { margin: 0; }
.login-card p { margin: 0; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }
.code-input { font-size: 22px !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 8px; padding: 8px; }
.qr svg { width: 200px; height: 200px; }
.secret { display: block; text-align: center; font-size: 13px; word-break: break-all; padding: 6px; }
.enroll-steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.login-foot { margin-top: 14px !important; text-align: center; }

/* ---------- user menu ---------- */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); white-space: nowrap; font-size: 13px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 180px; padding: 4px; z-index: 20; }
.user-menu .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; }
.user-menu .menu button:hover, .user-menu .menu a:hover { background: var(--surface-2); }
.user-menu .menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.user-menu .menu a.active { background: var(--info-bg); color: var(--info); font-weight: 600; }
.user-menu .menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.is-super) .super-only { display: none !important; }

/* ---------- supplier pick, ready queue, audit ---------- */
.pick-create { margin-top: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--warn-bg); color: var(--warn); border-radius: 8px; font-size: 13px; }
.ready-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--info-bg); color: var(--info); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.ready-bar.offline { background: var(--warn-bg); color: var(--warn); }
.tile[data-status="ready"] .n { color: var(--info); }
.search.narrow { flex: 0 1 200px; }
.table.audit td { font-size: 13px; vertical-align: top; }
.table.audit td.details { max-width: 420px; color: var(--muted); word-break: break-word; }
.act { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.act.fail { color: var(--err); font-weight: 600; }
.who { font-size: 12px; color: var(--muted); }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* top bar: nav moves to its own scrollable row on narrower screens */
.topbar nav a { white-space: nowrap; }
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .brand { flex: 1; }
  .topbar nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; }
}
@media (max-width: 520px) {
  .mode-badge #mode-text { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .user-menu summary .role { display: none; }
}
.table.audit td.details { min-width: 260px; }
.table.audit td:nth-child(3) { min-width: 150px; }
.act { font-family: inherit; font-size: 13px; font-weight: 600; }

/* position within a multi-invoice upload */
.batch-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.batch-steps { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; text-decoration: none; border: 2px solid var(--border); color: var(--muted); background: var(--surface-2); }
.step-dot.current { border-color: var(--primary); color: var(--primary); }
.step-dot.s-posted, .step-dot.s-exported { background: var(--ok-bg); color: var(--ok); }
.step-dot.s-ready { background: var(--info-bg); color: var(--info); }
.step-dot.s-needs_review { background: var(--warn-bg); color: var(--warn); }
.step-dot.s-extraction_failed, .step-dot.s-post_failed { background: var(--err-bg); color: var(--err); }
.batch-arrows { display: inline-flex; gap: 12px; margin-left: auto; }
.batch-arrows a { text-decoration: none; font-weight: 600; }

/* ---------- posting ---------- */
.nav-count.ready { background: var(--info); }
.posting-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.summary-card { position: sticky; top: 76px; }
.summary { margin: 0 0 12px; display: grid; gap: 6px; }
.summary div { display: flex; justify-content: space-between; gap: 10px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .total { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.summary .total dd { font-size: 18px; }
.sum-lists { display: grid; gap: 8px; margin-bottom: 12px; }
.sum-lists h4 { margin: 0 0 2px; font-size: 12px; }
.table.posting tr.group td { background: var(--surface-2); font-weight: 600; font-size: 13px; }
.table.posting tr.group td .muted { font-weight: 400; }
.table.posting td:first-child { width: 32px; }
.table.posting tr.sel td { background: var(--info-bg); }
.table.posting tr.group.sel td { background: var(--info-bg); }
.run-table td { font-size: 13px; }
@media (max-width: 980px) {
  .posting-layout { grid-template-columns: minmax(0, 1fr); }
  .summary-card { position: static; }
}
.table.posting td:nth-child(3), .table.posting td:nth-child(5), .run-table td:nth-child(5) { white-space: nowrap; }
.run-table tr.err-row td { color: var(--err); background: var(--err-bg); font-size: 12px; padding-top: 4px; }

/* ---------- master data requests / approvals ---------- */
.master-help { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.master-help.pending { background: var(--info-bg); color: var(--info); }
.master-help.rejected { background: var(--err-bg); color: var(--err); }
.master-help .btn { font-size: 12px; padding: 4px 10px; }
.checklist li.info { color: var(--info); }
.request-list { display: grid; gap: 10px; }
.request { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; }
.request .name { font-size: 16px; font-weight: 700; }
.request .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.request .edit { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.request .edit input { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); min-width: 0; }
.request .buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .request { grid-template-columns: minmax(0, 1fr); } .request .buttons { justify-content: flex-start; } }

/* ---------- charges on the invoice ---------- */
.items-table td { vertical-align: middle; }
.items-table input, .items-table select { width: 100%; min-width: 0; font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.items-table td.num input { text-align: right; max-width: 140px; margin-left: auto; display: block; }
.items-table .remove { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.items-table .remove:hover { color: var(--err); }
#items-card .amount-check:empty { display: none; }
.items-table { table-layout: fixed; }
.items-table th:nth-child(1) { width: 30%; }
.items-table th:nth-child(2) { width: 24%; }
.items-table th:nth-child(3) { width: 26%; }
.items-table th:nth-child(4) { width: 15%; }
.items-table th:nth-child(5) { width: 36px; }
.items-table input.invalid { border-color: var(--err); }
.banner-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- GST registrations (settings) ---------- */
.gst-table { table-layout: fixed; width: 100%; min-width: 880px; }
.gst-table col.c-state { width: 128px; }
.gst-table col.c-code { width: 52px; }
.gst-table col.c-gstin { width: 136px; }
.gst-table col.c-x { width: 36px; }
.gst-table th, .gst-table td { padding: 6px 5px; vertical-align: middle; }
.gst-table th:first-child, .gst-table td:first-child { padding-left: 10px; }
.gst-table input { width: 100%; min-width: 0; font: inherit; font-size: 12.5px; padding: 6px 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); text-overflow: ellipsis; }
.gst-table td:nth-child(3) input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.gst-table .remove { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.gst-table .remove:hover { color: var(--err); }

/* ---------- vendor portal ---------- */
body.is-vendor .topbar { justify-content: space-between; }
.v-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.v-tile .v-paid { color: var(--ok); }
.v-asof { margin: -6px 0 12px; }
.v-table tfoot td { border-bottom: 0; color: var(--muted); }
.v-table tfoot tr.total td { color: var(--text); border-top: 1px solid var(--border); }
.v-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.v-tile .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.v-tile .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.v-tile .v-overdue.has { color: var(--err); }
.v-tile .v-returned.has { color: var(--warn); }
.v-result { margin-top: 12px; font-size: 13px; }
.v-result ul { margin: 6px 0 0; padding-left: 18px; }
.v-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.v-head h3 { margin: 0; }
.v-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.v-filters input { min-width: 160px; font: inherit; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.chip { font: inherit; font-size: 12px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.chip.active { background: var(--info-bg); color: var(--info); border-color: var(--info); font-weight: 600; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.v-table .reason { margin-top: 4px; font-size: 12px; color: var(--warn); }
.v-table .sub { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .v-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { padding: 16px 16px 48px; }
  /* Tables become one card per row on phones */
  .v-table thead { display: none; }
  .v-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .v-table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .v-table td:first-child { display: block; text-align: left; padding-bottom: 6px; }
  .v-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
  .v-table td:empty { display: none; }
  .v-table td:not([data-label]):not(:first-child) { justify-content: flex-end; }
  .v-filters input { flex: 1; min-width: 0; }
}
