/* Tiny stylesheet — keeps forms readable without dragging in a CSS framework. */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 720px;
  margin: 2em auto;
  padding: 0 1em;
  color: #222;
  line-height: 1.4;
}

/* Page header — scoped to direct child of body so it doesn't bleed into
   semantic <header> elements inside reports, modals, etc. */
body > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #7b1e3a;   /* the burgundy house colour */
  padding-bottom: .5em;
  margin-bottom: 1.5em;
  gap: 1em;
  flex-wrap: wrap;
}
body > header h1 { margin: 0; font-size: 1.4em; color: #7b1e3a; }
body > header .header-title {
  display: flex;
  align-items: center;
  gap: .75em;
}
body > header nav {
  display: flex;
  align-items: center;
  gap: 1em;
  font-size: .9em;
}

/* Database environment badge — colour-coded by DB_NAME suffix.
   .env-live  -> green  (real data)
   .env-test  -> amber  (frozen test fixture)
   .env-other -> grey   (anything else, e.g. a custom DB) */
.env-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .8em;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid;
  white-space: nowrap;
}
.env-badge.env-live  { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.env-badge.env-test  { background: #fff3cd; color: #856404; border-color: #ffeeba; }
.env-badge.env-other { background: #e2e3e5; color: #383d41; border-color: #d6d8db; }

/* Period-lock badge — distinct rust red so it doesn't clash with the
   green/amber env badges. Visible whenever any period_locks row exists. */
.lock-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .8em;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid #f5c6cb;
  background: #f8d7da;
  color: #721c24;
  white-space: nowrap;
}

/* --- Year-End Close --- */

.year-end-close-form    { margin: 1.5em 0; }
.year-end-close-confirm { margin: 1.5em 0; }

.year-end-close-confirm .profit { color: #1b7f1b; }
.year-end-close-confirm .loss   { color: #b03030; }

/* Closing-journal preview table — fixed columns so the layout doesn't
   shift between confirm previews of different shapes. */
.yec-table {
  width: 100%;
  margin: 1em 0 1.5em;
  table-layout: fixed;
}
.yec-table col.col-drcr   { width: 70px;  }
.yec-table col.col-acct   { width: 120px; }
.yec-table col.col-name   { width: auto;  }
.yec-table col.col-amount { width: 140px; }

/* The 3100 balancing row stands out so the auditor can find it at a glance. */
.yec-table tr.yec-balancing-entry td {
  background: #f4ecee;
  font-weight: 600;
  border-top: 2px solid #7b1e3a;
}

.yec-warning-panel {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  background: #fff8d8;
  border: 1px solid #e8d27a;
  border-radius: 6px;
}
.yec-warning-panel ol { margin: .5em 0 0 1.5em; padding: 0; }
.yec-warning-panel ol li { margin: .25em 0; }

.year-end-close-confirm .confirm-actions {
  display: flex;
  gap: 1em;
  align-items: center;
  margin-top: 1em;
}
.year-end-close-confirm .btn-secondary {
  text-decoration: none;
  padding: .5em 1em;
}

/* --- Period Locks admin page --- */

.period-lock-current { margin: 1.5em 0; }
.period-lock-current .locked   { color: #721c24; font-size: 1.05em; }
.period-lock-current .unlocked { color: #555;    font-style: italic; }

.period-lock-create   { margin: 1.5em 0; }
.period-lock-history  { margin: 2em 0; }

/* Confirmation panel — yellow background to flag "this is a destructive
   action requiring extra attention". Buttons sit in a flex row at the
   bottom so Cancel sits right next to the confirm button. */
.period-lock-confirm {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  background: #fff8d8;
  border: 1px solid #e8d27a;
  border-radius: 6px;
}
.period-lock-confirm .warning {
  color: #b03030;
  font-weight: bold;
  margin-top: 1em;
}
.period-lock-confirm .confirm-actions {
  display: flex;
  gap: 1em;
  align-items: center;
  margin-top: 1em;
}
.period-lock-confirm .btn-secondary {
  text-decoration: none;
  padding: .5em 1em;
}

/* Version footer — small, grey, right-aligned, hidden in print. */
footer.page-footer {
  margin-top: 3em;
  padding: .5em 0;
  border-top: 1px solid #eee;
  text-align: right;
  font-size: .75em;
  color: #888;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

h2 { margin-top: 0; }

a { color: #7b1e3a; }

form.card {
  border: 1px solid #ddd;
  background: #fafafa;
  padding: 1em 1.25em;
  border-radius: 6px;
  max-width: 420px;
}

form label {
  display: block;
  margin: .75em 0;
  font-size: .95em;
}
form input {
  display: block;
  padding: .45em .55em;
  font-size: 1em;
  width: 100%;
  margin-top: .25em;
  border: 1px solid #bbb;
  border-radius: 4px;
}
form input:focus { outline: 2px solid #7b1e3a; outline-offset: 1px; }

form button {
  margin-top: .5em;
  padding: .5em 1.2em;
  font-size: 1em;
  cursor: pointer;
  background: #7b1e3a;
  color: #fff;
  border: 1px solid #5c1229;
  border-radius: 4px;
}
form button:hover { background: #5c1229; }
form.inline { display: inline; }
form.inline button {
  background: #fff;
  color: #7b1e3a;
  border-color: #7b1e3a;
  padding: .25em .75em;
  font-size: .9em;
}
form.inline button:hover { background: #f8eef1; }

.flashes { list-style: none; padding: 0; margin: 0 0 1em 0; }
.flash {
  padding: .6em 1em;
  border-radius: 4px;
  margin-bottom: .5em;
}
.flash-info    { background: #f6e8ec; border: 1px solid #aac4ff; }
.flash-success { background: #e6f6e6; border: 1px solid #9bd49b; }
.flash-error   { background: #fce4e4; border: 1px solid #f3a8a8; }

.notice {
  background: #fff8d8;
  padding: .6em 1em;
  border: 1px solid #e8d27a;
  border-radius: 4px;
  margin-bottom: 1em;
}

ul { padding-left: 1.5em; }
ul li { margin: .25em 0; }

/* --- Main menu buttons (Phase 3) --- */

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: .5em;
  margin: 1.5em 0;
  max-width: 480px;
}

.menu-button-form { margin: 0; }

/* --- Home: menu beside the dashboard (menu.html, services/dashboard.py) --- */
body:has(.home) { max-width: 1240px; }
.home { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.5em; align-items: start; }
.home-menu .menu-buttons { margin-top: .5em; }
.home-menu .menu-button { padding: .55em .7em; }
.home-menu .menu-hint { display: none; }   /* the narrow column has no room; the screens say it */
.chart-empty { color: var(--ink-3); font-size: .9em; padding: 2em 0; text-align: center; }
.home-menu .menu-footer { margin-top: 1em; line-height: 1.8; }
@media (max-width: 860px) { .home { grid-template-columns: minmax(0, 1fr); } .home-menu { order: 2; } }

:root {   /* chart and figure colours: home dashboard, Sales and Purchases */
  --series-1: #9e2f4b;     /* burgundy and dark gold: validated as a pair (dataviz validator) */
  --series-2: #b8860b;
  --ink-2: #52514e;
  --ink-3: #6f6e69;
  --grid: #e4e3df;
  --good: #1b7f1b;
  --bad: #b03030;
}
.home-board h2 { margin-top: 0; }
.dash-card { background: #fafaf9; border: 1px solid #e4e3df; border-radius: 6px; padding: .8em 1em; margin: 0 0 1em; overflow-x: auto; }
.dash-card h3 { margin: 0 0 .5em; font-size: 1em; }
/* Status pills the payment run uses (pay_run.html); the same as the
   Inbox's, so it doesn't matter which change arrives first. */
.pill-warn { background: #fdf3dc; color: #7a5300; border-color: #ecd49a; }
.pill-bad { background: #fce4e4; color: #8f1d1d; border-color: #f3a8a8; }
.dash-tasks { list-style: none; margin: 0; padding: 0; }
.dash-tasks li { padding: .25em 0; display: flex; gap: .5em; align-items: baseline; }
.task-icon { display: inline-flex; width: 1.3em; height: 1.3em; border-radius: 50%; justify-content: center;
             align-items: center; font-size: .8em; font-weight: bold; color: #fff; flex: none; }
.task-todo .task-icon { background: #c97a00; }
.task-ok .task-icon { background: var(--good); }
.task-ok { color: var(--ink-2); }

.dash-period { color: var(--ink-3); font-size: .9em; margin: 0 0 .4em; }
.dash-tiles, .dash-banks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: .8em; margin-bottom: 1em; }
.dash-tile, .dash-bank { display: flex; flex-direction: column; gap: .15em; padding: .7em .9em; border: 1px solid #e4e3df;
                         border-radius: 6px; background: #fff; color: inherit; text-decoration: none; }
.dash-tile:hover, .dash-bank:hover { border-color: var(--series-1); }
.tile-label, .bank-name { font-size: .9em; color: var(--ink-2); }
.bank-number { font-size: .8em; color: var(--ink-3); }
.tile-value, .bank-balance { font-size: 1.45em; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-hero .tile-value { font-size: 1.8em; }
.tile-value.negative, .bank-balance.negative { color: var(--bad); }
.tile-delta { font-size: .85em; font-weight: 600; }
.tile-delta.good { color: var(--good); }
.tile-delta.bad { color: var(--bad); }
.tile-delta.flat { color: var(--ink-3); }
.tile-note { font-size: .8em; color: var(--ink-3); }

.dash-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 1em; }
.dash-chart { margin: 0 0 1em; }
.dash-chart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5em; }
.chart-legend { display: flex; gap: 1em; font-size: .85em; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: .35em; }
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis-zero { stroke: #b9b8b2; stroke-width: 1; }
svg.chart .tick { font-size: 11px; fill: var(--ink-3); }
svg.chart .end-label { font-size: 11px; fill: var(--ink-2); }
svg.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg .mark-s1 { stroke: var(--series-1); stroke-width: 2; }
svg .mark-s2 { stroke: var(--series-2); stroke-width: 2; }
svg .fill-s1 { fill: var(--series-1); }
svg .fill-s2 { fill: var(--series-2); }
svg.chart .dot { stroke: #fafaf9; stroke-width: 2; }
svg.chart .crosshair { stroke: #9a9993; stroke-width: 1; }
svg.chart .hit { fill: transparent; cursor: default; outline: none; }
svg.chart .hit.hover { fill: rgba(158, 47, 75, .06); }
.chart-tip { position: absolute; top: 0; background: #fff; border: 1px solid #d6d5d0; border-radius: 4px;
             padding: .35em .6em; font-size: .85em; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,.08);
             white-space: nowrap; }
.tip-title { color: var(--ink-3); font-size: .9em; }
.tip-key { display: inline-block; width: 12px; height: 2px; margin-right: .4em; vertical-align: middle; }
.key-s1 { background: var(--series-1); }
.key-s2 { background: var(--series-2); }
.chart-table summary { cursor: pointer; font-size: .85em; color: var(--ink-2); margin-top: .3em; }

.menu-button {
  display: flex;
  align-items: center;
  gap: 1em;
  padding: .9em 1.25em;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  text-decoration: none;
  color: #222;
  font-size: 1.05em;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.menu-button:hover {
  background: #f7f0f2;
  border-color: #7b1e3a;
}
.menu-button .menu-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  background: #7b1e3a;
  color: #fff;
  font-weight: bold;
  font-size: .9em;
  flex-shrink: 0;
}
.menu-button .menu-label { flex: 1; }
.menu-button .menu-hint {
  font-size: .8em;
  color: #777;
  font-style: italic;
}
.menu-button--logout .menu-num { background: #888; }

.menu-footer {
  margin-top: 2em;
  font-size: .9em;
  color: #555;
}

/* --- Add Users screen (Phase 4) --- */

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin: .5em 0 1.5em;
  font-size: .9em;
}
.users-table th,
.users-table td {
  padding: .45em .65em;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.users-table th { background: #f7f1f3; }
.users-table tbody tr:hover { background: #fcf9fa; }

label.checkbox-row {
  display: flex;
  align-items: center;
  gap: .5em;
  font-size: .95em;
}
label.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* --- Add Accounts screen (Phase 5) --- */

.account-group-heading {
  margin: 1.5em 0 .25em;
  padding: .25em .5em;
  background: #f7f1f3;
  border-left: 4px solid #7b1e3a;
  font-size: .95em;
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 .5em;
  font-size: .9em;
}
.accounts-table th,
.accounts-table td {
  padding: .35em .6em;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.accounts-table th { background: #fcf9fa; }

form select {
  display: block;
  padding: .45em .55em;
  font-size: 1em;
  width: 100%;
  margin-top: .25em;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #fff;
}
form select:focus { outline: 2px solid #7b1e3a; outline-offset: 1px; }

/* --- Add Transaction screen (Phase 6) --- */

form.txn-form { max-width: 800px; }

/* Top row of fields: Date 150px (no grow), Description grows to fill,
   Reference 180px (no grow). Wraps below 600px-ish viewports thanks to
   flex-wrap; the per-label flex-basis is the post-wrap baseline. */
.txn-header {
  display: flex;
  gap: 1em;
  flex-wrap: wrap;
}
.txn-header label { margin: 0; min-width: 0; }
.txn-header label.txn-header-date { flex: 0 0 150px; }
.txn-header label.txn-header-desc { flex: 1 1 250px; }
.txn-header label.txn-header-ref  { flex: 0 0 180px; }

/* Pin all three header inputs to the same height. Native <input type="date">
   on macOS has slightly taller intrinsic rendering than plain text inputs,
   so without an explicit height the Date field stands out. 36px matches the
   date picker's natural rendering on macOS Safari/Chrome. */
.txn-header input {
  height: 36px;
  box-sizing: border-box;
}

/* Consistent vertical rhythm between major sections of the form. The
   first child (.txn-header) gets no top margin so the form starts flush. */
form.txn-form > * + * { margin-top: 1.5em; }
.txn-section-heading { margin-bottom: .5em; font-size: 1.05em; }
.txn-add-line-row { margin-top: 1em; }

/* Lines table — fixed layout so columns are predictable and the totals
   row sits cleanly under the Amount column regardless of content width. */
.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95em;
  table-layout: fixed;
}
.lines-table col.col-drcr   { width: 80px;  }
.lines-table col.col-acct   { width: auto;  }   /* takes remaining space */
.lines-table col.col-amount { width: 130px; }
.lines-table col.col-remove { width: 90px; }
.lines-table col.col-tax    { width: 92px; }
.lines-table col.col-tax-amount { width: 92px; }

.lines-table th,
.lines-table td {
  padding: .4em .5em;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.lines-table th { background: #fcf9fa; text-align: left; }
/* Data and totals cells with class .amt right-align so values stack neatly.
   The Amount column HEADER stays left-aligned to match DR/CR and Account #
   (it inherits text-align:left from the .lines-table th rule above). */
.lines-table td.amt { text-align: right; }

.lines-table input,
.lines-table select {
  width: 100%;
  /* Override the form-wide `min-width: 280px` floor — inside a fixed-width
     table column we want the input to actually be the column's width, not
     a 280px overflow. Without this, the Amount input (150px column) would
     try to be 280px wide and visually misalign. */
  min-width: 0;
  padding: .35em .45em;
  font-size: .95em;
  margin: 0;
}
/* Amount input: right-aligned tabular numbers — looks like an accounting
   field, lines up neatly when stacked above the totals row. */
.lines-table input[name="amount"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Totals tfoot. Three rows of the same shape: label spans columns 1+2 and
   right-aligns next to the value in the Amount column. The fourth (Remove)
   column is intentionally empty for visual symmetry with the data rows. */
.lines-table tfoot .totals-row {
  background: #f7f1f3;
  font-size: .95em;
}
.lines-table tfoot .totals-row td { padding: .5em .65em; border-bottom: none; }
.lines-table tfoot .totals-row td.totals-label {
  text-align: right;
  font-weight: 600;
  color: #444;
}
.lines-table tfoot .totals-row td.amt {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}
.lines-table tfoot .totals-row-diff td.totals-label {
  color: #222;
  font-weight: 700;
}
/* Visual separator above the Difference row so it reads as the bottom-line
   summary of the totals block. */
.lines-table tfoot .totals-row-diff td { border-top: 1px solid #dcc7cd; }

/* Existing diff colour classes — applied by JS to the inner <span>. */
.diff-balanced   { color: #1b7f1b; font-weight: bold; }
.diff-unbalanced { color: #b03030; font-weight: bold; }

.btn-secondary {
  background: #fff;
  color: #7b1e3a;
  border: 1px solid #7b1e3a;
  padding: .35em .9em;
  font-size: .95em;
  border-radius: 4px;
  cursor: pointer;
}
.btn-secondary:hover { background: #f8eef1; }

/* Section menu under the header (base.html), like Xero's top bar. */
.section-nav { display: flex; flex-wrap: wrap; gap: .2em 1.2em; align-items: center; margin: -1em 0 1.2em;
               padding-bottom: .4em; border-bottom: 1px solid #ece4e6; font-size: .95em; }
.section-nav a { text-decoration: none; color: #3d3b38; padding: .25em 0; }
.section-nav a:hover, .section-nav a.nav-active { color: #7b1e3a; }
.section-nav a.nav-active { font-weight: 600; border-bottom: 2px solid #7b1e3a; }
.nav-drop { position: relative; }
.nav-menu { display: none; position: absolute; left: -.6em; top: 100%; z-index: 20; min-width: 13em;
            background: #fff; border: 1px solid #e4dadd; border-radius: 6px; box-shadow: 0 6px 18px rgba(60, 20, 30, .12);
            padding: .35em 0; }
.nav-drop:hover .nav-menu, .nav-drop:focus-within .nav-menu { display: block; }
.nav-menu a { display: block; padding: .35em .9em; white-space: nowrap; border: 0 !important; font-weight: normal !important; }
.nav-menu a:hover, .nav-menu a:focus { background: #f8eef1; }
.section-tabs { flex-wrap: wrap; gap: .2em 1em; }

/* Sales and Purchases (ar_ap.py): status pills, the document facts, filters. */
.state { display: inline-block; padding: 0 .5em; border-radius: 10px; font-size: .78em; font-weight: 600;
         vertical-align: middle; border: 1px solid; white-space: nowrap; }
.state-draft, .state-voided { background: #f1f0ee; color: #52514e; border-color: #dad8d3; }
.state-awaiting_approval { background: #fff4d6; color: #6b5200; border-color: #e8c766; }
.state-awaiting_payment { background: #f8eef1; color: #7b1e3a; border-color: #e3c3cc; }
.state-overdue { background: #fdecec; color: #9b2020; border-color: #efb9b9; }
.state-paid { background: #e5f3e5; color: #1b5e1b; border-color: #b9dcb9; }
/* MyInvois e-invoice status (myinvois.py). */
.einv { display: inline-block; padding: 0 .5em; border-radius: 10px; font-size: .85em; font-weight: 600;
        border: 1px solid; white-space: nowrap; background: #f1f0ee; color: #52514e; border-color: #dad8d3; }
.einv-sending, .einv-submitted { background: #fff4d6; color: #6b5200; border-color: #e8c766; }
.einv-valid { background: #e5f3e5; color: #1b5e1b; border-color: #b9dcb9; }
.einv-invalid, .einv-rejected, .einv-failed { background: #fdecec; color: #9b2020; border-color: #efb9b9; }
.einvoice-box ul { margin: .3em 0 .6em 1.2em; }
/* The MyInvois page's connection bar (sales_einvoices.html), as the original portal's. */
.einv-conn { display: flex; flex-wrap: wrap; gap: .4em 1.4em; align-items: center; padding: .6em .9em; margin: 0 0 1em;
  border: 1px solid #e4e3df; border-radius: 6px; background: #fafaf9; font-size: .9em; }
.doc-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: .6em 1.2em; margin: 0; }
.doc-facts dt { color: var(--ink-3); font-size: .85em; }
.doc-facts dd { margin: 0; }
.filter-row { display: flex; flex-wrap: wrap; gap: .5em; align-items: center; margin: 0 0 1em; }
.filter-row input[type="search"] { width: auto; flex: 1 1 18em; max-width: 28em; }
.dash-tile.tile-alert { border-color: #efb9b9; }
.dash-tile.tile-alert .tile-value { color: var(--bad); }
/* Status cards that filter a list (quotations, purchase orders): the chosen one is filled. */
.status-cards .dash-tile.tile-on { border-color: var(--series-1); background: var(--series-1); }
.status-cards .dash-tile.tile-on .tile-label, .status-cards .dash-tile.tile-on .tile-value,
.status-cards .dash-tile.tile-on .tile-note { color: #fff; }
td.amt.negative { color: var(--bad); }
.void-box { margin: 1em 0; }
.void-box summary { cursor: pointer; color: #7b1e3a; }
form.contact-form { max-width: 36em; }
.doc-form .txn-header { flex-wrap: wrap; }
.print-only { display: none; }
@media print { .print-only { display: block; } }
body:has(.doc-form, .section-tabs) { max-width: 1120px; }

/* Manual Journals: New journal / New repeating journal / Import, as buttons. */
.btn-row { display: flex; flex-wrap: wrap; gap: .5em; }
.btn-row a.btn {
  display: inline-block; background: #7b1e3a; color: #fff; border: 1px solid #7b1e3a;
  padding: .35em .9em; border-radius: 4px; text-decoration: none; font-size: .95em;
}
.btn-row a.btn:hover { background: #5c1229; }
.btn-row a.btn.btn-secondary { background: #fff; color: #7b1e3a; }
.btn-row a.btn.btn-secondary:hover { background: #f8eef1; }

/* SST-02: the year's taxable periods (_sst_filing.html). */
.sst-calendar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5em; }
.sst-calendar a { display: flex; flex-direction: column; gap: .2em; padding: .5em .6em; border: 1px solid #e4e3df; border-radius: 6px; color: inherit; text-decoration: none; }
.sst-calendar a.current { border-color: var(--brand, #7b1e3a); box-shadow: inset 0 0 0 1px var(--brand, #7b1e3a); }
.sst-calendar .pill { align-self: flex-start; white-space: normal; }
.sst-filing { margin-top: 1em; }
@media (max-width: 760px) { .sst-calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Corporate tax: the year-end checklist being edited (_corporate_tax.html). */
.checklist-row { display: flex; gap: .5em; margin: .3em 0; }
.checklist-row input { flex: 1; min-width: 0; }

/* "← Back to ..." sits at the top of the page, so a long report or form
   doesn't need scrolling to leave it. */
.back-link { margin: 0 0 .4em; }

.lines-table .btn-remove-line {
  background: #fff;
  color: #b03030;
  border: 1px solid #d99;
  padding: .25em .6em;
  font-size: .85em;
  border-radius: 4px;
  cursor: pointer;
}
.lines-table .btn-remove-line:hover { background: #fdecec; }

.txn-actions button { padding: .55em 1.4em; font-size: 1.05em; }

/* --- Reports stubs (Phase 7) --- */

.report-stub {
  margin: 1.5em 0;
  padding: 1em 1.25em;
  background: #f7f1f3;
  border: 1px solid #e8d3d9;
  border-radius: 6px;
  color: #444;
}
.report-stub p { margin: .25em 0; }

/* --- Trial Balance report --- */

.report-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 1em;
  flex-wrap: wrap;
  margin-bottom: 1em;
}
.tb-form { margin: 0; }
.btn-print { margin-top: .5em; }

.tb-report {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.5em 1.5em 1em;
  margin: 1em 0;
}

/* Report header — lives inside the table's <thead> as a single colspan-4
   cell so browsers repeat it on every printed page when the table spans
   multiple pages. The !important overrides are because the surrounding
   .tb-table th rules (cell background, padding, etc.) would otherwise
   make this look like a column header. */
.tb-heading-cell {
  background: #fff !important;
  text-align: center !important;
  border-bottom: 1px solid #eee !important;
  padding: 1.25em 1em !important;
  font-weight: normal !important;
}
.tb-heading-cell .tb-title {
  font-size: 1.7em;
  font-weight: 700;
  color: #222;
  margin: 0 0 .35em;
}
.tb-heading-cell .tb-company {
  font-size: 1.05em;
  color: #333;
  margin: 0 0 .25em;
}
.tb-heading-cell .tb-as-of {
  font-size: .95em;
  color: #555;
  margin: 0;
}

.tb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95em;
}
/* Generous horizontal padding so columns don't crowd each other. */
.tb-table th,
.tb-table td {
  padding: 10px 20px;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.tb-table th { background: #f7f1f3; }
.tb-table td.amt,
.tb-table th.amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tb-table tbody tr:hover { background: #fcf9fa; }

.tb-table a.tb-drill { color: #7b1e3a; text-decoration: none; }
.tb-table a.tb-drill:hover { text-decoration: underline; }

/* Totals row stands out clearly from the data rows above. */
.tb-totals {
  background: #f4ecee;
  border-top: 2px solid #7b1e3a;
}
.tb-totals td {
  padding: 14px 20px;
  border-bottom: none;
  font-size: 1.02em;
  font-weight: 700;
  color: #222;
}
.tb-totals--imbalanced {
  background: #fce4e4;
  border-top-color: #b03030;
}
.tb-imbalance-warning {
  font-weight: bold;
  margin-top: 1em;
}

.tb-empty {
  text-align: center;
  color: #888;
  font-style: italic;
  padding: 1em !important;
}

/* --- Balance Sheet --- */

/* Section heading band — full-width tinted row inside the table.
   Lighter than a subtotal but distinct from data rows. */
.bs-section-heading td {
  background: #f4ecee;
  font-weight: 700;
  letter-spacing: .04em;
  font-size: .9em;
  color: #7b1e3a;
  padding: 10px 20px !important;
  border-bottom: 1px solid #e8d3d9;
}

/* "(none)" placeholder when a section has no accounts. */
.bs-section-empty {
  font-style: italic;
  color: #888;
  text-align: center;
  padding: 8px 20px !important;
}

/* Section subtotal rows (Total Assets / Liabilities / Equity). */
.bs-subtotal td {
  background: #f7f1f3;
  border-top: 1px solid #dcc7cd;
  border-bottom: 1px solid #dcc7cd;
  padding: 12px 20px !important;
  font-size: 1em;
  color: #222;
}

/* NET ASSETS row — heavier than a subtotal. The pivot point of the
   audit-format balance sheet (Assets − Liabilities = Net Assets). */
.bs-net-assets td {
  background: #efe1e5;
  border-top: 2px solid #7b1e3a;
  border-bottom: 2px solid #7b1e3a;
  padding: 14px 20px !important;
  font-size: 1.05em;
  color: #7b1e3a;
  letter-spacing: .04em;
}
.bs-net-assets.bs-loss td.amt {
  color: #b03030;
}

/* Profit / (Loss) for the period row — italic label, top border to set
   it apart from the Equity entries above. NOT a subtotal — lighter weight. */
.bs-pl-row td {
  background: #fff;
  border-top: 2px solid #7b1e3a;
  padding: 10px 20px !important;
}
.bs-pl-row.bs-loss td.amt {
  color: #b03030;
  font-weight: 700;
}

/* --- Chart of Accounts -------------------------------------------------- */

/* Fixed column widths so the layout stays predictable regardless of
   account-name length. Account-name column absorbs the slack. */
.coa-table { table-layout: fixed; }
.coa-table col.col-acct { width: 160px; }
.coa-table col.col-name { width: auto;  }
.coa-table col.col-type { width: 100px; }
.coa-table th, .coa-table td { word-break: break-word; overflow-wrap: anywhere; }

/* Right-aligned today's date sits below the centred title/company block
   inside the heading cell. Subtle so it doesn't compete with the title. */
.coa-heading-cell .coa-date {
  text-align: right;
  font-size: .9em;
  color: #555;
  margin-top: .5em;
}

/* Grand-total row at the bottom of the report — slightly heavier than the
   per-group subtotal rows so the eye lands on it. */
.coa-grand-total td {
  text-align: center;
  padding: 14px 20px !important;
  font-size: 1.05em;
}

/* --- Journal Listing ---------------------------------------------------- */

.jl-form .txn-header { gap: 1em; }

/* Centred header at the top of the report; sits above the per-transaction
   blocks. We don't repeat it on every printed page (each block is short
   enough that the report header at the top is visible context). */
.jl-report-header {
  display: block;
  text-align: center;
  padding: 1.25em 1em 1em;
  margin-bottom: 1em;
  border-bottom: 1px solid #eee;
}
.jl-report-header .tb-title    { font-size: 1.7em; font-weight: 700; color: #222; margin: 0 0 .35em; }
.jl-report-header .tb-company  { font-size: 1.05em; color: #333; margin: 0 0 .25em; }
.jl-report-header .tb-as-of    { font-size: .95em; color: #555; margin: 0; }

.journal-block {
  margin: 1em 0;
  padding: .75em 1em 1em;
  border: 1px solid #e9dde1;
  border-radius: 6px;
  background: #fff;
  /* Hint to the browser to keep each transaction together when printing. */
  page-break-inside: avoid;
  break-inside: avoid;
}

.journal-block-header {
  display: flex;
  align-items: baseline;
  gap: 1em;
  flex-wrap: wrap;
  padding-bottom: .5em;
  margin-bottom: .5em;
  border-bottom: 1px solid #eee;
}
.journal-block-header .jl-date {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.journal-block-header .jl-ref {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9em;
  background: #f4ecee;
  padding: .1em .55em;
  border-radius: 3px;
  white-space: nowrap;
}
.journal-block-header .jl-desc {
  flex: 1;
  min-width: 200px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.journal-block-header .jl-user {
  color: #777;
  font-size: .9em;
  white-space: nowrap;
  font-style: italic;
}
.journal-block-header .attachment-link {
  text-decoration: none;
  font-size: 1.1em;
  display: inline-block;
  line-height: 1;
}
.journal-block-header .attachment-link:hover { transform: scale(1.15); }

.journal-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: .92em;
  /* Fixed layout so every block's table uses the same column widths
     defined on the colgroup below — content can't bend the columns. */
  table-layout: fixed;
}
/* Explicit column widths shared across every .journal-lines table on the
   page. The Account Name column is `auto` and absorbs whatever space is
   left after the fixed-width columns. */
.journal-lines col.col-acct { width: 130px; }
.journal-lines col.col-name { width: auto;  }
.journal-lines col.col-dr   { width: 150px; }
.journal-lines col.col-cr   { width: 150px; }

.journal-lines th,
.journal-lines td {
  padding: 6px 14px;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
  /* With fixed layout, long account names can otherwise push to overflow.
     Wrap inside the cell instead. */
  word-break: break-word;
  overflow-wrap: anywhere;
}
.journal-lines th { background: #fcf9fa; }
.journal-lines th.amt,
.journal-lines td.amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.journal-lines a.tb-drill { color: #7b1e3a; text-decoration: none; }
.journal-lines a.tb-drill:hover { text-decoration: underline; }

/* Subtle highlight for lines whose account matches the active filter. */
.jl-line-matched td { background: #f6e8ec; }

/* Per-block totals — small, light, low-contrast. They confirm the block
   balances without competing visually with the data rows. */
.jl-block-totals td {
  background: #faf5f6;
  font-size: .85em;
  color: #555;
  border-bottom: none;
  padding: 6px 14px;
  font-style: italic;
}

.jl-empty {
  background: #fafafa;
  border: 1px dashed #ccc;
  padding: 2em !important;
  margin: 1.5em 0;
  text-align: center;
  color: #888;
  font-style: italic;
  border-radius: 6px;
}

.jl-summary {
  margin-top: 1.5em;
  padding: 1em 1.25em;
  background: #f7f1f3;
  border: 1px solid #e8d3d9;
  border-radius: 6px;
}
.jl-summary-row {
  display: flex;
  gap: 2em;
  flex-wrap: wrap;
  justify-content: space-around;
}
.jl-summary-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
}
/* The cash forecast's scenario tabs, assumptions and sources (portal_cash.html). */
.scenario-tabs { display: flex; flex-wrap: wrap; gap: .3em; margin: .5em 0 1em; }
.tab-button { background: none; border: 0; border-bottom: 2px solid transparent; padding: .3em .6em; color: #7b1e3a; font: inherit; cursor: pointer; }
span.tab-button { cursor: default; color: inherit; }
.tab-button.tab-active { border-bottom-color: #7b1e3a; font-weight: 600; }
.forecast-form { display: flex; flex-wrap: wrap; gap: .5em .8em; align-items: flex-end; margin: .5em 0; }
.forecast-form label { display: flex; flex-direction: column; font-size: .9em; }
.forecast-form input, .forecast-form select { width: 9em; }
.forecast-form input[name=description] { width: 14em; }
.built-from { list-style: none; padding: 0; margin: 0; }
.built-from li { margin: 0 0 .5em; }
.built-from .pill { min-width: 9em; text-align: center; margin-right: .3em; }
.pill-bad { background: #fce4e4; color: #8f1d1d; border-color: #f3a8a8; }
.jl-summary-label {
  font-size: .8em;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.jl-summary-value {
  font-weight: 700;
  font-size: 1.1em;
  font-variant-numeric: tabular-nums;
  color: #222;
}

/* --- P&L bottom-line row -----------------------------------------------
   Distinct from the Balance Sheet's lighter .bs-pl-row. The P&L's bottom
   line is the report's headline number, so the label is bold (not italic)
   and we put a clear top-border separator above. On a loss, the amount
   cell goes red + italic per spec. */
.pl-result-row td {
  background: #fff;
  border-top: 2px solid #7b1e3a;
  padding: 14px 20px !important;
  font-size: 1.05em;
  color: #222;
}
.pl-result-row.pl-loss td.amt {
  color: #b03030;
  font-style: italic;
}

/* Balance-check footer panel — two values side by side under the table. */
.bs-balance-check {
  display: flex;
  gap: 1.5em;
  align-items: center;
  margin-top: 1.25em;
  padding: 1em 1.25em;
  background: #fcf9fa;
  border: 1px solid #e8d3d9;
  border-radius: 6px;
}
.bs-balance-side { flex: 1; }
.bs-balance-label {
  font-size: .85em;
  color: #555;
  margin-bottom: .25em;
}
.bs-balance-value {
  font-weight: 700;
  font-size: 1.05em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.bs-balance-equals {
  font-size: 1.4em;
  font-weight: 700;
  color: #7b1e3a;
}
.bs-balance-check--imbalanced {
  background: #fce4e4;
  border-color: #f3a8a8;
}
.bs-balance-check--imbalanced .bs-balance-value,
.bs-balance-check--imbalanced .bs-balance-equals {
  color: #b03030;
}

/* --- Drill-down modal (native <dialog>) --- */

dialog.account-modal {
  width: min(820px, 92vw);
  max-height: 85vh;
  padding: 0;
  border: 1px solid #bbb;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
}
dialog.account-modal::backdrop {
  background: rgba(0, 0, 0, .35);
}
dialog.account-modal .dialog-content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75em 1em;
  border-bottom: 1px solid #eee;
  background: #f7f1f3;
}
.modal-header h3 { margin: 0; font-size: 1.1em; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 .25em;
}
.modal-close:hover { color: #000; }

.modal-subtitle {
  margin: .5em 1em;
  color: #555;
  font-size: .9em;
}

.modal-body {
  padding: 0 1em 1em;
  overflow-y: auto;
  flex: 1;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9em;
}
.detail-table th,
.detail-table td {
  padding: 8px 18px;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.detail-table th {
  background: #fcf9fa;
  position: sticky;
  top: 0;
}
.detail-table th.amt,
.detail-table td.amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Reference cell — slightly more compact and a touch greyer so it doesn't
   compete with the description column. Reference values are short. */
.detail-table td.ref-cell {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9em;
  color: #444;
  white-space: nowrap;
}

/* Attachment column — narrow column at the right edge. Wide enough
   for either the 📎 icon or a "+ Add" link. */
.detail-table th.att-col,
.detail-table td.att-col {
  width: 4em;
  text-align: center;
  padding-left: 6px;
  padding-right: 6px;
}
.detail-table a.attachment-link {
  text-decoration: none;
  font-size: 1.1em;
  display: inline-block;
  line-height: 1;
}
.detail-table a.attachment-link:hover {
  transform: scale(1.15);
}
.detail-table a.add-attachment-link {
  font-size: .85em;
  color: #7b1e3a;
  text-decoration: none;
  white-space: nowrap;
}
.detail-table a.add-attachment-link:hover {
  text-decoration: underline;
}

/* --- Attachment viewer modal --------------------------------------------
   Sits on top of the drill-down modal when a 📎 link is clicked.
   Larger than the drill-down to give PDFs / images real estate. */

dialog.attachment-viewer {
  width: min(92vw, 1200px);
  height: 90vh;
  max-height: 90vh;
  padding: 0;
  border: 1px solid #bbb;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .35);
}
dialog.attachment-viewer::backdrop {
  background: rgba(0, 0, 0, .55);
}
dialog.attachment-viewer .dialog-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

dialog.attachment-viewer .modal-header h3 {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1em;
  word-break: break-all;
  flex: 1;
  margin-right: 1em;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: .75em;
  flex-shrink: 0;
}
.viewer-actions a.btn-secondary {
  text-decoration: none;
  padding: .35em .75em;
}

.viewer-body {
  flex: 1;
  min-height: 0;     /* let flex children shrink */
  overflow: auto;
  padding: 0;
  background: #2b2b2b;   /* dark canvas behind the file */
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}
.viewer-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}

.viewer-fallback {
  background: #fff;
  padding: 2em 2.5em;
  border-radius: 6px;
  text-align: center;
  max-width: 480px;
}
.viewer-fallback p { margin: .5em 0; }

/* PDF.js canvas rendering — stacked pages with a touch of card shadow. */
.pdf-pages {
  padding: 1.25em 1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25em;
  width: 100%;
}
canvas.pdf-page {
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  max-width: 100%;
  height: auto;
}

/* --- Print rules ---
   Hide all interactive UI; print only the report itself with nice page
   margins. "Page N of M" is rendered via @page @bottom-center which works
   in Chrome/Edge/Firefox; Safari may not honour it (workaround: enable
   browser-native headers/footers in the print dialog).
*/
@media print {
  body { margin: 0; color: #000; }

  /* IMPORTANT: scope `body > header` so we only hide the page-level
     navigation header, NOT the semantic <header>/<thead> blocks inside
     the report (those carry the report title/company/as-of). */
  body > header,
  .no-print,
  .menu-footer,
  .flashes,
  dialog,
  .report-back-link,
  .report-toolbar { display: none !important; }

  .tb-report {
    border: none;
    padding: 0;
    margin: 0;
  }
  .tb-table tbody tr:hover { background: transparent; }
  a.tb-drill {
    color: #000 !important;
    text-decoration: none !important;
  }

  /* Repeat the table head (which now contains the report title block AND
     the column-label row) on every printed page. table-header-group is
     the default for <thead>, but we set it explicitly so any browser
     extension or override can't accidentally remove it. */
  .tb-table thead { display: table-header-group; }

  /* Avoid splitting individual rows across page breaks. */
  .tb-table tr { page-break-inside: avoid; break-inside: avoid; }

  @page {
    margin: 1in;
    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
      font-size: 9pt;
      color: #555;
    }
  }
}

/* --- Login form: database selector ----------------------------------------
   The selected database is signalled by a coloured top border on the form
   (amber for Test, green for Live). Pure CSS via :has(); no JS, no button
   recolour. The Sign in button keeps the standard app burgundy so the colour
   cue stays subtle.

   Layout note: each .login-db-option is a <label> wrapping a radio + a
   badge + a hint. The form-wide rules (`form label { display: block }`
   and `form input { display: block; width: 100% }`) would otherwise stretch
   the radio across the full card width and push the badge onto a new line,
   so we override both inside .login-db-option. */

.login-form {
  border-top: 4px solid #ffeeba;        /* default = test = amber */
  transition: border-color 120ms ease;
}
.login-form:has(input[name="database"][value="live"]:checked) {
  border-top-color: #c3e6cb;            /* live = green */
}

.login-db-select {
  border: 1px solid #e8d3d9;
  border-radius: 6px;
  padding: 10px 14px 12px;
  margin: 1em 0;
}
.login-db-select legend {
  padding: 0 6px;
  font-size: .85em;
  font-weight: 600;
  color: #555;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-db-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  margin: 0;                            /* override form label margin */
  font-size: .95em;
  cursor: pointer;
}
.login-db-option input[type="radio"] {
  display: inline-block;                /* override form input { display: block } */
  width: auto;                          /* override form input { width: 100% } */
  margin: 0;
  flex: 0 0 auto;
}
.login-db-hint {
  font-size: .85em;
  color: #777;
}

/* Company picker (/select-company). */
.company-list { list-style: none; padding: 0; }
.company-option { display: flex; align-items: center; gap: 1em; }
.company-role { color: #555; font-size: .9em; }

/* --- Main and sub-accounts (migration 014) ---
   Sub-accounts are indented under their main account; the main account's
   subtotal row closes the group. Same look on screen and in print. */
tr.row-sub td:nth-child(-n+2) { padding-left: 1.6em; }
tr.row-subtotal td { border-top: 1px solid #ccc; }
.accounts-table tr.sub-account td:nth-child(-n+2) { padding-left: 1.6em; }

/* A switched-off tax code (SST settings). */
.row-muted td { color: #888; }

/* --- Report library (like Xero's Reports page) --- */
.lib-section h4 { margin: 1.2em 0 .3em; }
.lib-list { list-style: none; padding: 0; margin: 0; display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            border: 1px solid #ddd; border-radius: 6px; }
.lib-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4em;
            padding: .45em .7em; border-bottom: 1px solid #eee; }
.lib-name { flex: 1 1 auto; }
.lib-desc { display: none; flex-basis: 100%; color: #666; font-size: .85em; padding-left: 1.9em; }
.lib-show-desc .lib-desc, .lib-desc-always { display: block; }
.lib-missing .lib-name { color: #999; }
.lib-star { background: none; border: none; padding: 0 .2em; font-size: 1.15em; cursor: pointer;
            color: #999; width: auto; }
.lib-star-on { color: #7b1e3a; }
.lib-star-off { cursor: default; }
.lib-toolbar { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5em; }
.lib-toolbar .checkbox-row { margin: 0; }

/* --- Multi-column reports (report_grid.html) --- */
.grid-table td.amt, .grid-table th.amt { white-space: nowrap; }
.grid-table .col-number { width: 6em; color: #555; }
.grid-table tr.row-total td, .grid-table tr.row-grand td { border-top: 1px solid #999; }
.grid-table tr.row-grand td { font-weight: bold; border-bottom: 3px double #999; }
.grid-scroll { overflow-x: auto; }
.budget-table .budget-input { width: 7em; text-align: right; }
.hint { color: #666; font-size: .9em; }

/* --- Company profile and logo --- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .2em 1em; }
.inline-fields { display: flex; gap: .5em; }
.inline-fields select { width: auto; }
.settings-logo { max-height: 80px; max-width: 240px; }
.report-company { text-align: center; }
.report-logo { max-height: 56px; max-width: 200px; display: block; margin: 0 auto .3em; }
.report-company-sub { font-size: .85em; color: #555; }
.pack-cover { text-align: center; padding: 3em 0; page-break-after: always; }
.pack-logo { max-height: 100px; max-width: 280px; }
.pack-part { page-break-after: always; margin-bottom: 2em; }

/* --- Manual journals --- */
.tabs { display: flex; gap: 1em; margin: .5em 0 1em; border-bottom: 1px solid #ddd; }
.tabs a { padding: .4em .2em; text-decoration: none; }
.tabs a.tab-active { border-bottom: 2px solid #7b1e3a; font-weight: bold; }
.lines-table col.col-acct { width: 130px; }
.lines-table col.col-line-desc { width: auto; }   /* the narration takes the slack */
.lib-item form.inline { flex: 0 0 auto; }
.lib-name { flex: 1 1 0; min-width: 0; }
.grid-report { overflow-x: auto; }
@media print { .grid-report { overflow: visible; } }
/* Wide pages: multi-column reports, the report library, budgets and the
   journal form (with its narration column) get room to breathe. */
body:has(.grid-report, .lib-list, .budget-table, form.txn-form, .journal-tabs) { max-width: 1120px; }
body:has(form.txn-form) form.txn-form { max-width: none; }

/* Report pickers: fields of the views not chosen (report_grid.html). */
label[data-group][hidden] { display: none; }

/* Header title links to the main menu (base.html). */
.header-title h1 a.home-link { color: inherit; text-decoration: none; }

/* Edit Account Details: the form beside "how account types affect your reports". */
.account-edit { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.account-edit > form { flex: 1 1 360px; }
.account-types-help { flex: 1 1 360px; font-size: 0.9em; }
.types-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.types-help-grid p { margin: 0.2rem 0; }
.types-help-grid p.total { font-weight: 600; border-top: 1px solid #ddd; padding-top: 0.2rem; }
body:has(.account-edit) { max-width: 1120px; }
form.card label textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 0.25rem; font: inherit; }

/* Users and roles: invitation badge and the password-setup choice. */
.badge { display: inline-block; padding: 0 0.45em; border-radius: 3px; font-size: 0.8em;
         background: #fff4d6; border: 1px solid #e8c766; color: #6b5200; }
fieldset.setup-choice { border: 1px solid #ddd; border-radius: 4px; padding: 0.5rem 0.8rem; margin: 0.6rem 0; }
fieldset.setup-choice label.radio { display: block; font-weight: normal; margin: 0.3rem 0; }
fieldset.setup-choice label.radio input { width: auto; margin-right: 0.4em; }
.temp-password[hidden] { display: none; }

/* --- Client portal (portal_*.html) ------------------------------------------- */
.portal-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1em; margin: 0 0 1em; }
.portal-tile { display: block; color: inherit; text-decoration: none; margin: 0; }
a.portal-tile:hover { border-color: #7a1f3d; }
.portal-figure { font-size: 1.6em; font-weight: 600; margin: .15em 0; }
.portal-send { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1em; }
.portal-send .card { margin: 0; }
.portal-send label { display: block; margin-top: .6em; }
.portal-photo-preview { display: flex; flex-wrap: wrap; gap: .4em; align-items: center; margin-top: .5em; }
.portal-photo-preview img { max-width: 96px; max-height: 96px; border: 1px solid var(--line, #ddd); border-radius: 4px; }
.portal-paste-zone { margin-top: .6em; padding: 1em; border: 2px dashed var(--series-1, #9e2f4b); border-radius: 6px; text-align: center; color: var(--ink-2); cursor: text; caret-color: transparent; }
.portal-paste-zone:focus { outline: none; background: #fbf3f4; border-style: solid; }
.portal-paste-button { margin-top: .5em; }
.portal-paste-zone.paste-compact { display: inline-block; margin: 0 .4em; padding: .25em .6em; font-size: .85em; border-width: 1px; }
.paste-compact + .portal-photo-preview { display: inline-flex; margin: 0; }
.paste-compact + .portal-photo-preview img { max-width: 40px; max-height: 40px; }
.portal-send label input[type=text] { width: 100%; box-sizing: border-box; }
body:has(.portal-page) { max-width: 1120px; }

/* Client portal dashboards (routers/portal.py, portal_charts.html) */
svg.chart .line.dashed, svg line.dashed { stroke-dasharray: 5 4; }
.portal-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1em; }

/* Bank reconciliation (bank_reconciliation.html): the account cards, the
   quarters, the reconciliation statement and how the lines stand. */
.bank-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: .8em; margin: 1em 0; }
.bank-card { color: inherit; text-decoration: none; display: block; margin: 0; }
.bank-card.current { border-color: #7b1e3a; box-shadow: inset 0 0 0 1px #7b1e3a; }
.bank-card-figs { display: grid; grid-template-columns: auto 1fr; gap: .1em .8em; margin: .3em 0 .5em; font-size: .9em; }
.bank-card-figs dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.progress-bar { height: 6px; background: #e4e3df; border-radius: 3px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: #2e7d32; }
/* The portal's Capture page (portal_capture.html): channel cards, the
   statement totals form, completeness meters, and the chaser and AP/AR
   update as a conversation (ours on the left, the client's on the right). */
.capture-channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 1em; margin-bottom: 1em; }
.capture-channels .dash-card { margin: 0; }
.capture-addr { font-family: ui-monospace, monospace; font-size: .85em; word-break: break-all; margin-bottom: .3em; }
.capture-off { color: #8f1d1d; }
.tb-table.capture-table th, .tb-table.capture-table td { padding: 6px 10px; }
.capture-table { font-size: .9em; }
.capture-wrap { overflow-wrap: anywhere; min-width: 8em; }
.capture-totals summary { cursor: pointer; color: var(--ink-3); font-size: .9em; }
.capture-totals form { margin-top: .5em; }
.capture-meter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 3em; gap: .6em; align-items: center; margin: .4em 0; }
.capture-meter span:last-child { text-align: right; }
.capture-chat { display: flex; flex-direction: column; gap: .5em; margin: .5em 0; }
.capture-msg { max-width: 88%; padding: .5em .75em; border-radius: 10px; background: #f3e8ec; border: 1px solid #e6cfd8; overflow-wrap: anywhere; }
.capture-msg.client { align-self: flex-end; background: #fff; border-color: #e4e3df; }
.capture-ts { display: block; margin-top: .25em; color: var(--ink-3); font-size: .78em; }
.capture-msg form { margin-top: .3em; }
.bank-quarters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5em; margin: 0 0 1em; }
.bank-quarters > div { display: flex; flex-direction: column; gap: .2em; padding: .5em .6em; border: 1px solid #e4e3df; border-radius: 6px; }
.bank-quarters > div.current { border-color: #7b1e3a; }
.bank-quarters .pill { align-self: flex-start; }
@media (max-width: 600px) { .bank-quarters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rec-statement td:first-child { white-space: normal; }
.mix-bar { display: flex; gap: 2px; height: 1.6em; border-radius: 4px; overflow: hidden; margin: .4em 0; }
.mix-bar i { display: flex; align-items: center; justify-content: center; color: #fff; font-style: normal; font-size: .8em; font-weight: 600; }
.mix-done { background: #2e7d32; }
.mix-click { background: #b7791f; }
.mix-person { background: #7b1e3a; }
.mix-legend { list-style: none; padding: 0; margin: 0; font-size: .9em; }
.mix-legend li { display: flex; align-items: center; gap: .5em; margin: .2em 0; }
.mix-legend li b { margin-left: auto; }
.mix-legend i { width: .8em; height: .8em; border-radius: 2px; display: inline-block; }
.bank-questions { list-style: none; padding: 0; margin: 0; }
.bank-questions > li { margin: 0 0 .9em; }
.bank-question { margin: 0 0 .5em; padding: .4em .6em; border-left: 3px solid #e3c3cc; background: #fbf7f8; }
.bank-post-to { margin: 0 0 .5em; }
.account-search { min-width: 18em; max-width: 100%; }
/* The account boxes' own dropdown (account_search.js): the same in every browser. */
.account-search, input[role="combobox"] {
  background-image: linear-gradient(45deg, transparent 50%, #7b1e3a 50%), linear-gradient(135deg, #7b1e3a 50%, transparent 50%);
  background-position: right 12px center, right 7px center; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 22px;
}
.account-menu { position: absolute; z-index: 1000; margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: #fff; border: 1px solid #c9b3bb; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.15);
  overflow-y: auto; font-size: .92rem; }
.account-menu li { padding: .35em .75em; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-menu li.is-active, .account-menu li:hover { background: #f8eef1; }
.account-menu li.is-current { font-weight: 600; }
.account-menu-no { display: inline-block; min-width: 5.5em; color: #7b1e3a; font-variant-numeric: tabular-nums; }
.account-menu-none { color: #666; cursor: default !important; }
.account-menu-add { border-top: 1px solid #eee; color: #7b1e3a; font-weight: 600; }
dialog.account-add { border: 1px solid #c9b3bb; border-radius: 8px; max-width: 26em; width: calc(100% - 32px); }
dialog.account-add label { display: block; margin: .5em 0; }
dialog.account-add input, dialog.account-add select { display: block; width: 100%; box-sizing: border-box; margin-top: .2em; }
.account-add-error { color: #a3271f; }
/* The portal's Ask page (services/portal_agents.py): the client on the right, the assistant
   and our team on the left, like a messaging app. */
.chat { list-style: none; padding: 0; margin: 0 0 1em; display: flex; flex-direction: column; gap: .5em; }
.chat li { max-width: 80%; padding: .55em .8em; border-radius: 12px; line-height: 1.45; }
.chat-text { white-space: pre-line; }
.chat-me { align-self: flex-end; background: #7b1e3a; color: #fff; border-bottom-right-radius: 3px; }
.chat-ai { align-self: flex-start; background: #f8eef1; border-bottom-left-radius: 3px; }
.chat-team { align-self: flex-start; background: #e5f3e5; border-bottom-left-radius: 3px; }
.chat-form { display: flex; gap: .5em; align-items: flex-end; }
.chat-form textarea { flex: 1; min-width: 0; }
.chat-examples { display: flex; flex-wrap: wrap; gap: .4em; margin-top: .6em; }
.link-button, .chat .link-button { background: transparent; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: .85em; }
@media (max-width: 600px) { .chat li { max-width: 92%; } }
.bank-tiles + .portal-board { margin-bottom: 1em; }
.pill-warn { background: #fdf3dc; color: #7a5300; border-color: #ecd49a; }
.pill-bad { background: #fce4e4; color: #8f1d1d; border-color: #f3a8a8; }
.portal-board > * { margin: 0; }
.portal-list { list-style: none; margin: 0; padding: 0; }
.portal-list li { display: flex; justify-content: space-between; gap: 1em; padding: .35em 0; border-bottom: 1px solid var(--grid); }
.portal-list li:last-child { border-bottom: 0; }
.portal-list .when { color: var(--ink-3); font-size: .85em; white-space: nowrap; }
/* "From your accountant" on the portal Home (services/portal_notes.py) and its settings form. */
.accountant-notes ul { margin: 0; padding-left: 1.2em; }
.accountant-notes li { padding: .2em 0; }
#portal-notes label { display: block; margin-bottom: .75em; }
#portal-notes textarea { display: block; width: 100%; box-sizing: border-box; margin-top: .25rem; font: inherit; }
.level { display: inline-block; font-size: .75em; font-weight: 600; padding: 0 .45em; border-radius: 3px; margin-right: .4em; color: #fff; }
.level-bad { background: var(--bad); } .level-warn { background: #a86a00; } .level-info { background: var(--ink-3); }
.close-steps { list-style: none; margin: 0; padding: 0; }
.close-steps li { display: grid; grid-template-columns: 1.6em 1fr auto; gap: .6em; align-items: center; padding: .35em 0; border-bottom: 1px solid var(--grid); }
.close-steps li:last-child { border-bottom: 0; }
.close-steps .n { width: 1.5em; height: 1.5em; border-radius: 50%; display: grid; place-items: center; font-size: .8em; background: #eceae6; color: var(--ink-2); }
.close-steps .done .n { background: var(--good); color: #fff; }
.close-steps .now .n { background: var(--series-1); color: #fff; }
.close-steps .note { color: var(--ink-3); font-size: .85em; }
/* Ageing: one hue, light (current) to dark (oldest); every bucket is also labelled in the legend. */
.age-bar { display: flex; gap: 2px; height: 14px; margin: .4em 0 .6em; }
.age-seg { min-width: 4px; flex-basis: 0; }
.age-seg:first-child { border-radius: 4px 0 0 4px; } .age-seg:last-child { border-radius: 0 4px 4px 0; }
.age-seg:only-child { border-radius: 4px; }
.age-0 { background: #ecd0d7; } .age-1 { background: #d9a0ae; } .age-2 { background: #bf6680; }
.age-3 { background: #962a47; } .age-4 { background: #561326; }
.age-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3em 1.2em; font-size: .85em; color: var(--ink-2); }
.age-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35em; vertical-align: -1px; }
.portal-how ol, .portal-how ul { padding-left: 1.3em; }
.portal-how li { margin: .25em 0; }
.portal-how td, .portal-how th { vertical-align: top; }
@media (max-width: 600px) { .portal-send input[type=file] { max-width: 100%; } }
.portal-wide { max-width: 760px; margin-top: 1em; }
.portal-page td:first-child { white-space: nowrap; }
.bank-tiles { margin-top: 1em; }

/* CP204 instalments (_corporate_tax.html): one block per month, filled once due. */
.cp204-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; margin: .3em 0 .5em; }
.cp204-months div { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7em; color: #666; }
.cp204-months i { display: block; width: 100%; height: 18px; border-radius: 3px; background: #f1f0ec; border: 1px solid #e4e3df; }
.cp204-months .due i { background: var(--good); border-color: var(--good); }
@media (max-width: 520px) { .cp204-months { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* CFO brief (_cfo_brief.html): stages, scorecard with lights, slides. */
.brief-stages { list-style: none; margin: 0 0 1em; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid #e4e3df; border-radius: 6px; overflow: hidden; }
.brief-stages li { padding: .5em .8em; border-right: 1px solid #e4e3df; display: flex; flex-direction: column; font-size: .85em; color: var(--ink-3); }
.brief-stages li:last-child { border-right: 0; }
.brief-stages li b { color: var(--ink); }
.brief-stages li.done { background: #eaf4ea; } .brief-stages li.done b { color: var(--good); }
.brief-stages li.now { box-shadow: inset 0 -3px 0 var(--series-1); }
.brief-score { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: #e4e3df; border: 1px solid #e4e3df; border-radius: 6px; overflow: hidden; }
.brief-score > div { background: #fff; padding: .7em .9em; display: flex; flex-direction: column; gap: .2em; min-width: 0; }
.brief-score-top { display: flex; justify-content: space-between; align-items: center; gap: .5em; }
.light { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.light-good { background: var(--good); } .light-warn { background: #c88a00; } .light-bad { background: var(--bad); }
.spark { width: 100%; height: 30px; display: block; color: var(--series-1); }
.brief-deck { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 1em; margin-bottom: 1em; }
.brief-deck.one-at-a-time { grid-template-columns: minmax(0, 1fr); margin-bottom: .6em; }
.brief-slide[hidden], .deck-nav[hidden] { display: none; }   /* their display: flex would win over [hidden] */
@media print { .brief-deck.one-at-a-time .brief-slide[hidden] { display: flex; } }
/* Laid out like the original portal's AI CFO brief: header with the next
   step, four delivery cards, panels with a heading row, the deck viewer,
   the English / Bahasa Melayu script tabs. */
.brief-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1em; flex-wrap: wrap; margin-bottom: .8em; }
.brief-head h2 { margin: 0 0 .2em; }
.brief-head .tile-note { max-width: 60em; margin: 0; }
.brief-deliver { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: .8em; margin: 1em 0; }
.brief-deliver .card { margin: 0; display: flex; flex-direction: column; gap: .35em; min-width: 0; }
.brief-deliver h3 { margin: 0; font-size: 1em; }
.brief-panel-h { display: flex; justify-content: space-between; align-items: center; gap: .6em; flex-wrap: wrap; margin-bottom: .6em; }
.brief-panel-h h3 { margin: 0; }
.pill { display: inline-block; padding: 0 .55em; border-radius: 10px; font-size: .78em; font-weight: 600; border: 1px solid; white-space: nowrap; }
.pill-good { background: #e5f3e5; color: #1b5e1b; border-color: #b9dcb9; }
.pill-info { background: #f8eef1; color: #7b1e3a; border-color: #e3c3cc; }
.pill-mute { background: #f1f0ee; color: #52514e; border-color: #dad8d3; }
.pill-warn { background: #fdf3dc; color: #7a5300; border-color: #ecd49a; }
.pill-bad { background: #fce4e4; color: #8f1d1d; border-color: #f3a8a8; }
/* Post to Bukku's pre-posting checks and entries (portal_import.html). */
.check-list { list-style: none; padding: 0; margin: .4em 0 1em; }
.check-list li { margin: .35em 0; }
.check-list .tile-note { display: block; margin-left: 2.2em; }
.bukku-entry { border-top: 1px solid #ece8e6; padding: .5em 0; }
.bukku-entry summary { cursor: pointer; }
.deck-nav { display: flex; justify-content: space-between; align-items: center; gap: .5em; flex-wrap: wrap; }
.deck-thumbs { display: flex; gap: .3em; flex-wrap: wrap; justify-content: center; }
.deck-thumbs button { min-width: 2.2em; padding: .2em .5em; background: #fff; color: #7b1e3a; border: 1px solid #e3c3cc; }
.deck-thumbs button[aria-current="true"] { background: #7b1e3a; color: #fff; }
.seg { display: inline-flex; background: #f1f0ee; border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: transparent; color: var(--ink); border: 0; padding: .25em .8em; border-radius: 6px; }
.seg button[aria-selected="true"] { background: #fff; color: #7b1e3a; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.brief-script { line-height: 1.6; background: #faf9f7; border: 1px solid #e4e3df; border-radius: 6px; padding: .4em 1em; max-height: 360px; overflow: auto; }
.brief-qa { border-bottom: 1px solid #e4e3df; padding: .5em 0; }
.brief-qa summary { font-weight: 600; cursor: pointer; }
.brief-qa p { margin: .4em 0 0; }
/* The one-page summary (cfo_summary.html), an A4 page for the directors. */
.brief-summary { max-width: 800px; margin: 0 auto; padding: 1.5em; background: #fff; color: #222; font-size: 14px; }
.brief-summary header { border-bottom: 3px solid #6d1a33; padding-bottom: .5em; margin-bottom: .8em; }
.brief-summary .eyebrow { font-size: .78em; letter-spacing: .1em; text-transform: uppercase; color: #6d1a33; }
.brief-summary h1 { font-size: 1.45em; margin: .2em 0 0; }
.brief-summary h2 { font-size: 1em; margin: .8em 0 .2em; color: #6d1a33; }
.brief-summary ul { margin: 0; padding-left: 1.2em; }
.brief-summary table { width: 100%; border-collapse: collapse; }
.brief-summary td { border-bottom: 1px solid #e4e3df; padding: .25em .3em; vertical-align: top; }
.brief-summary-score { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5em; }
.brief-summary-score > div { border: 1px solid #e4e3df; border-radius: 6px; padding: .4em .6em; display: flex; flex-direction: column; }
.brief-summary-score small { color: #666; }
.brief-summary-score b { font-size: 1.2em; }
.brief-summary-foot { margin-top: 1em; color: #666; font-size: .85em; }
@media (max-width: 600px) { .brief-summary-score { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print { .brief-summary { padding: 0; font-size: 12px; }
  .brief-summary .light { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.brief-slide { aspect-ratio: 16 / 9; background: #6d1a33; color: #fff; border-radius: 6px; padding: 5% 6%; display: flex; flex-direction: column; gap: .5em; overflow: hidden; }
.brief-slide .eyebrow { font-size: .75em; letter-spacing: .1em; text-transform: uppercase; opacity: .75; }
.brief-slide h2 { margin: 0; font-size: 1.25em; color: #fff; }
.brief-slide ul { margin: 0; padding-left: 1.1em; font-size: .9em; }
.brief-slide .row { display: flex; gap: 2em; flex-wrap: wrap; }
.brief-slide .row div { display: flex; flex-direction: column; }
.brief-slide .row small { opacity: .75; font-size: .8em; }
.brief-slide .row b { font-size: 1.3em; font-weight: 500; }
.brief-slide .big { font-size: 2em; color: #f2c46d; }
@media (max-width: 600px) { .brief-stages, .brief-score { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* The printable deck: one slide per landscape page. */
.deck-print .brief-slide { width: 100%; max-width: 960px; margin: 0 auto 1em; font-size: 1.4em; }
@media print { .deck-print .brief-slide { page-break-after: always; break-after: page; border-radius: 0; margin: 0; max-width: none; height: 100vh; aspect-ratio: auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* How it runs: the workflow steps (portal_how.html). */
.how-step { border-top: 1px solid #ece8e6; padding: .5em 0; }
.how-step summary { cursor: pointer; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: .8em; }
.how-grid h4 { margin: .2em 0; font-size: .9em; }
.how-grid ul { margin: 0; padding-left: 1.2em; }
.portal-how .portal-board { margin-bottom: 1em; }

/* Manage companies: the one button that drops a company's books for good. */
.companies-delete-button { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Spendshare, the GL tab (spendshare.html): the QR code beside what is owed. */
.spendshare-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 1em; }
@media (max-width: 800px) { .spendshare-top { grid-template-columns: 1fr; } }
.spendshare-get { display: grid; grid-template-columns: auto 1fr; gap: .4em 1em; align-items: start; }
.spendshare-get h3, .spendshare-get > p { grid-column: 1 / -1; }
.spendshare-qr svg { display: block; width: 180px; height: 180px; }
.spendshare-steps { margin: 0; padding-left: 1.2em; min-width: 0; }
.spendshare-steps code { overflow-wrap: anywhere; }
.spendshare-steps li { margin-bottom: .4em; }
@media (max-width: 600px) { .spendshare-get { grid-template-columns: 1fr; } }
.spendshare-decide, .spendshare-pay, .spendshare-enter { display: flex; flex-wrap: wrap; gap: .4em; align-items: end; margin: .2em 0; }
.spendshare-enter { margin-top: .8em; }
.spendshare-claim td { border-bottom: 0; }
.spendshare-act td { padding-top: 0; }
.spendshare-decide input { width: auto; flex: 1 1 10em; }
.spendshare-enter label { display: flex; flex-direction: column; font-size: .9em; }
.spendshare-warn { color: #8a1c1c; }
.spendshare-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22em), 1fr)); gap: .4em 1.2em; }
.spendshare-map label { display: grid; grid-template-columns: 9em minmax(0, 1fr); gap: .5em; align-items: center; }
.spendshare-map select { width: 100%; min-width: 0; }
.spendshare-map .btn-row { grid-column: 1 / -1; }
.spendshare-decide select[hidden], .spendshare-map select[hidden], .spendshare-enter select[hidden] { display: none; }
.spendshare-why { color: #6b5a60; font-style: italic; }

/* --- Phone and form fixes (docs: Setpoint GL UI and UX review, Nov 2026) --- */

/* Wide tables scroll inside their own box (static/table_scroll.js wraps
   them), so a phone no longer slides the whole page sideways. */
.table-scroll { overflow-x: auto; max-width: 100%; }
@media print { .table-scroll { overflow: visible; } }

/* Tick boxes and radios sit beside their words: "form input" above makes
   every input a full-width block, which floated them above their label. */
form input[type="checkbox"], form input[type="radio"] {
  display: inline-block;
  width: auto;
  margin: 0 .45em 0 0;
  vertical-align: middle;
}
/* An input inside a sentence-style inline form stays in the sentence
   (Inbox: "Post every draft ... at [90] % confidence or above"). */
form.inline input { display: inline-block; width: auto; margin-top: 0; }

/* Pages that need the room (the Inbox's draft table). */
body:has(h2.wide-page) { max-width: 1120px; }

/* Paste picture is a helper, not the form's main action: outlined, so the
   Send / Upload button stays the one that stands out. */
form button.portal-paste-button { background: #fff; color: #7b1e3a; border-color: #7b1e3a; }
form button.portal-paste-button:hover { background: #f8eef1; }

/* Touch screens have no Ctrl+V: hide the "click here, then press Ctrl+V"
   box. The Paste button stays where the phone can read the clipboard. */
@media (hover: none) and (pointer: coarse) {
  .portal-paste-zone { display: none; }
}

@media (max-width: 640px) {
  /* The section menu is one line that swipes sideways, instead of 4-5
     wrapped lines above the page. Sub-menus are left out: each top link
     opens an overview with the same list as tabs. */
  .section-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: .2em; }
  .section-nav::-webkit-scrollbar { display: none; }
  .section-nav a { white-space: nowrap; }
  .section-nav .nav-menu { display: none !important; }
  /* Status tabs (Draft, Awaiting payment, Paid...) swipe the same way. */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }
  /* A search box never wider than the screen (its 18em start was). */
  .filter-row input[type="search"] { flex-basis: 100%; min-width: 0; }

  /* Tighter cells, and the first column stays put while the rest scrolls,
     so the row's name (employee, invoice, account) is always in view. */
  .tb-table th, .tb-table td { padding: 8px 12px; }
  .table-scroll th:first-child, .table-scroll td:first-child,
  .grid-scroll th:first-child, .grid-scroll td:first-child {
    position: sticky; left: 0; z-index: 1; background: #fff;
  }
  .table-scroll th:first-child, .grid-scroll th:first-child { background: #f7f1f3; }
  .table-scroll .tb-totals td:first-child, .grid-scroll .tb-totals td:first-child { background: #f4ecee; }
}

/* --- Document preview beside the page (static/doc_preview.js) --- */
.doc-preview {
  position: fixed; top: 0; right: 0; bottom: 0; width: 42vw; z-index: 950;
  display: flex; flex-direction: column;
  background: #fff; border-left: 3px solid #7b1e3a; box-shadow: -6px 0 18px rgba(0, 0, 0, .15);
}
.doc-preview[hidden] { display: none; }
.doc-preview-bar { display: flex; align-items: center; gap: .9em; padding: .6em .9em; border-bottom: 1px solid #eee5e7; font-size: .9em; }
.doc-preview-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #7b1e3a; }
.doc-preview-bar a[hidden] { display: none; }
.doc-preview-close { background: none; border: 0; font-size: 1.3em; line-height: 1; cursor: pointer; color: #555; padding: 0 .2em; }
.doc-preview-frame { flex: 1; width: 100%; border: 0; background: #f6f4f3; }
/* The page moves left so the list and the document sit side by side. */
body.doc-preview-open { max-width: none; margin-left: 2vw; margin-right: calc(42vw + 2vw); }
body.doc-preview-open .claude-fab { right: calc(42vw + 18px); }
a.doc-previewing { background: #f8eef1; outline: 2px solid #7b1e3a; outline-offset: 1px; border-radius: 2px; }
@media (max-width: 760px) {
  /* A phone has no room beside the list: a sheet over the lower part instead. */
  .doc-preview { top: auto; left: 0; width: auto; height: 72vh; border-left: 0; border-top: 3px solid #7b1e3a;
                 box-shadow: 0 -6px 18px rgba(0, 0, 0, .2); border-radius: 10px 10px 0 0; }
  body.doc-preview-open { margin-left: auto; margin-right: auto; padding-bottom: 72vh; }
  body.doc-preview-open .claude-fab { display: none; }
}

/* Inbox draft lines: "DR 5000 Costs 95.40", the name quieter than the number. */
.acct-name { color: #555; font-size: .92em; }
.amt-inline { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The floating Claude button no longer covers the end of a page. */
body:has(.claude-fab) { padding-bottom: 64px; }
.more-actions { margin: 2em 0 1em; font-size: .9em; }
.more-actions summary { cursor: pointer; color: #555; }

/* --- Portal: one send form at a time (templates/_portal_send.html) --- */
/* Without :has (older browsers) the choice stays hidden and every form
   shows, as before. With it, only the chosen form is on the page. */
.portal-send .send-kinds { display: none; }
@supports selector(:has(*)) {
  .portal-send { display: block; }
  .portal-send .send-kinds {
    display: flex; flex-wrap: wrap; gap: .5em; margin: 0 0 1em; padding: 0; border: 0;
  }
  .portal-send .send-kinds legend { width: 100%; font-weight: 600; margin-bottom: .4em; padding: 0; }
  .portal-send .send-kinds label {
    display: inline-flex; align-items: center; margin: 0; padding: .55em 1em; min-height: 44px;
    border: 1px solid #7b1e3a; border-radius: 999px; color: #7b1e3a; cursor: pointer; background: #fff;
  }
  /* The radio is the whole pill: hidden, but still focusable and announced. */
  .portal-send .send-kinds input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
  .portal-send .send-kinds label:has(input:checked) { background: #7b1e3a; color: #fff; }
  .portal-send .send-kinds label:has(input:focus-visible) { outline: 2px solid #7b1e3a; outline-offset: 2px; }
  .portal-send > form[data-kind] { display: none; max-width: 640px; }
  .portal-send:has(#send-photo:checked) > form[data-kind="photo"],
  .portal-send:has(#send-docs:checked) > form[data-kind="docs"],
  .portal-send:has(#send-statements:checked) > form[data-kind="statements"],
  .portal-send:has(#send-list:checked) > form[data-kind="list"],
  .portal-send:has(#send-folder:checked) > form[data-kind="folder"] { display: block; }
}
/* A phone can't pick a folder. */
@media (hover: none) and (pointer: coarse) {
  .portal-send .send-kind-folder { display: none !important; }
}

/* --- Draft auto-save (static/autosave.js) --- */
.autosave-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6em;
  margin: 0 0 1em; padding: .7em .9em; border-radius: 6px;
  background: #fdf3dc; border: 1px solid #ecd49a; color: #5c4300;
}
.autosave-note span { flex: 1 1 18em; }
form .autosave-note button { margin-top: 0; }

/* Bank: a matched or suggested journal's receipts, beside it. */
.bank-receipt { margin-left: .5em; font-size: .9em; white-space: nowrap; }
/* Portal home on a phone: the five headline figures two to a row, so
   "What are you sending?" is reached without scrolling past five screens. */
@media (max-width: 640px) {
  .portal-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6em; }
  .portal-tile .portal-figure { font-size: 1.3em; }
}
.portal-send-block { margin: 0 0 1.5em; }

/* Portal Billing: upload files, a folder or a photo (portal_billing.html) */
.upload-options { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.upload-options label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9em; }
/* A scan to check beside its invoice form (portal_billing_form.html) */
.scan-check { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.scan-check .scan-view img, .scan-check .scan-view iframe { width: 100%; border: 1px solid var(--border, #ddd); border-radius: 4px; }
.scan-check .scan-view iframe { height: 70vh; }
@media (min-width: 1000px) { .scan-check { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
