:root {
  /* Black & white palette */
  --bg: #f4f4f4;
  --surface: #ffffff;
  --text: #000000;
  --muted: #666666;
  --border: #d4d4d4;
  --accent: #000000;
  --accent-text: #ffffff;
  --danger: #c62828;        /* errors: red */
  --danger-bg: #fdecea;
  --warning: #8a6d00;       /* warnings: yellow (dark text for readability) */
  --warning-bg: #fff8d6;
  --warning-border: #f2c200;
  --ok: #000000;
  --group: #ededed;
  --header: #000000;
  --header-link: #cccccc;
  --header-faint: #999999;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main a:not(.btn):not(.linkcard) { text-decoration: underline; text-decoration-color: #aaa; text-underline-offset: 2px; }
main a:not(.btn):not(.linkcard):hover { text-decoration-color: #000; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
main { padding: 1.25rem 1.5rem 3rem; max-width: 1400px; margin: 0 auto; }
.muted { color: var(--muted); }
.app-version { color: var(--muted); font-size: .75rem; text-align: center; padding: 0 1rem 1rem; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { margin-left: auto; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1.5rem; background: var(--header); color: #fff; padding: 0 1.5rem; height: 52px; }
.topbar a { color: var(--header-link); }
.topbar a:hover { color: #fff; text-decoration: underline; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: #fff !important; font-size: 1.05rem; white-space: nowrap; letter-spacing: .02em; }
.brand:hover { text-decoration: none !important; }
.brand img { display: block; height: 30px; width: auto; }
.login-logo { background: #000; margin: -1rem -1.25rem 1rem; border-radius: 8px 8px 0 0; padding: 1rem 2.5rem; text-align: center; }
.login-logo img { display: block; width: 100%; height: auto; max-width: 260px; margin: 0 auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand-company { font-weight: 400; font-size: .85rem; color: var(--header-faint); margin-left: .4rem; padding-left: .5rem; border-left: 1px solid #555; }
.company-switch { margin: 0; }
.company-switch select { background: #000; color: #fff; border: 1px solid #555; padding: .25rem .5rem; max-width: 260px; font-size: .9rem; }
.company-switch select:focus { outline: 2px solid #fff; }
.topbar nav { display: flex; gap: 1.4rem; flex: 1; min-width: 0; font-size: .95rem; }
.topbar nav a, .topbar .menu-button { white-space: nowrap; }
.flow-node .menu-button span { white-space: normal; overflow-wrap: anywhere; }
.menu-button .caret { font-size: .6rem; opacity: .55; margin-left: .15rem; vertical-align: .1em; }
.usermenu { display: flex; align-items: center; font-size: .9rem; margin-left: auto; }
.usermenu form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--header-link); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: #fff; }

/* top-bar drop-down menu (Lists) */
.menu { position: relative; display: flex; align-items: center; }
.menu-button { background: none; border: 0; color: var(--header-link); font: inherit; cursor: pointer; padding: 0; }
.menu-button:hover, .menu.open .menu-button { color: #fff; }
.menu-items { display: none; position: absolute; top: 100%; left: -.75rem; z-index: 20; min-width: 210px; padding: .35rem 0;
  background: #000; border: 1px solid #333; border-top: 0; border-radius: 0 0 6px 6px; box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.menu::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; } /* hover bridge */
.menu:hover .menu-items, .menu.open .menu-items { display: block; margin-top: 14px; }
.menu.picked .menu-items { display: none; } /* 0.33.0: just picked an item (tabs.js) */
.usermenu .menu-items { left: auto; right: -.75rem; min-width: 180px; }
.backup-now { margin: 1rem 0; }
.backup-actions { display: flex; gap: .4rem; align-items: center; }
.backup-actions form { margin: 0; }
.topbar .menu-items a { display: block; padding: .45rem 1rem; color: var(--header-link); white-space: nowrap; }
.topbar .menu-items a:hover, .topbar .menu-items a:focus { background: #222; color: #fff; text-decoration: none; }
.topbar .menu-items a[aria-current="page"] { color: #fff; font-weight: 600; }
.menu-items form { margin: 0; }
.menu-signout { display: block; width: 100%; text-align: left; padding: .45rem 1rem; background: none; border: 0; color: var(--header-link); font: inherit; cursor: pointer; }
.menu-signout:hover, .menu-signout:focus { background: #222; color: #fff; }

/* layout */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.pagehead p { margin: -.5rem 0 1rem; }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.linkcard { display: block; color: inherit; }
.linkcard:hover { border-color: var(--accent); text-decoration: none; }
.tiles { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .9rem 1.2rem; min-width: 220px; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.neg { color: var(--text); }

/* forms */
input, select, textarea { font: inherit; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #000; outline-offset: 1px; border-color: var(--accent); }
.form div { margin-bottom: .8rem; }
.form label { display: block; font-weight: 500; margin-bottom: .2rem; }
.form input:not([type=checkbox]), .form select, .form textarea { width: 100%; max-width: 480px; }
.form .helptext { display: block; color: var(--muted); font-size: .85rem; }
.form ul.errorlist, .errorlist { color: var(--danger); margin: .2rem 0; padding-left: 1rem; }
.narrow { max-width: 620px; }
.wide-form { max-width: 980px; }
.form-section { margin: 0 0 1rem; }
.form-section legend { font-weight: 700; padding: 0 .4rem; margin-left: -.4rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 1.25rem; }
.form-grid .field { margin-bottom: .8rem; }
.form-grid .field.wide { grid-column: 1 / -1; }
.form-grid .field.wide textarea { max-width: none; }
.form-grid .field.check { align-self: end; }
.form-grid .field.check label { display: flex; gap: .45rem; align-items: center; font-weight: 500; }
.req { color: var(--danger); }
.right { margin-left: auto; }
.crumbs { margin: 0 0 .25rem; font-size: .9rem; }
.card-title { font-size: 1rem; margin: 0 0 .6rem; }
dl.fields { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
dl.fields dd.full { grid-column: 1 / -1; }
.import-section { margin-bottom: 1rem; }
.import-section summary { cursor: pointer; padding: .5rem 0; }
.import-section .table { margin-top: .25rem; }
.filters { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); }
.btn { display: inline-block; padding: .45rem .9rem; border-radius: 5px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: #333; border-color: #333; }
.btn.danger { color: #000; border: 2px solid #000; font-weight: 600; }
.btn.small { padding: .2rem .6rem; font-size: .85rem; }
.report-post { margin: .3rem 0 0; }
.row-actions { text-align: right; }
.row-actions form { display: inline; margin: 0; }
.row-actions > * + * { margin-left: .35rem; }
a.danger { color: var(--text); font-weight: 600; }

/* alerts & badges */
.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
/* without color, alert types differ by border weight and background */
.alert-success, .alert-info { background: #fff; border-color: #999; border-left: 4px solid #000; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); border-left: 4px solid var(--warning-border); }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); border-left: 4px solid var(--danger); font-weight: 600; }
.alert-error a, .alert-danger a { color: var(--danger); }
.alert ul { margin: 0; padding-left: 1rem; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 10px; background: var(--group); color: var(--muted); }
.status-created { background: #fff; color: #000; border: 1px solid #000; }
.status-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); font-weight: 600; }
.status-skipped { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.err { color: var(--danger); font-weight: 600; }
#id_members { columns: 3 180px; max-width: 720px; }
#id_members > div { margin-bottom: .25rem; }
#id_members label { font-weight: 400; display: inline; }
.ok { color: var(--ok); }
.warn { color: var(--warning); }
.inline-form { margin: .4rem 0 0; }
.import-table td.imp-status { white-space: nowrap; }
.import-table .imp-actions { display: inline-flex; gap: 1.25rem; margin-left: 1.5rem; vertical-align: middle; }
.import-table .imp-po-hint { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); font-weight: 600; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.table th, .table td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: var(--group); font-weight: 600; font-size: .85rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.group td { background: var(--group); font-weight: 600; font-size: .9rem; }
.table tr.inactive td { color: var(--muted); }
.table tfoot td { font-weight: 600; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; align-items: center; }

/* journal entry form */
.je-head { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.je-head label { display: flex; flex-direction: column; font-weight: 500; gap: .2rem; }
.je-head label.check { flex-direction: row; align-items: center; gap: .4rem; }
.je-head label.grow { flex: 1; min-width: 260px; }
.je-head label.grow input { width: 100%; }
.je-lines select { width: 100%; min-width: 260px; }
.je-lines input.amt { width: 120px; text-align: right; }
.je-lines input[type=text] { width: 100%; }

/* reports */
.report { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; max-width: 900px; }
.report-head { text-align: center; margin-bottom: 1rem; }
.report-wide { max-width: 1200px; }
.doc-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .25rem; }
.doc-topbar .crumbs { margin: 0; }
.doc-nav { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; }
.doc-nav-btn { min-width: 2.6rem; justify-content: center; text-align: center; font-size: 1rem; line-height: 1; padding: .45rem .75rem; }
.doc-nav-btn.disabled { opacity: .35; cursor: default; pointer-events: none; }
.doc-nav-pos { white-space: nowrap; min-width: 4.5rem; text-align: center; }
.report-exports { display: flex; gap: .5rem; margin-left: auto; }
.report-table thead th { font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.report-table td.num { white-space: nowrap; }
.report-table tr.group td { font-weight: 700; }
.report-table tr.grand td { border-top: 1px solid var(--text); }
.reports-list { columns: 2 280px; column-gap: 2rem; }
.reports-list section { break-inside: avoid; margin-bottom: 1.25rem; }
.reports-list h2 { font-size: 1rem; margin: 0 0 .35rem; }
.reports-list a { display: block; padding: .2rem 0; }
.reports-list .muted { font-size: .8rem; margin: 0 0 .3rem; }
.report-head h1 { margin: .25rem 0; }
.report-table { border: 0; }
.report-table td { border-bottom: 0; padding: .25rem .6rem; }
.report-table tr.group td { background: none; padding-top: .8rem; }
.report-table tr.heading td { font-weight: 700; padding-top: 1rem; }
.report-table tr.subtotal td { font-weight: 600; }
.report-table tr.subtotal td.num, .report-table tr.total td.num { border-top: 1px solid var(--text); }
.report-table tr.total td { font-weight: 600; }
.report-table tr.grand td { font-weight: 700; padding-top: .5rem; }
.report-table tr.final td.num { border-top: 1px solid var(--text); border-bottom: 3px double var(--text); }

.login-box { max-width: 380px; margin: 8vh auto; }
.login-box label { display: block; margin-bottom: .8rem; font-weight: 500; }
.login-box input { width: 100%; margin-top: .2rem; }

@media print {
  .no-print, .topbar, .alert { display: none !important; }
  body, .report, .card, .table { background: #fff; border: 0; }
  main { padding: 0; max-width: none; }
  a { color: inherit; }
}

/* menus: dividers, inline forms */
.menu-heading { padding: .55rem 1rem .2rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #888; border-top: 1px solid #333; margin-top: .3rem; white-space: nowrap; }
.menu-items hr { border: 0; border-top: 1px solid #333; margin: .3rem 0; }
form.inline { display: inline; margin: 0; }
.hidden-form { display: none; }
.neg-red { color: var(--danger); }
.table.compact td { padding: .3rem .5rem; }
.table-scroll { overflow-x: auto; }

/* home: workflow chart */
.home-head { display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.home-head h1 { margin: 0; }
.home-head { align-items: center; }
.home-stats { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--muted); font-size: .95rem; }
.home-stats strong { color: var(--text); font-variant-numeric: tabular-nums; margin-left: .3rem; }
.home { display: grid; grid-template-columns: minmax(0, 900px) minmax(300px, 400px); gap: 1rem; align-items: start; }
@media (max-width: 1250px) { .home { grid-template-columns: minmax(0, 1fr); } }
.home-side { display: grid; gap: 1rem; }
.flow-panel { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.4rem .75rem .75rem; margin-bottom: 1rem; }
.home-side .flow-panel { margin-bottom: 0; }
.flow-panel.has-side-label { display: flex; align-items: center; gap: .25rem; padding-top: .75rem; }
.flow-panel.has-side-label .flow-scroll { flex: 1; min-width: 0; }
/* Reads bottom to top: vertical text turned 180deg, so the divider (border-left after the turn) faces the icons. */
.flow-side-label { flex: 0 0 auto; margin: 0; padding: 0 .5rem; border-left: 1px solid var(--border);
  writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; text-align: center;
  font-size: .9rem; font-weight: 700; line-height: 1.2; text-transform: uppercase; letter-spacing: .06em; }
.flow-title { position: absolute; top: -.8rem; left: 50%; transform: translateX(-50%); margin: 0; background: #fff; border: 1px solid #999;
  border-radius: 4px; padding: .1rem 1.4rem; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.flow-scroll { overflow: visible; }
@media (max-width: 960px) { .home-flow .flow-scroll { overflow-x: auto; padding-bottom: 8rem; margin-bottom: -8rem; } }
.flow { position: relative; margin: 0 auto; }
.flow-lines { position: absolute; inset: 0; pointer-events: none; }
.flow-lines path { fill: none; stroke: #000; stroke-width: 1.5; }
.flow-node { position: absolute; transform: translate(-50%, -22px); width: 118px; z-index: 1; }
.flow-node.open { z-index: 30; }
.flow-node .menu-button { display: flex; flex-direction: column; align-items: center; gap: .3rem; width: 100%; background: none; border: 0;
  padding: .2rem; cursor: pointer; font: inherit; font-size: .88rem; line-height: 1.2; color: var(--text); text-align: center; border-radius: 6px; }
.flow-node .menu-button:hover, .flow-node.open .menu-button { background: #efefef; }
.flow-node .menu-button:hover span, .flow-node.open .menu-button span { text-decoration: underline; }
.flow-node .menu-button:focus-visible { outline: 2px solid #000; }
.flow-node.soon .menu-button { color: var(--muted); }
.flow-node.soon .flow-icon { opacity: .45; }
.flow-icon { display: block; fill: none; stroke: #111; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; background: #fff; }
.flow-icon .f, #doc .f { fill: #fff; }
.flow-icon .g { fill: #dcdcdc; }
.flow-icon .b { stroke-width: 2.6; }
.flow-icon .t { fill: #111; stroke: none; font: 700 9px "Segoe UI", Arial, sans-serif; }
.flow-icon .t.s { font-size: 11px; }
.flow-node .menu-items { left: 50%; transform: translateX(-50%); top: 100%; margin-top: .2rem; border-top: 1px solid #333; border-radius: 6px; text-align: left; }
.flow-node.open .menu-items { display: block; }
.flow-node .menu-items a { display: block; padding: .45rem 1rem; color: #ddd; white-space: nowrap; text-decoration: none !important; }
.flow-node .menu-items a:hover, .flow-node .menu-items a:focus { background: #222; color: #fff; }
.node-menu-title { padding: .3rem 1rem .35rem; color: #888; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid #333; margin-bottom: .2rem; white-space: nowrap; }
.node-menu-note { padding: .4rem 1rem; color: #999; font-size: .85rem; white-space: nowrap; }
.balances .flow-title { left: 50%; }

/* document forms (bills, checks, POs...) */
.doc-head { display: flex; gap: .9rem 1.1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 1rem; }
.doc-head > label, .doc-head > .fld { display: flex; flex-direction: column; gap: .2rem; font-weight: 500; min-width: 150px; }
.doc-head > label.grow { flex: 1; min-width: 260px; }
.doc-head > label.grow input { width: 100%; }
.doc-head > label.check { flex-direction: row; align-items: center; gap: .4rem; align-self: center; min-width: 0; }
.doc-head small { font-weight: 400; }
.doc-head .err { font-weight: 600; font-size: .85rem; }
.doc-head .radio-row { display: flex; gap: .9rem; padding-top: .35rem; font-weight: 400; }
.doc-head .radio-row label { display: flex; gap: .35rem; align-items: center; }
.doc-head [hidden] { display: none; }
.seg { display: flex; gap: 1.2rem; margin-bottom: .8rem; }
.seg label { display: flex; gap: .35rem; align-items: center; font-weight: 600; }
/* Enter Bills tabs: Bill for items / Bill for expenses / Credit */
.doc-tabs { display: flex; flex-wrap: wrap; gap: 0; margin: -.2rem 0 1rem; border-bottom: 2px solid var(--border); }
.doc-tabs label { position: relative; padding: .5rem 1rem; margin-bottom: -2px; border: 1px solid transparent;
  border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.doc-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.doc-tabs label:has(input:checked) { color: var(--text); background: var(--surface); border-color: var(--border);
  border-bottom: 2px solid var(--accent); }
.doc-tabs label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.doc-tab-note { margin: -.4rem 0 .9rem; }
.doc-form[data-mode="item"] .col-acct,
.doc-form[data-mode="expense"] .col-item,
.doc-form[data-mode="credit"] .col-item { display: none; }
.doc-form[data-mode="item"] input.amt { background: var(--group); }
.doc-form .m-item, .doc-form .m-expense, .doc-form .m-credit, .doc-form .m-mixed { display: none; }
.doc-form[data-mode="item"] .m-item, .doc-form[data-mode="expense"] .m-expense,
.doc-form[data-mode="credit"] .m-credit, .doc-form[data-mode="mixed"] .m-mixed { display: inline; }
.doc-lines select { width: 100%; min-width: 170px; }
.doc-lines input.desc, .doc-lines textarea.desc { width: 100%; min-width: 180px; }
.doc-lines textarea.desc { resize: vertical; font: inherit; field-sizing: content; max-height: 12em; }
.doc-lines input.qty { width: 80px; text-align: right; }
.doc-lines input.rate { width: 105px; text-align: right; }
.doc-lines input.amt, #pay-form input.amt { width: 115px; text-align: right; }
/* Line-entry tables: titles centred over their columns, boxes centred under them. */
.doc-lines th, .doc-lines td, .doc-lines .num { text-align: center; vertical-align: middle; }
.doc-lines tfoot td:first-child { text-align: left; }

/* bank / card register */
.reg-sub { font-size: .95rem; font-weight: 400; margin-left: .4rem; }
.reg-scroll { max-height: calc(100vh - 280px); min-height: 320px; overflow: auto; border: 1px solid #999; background: #fff; }
.register { width: 100%; min-width: 1400px; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.register col.c-date { width: 132px; } .register col.c-num { width: 95px; } .register col.c-amt { width: 115px; }
.register col.c-clr { width: 34px; } .register col.c-act { width: 176px; } .register col.c-type { width: 80px; }
.register thead th { position: sticky; z-index: 2; background: #fff; color: #555; font-weight: 500; font-size: .75rem; letter-spacing: .05em;
  text-transform: uppercase; padding: .3rem .45rem; border-right: 1px solid #ddd; text-align: left; }
.register thead tr:first-child th { top: 0; border-bottom: 2px solid #999; }
.register td { padding: .28rem .45rem; border-right: 1px solid #e2e2e2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
/* Payee and Account take the width of their longest name; Memo gets what is left and is cut short with "..." */
.register tr.r1 td:nth-child(4), .register tr.r1 td:nth-child(5) { max-width: none; min-width: 160px; }
.register tr.r1 td:nth-child(6) { min-width: 140px; }
.register td.reg-actions { max-width: none; overflow: visible; vertical-align: middle; text-align: center; }
.register tr.r1 td { border-top: 1px solid #c8c8c8; }
.register .num { text-align: right; }
.register .center { text-align: center; }
.register tbody.reg-txn:hover tr.r1 td { background: #f6f6f6; }
.register tbody.flash tr td { animation: regflash 2s ease-out; }
@keyframes regflash { from { background: #fff3b0; } }
.register .clr { background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer; color: #bbb; font: inherit; padding: 0 .25rem; }
.register .clr:hover { border-color: #999; }
.register .clr.on { color: #000; font-weight: 700; }
.register tr.editing td { background: #fffbe6 !important; padding: .2rem .25rem; overflow: visible; }
.register tr.editing input, .register tr.editing select { width: 100%; padding: .2rem .3rem; font-size: .9rem; border-radius: 3px; }
.register tr.editing input.amt { text-align: right; }
.register tbody.reg-new tr.editing td { background: #fff !important; border-top: 2px solid #999; }
.register .reg-code { font-size: .8rem; color: #555; }
.reg-actions .btn.small { padding: .1rem .45rem; font-size: .78rem; }
.reg-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem .25rem; flex-wrap: wrap; }
.reg-ending { font-size: 1.5rem; margin-left: .75rem; font-variant-numeric: tabular-nums; }

/* Statement import review */
.import-table { width: 100%; }
.import-table td { vertical-align: middle; }
.import-table input[type=text] { width: 11rem; }
.import-table select { width: 12rem; }
.import-table .imp-desc { max-width: 13rem; font-size: .8rem; }
.import-table .imp-vmatch { display: block; font-size: .72rem; margin-top: .1rem; }
.import-table select.suggested { background: #f3f3f3; }
.import-table tr.imp-imported td { color: var(--muted); }
.import-table tr.imp-match, .import-table tr.imp-twice, .import-table tr.imp-flagged { background: #fffbe6; }
.import-table tr.imp-note td { border-top: 0; padding-top: 0; font-size: .8rem; }
.import-table tr.imp-note .warn { color: var(--warning); }
.inline-form { margin: .4rem 0 0; }
.import-table td.imp-status { white-space: nowrap; }
.import-table .imp-actions { display: inline-flex; gap: 1.25rem; margin-left: 1.5rem; vertical-align: middle; }
.import-table .imp-po-hint { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); font-weight: 600; }
.import-table tr.imp-note .ok { color: var(--muted); }
/* check notes: Error: red, Warning: orange, Confirmed: green (templatetags/notes.py) */
.note-error { color: var(--danger); }
.note-warn { color: #c2410c; }
.note-ok { color: #1b7f3b; }
.note-label { font-weight: 700; }
.alert-error .note-label { color: var(--danger); }
.imp-preview .imp-balances { display: block; margin-top: .3rem; }
.import-table tr.has-error { background: #fdecec; }
.fld-check label { display: flex; gap: .4rem; align-items: center; font-weight: normal; }
.overview-sub { margin: .75rem 0 .25rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.overview td { padding-top: .15rem; padding-bottom: .15rem; }
.overview tr.ov-sub td { font-weight: 600; border-top: 1px solid var(--border, #ccc); }
.overview tr.ov-total td { font-weight: 700; border-top: 1px solid #000; border-bottom: 3px double #000; }
.overview-sub a { color: inherit; }
.overview a.ov-drill { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.overview a.ov-drill:hover { color: var(--accent, #2563eb); border-bottom-style: solid; }
.overview-sub span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.overview-year { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .5rem; }
.overview-year label { font-weight: 600; }
.overview-year select { width: auto; }
.ov-statement { border-top: 1px solid var(--border); padding: .35rem 0; }
.ov-statement:last-of-type { border-bottom: 1px solid var(--border); }
.ov-statement summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.ov-statement[open] summary { margin-bottom: .25rem; }
.ov-statement p { margin: 0 0 .25rem; }
.ov-statement > a { display: inline-block; margin: .35rem 0 .15rem; }

/* Reconciliation */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
form.inline { display: inline; margin: 0; }
.rc { display: inline-block; font-size: .8rem; padding: .05rem .5rem; border-radius: 10px; border: 1px solid var(--border); white-space: nowrap; }
.rc-ok { background: #e6f4ea; color: #1e6b34; border-color: #2e7d32; font-weight: 600; }
.rc-warn { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); font-weight: 600; }
.rc-off { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); font-weight: 600; }
.recon-figures { max-width: 560px; }
.heat-wrap { overflow-x: auto; }
table.heat { border-collapse: separate; border-spacing: 2px; font-size: .8rem; }
table.heat th { font-weight: 600; color: var(--muted); text-align: center; padding: 0 0 2px; }
table.heat th[scope="row"] { text-align: left; color: var(--text); font-weight: 400; padding-right: .4rem; max-width: 9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm { width: 16px; height: 16px; min-width: 16px; border-radius: 3px; padding: 0; }
span.hm { display: inline-block; vertical-align: -3px; margin: 0 .2rem 0 .5rem; }
.heat-key span.hm:first-child { margin-left: 0; }
.hm-ok { background: #2e7d32; }
.rs { white-space: nowrap; font-weight: 600; }
.rs span.hm { width: 12px; height: 12px; min-width: 12px; margin: 0 .4rem 0 0; vertical-align: -1px; }
.rs-ok, .rs-ok a { color: #1b7f3b; }
.rs-off, .rs-off a { color: var(--danger); }
.rs-none { color: var(--muted); font-weight: 400; }
td.hm { position: relative; }
.hm-link { position: absolute; inset: 0; border-radius: 3px; }
.hm-link:hover, .hm-link:focus { outline: 2px solid #000; outline-offset: 1px; }
.hm-file { position: absolute; right: 2px; top: 2px; width: 6px; height: 6px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
span.hm > .hm-file { position: relative; display: block; left: 8px; top: 2px; }
.hm-off { background: #d32f2f; }
.hm-none { background: #e0e0e0; }
dialog.popup { border: 1px solid #000; border-radius: 8px; padding: 1.25rem 1.5rem; max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
dialog.popup::backdrop { background: rgba(0,0,0,.35); }
dialog.popup p { margin: 0 0 1rem; }
dialog.popup-error { border: 2px solid var(--danger); max-width: 560px; }
dialog.popup-error p { color: var(--danger); font-weight: 600; }
a.badge.status-error { text-decoration: none; }
dialog.popup form { text-align: right; margin: 0; }
/* order to cash: printable invoices, estimates, payment receipts and statements */
.sales-doc .sd-head { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sales-doc .sd-title { text-align: right; }
.sales-doc .sd-title h2 { margin: 0 0 .4rem; font-size: 1.6rem; letter-spacing: .02em; }
.sales-doc .sd-meta { margin-left: auto; border-collapse: collapse; }
.sales-doc .sd-meta th { text-align: left; font-weight: 600; padding: .1rem .8rem .1rem 0; color: var(--muted); }
.sales-doc .sd-meta td { text-align: right; padding: .1rem 0; }
.sales-doc .sd-parties { display: flex; gap: 3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sales-doc .sd-lines { margin-bottom: .8rem; }
.sales-doc .sd-due td { font-size: 1.05rem; border-top: 2px solid var(--text, #000); }
.sales-doc .sd-memo { white-space: pre-line; margin: .5rem 0 0; }
.sales-doc .sd-aging { width: auto; margin-left: auto; }
@media print {
  .sales-doc { padding: 0; }
  .statement + .statement { break-before: page; }
}
/* Company logo and legal name */
.home-company { display: flex; align-items: center; gap: 1rem; margin: .25rem 0 .9rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border, #ddd); }
.home-logo { max-height: 64px; max-width: 260px; object-fit: contain; }
.home-legal { font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
.doc-logo { max-height: 70px; max-width: 240px; object-fit: contain; margin-bottom: .4rem; }
.report-logo { display: block; margin: 0 auto .3rem; max-height: 56px; max-width: 220px; object-fit: contain; }
.report-company { font-weight: 600; }
.doc-letterhead { margin-bottom: .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border, #ddd); }
.logo-current { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.logo-current img { max-height: 70px; max-width: 260px; object-fit: contain; background: #fff; padding: .25rem; border: 1px solid var(--border, #ddd); }
.print-only { display: none; }
@media print {
  .print-only { display: block !important; }
  .doc-logo, .report-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
/* Email drafts */
.email-draft .fld { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .8rem; max-width: 760px; }
.email-draft input[type=text], .email-draft textarea { width: 100%; box-sizing: border-box; }
.email-sig { display: flex; align-items: center; gap: 14px; padding: .7rem .9rem; border: 1px dashed var(--border); border-radius: 6px; background: #fff; font-size: .9rem; line-height: 1.5; }
.email-sig-logo { padding-right: 14px; border-right: 2px solid var(--border); }
.email-sig-logo img { display: block; max-height: 60px; max-width: 220px; }
.email-sig a { text-decoration: underline; }

/* Manage Sales Tax */
.tax-due { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.tax-due .big { font-size: 1.6rem; }
.tax-due > div:last-child { flex: 1; min-width: 240px; }
.preset-links { display: flex; gap: .6rem; flex-wrap: wrap; align-self: center; font-size: .9rem; }
.preset-links a { text-decoration: underline; }
.preset-links a.active { font-weight: 700; text-decoration: none; }
.narrow-table { max-width: 520px; }

/* Tax rate import */
.status-updated { background: #eef4ff; color: #1f4e8c; border: 1px solid #1f4e8c; }
.table.compact th, .table.compact td { padding: .25rem .4rem; font-size: .85rem; }

/* Receipts: the paperclip on bills, Pay Bills and registers */
.clip { display: inline-flex; align-items: center; gap: 1px; color: var(--muted, #8a8f98); opacity: .45; text-decoration: none; vertical-align: middle; }
.clip:hover, .clip:focus-visible { opacity: 1; color: var(--accent, #2b6cb0); }
.clip.has { opacity: 1; color: var(--accent, #2b6cb0); }
.clip-n { font-size: 11px; font-weight: 600; }
.clip-icon { vertical-align: -3px; }
#receipt-messages .err { color: var(--danger, #c53030); }
/* The paperclip at the top of a bill (check, card charge ...) form */
.doc-clip { margin-left: auto; }
.doc-clip + .doc-nav { margin-left: 0; }
.doc-clip-btn { display: inline-flex; align-items: center; gap: .25rem; padding: .45rem .7rem; color: var(--muted, #8a8f98); }
.doc-clip-btn.has { color: var(--accent, #2b6cb0); }
.doc-clip-btn .clip-icon { width: 18px; height: 18px; vertical-align: 0; }
#doc-clip-n { font-size: 12px; font-weight: 600; }
.doc-clip-list { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .8rem; margin: 0 0 .5rem; }
.doc-clip-list[hidden] { display: none; }
.doc-clip-file { display: inline-flex; align-items: center; gap: .2rem; }
.doc-clip-x { background: none; border: 0; padding: 0 .2rem; cursor: pointer; color: var(--muted, #8a8f98); font-size: 1rem; line-height: 1; }
.doc-clip-x:hover { color: var(--danger, #c53030); }
/* The paperclip on each line of the statement import preview, and its popup */
.imp-clip { display: inline-flex; align-items: center; gap: 2px; color: var(--muted, #8a8f98); }
.imp-clip.has { color: var(--accent, #2b6cb0); border-color: var(--accent, #2b6cb0); }
.imp-clip-dlg { border: 1px solid #ccd; border-radius: 8px; padding: 1.2rem 1.4rem; min-width: 26rem; max-width: 40rem; }
.imp-clip-dlg::backdrop { background: rgba(0, 0, 0, .35); }
.imp-clip-dlg h3 { margin: 0 0 .2rem; }
.imp-clip-dlg ul { list-style: none; padding: 0; margin: .6rem 0; }
.imp-clip-dlg li { padding: .2rem 0; }
.imp-clip-x { background: none; border: 0; cursor: pointer; color: var(--muted, #8a8f98); font-size: 1.1rem; }
.imp-clip-x:hover { color: var(--danger, #c53030); }
.imp-clip-drop { border: 2px dashed #ccd; border-radius: 6px; padding: 1rem; text-align: center; margin: .5rem 0 1rem; }
.imp-clip-drop.over { border-color: var(--accent, #2b6cb0); background: #eef4ff; }
/* Bank reconciliation: payments to credit cards tie out (green) or need review (red) */
.tie { display: inline-block; padding: .2rem .65rem; border-radius: 4px; font-size: .85rem; font-weight: 600; white-space: nowrap; text-decoration: none; vertical-align: middle; border: 1px solid; }
.tie-ok { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.tie-bad { background: var(--danger, #c62828); border-color: var(--danger, #c62828); color: #fff; }
a.tie:hover { filter: brightness(.9); }
.card-tie h2 .tie { margin-left: .5rem; }

/* 0.33.0: pages open in tabs inside the app (static/js/tabs.js). The top window keeps the menu bar and a tab bar;
   each tab's page shows in an iframe, which hides its own menu bar. */
html.in-tab .topbar { display: none; }
html.tab-host body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
html.tab-host main { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 0; display: flex; flex-direction: column; }
html.tab-host #page, html.tab-host .app-version { display: none; }
html.tab-host main > .alert { margin: .5rem 1.5rem 0; }
.tabbar { display: flex; gap: 2px; align-items: flex-end; background: #2a2a2a; padding: 4px 1rem 0; overflow-x: auto; scrollbar-width: thin; flex: none; }
.tabbar[hidden] { display: none; }
.tabbar .tab-close-others { margin-left: auto; align-self: center; margin-bottom: 3px; flex: none; background: #fff;
  color: #000; font-weight: 700; border: 1px solid #fff; border-radius: 4px; font-size: .78rem; padding: .15rem .55rem;
  cursor: pointer; white-space: nowrap; }
.tabbar .tab-close-others:hover { background: #ddd; }
.tabbar .tab { display: flex; align-items: center; gap: .35rem; max-width: 15rem; min-width: 6rem; padding: .3rem .4rem .3rem .75rem;
  background: #444; color: #ddd; border-radius: 5px 5px 0 0; font-size: .85rem; cursor: pointer; white-space: nowrap; user-select: none; }
.tabbar .tab:hover { background: #555; color: #fff; }
.tabbar .tab.active { background: var(--bg); color: var(--text); font-weight: 600; }
.tabbar .tab:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.tabbar .tab-title { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tabbar .tab-close { border: 0; background: transparent; color: inherit; font-size: 1.05rem; line-height: 1; padding: 0 .25rem; border-radius: 3px; cursor: pointer; opacity: .7; }
.tabbar .tab-close:hover { opacity: 1; background: rgba(128,128,128,.35); }
.tab-frames { position: relative; flex: 1; min-height: 0; }
.tab-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); visibility: hidden; }
.tab-frame.active { visibility: visible; }

/* 0.41.0: a task the user can't open: shown greyed out, not clickable */
.flow-node.empty:not(.soon) .menu-button { opacity: .4; cursor: not-allowed; }
.flow-node.empty:not(.soon) .menu-button:hover { background: none; }
.flow-node.empty:not(.soon) .menu-items, .flow-node.empty:not(.soon):hover .menu-items { display: none !important; }

/* 0.41.0: Reports menu: pick a category, its reports open beside it */
.submenu { position: relative; }
.submenu-button { display: flex; justify-content: space-between; gap: 1.5rem; width: 100%; padding: .45rem 1rem; background: none; border: 0;
  color: var(--header-link); font: inherit; text-align: left; cursor: pointer; white-space: nowrap; }
.submenu:hover > .submenu-button, .submenu:focus-within > .submenu-button, .submenu.open > .submenu-button { background: #222; color: #fff; }
.submenu-items { display: none; position: absolute; left: 100%; top: -.35rem; min-width: 230px; padding: .35rem 0;
  background: #111; border: 1px solid #333; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.35); z-index: 21; }
.submenu:hover > .submenu-items, .submenu:focus-within > .submenu-items, .submenu.open > .submenu-items { display: block; }
.topbar .submenu-items a { display: block; padding: .45rem 1rem; color: var(--header-link); white-space: nowrap; }
.topbar .submenu-items a:hover, .topbar .submenu-items a:focus { background: #222; color: #fff; text-decoration: none; }
