/* QBO Extender — "Redline" theme.
   Clean, modern, technical: white surfaces on a light neutral canvas, crisp
   hairline borders, soft flat shadows, a monospace technical voice for labels
   and figures, and an Oracle-style red (#C74634) as the single accent for
   actions, links, and active states. (Recolor/restyle only — class names and
   layout structure unchanged.) */

:root {
  color-scheme: light;

  /* Neutrals */
  --bg: #f3f4f6;            /* page canvas */
  --surface: #ffffff;       /* cards */
  --surface-2: #f7f8fa;     /* bands, input wells */
  --surface-3: #eceef1;     /* hover / raised */
  --ink: #17181b;           /* body text */
  --ink-soft: #54565c;      /* labels */
  --ink-mute: #8b8d94;      /* faint text / placeholders */

  /* Accent — Oracle Redwood red */
  --red: #c74634;
  --red-deep: #a3392a;
  --red-soft: rgba(199, 70, 52, 0.10);
  --ok: #2e7d52;            /* semantic success (status pills) */

  /* Lines & effects */
  --border: #e4e6ea;
  --border-strong: #d3d6dc;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-pop: 0 10px 28px -10px rgba(17, 24, 39, 0.22);
  --ring: 0 0 0 3px rgba(199, 70, 52, 0.18);

  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: var(--sans);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  min-height: 100vh;
  background-color: var(--bg);
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-deep); text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 650; line-height: 1.15; margin: 0; color: var(--ink); letter-spacing: -0.01em; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.num--neg { color: var(--red); }

