/*
 * saas-books UI.
 *
 * Hand-authored rather than Tailwind, deliberately: no build step means no purge, and the
 * source app was bitten exactly there -- classes added to a Blade template after a build
 * silently vanished from the compiled CSS. It also gives direct control over the numeric
 * typography a ledger needs, which is the whole visual job here.
 *
 * Every figure column uses tabular-nums so digits align vertically. In an accounting
 * interface that is not decoration: a column of proportional digits cannot be scanned for
 * a misplaced decimal, which is the single most common thing a person is looking for.
 */
:root {
  --paper: #f6f7f9;
  --surface: #ffffff;
  --sunk: #eef1f4;
  --rule: #d7dde4;
  --rule-strong: #b9c3cd;
  --ink: #171c22;
  --ink-soft: #3d4752;
  --ink-mute: #6a7684;
  --accent: #2a4a6b;
  --accent-lift: #3d7ea6;
  --debit: #1f4b6e;
  --credit: #6b4a1f;
  --crit: #a8322d;
  --crit-bg: #f7e9e7;
  --good: #2c6349;
  --good-bg: #e6f0ea;
  --warn: #7e6318;
  --warn-bg: #f6f0de;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-lift); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-lift); outline-offset: 2px;
}

/* ---- shell ---- */
.masthead {
  background: var(--surface); border-bottom: 1px solid var(--rule);
  padding: 0 1.25rem;
}
.masthead-inner {
  max-width: 78rem; margin: 0 auto; display: flex; align-items: center;
  gap: 1.5rem; min-height: 3.5rem; flex-wrap: wrap;
}
.brand { font-family: var(--serif); font-size: 1.05rem; letter-spacing: -.01em; }
.brand span { color: var(--ink-mute); font-family: var(--sans); font-size: .78rem; display: block; }
nav.primary { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
nav.primary a {
  padding: .4rem .7rem; border-radius: 3px; text-decoration: none;
  color: var(--ink-soft); font-size: .9rem;
}
nav.primary a:hover { background: var(--sunk); }
nav.primary a[aria-current="page"] { background: var(--accent); color: #fff; }

.banner {
  background: var(--warn-bg); border-bottom: 1px solid var(--rule);
  color: var(--warn); font-size: .85rem; padding: .55rem 1.25rem; text-align: center;
}

main { max-width: 78rem; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }

h1 { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; margin: 0 0 .25rem;
     letter-spacing: -.01em; }
.subtitle { color: var(--ink-mute); font-size: .9rem; margin: 0 0 1.5rem; }
h2 { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; margin: 2rem 0 .75rem; }

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 3px;
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
         gap: 1px; background: var(--rule); border: 1px solid var(--rule);
         border-radius: 3px; overflow: hidden; margin-bottom: 1.5rem; }
.tile { background: var(--surface); padding: .9rem 1rem; }
.tile dt { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase;
           color: var(--ink-mute); margin-bottom: .3rem; }
.tile dd { margin: 0; font-family: var(--serif); font-size: 1.5rem; line-height: 1.1;
           font-variant-numeric: tabular-nums; }
.tile dd small { display: block; font-family: var(--sans); font-size: .75rem;
                 color: var(--ink-mute); margin-top: .3rem; }

/* ---- ledger tables ---- */
.scroll { overflow-x: auto; }
table.ledger { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 34rem; }
table.ledger th, table.ledger td { padding: .45rem .6rem; border-bottom: 1px solid var(--rule);
                                   text-align: left; vertical-align: top; }
table.ledger thead th {
  font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; font-weight: 500;
  color: var(--ink-mute); border-bottom: 1px solid var(--rule-strong); white-space: nowrap;
}
table.ledger tbody tr:hover { background: var(--sunk); }
/* Money and any digit column: tabular figures, right aligned, so a stray decimal shows. */
table.ledger .num, table.ledger th.num {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
  font-feature-settings: "tnum";
}
table.ledger .code { font-family: var(--mono); font-size: .84rem; white-space: nowrap; }
table.ledger tfoot td { border-top: 2px solid var(--ink); border-bottom: none;
                        font-weight: 600; padding-top: .6rem; }
table.ledger tr.subtotal td { border-top: 1px solid var(--rule-strong); font-weight: 600; }
table.ledger tr.section td { background: var(--sunk); font-weight: 600; font-size: .82rem;
                             letter-spacing: .04em; text-transform: uppercase;
                             color: var(--ink-soft); }
.debit { color: var(--debit); }
.credit { color: var(--credit); }
.zero { color: var(--ink-mute); }

/* A negative figure is shown in parentheses, the accounting convention. A leading minus
   is easy to miss at the left edge of a number; brackets change the shape of the whole
   cell. */
.neg { color: var(--crit); }

/* ---- proof line ---- */
.proof { display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem;
         padding: .3rem .6rem; border-radius: 3px; font-variant-numeric: tabular-nums; }
.proof.ok { background: var(--good-bg); color: var(--good); }
.proof.bad { background: var(--crit-bg); color: var(--crit); font-weight: 600; }

/* ---- forms ---- */
form.stack { display: flex; flex-direction: column; gap: .9rem; max-width: 26rem; }
label { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: .45rem .55rem; border: 1px solid var(--rule-strong);
  border-radius: 3px; font: inherit; background: var(--surface); color: var(--ink);
}
input[type=number], input.money { font-variant-numeric: tabular-nums; text-align: right; }
button, .btn {
  font: inherit; padding: .45rem .9rem; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  text-decoration: none; display: inline-block;
}
button.secondary, .btn.secondary { background: var(--surface); color: var(--ink-soft);
                                   border-color: var(--rule-strong); }
.errors { background: var(--crit-bg); border: 1px solid var(--crit); color: var(--crit);
          padding: .7rem .85rem; border-radius: 3px; font-size: .88rem; margin-bottom: 1rem; }
.errors ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.hint { font-size: .8rem; color: var(--ink-mute); margin-top: .25rem; }
.flash { background: var(--good-bg); border: 1px solid var(--good); color: var(--good);
         padding: .7rem .85rem; border-radius: 3px; font-size: .88rem; margin-bottom: 1rem; }

.centered { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.centered .card { width: 100%; max-width: 24rem; }

.empty { color: var(--ink-mute); font-size: .9rem; padding: 1.5rem 0; text-align: center; }

/* ==========================================================================
   Reporting depth: general ledger, agings, cash flow, statements, comparatives.
   Same rules as above -- tabular figures everywhere a number appears, negatives in
   parentheses, and nothing that changes what a figure means without changing the figure.
   ========================================================================== */

/* ---- the report index ---- */
.report-index { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
                gap: 1px; background: var(--rule); border: 1px solid var(--rule);
                border-radius: 3px; overflow: hidden; }
.report-index a { background: var(--surface); padding: 1rem 1.1rem; text-decoration: none;
                  display: block; color: inherit; }
.report-index a:hover { background: var(--sunk); }
.report-index strong { font-family: var(--serif); font-weight: 400; font-size: 1.05rem;
                       display: block; color: var(--accent); }
.report-index span { display: block; color: var(--ink-mute); font-size: .82rem;
                     margin-top: .3rem; line-height: 1.45; }

/* ---- filter bars ---- */
form.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
form.filters > div { min-width: 9rem; }
form.filters select[multiple] { min-height: 7rem; }

/* ---- general ledger ---- */
/* An account's own heading row inside a continuous ledger table. Heavier than a section
   rule because the running balance restarts under it, and a reader who misses the break
   reads one account's balance as another's. */
table.ledger tr.account-head td { background: var(--surface); border-top: 2px solid var(--ink);
                                  border-bottom: 1px solid var(--rule-strong);
                                  padding-top: .8rem; font-weight: 600; }
table.ledger tr.account-head .code { font-size: .95rem; }
table.ledger tr.opening td, table.ledger tr.closing td { background: var(--sunk); font-weight: 600; }
.split { color: var(--ink-mute); font-size: .78rem; font-family: var(--mono); }
.tag { display: inline-block; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
       padding: .05rem .35rem; border-radius: 2px; background: var(--sunk); color: var(--ink-mute);
       vertical-align: .08em; }
.tag.reversal { background: var(--crit-bg); color: var(--crit); }
.tag.void { background: var(--crit-bg); color: var(--crit); }

/* ---- aging ---- */
table.aging th.num, table.aging td.num { min-width: 6.5rem; }
table.aging tr.customer-total td { border-top: 1px solid var(--rule-strong); font-weight: 600; }
table.aging tr.detail td { color: var(--ink-soft); font-size: .85rem; }
table.aging tr.detail td:first-child { padding-left: 1.6rem; }
.bucket-late { color: var(--crit); }

/* ---- comparative ---- */
/* Favourable and unfavourable are NOT "positive and negative": revenue up is good and
   expenses up is not, so the direction is decided per section in the template and only
   the colour is decided here. */
.var-good { color: var(--good); }
.var-bad { color: var(--crit); }
.pct { font-size: .82rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; }

/* ---- customer statement ---- */
.statement-head { display: flex; gap: 2rem; flex-wrap: wrap; justify-content: space-between;
                  align-items: flex-start; }
.statement-head .who { font-family: var(--serif); font-size: 1.1rem; }
.statement-head .who small { display: block; font-family: var(--sans); font-size: .82rem;
                             color: var(--ink-mute); }
.amount-due { text-align: right; }
.amount-due dt { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase;
                 color: var(--ink-mute); }
.amount-due dd { margin: .15rem 0 0; font-family: var(--serif); font-size: 1.7rem;
                 font-variant-numeric: tabular-nums; }

/* Print: a statement is a document that gets sent, so the chrome comes off. */
@media print {
  .masthead, .banner, form, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; margin-bottom: 1rem; }
}

/* ---- grouped navigation ---- */
.navgroup { position: relative; }
.navgroup-label {
  display: inline-block; padding: .4rem .7rem; border-radius: 3px;
  color: var(--ink-soft); font-size: .9rem; cursor: default;
}
.navgroup:hover .navgroup-label, .navgroup:focus-within .navgroup-label { background: var(--sunk); }
.navgroup-items {
  display: none; position: absolute; top: 100%; left: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 3px;
  box-shadow: 0 8px 24px -12px rgba(23,28,34,.35); min-width: 12rem; padding: .3rem;
}
/* Hover AND focus-within, so the menu is reachable from the keyboard rather than being
   a mouse-only affordance. */
.navgroup:hover .navgroup-items, .navgroup:focus-within .navgroup-items { display: block; }
.navgroup-items a { display: block; white-space: nowrap; }

/* ==========================================================================
   Banking: statement import, the match queue, reconciliation, rules.

   Appended as its own block rather than woven into the sections above, so that
   this area can be read -- and changed -- without touching a line another screen
   depends on.
   ========================================================================== */

/* A card that explains a consequence rather than holding data. Tinted, because the
   sentence it carries ("importing posts nothing", "a rule only suggests") is the one
   thing on the page a person must not skim past. */
.card.note { background: var(--sunk); border-color: var(--rule-strong); }
.card.note p { max-width: 52rem; font-size: .88rem; }
.card.note ul { max-width: 52rem; font-size: .88rem; margin: .5rem 0 0; padding-left: 1.1rem; }
.card.note li { margin-bottom: .35rem; }

/* Outcome tags in the import preview and the match queue. Deliberately quiet: a
   duplicate is not an error -- it is the idempotency working -- so it is grey, while
   only a posting, which is irreversible, gets a colour that stops the eye. */
.tag.new { background: var(--good-bg); color: var(--good); }
.tag.dup { background: var(--sunk); color: var(--ink-mute); }
.tag.ok { background: var(--good-bg); color: var(--good); }
.tag.posted { background: var(--warn-bg); color: var(--warn); }
.tag.rule { background: var(--sunk); color: var(--accent); }

/* ---- the match queue ---- */
/* The decision row sits under its bank line and belongs to it, so it carries no rule of
   its own -- the rule under the line above would otherwise read as a separator between
   the two halves of one thing. */
table.ledger tr.decide td { border-bottom: 1px solid var(--rule-strong); padding-top: 0; }
table.ledger tr.decide:hover { background: transparent; }
tr.decide summary { cursor: pointer; font-size: .85rem; color: var(--accent-lift); }
.decide-body { padding: .8rem 0 .4rem; max-width: 60rem; }
.decide-body h3 { font-family: var(--serif); font-weight: 400; font-size: 1rem;
                  margin: 1.1rem 0 .5rem; }
.decide-body h3:first-child { margin-top: .4rem; }
.decide-body table.ledger { min-width: 30rem; }

/* ---- the reconciliation difference ----
   One figure, large, and its own colour. The difference is the entire output of a
   reconciliation: a non-zero one means something has been FOUND -- a transaction the
   books are missing, one the bank has not processed, a transposed figure -- and it is
   the only evidence of it. A number that has to be picked out of a table of similar
   numbers is a number that gets skimmed past, which is how a month gets signed off
   while it is out by ninety cents. */
.recon-head {
  display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between;
  align-items: center; border: 1px solid var(--rule); border-radius: 3px;
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; background: var(--surface);
}
.recon-head.is-balanced { background: var(--good-bg); border-color: var(--good); }
.recon-head.is-off { background: var(--crit-bg); border-color: var(--crit); }
.recon-diff { display: flex; flex-direction: column; }
.recon-label { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
.recon-figure { font-family: var(--serif); font-size: 2.6rem; line-height: 1.05;
                font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.recon-sub { font-size: .8rem; margin-top: .2rem; }
.recon-head.is-balanced .recon-label, .recon-head.is-balanced .recon-figure,
.recon-head.is-balanced .recon-sub { color: var(--good); }
.recon-head.is-off .recon-label, .recon-head.is-off .recon-figure,
.recon-head.is-off .recon-sub { color: var(--crit); }
.recon-parts { display: flex; gap: 1.75rem; flex-wrap: wrap; margin: 0; }
.recon-parts dt { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase;
                  color: var(--ink-mute); }
.recon-parts dd { margin: .1rem 0 0; font-variant-numeric: tabular-nums;
                  font-feature-settings: "tnum"; font-size: 1.05rem; }

/* A file input is the one control the form rules above do not reach, and left alone it
   sits a full line taller than everything beside it. */
input[type=file] { width: 100%; padding: .35rem 0; font: inherit; font-size: .88rem; }

/* Document actions: print or send, offered on the document itself rather than only from
   the Documents and Email index screens. Laid out with gap rather than per-button margins
   so the row stays even when the optional buttons are absent, and marked no-print because
   a printed invoice should not carry its own "Download PDF" button. */
.doc-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0 0 1rem; }
.doc-actions form { margin: 0; }
@media print { .doc-actions { display: none; } }

/* Pagination. Laid out with space-between so the row count sits at one end and the controls
   at the other, and marked no-print because a printed list is whatever was on the page. */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
         flex-wrap: wrap; margin-top: .75rem; }
.pager-links { display: flex; align-items: center; gap: .5rem; }
.pager [aria-disabled="true"] { opacity: .45; pointer-events: none; }
@media print { .pager { display: none; } }
