/* ThymeCCC — dense accounting UI. Plain CSS, no build step. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #d9dde4;
  --border-strong: #b9bfc9;
  --ink: #1b2430;
  --muted: #5c6673;
  --accent: #2b5d87;
  --accent-ink: #ffffff;
  --ok: #1a7a3c;
  --ok-bg: #e6f4ea;
  --warn: #92600a;
  --warn-bg: #fdf1dc;
  --err: #b3261e;
  --err-bg: #fdecea;
  --reversed: #4a5568;
  --reversed-bg: #e9edf2;
  --focus: #7aa7c9;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.45 -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }

button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--accent); }

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 42px;
  padding: 0 14px;
  background: #22303f;
  color: #e8edf2;
  flex: none;
}
.brand { font-size: 15px; letter-spacing: 0.04em; user-select: none; }
.brand em { font-style: normal; color: #9fc3e0; }
.context {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: #c6d2dd;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.session-info { font-size: 12px; color: #c6d2dd; margin-right: 4px; }
#topbar .btn.ghost {
  background: transparent;
  border-color: #46586b;
  color: #dce6ee;
}
#topbar .btn.ghost:hover { background: #31435a; }

/* ---------- frame: sidebar + main ---------- */
#frame { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: 232px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 0 20px;
}
.side-caption {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 4px 14px;
}
.entity {
  border-top: 1px solid var(--border);
  padding: 6px 0 2px;
}
.entity:first-of-type { border-top: none; }
.entity > .entity-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 14px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.entity > .entity-link:hover { background: #eef2f6; }
.entity.open > .entity-link { background: #e7eef5; }
.entity-link .code { font-family: var(--mono); font-weight: 600; }
.entity-link .entity-identity { flex: 1 0 100%; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.entity-link .name { font-weight: 600; overflow-wrap: anywhere; }
.entity-link .code { font-size: 11px; color: var(--muted); font-weight: 400; }
.context .badge { margin-left: 6px; }
.sample-scope-note { margin-bottom: 12px; }
.table-scroll { overflow-x: auto; }
.pager-bar { flex-wrap: wrap; }
.pager-bar input[type="search"] { width: min(320px, 100%); }
@media (max-width: 800px) {
  #sidebar { width: 190px; }
  #topbar { gap: 8px; }
  #main { padding: 12px; }
}
.views { display: none; padding: 2px 0 6px; }
.entity.open .views { display: block; }
.views a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 14px 4px 26px;
  text-decoration: none;
  color: var(--ink);
}
.views a:hover { background: #eef2f6; }
.views a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

#main {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 14px 18px 24px;
  outline: none;
}
#main:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 0 7px;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 16px;
  vertical-align: 1px;
  white-space: nowrap;
}
.badge.draft { color: var(--warn); background: var(--warn-bg); }
.badge.posted { color: var(--ok); background: var(--ok-bg); }
.badge.reversed { color: var(--reversed); background: var(--reversed-bg); }
.badge.ready { color: #1d4ed8; background: #e3ebfb; border: 1px solid #c3d4f2; }
.badge.role { color: var(--muted); background: #eef0f3; border: 1px solid var(--border); font-weight: 600; }
.badge.bal-ok { color: var(--ok); background: var(--ok-bg); }
.badge.bal-no { color: var(--err); background: var(--err-bg); }

#batch-list-select, #ready-batch-select { max-width: 24rem; min-width: 0; }

/* Row-level action cells (Batch List / Post Batches single-batch Post) */
.row-actions { text-align: right; white-space: nowrap; }
/* Entry-header reversal provenance link (server-owned source) */
.provenance-link { font-size: 11.5px; margin-left: 6px; }
/* Radio option rows inside modal forms */
.radio-row { display: flex; flex-wrap: wrap; gap: 2px 22px; margin: 2px 0 4px; }
.radio-row .check-line { margin: 2px 0; }
.rev-preview-wrap { max-height: 240px; overflow: auto; margin: 8px 0; }
.rev-preview-wrap .muted { margin: 6px 0 0; }
/* NI1 native identity (UI11): retained Sage batch/entry numbers lead;
   app record IDs stay visible but secondary. */
.native-id { font-family: var(--mono); font-weight: 650; font-variant-numeric: tabular-nums; }
.toolbar .title .native-id { font-size: 15px; }
/* Keyboard-activatable batch rows (Enter/Space) */
.tbl tr.row-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
/* SA1 source-activity note on fiscal reports (sample companies only) */
.sample-activity-note { border-top: 1px solid var(--border); }
.sample-activity-note .stmt-flags { margin: 6px 0 4px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: linear-gradient(#ffffff, #f0f2f5);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #e9edf2; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: #1f4664;
  color: var(--accent-ink);
  font-weight: 600;
}
.btn.primary:hover { background: #356b9b; }
.btn.danger { background: var(--err); border-color: #8c1d17; color: #fff; font-weight: 600; }
.btn.danger:hover { background: #c53a31; }
.btn.ghost { background: transparent; }
.btn.sm { height: 22px; padding: 0 8px; font-size: 12px; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select, textarea {
  font: inherit;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}
input:disabled, select:disabled, textarea:disabled { background: #eef0f3; color: var(--muted); }

/* ---------- panels / toolbars ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 14px; }
.panel-head .spacer, .toolbar .spacer { flex: 1; }
.panel-body { padding: 12px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .title { font-size: 15px; font-weight: 650; }
.toolbar .crumb { color: var(--muted); }
.toolbar .meta { color: var(--muted); font-size: 12px; display: inline-flex; gap: 8px; align-items: center; }
.toolbar input[type="text"], .toolbar input[type="date"] { width: auto; }

.field { display: flex; align-items: center; gap: 6px; }
.field label { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- generic tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.tbl th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #fbfcfd;
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.tbl td.mono { font-family: var(--mono); }
.tbl tbody tr:hover { background: #f2f6fa; }
.tbl tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
  border-bottom: none;
  background: #fbfcfd;
}
.row-btn { cursor: pointer; }
.tbl .muted { color: var(--muted); }
.empty-note { color: var(--muted); padding: 14px 12px; }

/* ---------- audit detail / posting periods ---------- */
.detail-lines { font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.panel-body p { margin: 4px 0 10px; }
.period-field { margin: 8px 0; }
.period-field input[type="date"] { margin-right: 8px; }

/* ---------- batch editor ---------- */
.editor-head-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.editor-head-fields input[type="text"] { width: 320px; }
.grid-wrap { position: relative; }
.totals-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
  font-variant-numeric: tabular-nums;
}
.totals-bar .tot { display: flex; gap: 8px; align-items: baseline; }
.totals-bar .tot b { font-family: var(--mono); font-weight: 650; font-size: 13.5px; }
.totals-bar .lab { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.totals-bar .diff { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- entry bar (batch -> entry -> detail hierarchy) ---------- */
.entry-bar {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #f6f8fb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.entry-bar .entry-pick { gap: 8px; }
.entry-bar .entry-pick select { min-width: 240px; }
.entry-bar .entry-fields { gap: 14px; }
.entry-bar .entry-fields input[type="text"] { width: 240px; }
.entry-bar #entry-meta { margin-left: 8px; display: inline-flex; gap: 6px; align-items: center; }
.entry-bar select:disabled, .entry-bar input:disabled { opacity: 0.7; }

/* Whole-batch totals sit under the per-entry totals bar. */
.batch-totals-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: #f1f4f8;
  font-variant-numeric: tabular-nums;
}
.batch-totals-bar .lab { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.batch-totals-bar b { font-family: var(--mono); font-weight: 650; font-size: 13.5px; }
.batch-totals-bar .diff { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.batch-totals-bar .muted { font-size: 12px; }

/* Checkbox lines inside modal forms */
.check-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 10px 0 3px; }

/* Posting preview table inside the modal */
.modal .post-preview { margin: 4px 0 10px; }
.modal .post-preview .badge { white-space: nowrap; }

/* Fiscal calendar */
.legacy-note { font-size: 12.5px; }
.fy-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
#fy-periods input[type="date"] { width: 150px; }

/* Fiscal report views (R1–R3): controls, totals, notes, pager */
.report-controls { padding: 10px 12px 0; }
.report-results .tbl { margin-top: 10px; }
.report-note { color: var(--muted); font-size: 12px; padding: 10px 12px 12px; margin: 0; }
.report-error { color: var(--err); font-size: 12.5px; padding: 12px; background: var(--err-bg); border-top: 1px solid var(--err); }
.report-totals { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f7f9fb; }
.report-totals .lab { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.report-totals b { font-family: var(--mono); font-weight: 650; font-size: 13.5px; }
.pager-bar { padding: 0 12px 10px; margin: 0; }

/* Financial statements (F3/F4): grouped statement rows, flags, evidence */
.stmt-block { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.stmt-block h3 { font-size: 13px; margin: 2px 0 6px; }
.stmt-section td {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: #eef2f6; padding-top: 9px;
}
.stmt-group td { font-weight: 600; background: #f7f9fb; }
.stmt-total td { font-weight: 650; border-top: 1px solid var(--border-strong); }
.tbl tfoot tr.stmt-earnings td { font-weight: 700; }
.stmt-carryforward td { color: #1d4ed8; }
.stmt-verify td { color: var(--muted); font-style: italic; }
.stmt-flags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.stmt-scope { margin: 0 0 4px; padding-left: 18px; color: var(--muted); font-size: 12px; }
.stmt-scope li { margin: 2px 0; }
.stmt-reason { white-space: nowrap; }
/* RP1 sample reporting profile: literal native codes, leading identity block */
.stmt-native-code { white-space: pre-wrap; } /* keep fixed-width padding visible */
.stmt-profile { background: #f7f9fb; }
.stmt-native-list { margin: 4px 0 0; padding-left: 20px; }
.stmt-native-list li { margin: 1px 0; }
.stmt-profile-evidence { margin-top: 8px; }
.stmt-profile-evidence summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.stmt-profile-facts {
  display: grid; grid-template-columns: max-content minmax(120px, 1fr);
  gap: 3px 14px; margin: 8px 0 0;
}
.stmt-profile-facts dt {
  color: var(--muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.05em; align-self: baseline;
}
.stmt-profile-facts dd { margin: 0; font-size: 12px; overflow-wrap: anywhere; }

/* Tabulator theme alignment */
.tabulator { font-size: 13px; background: var(--panel); }
.tabulator .tabulator-header .tabulator-col {
  background: #fbfcfd;
  border-right: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.tabulator .tabulator-row .tabulator-cell { border-right: 1px solid var(--border); padding: 3px 8px; }
.tabulator .tabulator-row.tabulator-row-even { background: #ffffff; }
.tabulator .tabulator-row.tabulator-row-odd { background: #fbfcfd; }
.tabulator .tabulator-row .tabulator-cell.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tabulator .tabulator-cell.row-del-cell { text-align: center; padding: 0; }
.tabulator .tabulator-cell.row-del-cell .row-del {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.tabulator .tabulator-cell.row-del-cell .row-del:hover { color: var(--err); }
.tabulator .tabulator-cell.invalid { box-shadow: inset 0 0 0 2px var(--err); }
.row-del { font-size: 12px; line-height: 1; }
.tabulator .tabulator-edit-list .tabulator-edit-list-item.active { background: var(--accent); color: #fff; }

/* ---------- login ---------- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #22303f 0%, #3d5266 140%);
}
.login-card {
  width: 330px;
  background: var(--panel);
  border-radius: 8px;
  padding: 26px 28px 24px;
  box-shadow: 0 18px 50px rgba(10, 20, 30, 0.45);
}
.login-card h1 { font-size: 18px; margin-bottom: 2px; }
.login-card .sub { color: var(--muted); margin: 0 0 16px; font-size: 12.5px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 3px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 16px; height: 30px; }
.form-error { color: var(--err); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------- help drawer (htmx fragment) ---------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--panel);
  border-left: 1px solid var(--border-strong);
  box-shadow: -12px 0 30px rgba(15, 25, 40, 0.18);
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
  font-weight: 650;
}
.drawer-body { padding: 12px 16px 24px; overflow-y: auto; }
.help-doc h3 { font-size: 13.5px; margin: 4px 0 6px; }
.help-doc p, .help-doc li { font-size: 12.5px; color: #333c48; }
.help-doc ul { padding-left: 18px; margin: 6px 0; }
.help-doc kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: #eef1f4;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 4px;
}
.help-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.help-link {
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
}
.help-link:hover { background: #eef2f6; }
.help-link.active { background: var(--accent); border-color: #1f4664; color: #fff; }

/* ---------- toasts & modal ---------- */
.toasts {
  position: fixed;
  top: 50px;
  right: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.toast {
  background: #26313d;
  color: #eef2f6;
  border-radius: 6px;
  padding: 9px 12px;
  box-shadow: 0 8px 24px rgba(10, 20, 30, 0.35);
  cursor: pointer;
  font-size: 12.5px;
}
.toast.error { background: #7d1f19; }
.toast.ok { background: #14532d; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 26, 36, 0.55);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  width: 460px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(8, 16, 26, 0.5);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
  font-weight: 650;
}
.modal-body { padding: 14px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
}
.modal .kv { width: 100%; border-collapse: collapse; margin: 4px 0 10px; }
.modal .kv td { padding: 3px 6px 3px 0; }
.modal .kv td:last-child { text-align: right; font-family: var(--mono); }
.modal .warn-note {
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
  padding: 8px 10px;
  border-radius: 0 4px 4px 0;
  margin: 8px 0;
}
.modal .modal-inputs label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 3px; }
.modal .modal-inputs input { width: 100%; }
.modal .form-error { margin-top: 8px; }

/* ---------- paste import dialog ---------- */
.modal .paste-text {
  width: 100%;
  min-height: 130px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}
.paste-actions { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; }
.paste-preview { margin-top: 4px; }
.paste-note { font-size: 12px; }
.paste-scroll { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; }
.paste-scroll .tbl { margin: 0; }
.paste-summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.paste-summary b { font-family: var(--mono); font-weight: 650; font-size: 13px; }
.paste-summary .lab { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.paste-errors { border: 1px solid var(--err); border-radius: 4px; background: var(--err-bg); padding: 8px 10px; }
.paste-errors p { margin: 0 0 4px; font-size: 12.5px; }
.paste-errors ul { max-height: 180px; overflow: auto; margin: 0; padding-left: 16px; }
.paste-errors li { color: var(--err); font-size: 12.5px; }

.skeleton { color: var(--muted); padding: 30px; text-align: center; }

.modal:has(.paste-text) { width: 900px; }

/* Keep statement scope readable and every exception amount reachable. */
.statement-meta { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12px; }
.stmt-exceptions { overflow-x: auto; }

/* ---------- account structures (F2): segment settings editor ---------- */
.segments-editor input[type="number"] { width: 76px; }
.segments-editor input[type="text"] { width: 100%; max-width: 380px; }
.seg-add { margin: 10px 0 6px; display: flex; gap: 8px; align-items: center; }
.hint-line { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.modal .segments-editor { margin: 6px 0; }
.modal .hint-line { margin: 6px 0 2px; }

/* ---------- Accounts payable setup (AP1–AP3) ---------- */
/* Sidebar group caption between the GL view links and the AP links. */
.views .views-caption {
  display: block;
  margin-top: 6px;
  padding: 2px 14px 0 26px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Full-width selects inside AP modal forms (other modals keep their
 * existing compact select widths). */
.modal select.ap-wide { width: 100%; }
/* Terms due-date preview block inside the master form. */
.ap-preview { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 8px; }
.ap-preview > label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 3px; }
.ap-preview-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-preview-result { margin-top: 6px; }

/* ---------- Accounts payable invoices & reports (AP4–AP8) ---------- */
.badge.deleted { color: #6b7280; background: #f3f4f6; border: 1px solid #d1d5db; }
.tbl tbody tr.selected > td { background: #e7eef5; }
.tbl tbody tr.selected:hover > td { background: #dfe9f3; }

/* AP options grid on the Setup view (fixed policy fields + editable two). */
.ap-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px 18px;
}
.ap-options-grid label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 3px; }
.ap-options-grid input, .ap-options-grid select { width: 100%; }

/* AP invoice document form: dense field grid with full-width inputs. */
.ap-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px 18px;
  padding: 12px;
}
.ap-form-grid label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 3px; }
.ap-form-grid input, .ap-form-grid select { width: 100%; }
.ap-form-grid input[type="checkbox"] { width: auto; }
.ap-num-in { font-family: var(--mono); text-align: right; }
.ap-inline-note { display: block; font-size: 11.5px; margin-top: 3px; }
.ap-due-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ap-due-controls input[type="date"] { width: auto; }
.ap-hold-warning {
  margin: 10px 12px 0;
  padding: 8px 10px;
  border: 1px solid var(--warn);
  background: var(--warn-bg);
  border-radius: 4px;
  font-size: 12.5px;
}
.ap-hold-row { padding: 0 12px 8px; }
.ap-doc-grid-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 0;
}
.ap-doc-grid-head .spacer { flex: 1; }
.ap-grid-wrap { position: relative; margin: 0 12px 10px; }
.ap-doc-panel .panel { margin-top: 14px; }
.ap-gl-link-panel .panel-body { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ap-aging-controls { align-items: flex-end; }
.ap-scroll { max-height: 320px; overflow: auto; }
.ap-scroll .tbl { margin: 0; }
/* Distribution grid rows keep the Tabulator theme from the GL editor. */
.ap-grid-wrap .tabulator .tabulator-row .tabulator-cell.num { text-align: right; font-family: var(--mono); }

/* Shared modules and standalone workspaces. Native details supports Tab,
   Enter/Space and screen readers without a custom keyboard menu model. */
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 2000; padding: 8px 12px; background: var(--panel); }
.skip-link:focus { top: 8px; }
#sidebar details { margin: 4px 8px; }
#sidebar summary { cursor: pointer; padding: 8px; font-weight: 600; }
#sidebar details a { display: block; padding: 6px 12px; text-decoration: none; border-radius: 3px; }
#sidebar details a:hover, #sidebar details a.active { background: #e7eef5; }
#sidebar details a.active { font-weight: 600; }
a:focus-visible, button:focus-visible, summary:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.workspace-content { flex: 1; min-width: 0; overflow: auto; }
.workspace-content > main { width: 100%; max-width: 1400px; margin: 0 auto !important; padding: 24px !important; }
.workspace-content h1 { margin-bottom: 14px; }
.workspace-content h2 { margin: 16px 0 8px; }
.workspace-content form { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 16px; margin: 16px 0; }
.workspace-content label { display: inline-block; margin: 4px 8px 4px 0; }
.workspace-content button { cursor: pointer; padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--panel); }
.workspace-content textarea { max-width: 100%; }
#topbar a.brand { color: inherit; text-decoration: none; }
@media (max-width: 700px) {
  #frame { flex-direction: column; overflow: auto; }
  #sidebar { width: 100%; max-height: 240px; border-right: 0; border-bottom: 1px solid var(--border); }
  .workspace-content { overflow: visible; }
  #topbar { height: auto; min-height: 42px; flex-wrap: wrap; padding: 8px; gap: 8px; }
  .workspace-content > main { padding: 12px !important; }
}
#sidebar .views details a.active { color: var(--ink); }
.workspace-content textarea { height: auto; min-height: 140px; padding: 8px; font-family: var(--mono); }
.workspace-content select[multiple] { height: auto; min-height: 120px; }
.workspace-content input:not([type]), .workspace-content input[type="email"], .workspace-content input[type="tel"] {
  font: inherit; min-height: 26px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 4px;
}
.workspace-content table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; background: var(--panel); }
.workspace-content th, .workspace-content td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.workspace-content th { background: #eef2f6; }

/* Module grants narrow the workspace controls without changing their busy state. */
.module-permission-denied { display: none !important; }
