/* TBooks: a ledger green header over a calm grey page; numbers in tabular figures, debits and credits in columns. */
:root {
  color-scheme: light;
  --ink: #1b2420; --muted: #56635c; --line: #dbe2de; --paper: #fff; --bg: #f2f5f3; --soft: #eef2ef;
  --accent: #1f6f4a; --accent-ink: #fff; --accent-soft: #e2f1e8; --head: #123d2b; --head-2: #19503a; --gold: #f2b705;
  --good: #1e6b34; --good-bg: #e5f6e9; --good-line: #b9e3c4;
  --warn: #7a5200; --warn-bg: #fdf3df; --warn-line: #f0d9a8;
  --bad: #9b2c1f; --bad-bg: #fbe8e5; --bad-line: #f0bdb4;
  --info: #2b4f8a; --info-bg: #e7eefa; --info-line: #c4d4ef;
  --field: #74827a; --focus: #b35c00; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e9ece9; --muted: #aeb7b1; --line: #2f3632; --paper: #181c1a; --bg: #101311; --soft: #202623;
    --accent: #6fc69a; --accent-ink: #0b1a12; --accent-soft: #17311f; --head: #0d2419; --head-2: #133223; --gold: #f2c33d;
    --good: #7fd69a; --good-bg: #16301f; --good-line: #2c5a3a;
    --warn: #f2c66d; --warn-bg: #33270e; --warn-line: #5c4718;
    --bad: #f3a196; --bad-bg: #3a1a16; --bad-line: #6b2d25;
    --info: #9cbcf0; --info-bg: #1a2638; --info-line: #2f4566;
    --field: #7c8a82; --focus: #ffb35c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
.btn, .brand, .menu a, .nav a, .nav-out, .new-list a, .tabs a, .tile { text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.site-header :focus-visible { outline-color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: #fff; color: #123d2b; padding: 8px 14px; border-radius: 8px; z-index: 50; font-weight: 600; }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Header and menu */
.site-header { background: var(--head); color: #fff; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { color: #fff; font-weight: 750; font-size: 1.15rem; letter-spacing: .01em; }
.co-name { color: rgba(255,255,255,.9); font-weight: 600; font-size: .92rem; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.nav a, .nav-out { color: rgba(255,255,255,.92); padding: 7px 10px; border-radius: 8px; font-size: .92rem; font-weight: 500; }
.nav a:hover, .nav-out:hover { background: rgba(255,255,255,.14); }
.nav a.cta, .new-btn { background: var(--gold); color: #1d1600; font-weight: 700; border-color: transparent; }
.nav a.cta:hover { background: #ffc933; }
.switcher select { width: auto; min-height: 34px; padding: 4px 8px; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.45); font-size: .88rem; max-width: 220px; }
.switcher select option { color: #1b2420; background: #fff; }
.new-menu { position: relative; }
.new-menu summary { list-style: none; cursor: pointer; }
.new-menu summary::-webkit-details-marker { display: none; }
.new-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.18); padding: 6px; min-width: 190px; z-index: 30; display: grid; }
.new-list a { color: var(--ink); padding: 8px 10px; border-radius: 7px; font-size: .93rem; }
.new-list a:hover { background: var(--soft); }
.menu { background: var(--head-2); }
.menu-row { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.menu-row::-webkit-scrollbar { display: none; }
.menu a { color: rgba(255,255,255,.86); padding: 10px 12px; font-size: .92rem; font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; }
.menu a:hover { color: #fff; background: rgba(255,255,255,.07); }
.menu a.active { color: #fff; border-bottom-color: var(--gold); font-weight: 650; }

main.wrap { padding-top: 22px; padding-bottom: 48px; }
h1 { font-size: 1.55rem; margin: 0 0 10px; line-height: 1.2; } h2 { font-size: 1.12rem; margin: 0 0 12px; line-height: 1.3; } h3 { font-size: 1rem; margin: 14px 0 6px; }
.muted { color: var(--muted); } .small { font-size: .87rem; } .tiny { font-size: .78rem; } .center { text-align: center; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.neg { color: var(--bad); }
.pre { white-space: pre-line; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card.narrow { max-width: 600px; margin-left: auto; margin-right: auto; }
.card.flush { padding: 0; overflow: hidden; }
.card.danger { border-color: var(--bad-line); }
.card .pad { padding: 14px 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h1, .section-head h2 { margin: 0; }
.row { display: flex; align-items: center; flex-wrap: wrap; } .gap { gap: 8px; } .grow { flex: 1 1 200px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid.fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 0 14px; }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
@media (max-width: 880px) { .grid.main-side { grid-template-columns: 1fr; } }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 4px 0; }

/* Figures on the dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: inherit; }
a.tile:hover { border-color: var(--accent); }
.tile .label { font-size: .84rem; color: var(--muted); margin: 0; }
.tile .value { font-size: 1.5rem; font-weight: 700; margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: .82rem; color: var(--muted); margin: 2px 0 0; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 4.2em 1fr; gap: 8px; align-items: center; font-size: .82rem; }
.bar-pair { display: grid; gap: 2px; }
.bar-in, .bar-out { height: 9px; border-radius: 3px; min-width: 2px; }
.bar-in { background: var(--accent); } .bar-out { background: #d9822b; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .k-in::before { background: var(--accent); } .legend .k-out::before { background: #d9822b; }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; min-height: 40px; line-height: 1.2; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.outline { background: transparent; color: var(--accent); }
.btn.small { padding: 5px 11px; font-size: .86rem; min-height: 32px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.outline.danger { background: transparent; color: var(--bad); }
.linkish { background: none; border: 0; padding: 0 4px; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.field { margin-bottom: 12px; min-width: 0; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin: 6px 0; }
label.check input { margin-top: 4px; flex: none; width: auto; min-height: 0; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--field); border-radius: 8px; padding: 8px 10px; min-height: 40px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--accent); }
input.amt, td input.amt { text-align: right; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; }
.hint { font-size: .82rem; color: var(--muted); margin: 4px 0 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; }
.filters input, .filters select { min-height: 36px; padding: 6px 9px; }

/* Messages */
.flash, .alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; border: 1px solid; }
.flash.ok, .alert.ok { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.flash.error, .alert.error { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.flash.info, .alert.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.pill { display: inline-block; font-size: .76rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.paid { background: var(--good-bg); color: var(--good); } .pill.overdue { background: var(--bad-bg); color: var(--bad); }
.pill.open, .pill.partial { background: var(--info-bg); color: var(--info); } .pill.draft { background: var(--warn-bg); color: var(--warn); }
.pill.void { text-decoration: line-through; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }   /* relative: hidden labels inside stay inside */
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; background: var(--soft); }
tbody tr:hover td { background: color-mix(in srgb, var(--soft) 60%, transparent); }
tr.total td, tr.subtotal td { font-weight: 700; border-top: 2px solid var(--line); }
tr.grand td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
tr.section td { font-weight: 700; background: var(--soft); }
td.indent { padding-left: 26px; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 20px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 20px; }
td .muted.small { display: block; }
.empty { padding: 26px 20px; text-align: center; color: var(--muted); }

/* Line-item editors (invoices, bills, transactions) */
.lines td { padding: 6px 6px; vertical-align: middle; }
.lines input, .lines select { min-height: 36px; padding: 6px 8px; }
.lines .del { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.lines .del:hover { color: var(--bad); }
.lines tfoot td { border-bottom: 0; }
.totals { margin-left: auto; max-width: 340px; }
.totals td { border: 0; padding: 4px 6px; }
.totals tr.grand td { border-top: 2px solid var(--ink); }
@media (max-width: 720px) {
  .lines thead { display: none; }
  .lines tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .lines tbody td { border: 0; padding: 0; }
  .lines tbody td.wide { grid-column: 1 / -1; }
  .lines tbody td::before { content: attr(data-label); display: block; font-size: .74rem; color: var(--muted); font-weight: 600; }
}

/* An invoice to print or save as a PDF */
.paper { background: #fff; color: #1b2420; max-width: 860px; margin: 0 auto; padding: 40px 44px; border: 1px solid var(--line); border-radius: 6px; }
.paper .doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.paper .doc-title { font-size: 1.9rem; font-weight: 800; letter-spacing: .02em; color: #123d2b; margin: 0; }
.paper table th { background: #f1f4f2; color: #56635c; }
.paper td, .paper th { border-color: #dbe2de; }
.paper .muted { color: #56635c; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; max-width: 860px; margin: 0 auto 14px; }
@media print {
  .site-header, .site-footer, .doc-actions, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main.wrap { padding: 0; max-width: none; }
  .paper { border: 0; padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
}

/* Reconciling */
.rec-bar { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); padding: 12px 20px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; justify-content: space-between; box-shadow: 0 -6px 16px rgba(0,0,0,.06); }
.rec-bar .figs { display: flex; gap: 18px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.diff-ok { color: var(--good); font-weight: 700; } .diff-bad { color: var(--bad); font-weight: 700; }

/* Landing page */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 28px; align-items: center; padding: 18px 0 28px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); line-height: 1.08; margin-bottom: 14px; text-wrap: balance; }
.hero .lede { font-size: 1.1rem; color: var(--muted); max-width: 56ch; }
.ledger-demo { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 14px 34px rgba(18,61,43,.10); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.features .card h2 { font-size: 1.02rem; margin-bottom: 6px; }

.site-footer { border-top: 1px solid var(--line); padding: 22px 0 30px; color: var(--muted); font-size: .9rem; }
.site-footer p { margin: 0 0 6px; }
.inline-form { display: inline; }
input.short, .short { max-width: 180px; }