/* ===== Masthead ===== */
.masthead {
  position: relative;
  z-index: 100; /* keep the nav dropdowns above page content */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.masthead__bar {
  max-width: 1100px; margin: 0 auto; padding: 13px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.wordmark { display: flex; align-items: center; gap: 10px; }
.wordmark__qbo {
  font-family: var(--mono);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  color: #fff; text-transform: uppercase;
  background: var(--red); border-radius: 5px; padding: 3px 8px;
}
.wordmark__name {
  font-family: var(--display);
  font-size: 1.2rem; font-weight: 650; letter-spacing: -0.01em; color: var(--ink);
}
.mast-nav { display: flex; align-items: center; gap: 6px; }
.mast-nav > a {
  font-size: 0.9rem; font-weight: 550; color: var(--ink-soft);
  padding: 7px 10px; border-radius: var(--radius-sm);
}
.mast-nav > a:hover { color: var(--red); background: var(--red-soft); text-decoration: none; }
.mast-nav .who { color: var(--ink-mute); font-size: 0.82rem; margin-left: 6px; }

/* Nav dropdown menus */
.navmenu { position: relative; display: inline-flex; }
.navmenu__trigger {
  font-family: var(--sans); font-size: 0.9rem; font-weight: 550;
  color: var(--ink-soft); background: transparent; border: 0;
  padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.navmenu:hover .navmenu__trigger,
.navmenu:focus-within .navmenu__trigger { color: var(--red); background: var(--red-soft); }
.navmenu__panel {
  position: absolute; top: 100%; right: 0; min-width: 200px;
  display: none; flex-direction: column;
  margin-top: 8px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 80;
}
.navmenu__panel::before { content: ""; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
.navmenu:hover .navmenu__panel,
.navmenu:focus-within .navmenu__panel { display: flex; }
.navmenu__panel a {
  font-size: 0.88rem; font-weight: 500; color: var(--ink);
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.navmenu__panel a:hover { color: var(--red); background: var(--red-soft); text-decoration: none; }

/* thin red accent rule under the masthead (was the guilloche) */
.guilloche { height: 2px; background: var(--red); }

/* ===== Layout ===== */
.wrap { max-width: 1100px; margin: 0 auto; padding: 30px 24px 90px; position: relative; z-index: 1; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 1.9rem; font-weight: 680; letter-spacing: -0.02em; }
.page-head .eyebrow { display: block; margin-bottom: 7px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 0.86rem; font-weight: 560;
  letter-spacing: 0;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-mute); }
.btn:active { transform: translateY(0.5px); }
.btn--primary {
  background: var(--red); border-color: var(--red); color: #fff;
}
.btn--primary:hover { background: var(--red-deep); border-color: var(--red-deep); color: #fff; }
.btn--danger { color: var(--red); border-color: var(--border-strong); background: var(--surface); }
.btn--danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn--ghost:hover { color: var(--red); background: var(--red-soft); border-color: transparent; }
.btn--sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }

/* ===== Cards / sheets ===== */
.sheet {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sheet__band {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0;
}
.sheet__body { padding: 20px 18px; }

/* ===== Fields ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
}
.input, .select {
  width: 100%; font-family: var(--sans); font-size: 0.92rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder { color: var(--ink-mute); }
.input:focus, .select:focus {
  outline: none; border-color: var(--red); box-shadow: var(--ring);
}
.input--num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.field-error { color: var(--red); font-size: 0.78rem; font-weight: 500; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }

/* ===== Ledger tables ===== */
.ledger { width: 100%; border-collapse: collapse; }
.ledger thead th {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mute);
  text-align: left; padding: 11px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.ledger thead th.r { text-align: right; }
.ledger tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger tbody tr:hover td { background: var(--surface-2); }
.ledger .doclink { font-family: var(--mono); font-weight: 600; color: var(--red); }
.ledger .doclink:hover { color: var(--red-deep); text-decoration: underline; text-underline-offset: 2px; }

.tag {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.02em; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 1px 9px;
}

/* reference-table cell utilities */
.ledger td.r { text-align: right; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-mute); }
.pill {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.02em;
  padding: 1px 9px; border-radius: 999px; border: 1px solid;
}
.pill--on { color: var(--ok); border-color: rgba(46, 125, 82, 0.4); background: rgba(46, 125, 82, 0.08); }
.pill--off { color: var(--ink-mute); border-color: var(--border-strong); }
code {
  font-family: var(--mono); font-size: 0.85em; color: var(--red-deep);
  background: var(--red-soft); padding: 1px 5px; border-radius: 4px;
}

/* ===== Definition grid ===== */
.defs { display: grid; grid-template-columns: max-content 1fr; gap: 11px 24px; margin: 0; }
.defs dt {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-mute); align-self: center;
}
.defs dd { margin: 0; }

/* ===== Document form: lines + live total ===== */
.lines-wrap { overflow-x: auto; }
.lines { width: 100%; border-collapse: collapse; min-width: 720px; }
.lines thead th {
  font-family: var(--mono); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-mute);
  text-align: left; padding: 8px 8px 10px; border-bottom: 1px solid var(--border);
}
.lines thead th.r { text-align: right; }
.lines tbody td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines .col-amount {
  font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right;
  padding-top: 16px; white-space: nowrap; color: var(--ink);
}
.lines .col-rm { text-align: center; width: 44px; }
.line-row.is-removed { display: none; }

.rm-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-mute);
  font-family: var(--mono); font-size: 1.1rem; line-height: 1;
  width: 30px; height: 30px; border-radius: var(--radius-sm); cursor: pointer; margin-top: 6px;
}
.rm-btn:hover { color: var(--red); border-color: var(--border-strong); background: var(--red-soft); }

/* running-total readout */
.totals {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 18px; border-top: 1px solid var(--border);
  background: var(--surface-2); flex-wrap: wrap;
  border-radius: 0 0 var(--radius) var(--radius);
}
.totals__note { font-size: 0.84rem; color: var(--ink-soft); max-width: 38ch; }
.totals__fig { text-align: right; }
.totals__fig .eyebrow { display: block; margin-bottom: 4px; }
.totals__amount {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(1.9rem, 5.5vw, 2.8rem); font-weight: 600; letter-spacing: -0.01em;
  line-height: 1; color: var(--ink);
}
.totals__amount.is-neg { color: var(--red); }

