/*
  VOICE   cool, exacting, understated: a card that is passed across a table
  IDEA    an engraved calling card: bone stock, black ink, small spaced capitals, everything centred
  PICTURE the wordmark itself, set like a card; figures set like a statement
  COLOUR  cool white card stock with a fine grain, charcoal ink; burgundy, ochre and green only for status
  TYPE    Cormorant SC (capitals with small capitals, old-style figures) for names and titles, Source Serif 4 for text and table figures
*/
:root {
  color-scheme: light;
  --bg: #efefec;
  --card: #f6f6f3;
  --ink: #262624;
  --muted: #5c5c57;
  --line: #dadad5;
  --accent: #262624;
  --accent-ink: #f6f6f3;
  --accent-soft: #e7e7e3;
  --brass: #8a8a84;
  --red: #7a1f2b;
  --red-soft: #f1e1dd;
  --amber: #6e4d0f;
  --amber-soft: #f0e6cf;
  --green: #1f5236;
  --green-soft: #e0e7d8;
  --caps: 600 15px/1.3 "Cormorant SC", "Cormorant Garamond", Georgia, serif;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: light; }
* { box-sizing: border-box; min-width: 0; }
body { margin: 0; font: 16px/1.5 "Source Serif 4", Georgia, "Times New Roman", serif; background: var(--bg); color: var(--ink); font-variant-numeric: lining-nums tabular-nums; overflow-x: clip; }
a { color: var(--accent); text-underline-offset: 3px; }
body, header, .card { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .48 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.brand .name, .brand .est, h2, h3, .stat .value, nav a.active { text-shadow: 0 1px 0 rgba(255,255,255,.75), 0 -.5px 0 rgba(0,0,0,.18); }

header { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: grid; justify-items: center; gap: 6px; padding: 20px 16px 8px; max-width: 960px; margin: 0 auto; text-align: center; }
.brand .name { font: 600 28px/1.05 "Cormorant SC", "Cormorant Garamond", Georgia, serif; letter-spacing: .03em; }
.brand .name span { font: inherit; color: inherit; }
.brand .est { font: var(--caps); font-size: 15px; color: var(--ink); letter-spacing: .03em; font-variant-numeric: oldstyle-nums; }
nav { display: flex; justify-content: safe center; gap: 2px; overflow-x: auto; padding: 2px 10px 0; scrollbar-width: none; max-width: 960px; margin: 0 auto; }
nav a { flex: none; padding: 12px 9px 12px; color: var(--muted); cursor: pointer; font: 500 15px/1.3 "Cormorant SC", "Cormorant Garamond", Georgia, serif; letter-spacing: .03em; text-decoration: none; border-bottom: 1px solid transparent; }
nav a:hover { color: var(--ink); }
nav a.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }
h2 { font: 600 26px/1.15 "Cormorant SC", "Cormorant Garamond", Georgia, serif; letter-spacing: .03em; text-align: center; margin: 10px 0 18px; text-wrap: balance; }
h2::after { content: ""; display: block; width: 40px; height: 1px; background: var(--brass); margin: 12px auto 0; }
h3 { font: var(--caps); font-size: 17px; letter-spacing: .03em; margin: 22px 0 10px; color: var(--ink); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 1px; padding: 18px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(60,50,30,.08); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; }
.stat { margin: 0; }
.stat { text-align: center; }
.stat .label { color: var(--muted); font: var(--caps); font-size: 14px; letter-spacing: .03em; }
.stat .value { font: 500 28px/1.15 "Cormorant Garamond", Georgia, serif; margin-top: 6px; font-variant-numeric: oldstyle-nums proportional-nums; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font: var(--caps); font-size: 14px; letter-spacing: .03em; border-bottom: 1px solid var(--ink); }
tr:last-child th { border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
td.num, th.num { text-align: right; white-space: nowrap; }
.scroll { overflow-x: auto; }

form { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 10px; }
label { font: var(--caps); font-size: 14px; letter-spacing: .03em; color: var(--muted); display: grid; gap: 6px; }
input, select, textarea { font: 16px/1.4 "Source Serif 4", Georgia, serif; font-variant: normal; letter-spacing: 0; text-transform: none; padding: 9px 10px; border: 1px solid var(--line); border-radius: 2px; background: var(--bg); color: var(--ink); width: 100%; min-height: 44px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, nav a:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
textarea { min-height: 240px; font: 14px/1.5 ui-monospace, Menlo, monospace; }
button { font: 600 16px/1 "Cormorant SC", "Cormorant Garamond", Georgia, serif; letter-spacing: .04em; padding: 12px 18px; min-height: 44px; border: 1px solid var(--accent); border-radius: 2px; background: var(--accent); color: var(--accent-ink); cursor: pointer; justify-self: start; }
button:hover { filter: brightness(1.12); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); padding: 8px 12px; min-height: 36px; font-weight: 500; letter-spacing: .03em; }
button.ghost:hover { border-color: var(--accent); filter: none; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 2px; font: 600 13px/1.4 "Cormorant SC", "Cormorant Garamond", Georgia, serif; letter-spacing: .03em; border: 1px solid currentColor; }
.overdue { background: var(--red-soft); color: var(--red); }
.due_soon { background: var(--amber-soft); color: var(--amber); }
.upcoming { background: var(--accent-soft); color: var(--accent); }
.done { background: var(--green-soft); color: var(--green); }
.info { background: transparent; color: var(--muted); }

.ob { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ob:last-of-type { border-bottom: 0; }
.ob .t { font-weight: 500; }
.ob .d, .muted { color: var(--muted); font-size: 14px; }
.ob.isdone .t { text-decoration: line-through; color: var(--muted); }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 2px; display: none; max-width: 90vw; z-index: 30; }
.login { max-width: 360px; margin: 60px auto; }
.lines .row { grid-template-columns: 2fr 1fr 1fr; }

.modal, .preview { position: fixed; inset: 0; background: rgba(16, 24, 15, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal .card { width: min(440px, 100%); margin: 0; }
.preview .card { width: min(720px, 100%); max-height: 85vh; overflow: auto; margin: 0; }
.preview img { max-width: 100%; }
.preview pre { white-space: pre-wrap; font-size: 13px; max-height: 60vh; overflow: auto; }

@media (max-width: 600px) {
  h2 { font-size: 30px; }
  .stat .value { font-size: 23px; }
  table { font-size: 14px; }
  .lines .row { grid-template-columns: 1fr 1fr; }
  .lines .row select { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) {
  main > * { animation: rise .35s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } }
}

.card { position: relative; }
.card > .help { position: absolute; top: 8px; right: 8px; }
.card > .help ~ h3, .card > .help ~ .label { padding-right: 34px; }
.help { width: 30px; height: 30px; min-height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 500 15px/1 "Cormorant Garamond", Georgia, serif; letter-spacing: 0; text-shadow: none; }
.help:hover { color: var(--ink); border-color: var(--ink); filter: none; }
.stat .label { padding: 0 30px; }
.ob-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ob-side .help { position: static; }
.card > .help ~ table { margin-top: 28px; }

#company { width: auto; min-height: 34px; padding: 4px 28px 4px 10px; margin-top: 4px; font: var(--caps); font-size: 15px; letter-spacing: .03em; background-color: transparent; border-color: var(--line); text-align: center; }
#company[hidden] { display: none; }
.stat .value .muted { font: 14px/1.4 "Source Serif 4", Georgia, serif; margin-top: 2px; }
.card > .help ~ .row:first-of-type { padding-right: 34px; }
