/* Catalyst staff UI and portal. Plain CSS, no build step.
   The look follows the Viridian Guard site: warm paper in light mode, deep
   spruce in dark mode, a serif for headings, mono for small labels. The theme
   follows the system unless someone picks one (theme.js sets data-theme). */

@font-face { font-family: "Public Sans"; src: url("/static/fonts/public-sans.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/static/fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/static/fonts/geist-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/static/fonts/geist-mono-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --sans: "Public Sans", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, monospace;

  /* Light: paper. */
  --bg: #f4f1ea;
  --surface: #fbfaf6;
  --ink: #1d2622;
  --muted: #555e59;
  --line: rgba(22, 48, 42, 0.16);
  --accent: #2a6e55;
  --btn: #16302a;
  --btn-ink: #ffffff;
  --btn-hover: #2a6e55;
  --ok: #2a6e55;
  --bad: #a23b2a;
  --sel: #8be3bf;
  /* The header bar is spruce in both themes. */
  --bar-bg: #16302a;
  --bar-ink: #eef3ef;
  --bar-muted: #b4c4bc;
  --bar-accent: #8be3bf;
  --bar-line: rgba(139, 227, 191, 0.18);
  --radius: 6px;
  color-scheme: light;
}
/* Dark: spruce. Kept in two places (system preference unless light was
   chosen, and an explicit choice) because CSS cannot share the block. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16302a;
    --surface: #1d3b34;
    --ink: #eef3ef;
    --muted: #b4c4bc;
    --line: rgba(139, 227, 191, 0.18);
    --accent: #8be3bf;
    --btn: #f4f1ea;
    --btn-ink: #16302a;
    --btn-hover: #ffffff;
    --ok: #8be3bf;
    --bad: #f39a87;
    --bar-bg: #10241f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16302a;
  --surface: #1d3b34;
  --ink: #eef3ef;
  --muted: #b4c4bc;
  --line: rgba(139, 227, 191, 0.18);
  --accent: #8be3bf;
  --btn: #f4f1ea;
  --btn-ink: #16302a;
  --btn-hover: #ffffff;
  --ok: #8be3bf;
  --bad: #f39a87;
  --bar-bg: #10241f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--sel); color: #16302a; }
code { font: 0.88em var(--mono); }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; font-optical-sizing: auto; }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 1.25rem; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 0 0 0.75rem; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem;
  padding: 0.85rem 16px;
  background: var(--bar-bg);
  color: var(--bar-ink);
  border-bottom: 1px solid var(--bar-line);
  color-scheme: dark;
}
.brand { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.bar .brand { color: var(--bar-ink); }
.bar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.bar nav a { color: var(--bar-muted); text-decoration: none; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.bar nav a:hover { color: var(--bar-ink); }
.bar nav a[aria-current="page"] { color: var(--bar-ink); border-bottom-color: var(--bar-accent); }
.bar a, .bar button.link { color: var(--bar-accent); }
.bar :focus-visible { outline-color: var(--bar-accent); }
.who { display: flex; align-items: center; gap: 0.75rem; color: var(--bar-muted); font-size: 0.9rem; }
.who form { margin: 0; }
.role {
  font: 500 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em;
  border: 1px solid var(--bar-line); border-radius: 999px; padding: 0.1rem 0.5rem; color: var(--bar-accent);
}
button.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: none; border: 1px solid var(--bar-line); border-radius: 999px;
  padding: 0.15rem 0.65rem; font-size: 0.85rem; color: var(--bar-muted); cursor: pointer;
}
button.theme-toggle[hidden] { display: none; }
button.theme-toggle:hover { color: var(--bar-ink); border-color: var(--bar-accent); }
body.plain .theme-toggle { position: fixed; top: 12px; right: 16px; color: var(--muted); border-color: var(--line); }

main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.grid th, .grid td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid th { font: 500 0.72rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.grid tr.more td { text-align: center; }
@media (max-width: 640px) {
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid thead { display: none; }
  .grid tr { border-bottom: 1px solid var(--line); padding: 0.5rem 0; }
  .grid td { border: 0; padding: 0.15rem 0.75rem; }
}

.muted { color: var(--muted); }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

button.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline;
}
.button {
  display: inline-block; background: var(--btn); color: var(--btn-ink);
  padding: 0.55rem 1.1rem; border-radius: 4px; text-decoration: none; font-weight: 600;
  transition: background 0.15s ease;
}
.button:hover { background: var(--btn-hover); }

body.plain { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  max-width: 28rem; width: 100%; padding: 1.5rem; margin: 0;
}
.card .brand { margin: 0 0 1rem; color: var(--accent); }

.htmx-request { opacity: 0.6; }

/* Ledger and forms */
.subnav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: -0.5rem 0 1rem; font-size: 0.95rem; }
.subnav a { color: var(--muted); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
h2 { margin-top: 1.5rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-bottom: 1rem; }
.toolbar h2 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; margin: 0 0 1rem; }
.filters label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 0.2rem; }
.form { display: grid; gap: 0.9rem; max-width: 36rem; }
.form.wide { max-width: none; }
.form label { display: grid; gap: 0.3rem; font-weight: 600; }
.form label small { font-weight: 400; }
.form label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.form .row { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.form .row label { flex: 1 1 14rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.55rem; min-width: 0; width: 100%;
}
.filters input, .filters select { width: auto; }
button:not(.link):not(.button):not(.theme-toggle) {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.45rem 0.9rem; cursor: pointer;
}
button:not(.link):not(.button):not(.theme-toggle):hover { border-color: var(--accent); }
button.button { border: 0; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 0.5rem; }
form.inline { display: inline; margin: 0; }
.danger { color: var(--bad) !important; }
.problems { border: 1px solid var(--bad); border-radius: var(--radius); padding: 0.5rem 1rem; margin-bottom: 1rem; background: var(--surface); }
.problems p { margin: 0.25rem 0; color: var(--bad); }
.problems ul { margin: 0.25rem 0 0.5rem; padding-left: 1.25rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid tr.sum td { font-weight: 600; background: var(--bg); }
.grid.lines td { padding: 0.3rem 0.4rem; vertical-align: middle; }
.grid.lines input.num, .grid.lines td.num input { text-align: right; }
.tag {
  display: inline-block; font-size: 0.75rem; border: 1px solid var(--line); border-radius: 999px;
  padding: 0 0.5rem; color: var(--muted); white-space: nowrap;
}
.tag.draft { border-color: var(--bad); color: var(--bad); }
.pager { display: flex; gap: 1rem; }
@media (max-width: 640px) {
  .grid td.num { text-align: left !important; }
  .grid.lines td { padding: 0.25rem 0.75rem; }
}
.form label :is(input, select, textarea) { font-weight: 400; }
:is(.grid, .facts) + :is(form, .panel, .actions, p), .panel > form + p { margin-top: 1rem; }
.panel h2:first-child { margin-top: 0; }
@media (max-width: 640px) {
  .grid tfoot, .grid tfoot tr { display: block; width: 100%; }
  .grid tfoot td { display: flex; justify-content: space-between; }
  .grid tfoot td:empty { display: none; }

}
.mobile-only { display: none; }
@media (max-width: 640px) { .mobile-only { display: inline; color: var(--muted); font-weight: 400; } }

/* Billing (M2) */
.notice {
  padding: 0.6rem 0.9rem; margin: 0 0 1rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.notice.ok { border-left-color: var(--ok); }
.form fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; gap: 0.9rem;
  padding: 0.75rem 1rem 1rem; margin: 0; min-width: 0;
}
.form fieldset[disabled] { border: 0; padding: 0; }
.form legend { font-weight: 600; padding: 0 0.35rem; }
input:not([type=checkbox]):focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
input[type=checkbox] { accent-color: var(--accent); }
.form fieldset > p { margin: 0 0 0.75rem; }
.pre { white-space: pre-line; }
.tag.bad { color: var(--bad); border-color: var(--bad); }
tr.muted td { color: var(--muted); }
.lines td small { display: block; margin-top: 0.2rem; }
.form label { align-content: start; }
.form > p, .form > h2, .form fieldset > p { margin: 0; }
.grid form.inline { display: inline-flex; align-items: center; gap: 0.5rem; }
.grid form.inline input { width: auto; }
@media (max-width: 640px) {
  .grid.lines td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.8rem; color: var(--muted);
  }
}

/* M3: payments and the client portal */
.tag.ok { color: var(--ok); border-color: var(--ok); }
.notice.bad { border-left-color: var(--bad); }
code.wrap { overflow-wrap: anywhere; word-break: break-all; }
details.panel > summary { cursor: pointer; font-weight: 600; }
details.panel[open] > summary { margin-bottom: 0.9rem; }
main.narrow { max-width: 52rem; }
body.portal .bar .who span { color: var(--bar-ink); }
.summary .facts dd strong { font-size: 1.25rem; }
p.problems { color: var(--bad); }
@media (max-width: 640px) {
  .grid:not(.lines) td[data-label]::before {
    content: attr(data-label); display: inline-block; min-width: 6.5rem; color: var(--muted); font-size: 0.85rem;
  }
}
.button.danger, button.button.danger { background: var(--bad); border-color: var(--bad); color: var(--bg) !important; }
.grid td form.inline + form.inline { margin-left: 0.75rem; }

/* Report index: panels side by side where there is room. */
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.cards .panel ul { margin: 0 0 0.5rem; padding-left: 1.1rem; }
.cards .panel li { margin: 0.3rem 0; }
