/* The Falcon ERP web app.
   Navy is the structure, white the page, cool grey the surfaces. Magenta, the
   falcon's colour, is kept for one job: the action you can take now.
   Green, amber and red mean status and nothing else. */
:root {
  --navy: #13294a;
  --navy-2: #1f3a63;
  --navy-3: #2c4a78;
  --ink: #13294a;
  --ink-2: #4b5a72;
  --ink-3: #7a879b;
  --line: #dde2ea;
  --line-2: #eef1f5;
  --surface: #f4f6fa;
  --page: #ffffff;
  --action: #d4145f;
  --action-ink: #ffffff;
  --action-soft: #fdeaf2;
  --ok: #17794b;
  --ok-soft: #e4f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --info: #5b3299;
  --info-soft: #efe8fa;
  --radius: 8px;
  --radius-lg: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Cambria, Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --focus: 0 0 0 3px rgba(212, 20, 95, 0.35);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--sans); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.num, td.num, .amount { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- Shell ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #dbe4f1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; text-decoration: none; color: #fff; }
.brand img { width: 34px; height: auto; }
.brand b { font: 600 18px/1.1 var(--serif); letter-spacing: .01em; }
.brand span { display: block; font-size: 11.5px; color: #9fb0c8; margin-top: 2px; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav h4 { margin: 18px 12px 6px; font: 600 12px var(--sans); color: #8ea2bf; letter-spacing: .02em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 7px; text-decoration: none; color: #dbe4f1; font-size: 14.5px; }
.nav a svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav a:hover { background: var(--navy-2); }
.nav a.on { background: #fff; color: var(--navy); font-weight: 600; }
.nav a.on svg { opacity: 1; color: var(--action); }
.nav .count { margin-left: auto; background: var(--action); color: #fff; border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 1px 7px; }
.nav a.on .count { background: var(--action); }
.side-foot { padding: 14px 20px; font-size: 12px; color: #8ea2bf; border-top: 1px solid var(--navy-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; padding: 12px 32px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.top .org { font-weight: 600; }
.top .org small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.top .spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.who b { display: block; font-size: 14px; }
.who small { display: block; color: var(--ink-3); font-size: 12.5px; }
.demo-flag { background: var(--info-soft); color: var(--info); font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.content { padding: 28px 32px 64px; max-width: 1240px; width: 100%; }

/* ---- Page heading ------------------------------------------------------------- */
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 { font: 600 30px/1.15 var(--serif); margin: 0; letter-spacing: -.005em; }
.head p { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.head .grow { flex: 1; min-width: 260px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13.5px; color: var(--ink-3); margin-bottom: 6px; }
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* ---- Buttons -------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px;
  border-radius: var(--radius); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c5cdd9; background: var(--surface); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn.primary:hover { background: #b80f50; border-color: #b80f50; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #efc2bd; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--surface); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- Status ------------------------------------------------------------------------ */
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px/1.5 var(--sans); padding: 2px 9px; border-radius: 999px; white-space: nowrap; vertical-align: middle;
  background: var(--surface); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.action { background: var(--action-soft); color: var(--action); }

/* ---- Surfaces ------------------------------------------------------------------------- */
.panel { border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.panel > h2, .panel > header { margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.panel > h2, .panel > header h2 { font: 600 17px var(--serif); margin: 0; }
.panel > header .grow { flex: 1; }
.panel .body { padding: 18px 20px; }
.panel + .panel { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); align-items: start; }
.grid.halves { grid-template-columns: 1fr 1fr; }
.stack > * + * { margin-top: 18px; }
.note { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.note.warn { background: var(--warn-soft); color: #6d4100; }
.note.ok { background: var(--ok-soft); color: #0f5a37; }
.note.bad { background: var(--bad-soft); color: #8a1c16; }
.note.info { background: var(--surface); color: var(--ink-2); }
.note b { color: inherit; }

/* ---- Tables ------------------------------------------------------------------------------- */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t .num { text-align: right; white-space: nowrap; }
.t tr.link { cursor: pointer; }
.t tr.link:hover td { background: #fafbfd; }
.t td .sub { display: block; color: var(--ink-3); font-size: 13px; }
.t td.strong { font-weight: 600; white-space: nowrap; }
.t th .sub { display: block; font-weight: 600; }
.t tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }

/* ---- Forms ---------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12.5px; }
.input, select.input, textarea.input { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 11px; background: #fff; width: 100%; }
.input:focus { outline: none; border-color: var(--action); box-shadow: var(--focus); }
textarea.input { resize: vertical; min-height: 72px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.lines-edit td { padding: 6px 6px; }
.lines-edit .input { padding: 6px 8px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }

/* ---- Facts (definition lists) ---------------------------------------------------------------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 20px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12.5px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---- The trail: each document's path, as a chain ------------------------------------------------ */
.trail { display: flex; align-items: center; flex-wrap: wrap; gap: 0; margin: 2px 0 20px; }
.trail .step { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: 13.5px; text-decoration: none; color: var(--ink); }
.trail .step small { color: var(--ink-3); font-size: 12px; }
.trail .step.here { background: var(--navy); border-color: var(--navy); color: #fff; }
.trail .step.here small { color: #b9c7db; }
.trail .step.todo { border-style: dashed; color: var(--ink-3); }
.trail .step .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.trail .step.todo .dot { background: var(--line); }
.trail .step.held .dot { background: var(--warn); }
.trail .link { width: 22px; height: 2px; background: var(--line); }
a.step:hover { border-color: var(--navy-3); }

/* ---- Home -------------------------------------------------------------------------------------------- */
.welcome h1 { font: 600 32px/1.15 var(--serif); margin: 0 0 4px; }
.welcome p { margin: 0 0 22px; color: var(--ink-2); }
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); align-items: center; }
.tasks li:last-child { border-bottom: 0; }
.tasks a.what { text-decoration: none; display: block; }
.tasks a.what b { display: block; font-size: 15px; }
.tasks a.what span { color: var(--ink-2); font-size: 13.5px; }
.tasks .ref { color: var(--ink-3); font-size: 13px; }
.tasks .amt { font-weight: 700; font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
.tasks .when { color: var(--ink-3); font-size: 12.5px; text-align: right; }
.tasks li:hover { background: #fafbfd; }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.figures > div { padding: 16px 20px; border-right: 1px solid var(--line-2); }
.figures > div:last-child { border-right: 0; }
.figures dt { font-size: 13px; color: var(--ink-2); }
.figures dd { margin: 4px 0 0; font: 600 24px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.figures dd small { font: 400 13px var(--sans); color: var(--ink-3); display: block; margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars i { display: block; width: 100%; background: var(--navy-3); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars div.now i { background: var(--action); }
.bars span { font-size: 11.5px; color: var(--ink-3); }
.cash li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.cash li:last-child { border-bottom: 0; }
.cash { list-style: none; margin: 0; padding: 0; }

/* ---- Timeline of approvals ------------------------------------------------------------------------- */
.events { list-style: none; margin: 0; padding: 0; }
.events li { position: relative; padding: 0 0 16px 22px; font-size: 14px; }
.events li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--navy); }
.events li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.events li:last-child::after { display: none; }
.events li.bad::before { background: var(--bad); }
.events li.warn::before { background: var(--warn); }
.events li.ok::before { background: var(--ok); }
.events b { display: block; }
.events span { color: var(--ink-2); font-size: 13px; }
.events q { display: block; color: var(--ink-2); font-style: italic; margin-top: 2px; }

/* ---- Dialog ------------------------------------------------------------------------------------------- */
dialog.dlg { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(19, 41, 74, .28); }
dialog.dlg.wide { width: min(920px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(19, 41, 74, .45); }
.dlg header { padding: 18px 22px 0; }
.dlg header h2 { margin: 0; font: 600 20px var(--serif); }
.dlg header p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.dlg .body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg footer { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line-2); }
.dlg .error { color: var(--bad); font-size: 14px; }

/* ---- Toast ------------------------------------------------------------------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: var(--radius); font-size: 14px; box-shadow: 0 10px 30px rgba(19, 41, 74, .3); max-width: 420px; }
.toast.bad { background: var(--bad); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .18s ease-out; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Tabs and filters --------------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button, .tabs a { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; }
.tabs .on { color: var(--ink); border-bottom-color: var(--action); }
.tabs .n { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font: 600 17px var(--serif); margin-bottom: 4px; }

/* ---- Matrix --------------------------------------------------------------------------------------------- */
.matrix { overflow-x: auto; }
.matrix table { border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line-2); padding: 7px 10px; white-space: nowrap; }
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 600; color: var(--ink-2); padding: 10px 6px; height: 150px; text-align: left; }
.matrix td.yes { color: var(--ok); font-weight: 700; text-align: center; }
.matrix td.no { color: var(--line); text-align: center; }
.matrix tr.area td { background: var(--surface); font-weight: 700; color: var(--ink-2); }

/* ---- Sign in ---------------------------------------------------------------------------------------------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; }
.signin .left { background: var(--navy); color: #fff; padding: 48px 44px; display: flex; flex-direction: column; justify-content: space-between; }
.signin .left img { width: 220px; height: auto; }
.signin .left p { color: #c3d0e2; max-width: 34ch; font-size: 15.5px; }
.signin .right { padding: 48px 56px; max-width: 900px; }
.signin h1 { font: 600 30px var(--serif); margin: 0 0 6px; }
.signin .right > p { color: var(--ink-2); margin: 0 0 24px; max-width: 64ch; }
.people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.people button { display: flex; gap: 12px; align-items: center; text-align: left; padding: 14px 16px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-lg); cursor: pointer; }
.people button:hover { border-color: var(--navy-3); background: #fafbfd; }
.people b { display: block; }
.people small { color: var(--ink-2); font-size: 13.5px; display: block; }
.people em { font-style: normal; color: var(--ink-3); font-size: 12.5px; display: block; margin-top: 2px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav h4 { display: none; }
  .grid.two, .grid.halves { grid-template-columns: 1fr; }
  .figures { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .signin { grid-template-columns: 1fr; }
  .people { grid-template-columns: 1fr; }
  .content, .top { padding-left: 16px; padding-right: 16px; }
  .top { flex-wrap: wrap; gap: 10px; }
  .top .org small, .who > div { display: none; }
  .head h1, .welcome h1 { font-size: 26px; }
  .tasks li { padding: 12px 14px; }
}

/* Wide tables scroll inside their panel rather than spilling past it. */
.grid > *, .stack > * { min-width: 0; }
.panel { overflow-x: auto; }

/* ---- Ledgers and reports ------------------------------------------------------------------------- */
.late { color: var(--bad); }
.t.tb th.grp { text-align: center; border-bottom: 1px solid var(--line-2); }
.t tr.group td { font: 600 14px var(--serif); color: var(--ink); background: var(--surface); padding-top: 9px; padding-bottom: 9px; }
.t tbody + tbody tr.group td { border-top: 1px solid var(--line); }
.cash.parties li a { color: inherit; text-decoration: none; }
.t.tb td a { color: inherit; text-decoration: none; }
.t.tb tr.link:hover td a { text-decoration: underline; }
.t.ageing { table-layout: fixed; }
.t.ageing th:first-child { width: 26%; }
.t.ageing + .t.ageing { border-top: 1px solid var(--line); }

/* ---- Financial statements ---------------------------------------------------------------------- */
.t.statement td:first-child { width: 60%; }
.t.statement th.num { white-space: nowrap; }
.t.statement .prior { color: var(--ink-2); }
.t.statement tr.subtotal td { font-weight: 600; border-top: 1px solid var(--line); }
.t.statement tr.grand td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); background: var(--surface); }
.t.statement tr.section td { font: 600 15px var(--serif); color: var(--ink); padding-top: 18px; border-bottom: 1px solid var(--line); }
.t.statement tr.drill td { background: #fafbfd; font-size: 13.5px; padding-top: 7px; padding-bottom: 7px; color: var(--ink-2); }
.t.statement tr.drill td a { color: inherit; text-decoration: none; }
.t.statement tr.drill:hover td a { text-decoration: underline; }
.amount.muted { color: var(--ink-3); }
.t.statement .chev { width: 10px; height: 10px; margin: 0 8px 0 -18px; color: var(--ink-3); vertical-align: 0; }
.t.accounts td { padding: 7px 0; border-bottom: 1px dashed var(--line-2); font-size: 13.5px; }
.t.accounts td a { color: inherit; text-decoration: none; }
.t.accounts tr.link:hover td a { text-decoration: underline; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.foot-note { color: var(--ink-3); font-size: 12.5px; margin: 0; padding: 12px 20px; border-top: 1px solid var(--line-2); }

/* ---- Bank reconciliation ----------------------------------------------------------------------- */
.muted-label { color: var(--ink-3); font-size: 13px; }
.t tr.picked td { background: var(--action-soft, #fdeef4); }
.t tr.suggest td:last-child { box-shadow: inset -3px 0 0 var(--action); }
.row-acts { white-space: nowrap; text-align: right; }
.row-acts .btn + .btn { margin-left: 4px; }
.matchbar { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 18px; align-items: center; padding: 12px 16px; background: var(--navy); color: #fff;
  border-radius: var(--radius-lg); box-shadow: 0 6px 24px rgba(19, 41, 74, .25); }
.matchbar b { font-variant-numeric: tabular-nums; }
.matchbar .ok { color: #8be0b4; } .matchbar .late { color: #ffb4a8; }
.matchbar .grow { flex: 1; }
.matchbar .btn.quiet { color: #dbe4f1; }
.recon-sum { margin: 0; }
.recon-sum > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.recon-sum dt { font-size: 13.5px; color: var(--ink-2); }
.recon-sum dt small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.recon-sum dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.recon-sum .tot { border-top: 1px solid var(--line); border-bottom: 0; }
.recon-sum .tot dt { color: var(--ink); font-weight: 600; }
.recon-sum .diff { border: 0; margin-top: 6px; padding: 10px 12px; border-radius: var(--radius); }
.recon-sum .diff.ok { background: var(--ok-soft); } .recon-sum .diff.bad { background: var(--bad-soft); }
.recon-sum .diff dt { color: var(--ink); font-weight: 700; }
.recon-note { margin: 12px 0 0; font-size: 13.5px; display: flex; gap: 8px; align-items: flex-start; }
.recon-note.ok { color: #0f5a37; } .recon-note.bad { color: #8a1c16; }
.recon-note svg { flex: none; margin-top: 3px; }
.t td.nowrap { white-space: nowrap; }