.form-actions { display: flex; gap: 12px; margin-top: 24px; align-items: center; }

/* ===== Notices ===== */
.notice {
  border: 1px solid var(--border); border-left: 3px solid var(--ink-mute);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 11px 14px; margin-bottom: 16px; font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.notice--error { border-left-color: var(--red); }

.empty { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty .eyebrow { display: block; margin-bottom: 8px; }

/* ===== Login card ===== */
.cert {
  position: relative; max-width: 380px; margin: 9vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px 28px; overflow: hidden;
}
.cert::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--red);
}
.cert h1 { font-size: 1.4rem; font-weight: 680; margin-bottom: 20px; }
.cert .field { margin-bottom: 15px; }

.pagination {
  display: flex; gap: 12px; align-items: center; margin-top: 18px;
  font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft);
}

/* ===== Tom Select ===== */
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; font-family: var(--sans); font-size: 0.92rem; color: var(--ink);
  box-shadow: none; min-height: 0;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--red); box-shadow: var(--ring);
}
.ts-control input { color: var(--ink); }
.ts-control input::placeholder { color: var(--ink-mute); }
.ts-control > .item { color: var(--ink); }
.ts-dropdown {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); background: var(--surface);
  margin-top: 5px; color: var(--ink); z-index: 60;
}
.ts-dropdown .option { padding: 8px 11px; font-size: 0.9rem; color: var(--ink); }
.ts-dropdown .option.active { background: var(--red-soft); color: var(--red-deep); }
.ts-dropdown .active { background: var(--red); color: #fff; }
.ts-dropdown .no-results { padding: 8px 11px; color: var(--ink-soft); font-size: 0.86rem; }

/* ===== A11y & motion ===== */
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 680px) {
  .masthead__bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .mast-nav { flex-wrap: wrap; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .totals { flex-direction: column; align-items: stretch; }
  .totals__fig { text-align: left; }
}

/* ===== Comments ===== */
.comment-form textarea { resize: vertical; min-height: 64px; }
.comment-list {
  list-style: none; margin: 22px 0 0; padding: 18px 0 0;
  border-top: 1px solid var(--border);
}
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: 0; }
.comment-head {
  display: flex; align-items: baseline; gap: 12px;
  font-size: 0.85rem;
}
.comment-author { font-weight: 650; color: var(--ink); }
.comment-meta {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-mute);
}
.comment-edit { margin-left: auto; font-size: 0.8rem; }
.comment-body {
  margin-top: 6px; font-size: 0.92rem; color: var(--ink);
  white-space: normal; word-break: break-word;
}
.comment-empty { padding: 12px 0; }

/* Audit field-change diff list within a timeline item */
.change-list {
  list-style: none; margin: 6px 0 0; padding: 0;
  font-size: 0.86rem; color: var(--ink);
}
.change-list li { padding: 2px 0; word-break: break-word; }
.change-list .muted { color: var(--ink-mute); }

/* ===== Document tabs (detail pages) ===== */
.doc-summary { display: flex; gap: 10px; align-items: center; margin-top: 9px; flex-wrap: wrap; }
.doc-summary .amount {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--ink);
}
.doc-summary .amount.is-neg { color: var(--red); }

.tabbar {
  display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.tabbtn {
  font-family: var(--sans); font-size: 0.9rem; font-weight: 560;
  color: var(--ink-soft);
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 16px; margin-bottom: -1px; cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.tabbtn:hover { color: var(--red); background: var(--red-soft); }
.tabbtn.is-active { color: var(--red); border-bottom-color: var(--red); }
.tabbtn .tabbtn__count {
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink-mute);
  margin-left: 6px;
}
.tabpanel { display: none; }
.tabpanel.is-active { display: block; }
/* Without JS, reveal everything so no content is trapped behind a hidden tab. */
.no-js .tabpanel { display: block; margin-bottom: 20px; }
.no-js .tabbar { display: none; }
