:root {
  --bg: #f4f4f2; --panel: #ffffff; --ink: #1b1b1b; --muted: #5f625f; --line: #d4d6d2;
  --accent: #111111; --accent-ink: #ffffff; --soft: #ececea;
  --new: #2f5d8a; --talking: #8a6a1f; --proposal: #6b3f8a; --won: #2e6b3f; --lost: #8a3a32;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
a { color: inherit; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px max(16px, 3vw);
  background: var(--accent); color: var(--accent-ink); }
.top .brand { font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.top nav a { text-decoration: none; opacity: .85; }
.top nav a:hover { opacity: 1; text-decoration: underline; }
.top .link { color: var(--accent-ink); }
main { max-width: 1180px; margin: 0 auto; padding: 24px max(16px, 3vw) 64px; }
h1 { font-size: 1.8rem; margin: 0 0 8px; }
h2 { font-size: 1.2rem; margin: 32px 0 8px; }
p { max-width: 75ch; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.narrow { max-width: 380px; margin: 10vh auto 0; }
.flash { padding: 10px 14px; border-radius: 6px; background: var(--soft); max-width: none; }
.flash.error { background: #f7e1de; color: #6d2620; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 14px 0; }
.filters a { margin-left: 8px; }
.filters a[aria-current] { font-weight: 700; }
button, .button { display: inline-block; font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; }
button.secondary, .button.secondary { background: var(--panel); color: var(--ink); }
button.link { background: none; border: none; padding: 0; text-decoration: underline; font-weight: 400; color: inherit; }
button.small { padding: 3px 8px; font-size: .85rem; }
form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 900px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--ink); width: 100%; }
input[type=checkbox] { width: auto; }
input.ro { background: var(--soft); }
input.guess { color: var(--muted); font-style: italic; }
textarea { resize: vertical; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px 16px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; background: var(--panel); display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 700; padding: 0 6px; }
details summary { cursor: pointer; font-weight: 600; margin: 4px 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; text-decoration: none; display: flex; flex-direction: column; }
.tile b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .9rem; }
.tile.attention { border-color: var(--talking); }
.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { white-space: nowrap; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.edit input { min-width: 140px; padding: 6px 8px; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.pill.new { background: #e2ebf4; color: var(--new); }
.pill.talking { background: #f4eddc; color: var(--talking); }
.pill.proposal { background: #ece3f2; color: var(--proposal); }
.pill.won { background: #e0eee4; color: var(--won); }
.pill.lost { background: #f4e2df; color: var(--lost); }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.pre { white-space: pre-wrap; }
:focus-visible { outline: 2px solid var(--new); outline-offset: 2px; }
@media (max-width: 640px) { .top nav { order: 3; flex-basis: 100%; } .top { justify-content: space-between; } }
/* Home: control centre */
.needs { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--talking);
  border-radius: 8px; padding: 12px 16px; margin: 16px 0 20px; }
.needs h2 { margin: 0 0 6px; font-size: 1rem; }
.needs p { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 1.15rem; }
.card h2 a { text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.card p { margin: 0; }
.card ul.plain { gap: 4px; }
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 0; }
.figures div { background: var(--soft); border-radius: 6px; padding: 8px 10px; }
.figures dt { font-size: .8rem; color: var(--muted); }
.figures dd { margin: 0; font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: auto; padding-top: 4px; }
.subnav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 14px; font-size: .95rem; }
.subnav a { text-decoration: none; color: var(--muted); }
.subnav a[aria-current] { color: var(--ink); font-weight: 700; border-bottom: 2px solid var(--ink); }
/* Budget */
.figures.wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 12px 0; }
.figures dd small { font-size: .8rem; font-weight: 400; color: var(--muted); }
.figures dd.neg { color: var(--lost); }
.figures dd.pos { color: var(--won); }
.month { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 16px 0; }
.month.current { border-color: var(--talking); border-width: 2px; }
.month-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 14px; }
.month-head h2 { margin: 0 0 8px; }
.month .scroll { border: 0; border-radius: 0; }
.month-sum { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-top: 10px; }
.month-sum dd { font-size: 1.1rem; }
table.budget td a { text-decoration: none; }
table.budget td a:hover { text-decoration: underline; }
.pill.st-to_invoice { background: #f4e2df; color: var(--lost); }
.pill.st-awaiting_approval { background: #f4eddc; color: var(--talking); }
.pill.st-awaiting_payment { background: #e2ebf4; color: var(--new); }
.pill.st-paid { background: #e0eee4; color: var(--won); }
.group-h { font-size: 1.35rem; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.card .figures { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.card .figures dd { font-size: 1.05rem; white-space: nowrap; }
.card .figures div { padding: 8px; }
.figures div { min-width: 0; }
.card .figures.two { grid-template-columns: 1fr 1fr; }
.figures dd small.neg { color: var(--lost); font-weight: 600; }
.figures dd small.pos { color: var(--won); font-weight: 600; }
/* Budget months: a couple of sizes smaller than the rest of the page */
.month { font-size: .875rem; }
.month-head h2 { font-size: 1.05rem; }
.month table.budget { font-size: .85rem; }
.month table.budget th { font-size: .7rem; }
.month table.budget td, .month table.budget th { padding: 6px 8px; }
.month .pill { font-size: .72rem; }
.month-sum { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; }
.month-sum div { padding: 6px 8px; }
.month-sum dt { font-size: .72rem; }
.month-sum dd { font-size: .95rem; }
.month-sum div.total { background: var(--ink); }
.month-sum div.total dt, .month-sum div.total dd { color: var(--accent-ink); }
