/* Omarchy-styled: one monospace face, dense rows, the active theme's palette
   from themes.json applied as CSS variables by app.js. Defaults below are
   Tokyo Night so the page is right before the script runs, with the
   contrast floor of contrast.js already applied (Tokyo Night's own dim text
   is 2.8:1). The page's rules are in one layer; the keyboard focus at the
   end is outside it, so no rule in the page can take the focus mark away. */
@layer page {
:root {
  --bg: #1a1b26;
  --bg-dark: #13141c;
  --bg-darker: #0e0e14;
  --bg-light: #252a3d;
  --fg: #a9b1d6;
  --fg-dim: #7781ae;
  --fg-light: #b4bee6;
  --fg-bright: #c0caf5;
  --accent: #7aa2f7;
  --selection: #292e42;
  --muted: #414868;
  --red: #f7768e;
  --yellow: #e0af68;
  --green: #9ece6a;
  --cyan: #449dab;
  --blue: #7aa2f7;
  --magenta: #ad8ee6;
  /* The keyboard focus mark: the accent, at 3:1 or more on every background (set per theme by contrast.js). */
  --focus: #7aa2f7;
  /* The border of a typed field: --muted at 3:1 or more on the base and the panel (contrast.js). */
  --field: #5e6587;
  /* The line between a page's header and its content. --muted, not --bg-light:
     that one is hardly there on the dark themes and vanishes on the light ones. */
  --rule: var(--muted);
  --font: "JetBrainsMono Nerd Font", "JetBrains Mono", "Cascadia Mono", "Fira Code", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
  /* The interface size (settings): text, bars and the icons scale with it; tap areas keep their 44px floor.
     Set on <html> by size.js before the first paint, from the auth account through GET /me. */
  --ui: 1;
}
:root[data-size="small"] { --ui: 0.875; }
:root[data-size="large"] { --ui: 1.15; }

* { box-sizing: border-box; }
/* Everything still scrolls, by wheel, touch and keys; the bars themselves are not drawn. */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: calc(13px * var(--ui))/1.5 var(--font);
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
button, input, textarea { font: inherit; }
/* The parts the browser draws take the theme too: the placeholder at the dim text's floored contrast, selected text, the caret. */
::placeholder { color: var(--fg-dim); opacity: 1; }
::selection { background: var(--selection); color: var(--fg-bright); }
input, textarea { caret-color: var(--accent); }

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: calc(34px * var(--ui));
  background: var(--bg-dark);
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
}
.bar.top { border-bottom: 1px solid var(--rule); }
.bar.bottom { border-top: 1px solid var(--bg-light); gap: 18px; font-size: calc(12px * var(--ui)); }
/* The installed app on a phone with a notch: the page is drawn edge to edge (viewport-fit=cover)
   and nothing sits under the notch, the rounded corners or the home indicator. The top bar
   reaches up behind the status bar in its own colour; the rest keeps clear. Zero elsewhere. */
.bar.top { height: calc(34px * var(--ui) + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }
.bar { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
.bar.bottom { height: calc(34px * var(--ui) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); }
main { margin-left: env(safe-area-inset-left, 0px); margin-right: env(safe-area-inset-right, 0px); }
.bar.bottom b { color: var(--fg); font-weight: 500; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; letter-spacing: 0.02em; text-decoration: none; }
.brand .logo { height: calc(22px * var(--ui)); width: auto; display: block; }
.login .logo { height: 56px; width: auto; margin: 0 auto 12px; display: block; }
.grow { flex: 1; }
.title { color: var(--fg-bright); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.title:empty { display: none; }
.status { color: var(--yellow); }
.chip {
  background: transparent;
  color: var(--fg);
  border: 0;
  border-radius: 3px;
  padding: 1px 8px;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
}
/* A chip beside the filter or a title is one short label: it keeps to one line, and the field or the title gives way. */
.tools .chip, .inv-title .chip { white-space: nowrap; flex: none; }
.chip:hover, .chip:focus-visible { color: var(--fg-bright); background: var(--bg-light); }
/* The one button, everywhere: a word (or a drawn mark) with no box around it. The page's own buttons
   (dialogs, the invoice editor, notes, a project's page) are the chip's twins; the primary one is the
   accent word, a pressed or chosen one is bright on a 2px accent line, a dangerous one turns red. */
.dialog button, .invoice button:not(.chip), .note-actions button, .project button:not(.chip) {
  background: transparent; color: var(--fg); border: 0; border-radius: 3px; padding: 1px 8px; cursor: pointer; font: inherit;
}
.dialog button:hover, .dialog button:focus-visible, .invoice button:not(.chip):hover, .invoice button:not(.chip):focus-visible,
.note-actions button:hover, .note-actions button:focus-visible, .project button:not(.chip):hover, .project button:not(.chip):focus-visible,
a.open:hover, a.open:focus-visible, .care-link:hover, .care-link:focus-visible, .button:hover, .button:focus-visible { color: var(--fg-bright); background: var(--bg-light); }
.dialog button.primary, .invoice button.primary, .note-actions button.primary, .project button.primary, .integration a.open { color: var(--accent); font-weight: 600; }
a.open { color: var(--fg); }
.dialog button.danger:hover, .dialog button.danger:focus-visible, .invoice button.bad:hover, .invoice button.bad:focus-visible,
.note-actions button.bad:hover, .note-actions button.bad:focus-visible, .card-dialog button.bad:hover, .card-dialog button.bad:focus-visible { color: var(--red); }
.chip[aria-pressed="true"], .invoice button.on { color: var(--fg-bright); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 3px 3px 0 0; }
:is(.chip, .dialog button, .invoice button, .note-actions button, .project button):disabled { opacity: 0.5; cursor: default; background: transparent; }
/* An icon chip (settings in the top bar): a drawn stroke mark in
   the chip's own colour, as tall as a word chip's line so the bar does not move.
   Its name is in aria-label and the title. */
.chip.icon { display: inline-flex; align-items: center; justify-content: center; padding: 1px 6px; color: var(--fg-dim); }
.chip.icon[hidden] { display: none; }
.chip.icon svg { width: calc(15px * var(--ui)); height: 1.5em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

main { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100%; }

.side { border-right: 1px solid var(--bg-light); background: var(--bg-dark); display: flex; flex-direction: column; min-height: 0; }
.list { list-style: none; margin: 0; padding: 0 0 10px; outline: none; overflow: auto; flex: 1; }
.list li { margin: 0; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-left: 2px solid transparent;
  cursor: default;
  color: var(--fg);
  text-decoration: none;
}
.row:hover { background: var(--bg-light); }
.row.selected { background: var(--selection); border-left-color: var(--accent); color: var(--fg-bright); }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.archived .name { color: var(--fg-dim); }
.row .date { color: var(--fg-dim); font-size: calc(11px * var(--ui)); font-variant-numeric: tabular-nums; }
/* On the selection the dim count would sink (in White the dim text is the selection's own colour): it takes the text colour. */
.row.selected .date { color: var(--fg); }

.group { padding: 8px 0 0; }
.group button {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  color: var(--fg-dim);
  font-size: calc(11px * var(--ui));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  padding: 4px 12px;
  cursor: pointer;
}
/* The chevron: drawn, so it does not depend on the font having the glyph. Down when open, right when folded. */
.group button::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 8px 2px 1px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); vertical-align: middle; }
.group.shut button::before { transform: rotate(-45deg); margin-bottom: 0; }
.group button:hover, .group button:focus-visible { color: var(--fg-bright); outline: none; }
.group button:focus-visible { background: var(--bg-light); }
/* A group's sections hang under it, a step in; the root's sit flush. */
.kids { list-style: none; margin: 0; padding: 0; }
.row.in { padding-left: 24px; }
/* A section at the root after the groups is set apart from the last group. */
.row.tail { margin-top: 8px; border-top: 1px solid var(--bg-light); }
.row { cursor: pointer; }

.view { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tools { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--rule); background: var(--bg-dark); }
.tools input {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  background: var(--bg);
  color: var(--fg-bright);
  border: 1px solid var(--field);
  border-radius: 3px;
  padding: 4px 8px;
}
.tools input:focus { outline: none; border-color: var(--accent); }
.content { flex: 1; overflow: auto; min-height: 0; container-type: inline-size; }
/* A list in less room than its columns need (a phone, or a narrow window beside the sidebar) shows its key
   columns (sections.js, phone) and says so under it; the row's detail has every field. */
@container (max-width: 800px) {
  .rows .wide { display: none; }
  .rows .phone-cue { display: table-caption; }
  .rows .more-cue { display: none; }
}
.empty { color: var(--fg-dim); padding: 20px 14px; margin: 0; }
.empty.error { color: var(--red); }

.rows { border-collapse: collapse; width: 100%; }
.rows th {
  position: sticky;
  top: 0;
  background: var(--bg);
  color: var(--fg-dim);
  font-weight: 500;
  text-align: left;
  padding: 6px 14px;
  border-bottom: 1px solid var(--bg-light);
}
/* A cell wraps at 46ch, or sooner when the screen is narrow, rather than push the table past its edge; figures and times keep to one line. */
.rows td { padding: 4px 14px; border-bottom: 1px solid var(--bg-dark); vertical-align: top; max-width: 46ch; overflow-wrap: anywhere; }
.rows td.num, .rows td.when { white-space: nowrap; overflow-wrap: normal; }
/* A stored table (tables) shows its first six columns, which wrap like any others; the row opens every field.
   Nothing in the app scrolls sideways, a stored table neither (2026-11-15). */
.rows .more { display: none; }
.more-cue { caption-side: bottom; text-align: left; padding: 10px 14px; color: var(--fg-dim); font-size: calc(12px * var(--ui)); }
.rows tbody tr { cursor: pointer; }
.rows tbody tr:hover, .rows tbody tr:focus-visible { background: var(--selection); color: var(--fg-bright); }
.rows tbody tr:hover .dim, .rows tbody tr:focus-visible .dim { color: var(--fg); }
.rows .num, .fields .num { text-align: right; font-variant-numeric: tabular-nums; }
.fields .num { text-align: left; }
.neg { color: var(--red); }
.yes { color: var(--green); }
.when { color: var(--fg-light); font-variant-numeric: tabular-nums; }
.tags { color: var(--magenta); }
/* The label around a pick box only matters on a phone, where it is the 44px target; here it adds no box. */
.rows .pick-box { display: contents; }
.phone-cue { display: none; caption-side: bottom; text-align: left; padding: 10px; color: var(--fg-dim); font-size: calc(12px * var(--ui)); }

.overview { padding: 14px; display: grid; gap: 14px; max-width: 900px; }
.card { border: 1px solid var(--bg-light); border-radius: 4px; padding: 12px 14px; background: var(--bg-dark); }
.card h2, .detail h2 { margin: 0 0 8px; color: var(--accent); font-size: calc(13px * var(--ui)); font-weight: 600; }
.card p { margin: 0 0 8px; overflow-wrap: anywhere; }
.card p:last-child { margin-bottom: 0; }
.copy { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.copy code { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--muted); border-radius: 3px; padding: 4px 8px; color: var(--fg-bright); overflow-wrap: anywhere; user-select: all; }
.counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--bg-light);
  border-radius: 3px;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
}
.tile b { color: var(--fg-bright); font-size: calc(18px * var(--ui)); font-weight: 600; font-variant-numeric: tabular-nums; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
.card .fields + .figures, .card p + .figures { margin-top: 10px; }
.figures { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figures .tile b { font-size: calc(15px * var(--ui)); }
.tile b.neg, .card .error, .integration .error { color: var(--red); }
.connect { display: flex; gap: 8px; }
.connect input { flex: 1; min-width: 0; background: var(--bg); color: var(--fg-bright); border: 1px solid var(--field); border-radius: 3px; padding: 3px 8px; }
.connect input:focus { outline: none; border-color: var(--accent); }

/* The agenda: a column per day that has something on, side by side as far as they fit, one under the other on a phone. */
.agenda-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.agenda-head h2 { margin: 0; margin-right: auto; }
.agenda-link, .agenda-open { color: var(--fg-dim); font-size: calc(12px * var(--ui)); text-decoration: none; }
.agenda-link:hover, .agenda-link:focus-visible, .agenda-open:hover { color: var(--accent); }
.agenda-open { display: inline-block; margin-top: 12px; color: var(--accent); }
.agenda-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 12px 16px; align-items: start; }
.agenda-day { min-width: 0; }
.agenda-day h3 { margin: 0 0 4px; font-size: calc(12px * var(--ui)); font-weight: 600; color: var(--fg-dim); text-transform: lowercase; }
.agenda-day.today h3 { color: var(--fg-bright); }
.agenda-day p { margin: 0; }
.agenda-day ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.agenda-item {
  display: grid; grid-template-columns: 11ch minmax(0, 1fr) auto; align-items: baseline; gap: 8px; width: 100%;
  padding: 3px 6px 3px 8px; border: 0; border-left: 2px solid var(--cal, var(--accent)); border-radius: 0 3px 3px 0;
  background: var(--bg); color: var(--fg); font: inherit; text-align: left; cursor: pointer;
}
.agenda-item:hover, .agenda-item:focus-visible { outline: none; background: var(--selection); }
.agenda-item .when { color: var(--fg-dim); font-variant-numeric: tabular-nums; font-size: calc(12px * var(--ui)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-item .when.allday { color: var(--fg-dim); }
.agenda-item .what { display: grid; min-width: 0; }
.agenda-item .name { color: var(--fg-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-item .sub { color: var(--fg-dim); font-size: calc(11px * var(--ui)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-item.past { opacity: 0.45; }
.agenda-item.now { background: var(--bg-light); }
.agenda-item.now .when { color: var(--accent); }
.agenda-item .badge { color: var(--bg); background: var(--accent); border-radius: 3px; padding: 0 5px; font-size: calc(11px * var(--ui)); font-weight: 600; }
.card .agenda-days + p { margin-top: 10px; }

/* A desktop has room beside the cards: the company's details next to its figures. */
@media (min-width: 1100px) {
  .overview { max-width: none; grid-template-columns: minmax(0, 1fr); grid-template-areas: "you" "company" "stored"; }
  .overview > .you { grid-area: you; }
  .overview > .company { grid-area: company; display: grid; grid-template-columns: fit-content(54ch) minmax(0, 1fr); column-gap: 24px; align-content: start; }
  .overview > .company h2 { grid-column: 1 / -1; }
  .overview > .company .fields { align-self: start; }
  .overview > .company .figures { grid-column: 2; margin-top: 0; grid-auto-rows: 1fr; }
  .overview > .stored { grid-area: stored; }
}
/* With business switched off there is no company card. */
@media (min-width: 1100px) {
  .overview:not(:has(.company)) { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "you" "stored"; }
}
/* Wider still, the company goes beside you, and the whole overview fits on one screen. */
@media (min-width: 1600px) {
  .overview { max-width: 1900px; grid-template-columns: minmax(0, 2fr) minmax(0, 5fr); grid-template-rows: auto auto; grid-template-areas: "you company" "stored stored"; }
  .overview > .company { grid-template-columns: fit-content(66ch) minmax(0, 1fr); }
  .stored .counts { grid-auto-rows: 1fr; }
}
/* With a calendar connected, the agenda goes under you, as wide as the overview. */
@media (min-width: 1100px) {
  .overview > .agenda { grid-area: agenda; }
  .overview:has(.agenda) { grid-template-areas: "you" "agenda" "company" "stored"; }
  .overview:has(.agenda):not(:has(.company)) { grid-template-areas: "you" "agenda" "stored"; }
}
@media (min-width: 1600px) {
  .overview:has(.agenda) { grid-template-rows: auto auto auto; grid-template-areas: "you company" "agenda agenda" "stored stored"; }
  .overview:has(.agenda):not(:has(.company)) { grid-template-rows: none; grid-template-areas: "you" "agenda" "stored"; }
}
/* Private money beside the business: under you, next to the company card, when there is room. */
.spend { list-style: none; margin: 10px 0 8px; padding: 0; display: grid; gap: 2px; max-width: 72ch; }
.spend li { display: grid; grid-template-columns: minmax(0, 1fr) auto 15ch; gap: 10px; align-items: baseline; }
.spend .what { color: var(--fg-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spend .num { font-variant-numeric: tabular-nums; text-align: right; }
.spend .budget { font-size: calc(12px * var(--ui)); font-variant-numeric: tabular-nums; }
@media (min-width: 1100px) {
  .overview > .private { grid-area: private; }
  .overview:has(.private) { grid-template-areas: "you" "company" "private" "stored"; }
  .overview:has(.private):not(:has(.company)) { grid-template-areas: "you" "private" "stored"; }
  .overview:has(.private):has(.agenda) { grid-template-areas: "you" "agenda" "company" "private" "stored"; }
  .overview:has(.private):has(.agenda):not(:has(.company)) { grid-template-areas: "you" "agenda" "private" "stored"; }
}
@media (min-width: 1600px) {
  .overview:has(.private) { grid-template-rows: none; grid-template-areas: "you company" "private company" "stored stored"; }
  .overview:has(.private):not(:has(.company)) { grid-template-areas: "you" "private" "stored"; }
  .overview:has(.private):has(.agenda) { grid-template-areas: "you company" "private company" "agenda agenda" "stored stored"; }
  .overview:has(.private):has(.agenda):not(:has(.company)) { grid-template-areas: "you" "agenda" "private" "stored"; }
}

.upload { overflow: auto; padding: 14px; }
.upload .card { max-width: 560px; margin: 6vh auto 0; }
.upload .card h2 span { color: var(--fg-bright); overflow-wrap: anywhere; }
.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 12px 0 0;
  padding: 28px 14px;
  border: 1px dashed var(--muted);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
}
.pick b { color: var(--accent); font-weight: 600; }
.pick:hover, .pick:focus-visible, .pick.over { border-color: var(--accent); outline: none; }
.results { list-style: none; margin: 12px 0 0; padding: 0; }
.results li { padding: 2px 0 2px 10px; border-left: 2px solid var(--muted); margin-bottom: 4px; overflow-wrap: anywhere; }
.results .ok { border-left-color: var(--green); color: var(--fg-bright); }
.results .failed { border-left-color: var(--red); color: var(--red); }

.detail { width: min(760px, 92vw); max-height: 86vh; overflow: auto; }
.detail h3 { margin: 14px 0 6px; color: var(--fg-dim); font-size: calc(12px * var(--ui)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 16px; margin: 0; }
.fields dt { color: var(--fg-dim); }
.fields dd { margin: 0; color: var(--fg-bright); white-space: pre-wrap; overflow-wrap: anywhere; }
.steps { margin: 0; padding-left: 22px; }
.rows td.name { color: var(--accent); }
.rows td.dim { max-width: none; white-space: normal; }
.fields dd.dim { color: var(--fg-dim); }
.fields .type { color: var(--fg-dim); font-size: calc(11px * var(--ui)); margin-left: 8px; }
.detail .rows td { white-space: normal; }
/* A list inside a record (a workout's sets) has as many columns as it has fields: its headings may break too. */
.detail .rows th { overflow-wrap: anywhere; }

.login { max-width: 420px; margin: 18vh auto 0; text-align: center; }
.login h1 { color: var(--accent); font-size: calc(28px * var(--ui)); font-weight: 600; margin: 0 0 6px; }
.login p { margin: 6px 0 18px; }
.button { display: inline-block; color: var(--accent); text-decoration: none; padding: 7px 16px; border-radius: 3px; font-weight: 600; }
.dim { color: var(--fg-dim); }

.dialog {
  background: var(--bg-dark);
  color: var(--fg);
  border: 1px solid var(--bg-light);
  border-radius: 4px;
  padding: 14px 16px;
  min-width: min(480px, 92vw);
  max-width: 92vw;
}
.dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.dialog p { margin: 0 0 10px; }
.dialog input {
  width: 100%;
  background: var(--bg);
  color: var(--fg-bright);
  border: 1px solid var(--field);
  border-radius: 3px;
  padding: 6px 8px;
}
.dialog input:focus { outline: none; border-color: var(--accent); }
.dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 12px 0 0; padding: 0; }
.dialog button { padding: 3px 12px; }
.help h2 { margin: 0 0 10px; color: var(--accent); font-size: calc(13px * var(--ui)); font-weight: 600; }
.help table { border-collapse: collapse; width: 100%; }
.help td { padding: 2px 10px 2px 0; vertical-align: top; }
.help td:nth-child(odd) { color: var(--fg-bright); white-space: nowrap; }
.help td:nth-child(even) { color: var(--fg-dim); }
.help p { margin-top: 12px; font-size: calc(12px * var(--ui)); word-break: break-word; }
.help h3 { margin: 14px 0 6px; color: var(--fg-dim); font-size: calc(12px * var(--ui)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.help h3 + p { margin-top: 0; }
.help .copy { margin-bottom: 6px; }
.help p code { color: var(--fg); }

.settings { width: min(620px, 92vw); }
.settings p { margin-top: 0; }
.switches { display: grid; gap: 4px; }
.dialog .switch { display: grid; grid-template-columns: auto 9ch minmax(0, 1fr) auto; gap: 10px; align-items: baseline; width: 100%; padding: 5px 10px; text-align: left; background: var(--bg); color: var(--fg-dim); }
.switch .box { font-variant-numeric: tabular-nums; }
.switch b { font-weight: 600; }
.switch.on .box { color: var(--green); }
.switch.on b { color: var(--fg-bright); }
.switch kbd { font: inherit; font-size: calc(11px * var(--ui)); color: var(--fg-dim); }
.dialog .switch:hover { background: var(--bg-light); }
.tabs { display: flex; align-items: baseline; gap: 2px; margin: 0 0 12px; border-bottom: 1px solid var(--bg-light); }
.dialog .tab { border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px; padding: 4px 10px 6px; }
.dialog .tab:hover { color: var(--fg-bright); background: none; }
.dialog .tab[aria-selected="true"] { color: var(--fg-bright); border-bottom-color: var(--accent); }
.tabs kbd { margin-left: auto; padding-bottom: 6px; font: inherit; font-size: calc(11px * var(--ui)); color: var(--fg-dim); }
/* Both tabs are as tall as the switches, so the dialog stays where it is. */
.settings .panel { min-height: 250px; }
.integrations { display: grid; gap: 4px; }
.integration { border: 1px solid var(--bg-light); border-radius: 3px; background: var(--bg); padding: 6px 10px 8px; }
.integration .head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; }
.integration .head b { color: var(--fg-bright); font-weight: 600; }
.integration .state { margin-left: auto; font-size: calc(11px * var(--ui)); color: var(--fg-dim); }
.integration .state.on { color: var(--green); }
.integration p { margin: 0 0 6px; }
.integration p:last-child { margin-bottom: 0; }
.integration .actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin: 0 0 6px; }
.integration .actions:last-child { margin-bottom: 0; }
.integration .connect { margin: 0 0 6px; }
.integration .connect:last-child { margin-bottom: 0; }
/* Mail has a row per mailbox, and forms with more than one field: they wrap on a narrow screen. */
.integration .mailbox { margin: 0 0 6px; padding: 0 0 6px; border-bottom: 1px solid var(--bg-light); }
.integration .mailbox .line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0 0 4px; }
.integration .mailbox .line b { color: var(--fg-bright); font-weight: 600; }
.integration .mailbox .line .dim { overflow-wrap: anywhere; }
.integration .mailbox .state.bad { color: var(--red); }
.integration .mailbox .actions { margin: 0; }
.integration .mailbox .connect { margin: 0; }
.integration .toggle.on { color: var(--green); }
.integration p.ok { color: var(--green); }
.integration .connect.stack { flex-wrap: wrap; gap: 6px 8px; }
.integration .connect.stack input { flex: 1 1 16ch; }
.integration .signin { margin: 0 0 6px; }
.integration .signin .actions { margin: 6px 0 0; }
.integration code { color: var(--fg-bright); overflow-wrap: anywhere; user-select: all; }
.integration a.open { display: inline-block; padding: 3px 10px; border-radius: 3px; text-decoration: none; }

/* A state beside a name: on, a warning, wrong. */
.state { margin-left: auto; font-size: calc(11px * var(--ui)); font-weight: 400; color: var(--fg-dim); white-space: nowrap; }
.state.on { color: var(--green); }
.state.warn { color: var(--yellow); }
.state.bad { color: var(--red); }

.toast {
  position: fixed;
  right: 14px;
  bottom: 44px;
  max-width: min(520px, 90vw);
  background: var(--bg-light);
  color: var(--fg-bright);
  border-left: 2px solid var(--accent);
  padding: 6px 12px;
  border-radius: 3px;
  word-break: break-word;
}
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* The invoice editor: a draft is a form, a sent invoice a sheet to read.
   Dense rows, thin borders, the amounts in tabular figures on the right. */
.invoice { padding: 12px 14px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-width: 1180px; }
.invoice p { margin: 0; }
.invoice .error { color: var(--red); }
.invoice h3 { margin: 0 0 6px; color: var(--fg-dim); font-size: calc(11px * var(--ui)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.inv-title { display: flex; align-items: baseline; gap: 8px 12px; min-width: 0; }
.inv-title b { flex: 1 1 auto; min-width: 0; color: var(--fg-bright); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-title .state { flex: none; }
.invoice input, .invoice select, .invoice textarea {
  background: var(--bg);
  color: var(--fg-bright);
  border: 1px solid var(--field);
  border-radius: 3px;
  padding: 2px 6px;
  min-width: 0;
  font: inherit;
}
.invoice textarea { resize: vertical; width: 100%; }
.invoice input:focus, .invoice select:focus, .invoice textarea:focus { outline: none; border-color: var(--accent); }
.invoice input[type="date"] { color-scheme: inherit; }
.invoice button:not(.chip) { white-space: nowrap; flex: none; }

.inv-head { display: grid; grid-template-columns: minmax(18ch, 2fr) minmax(16ch, 1fr) minmax(16ch, 1fr); gap: 8px 14px; align-items: start; }
.inv-head .inv-field:last-of-type { grid-column: 1 / -1; }
.inv-head > button { justify-self: start; }
/* One column as wide as the field, not as wide as the longest thing in it. */
.inv-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.inv-field .hint { font-size: calc(11px * var(--ui)); }
.picker { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; }
.picker .matches { display: flex; flex-wrap: wrap; gap: 8px; }
/* A long client name is cut with an ellipsis rather than wrapped; the whole name is its title. */
.invoice .picker .matches button { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.inv-lines { display: grid; gap: 2px; border-top: 1px solid var(--bg-light); padding-top: 6px; }
.inv-line { display: grid; grid-template-columns: 3ch minmax(16ch, 1fr) 8ch 12ch 7ch 15ch 104px; gap: 8px; align-items: center; }
/* The columns are sized in ch of the rows' font, so the heading row keeps that font and only its labels are small. */
.inv-line.head span { color: var(--fg-dim); font-size: calc(11px * var(--ui)); text-transform: uppercase; letter-spacing: 0.06em; }
.inv-line.head .qty, .inv-line.head .price, .inv-line.head .amount { text-align: right; padding-right: 7px; }
.inv-line.head .vat { padding-left: 7px; }
.inv-line .pos { text-align: right; }
.inv-line .qty, .inv-line .price { text-align: right; font-variant-numeric: tabular-nums; }
.inv-line .amount { text-align: right; color: var(--fg-bright); font-variant-numeric: tabular-nums; }
.inv-line .acts { display: flex; gap: 8px; justify-content: flex-end; }
.invoice .inv-line .acts button { min-width: 28px; padding: 1px 6px; }
.inv-line .amount { white-space: nowrap; }
.inv-line.billed .desc { border-left: 2px solid var(--cyan); }
.inv-line.add { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--bg-light); }
.inv-tickets { margin: 0 0 4px calc(3ch + 8px); font-size: calc(12px * var(--ui)); }
.inv-tickets summary { cursor: pointer; }
.inv-tickets ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--cyan); display: grid; gap: 2px; }
.inv-tickets li { display: flex; gap: 8px; align-items: center; }
.inv-tickets li .num { margin-left: auto; font-variant-numeric: tabular-nums; }
.invoice .inv-tickets li button { min-width: 24px; padding: 0 6px; }
.inv-regroup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.inv-regroup:empty { display: none; }

.inv-totals { display: grid; grid-template-columns: max-content 16ch; justify-content: end; gap: 2px 16px; margin: 0; }
.inv-totals dt { text-align: right; color: var(--fg); }
.inv-totals dd { margin: 0; text-align: right; color: var(--fg-bright); font-variant-numeric: tabular-nums; }
.inv-totals .dim { color: var(--fg-dim); }
.inv-totals .total { font-weight: 600; color: var(--fg-bright); border-top: 1px solid var(--bg-light); padding-top: 2px; }
.inv-fixed td.wrap { white-space: normal; max-width: none; overflow-wrap: anywhere; }
.inv-fixed tbody tr { cursor: default; }

.inv-unbilled { border: 1px solid var(--bg-light); border-radius: 3px; padding: 8px 10px; background: var(--bg-dark); display: grid; gap: 8px; }
.inv-group { display: grid; gap: 2px; }
.inv-group .check { display: flex; gap: 8px; align-items: baseline; cursor: pointer; }
.inv-group .check input { accent-color: var(--accent); }
.inv-bill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.inv-bill input { width: 11ch; text-align: right; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inv-actions .dim { font-size: calc(12px * var(--ui)); }
.inv-actions a.open { white-space: nowrap; flex: none; padding: 1px 8px; border-radius: 3px; text-decoration: none; }
.invoice p.ok { color: var(--green); }
.inv-mail { border: 1px solid var(--bg-light); border-radius: 3px; padding: 8px 10px; background: var(--bg-dark); display: grid; gap: 8px; max-width: 760px; }
.inv-mail .check { display: flex; gap: 8px; align-items: baseline; cursor: pointer; }
.inv-mail .check input { accent-color: var(--accent); }

@media (max-width: 1000px) {
  .inv-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .inv-head .inv-field:first-child { grid-column: 1 / -1; }
}
/* A line takes two rows, the description above its numbers, when the editor has less room than its seven
   columns need (a phone, or a narrow window beside the sidebar). */
@container (max-width: 700px) {
  .inv-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "desc desc desc" "qty price vat" "amount acts acts"; padding: 6px 0; border-bottom: 1px solid var(--bg-light); }
  .inv-line.head, .inv-line .pos { display: none; }
  .inv-line .desc { grid-area: desc; }
  .inv-line .qty { grid-area: qty; }
  .inv-line .price { grid-area: price; }
  .inv-line .vat { grid-area: vat; }
  .inv-line .amount { grid-area: amount; text-align: left; }
  .inv-line .acts { grid-area: acts; }
}
/* A phone: a line takes two rows, the description above its numbers, and every control is big enough for a finger. */
@media (max-width: 720px) {
  .invoice { padding: 10px; }
  .invoice input:not([type="checkbox"]), .invoice select, .invoice textarea, .invoice button:not(.chip) { min-height: 40px; }
  .inv-group .check { min-height: 40px; align-items: center; }
  .inv-actions a.open { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; }
  .inv-group .check input { width: 22px; height: 22px; }
  .inv-tickets { margin-left: 0; font-size: calc(13px * var(--ui)); }
  .inv-tickets summary { padding: 10px 0; }
  .inv-tickets li { min-height: 40px; }
  .invoice .inv-tickets li button, .inv-regroup button { min-width: 40px; min-height: 40px; }
  .invoice .inv-line .acts button { min-width: 40px; padding: 0 10px; }
  .inv-title .chip { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; }
  .inv-title { align-items: center; }
  .inv-totals { grid-template-columns: minmax(0, 1fr) auto; justify-content: stretch; }
  /* The sheet of a sent invoice fits the screen: narrower cells, and the description wraps instead of the numbers. */
  .invoice .inv-fixed th, .invoice .inv-fixed td { padding-left: 4px; padding-right: 4px; font-size: calc(12px * var(--ui)); }
  .invoice .inv-fixed td.num { white-space: nowrap; }
  .tools .chip { padding: 0 10px; }
  .inv-head { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: absolute; inset: 0; z-index: 2; border-right: 0; }
  .side[hidden] { display: none !important; }
  .bar.bottom { display: none; }
  .brand { min-height: 44px; }
  .bar.top .status:empty { display: none; }
  /* The title: its own compact line under the chips, as there is no room beside them. */
  .bar.top { flex-wrap: wrap; height: auto; min-height: calc(56px + env(safe-area-inset-top, 0px)); padding: calc(6px + env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) 6px max(8px, env(safe-area-inset-left, 0px)); row-gap: 0; }
  .bar.top .title { order: 99; flex: 1 0 100%; font-weight: 600; line-height: 18px; padding: 0 2px; }
  .bar.top .title:empty { display: none; }
  .rows th, .rows td { padding-left: 10px; padding-right: 10px; }
  /* A row is a finger target, and only the key columns are there (sections.js, phone); the caption says so. */
  .rows td { padding-top: 11px; padding-bottom: 11px; }
  .rows td.lead { max-width: none; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* A phone: the bar's buttons are 44px to the finger (WCAG 2.5.5), and all of them fit at 320px. */
  .bar.top { gap: 6px; }
  .bar.top .chip { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 10px; }
  .bar.top .chip[hidden] { display: none; }
  .bar.top .chip.icon svg { width: calc(18px * var(--ui)); height: calc(18px * var(--ui)); }
  .row { height: 40px; padding: 0 12px; }
  .row.in { padding-left: 28px; }
  .group button { padding: 0 12px; min-height: 40px; }
  /* The filter keeps room to type in: what does not fit beside it goes to a second line. */
  .tools { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .tools input { flex: 1 1 150px; }
  .tools .chip, .tools input { min-height: 40px; }
  .tools .chip { display: inline-flex; align-items: center; padding: 0 12px; }
  .tools .chip[hidden] { display: none; }

  /* Dialogs: the settings, their tabs, the integrations. */
  .dialog { padding: 14px 12px; max-width: 96vw; min-width: min(480px, 96vw); max-height: 92dvh; overflow: auto; }
  .settings { width: 96vw; }
  .dialog button, .dialog a.open, .integration a.open { min-height: 40px; min-width: 40px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; }
  .dialog input { min-height: 40px; }
  .dialog menu { gap: 10px; margin-top: 16px; }
  .tabs { gap: 6px; align-items: center; }
  .dialog .tab { padding: 0 14px; }
  .tabs kbd { display: none; }
  .help tr { display: grid; grid-template-columns: minmax(9ch, max-content) minmax(0, 1fr); }
  .help td:nth-child(odd) { white-space: normal; }
  .switches { gap: 8px; }
  .dialog .switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 8px 12px; justify-content: stretch; align-items: baseline; }
  .dialog .switch > :nth-child(3) { grid-column: 2; }
  .switch kbd { display: none; }
  .integrations { gap: 8px; }
  .integration { padding: 10px 12px 12px; }
  .integration .actions, .integration .mailbox .actions { gap: 8px; align-items: center; margin-bottom: 8px; }
  .integration .head { flex-wrap: wrap; }
  .connect { flex-wrap: wrap; gap: 8px; }
  .copy { flex-wrap: wrap; }
}

/* A finger on glass: a field that is typed in is 16px, or a phone zooms in on it. */
@media (max-width: 900px) and (pointer: coarse) {
  input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="time"], input[type="date"], textarea, select { font-size: max(16px, calc(16px * var(--ui))); }
}

/* The notes: a list of one-line rows or a grid of cards, and the editor that
   opens in a note's own place. The scroll position is kept by the script, not
   by the browser's anchoring, so an editor that opens never pulls the page. */
.notepad { padding: 12px 14px 20px; overflow-anchor: none; }
.seg { display: inline-flex; flex: none; }
.seg[hidden] { display: none; }
.size-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
/* The look of the page, above the tabs: the size, then compact mode as one of the settings' own switches. */
.look { margin-bottom: 14px; }
/* Two radio buttons side by side. They overlap by their one-pixel border, so
   the one that is checked shows its whole outline on top of the other, and it
   is filled, not only outlined: a coloured border alone was hard to tell apart
   (and the checked right one used to lose its left edge to the border-left: 0
   the pair was joined with). */
.seg .chip[aria-checked="true"] { color: var(--fg-bright); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 3px 3px 0 0; cursor: default; }
.note-items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-width: 900px; }
.note-items > li { border: 1px solid var(--bg-light); border-radius: 3px; padding: 6px 10px; cursor: pointer; min-width: 0; }
.note-items > li.dim { cursor: default; border-style: dashed; }
.note-items > li:hover, .note-items > li:focus-visible { border-color: var(--fg-dim); outline: none; }
.note-items > li.editing { border-color: var(--accent); cursor: default; padding: 8px 10px; }
.note-head { display: flex; gap: 8px 12px; align-items: baseline; min-width: 0; }
.note-head b { flex: 1 1 auto; min-width: 0; color: var(--fg-bright); font-weight: 600; overflow-wrap: anywhere; }
.note-head span { flex: none; white-space: nowrap; }
.note-head .note-project { flex: 0 1 auto; white-space: normal; }
.note-head { flex-wrap: wrap; }
.note-head .note-tags { flex: 0 1 auto; min-width: 0; }
.note-tags { color: var(--accent); overflow-wrap: anywhere; }
.note-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; max-width: none; align-items: start; }
.note-cards > li { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; background: var(--bg-dark); }
.note-cards .note-head { flex-direction: column; gap: 0; }
.note-cards .note-head b { white-space: normal; overflow-wrap: anywhere; }
.note-cards .note-head .when { order: 2; font-size: calc(11px * var(--ui)); }
/* A note's text, in full, rendered from Markdown. */
.note-body { color: var(--fg); font-size: calc(13px * var(--ui)); line-height: 1.5; overflow-wrap: anywhere; min-width: 0; margin-top: 4px; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown pre, .markdown table { margin: 0 0 8px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { margin: 12px 0 6px; color: var(--fg-bright); font-weight: 600; line-height: 1.3; }
.markdown h1 { font-size: 1.35em; }
.markdown h2 { font-size: 1.2em; }
.markdown h3 { font-size: 1.08em; }
.markdown h4, .markdown h5, .markdown h6 { font-size: 1em; }
.markdown strong { color: var(--fg-bright); font-weight: 600; }
.markdown del { color: var(--fg-dim); }
.markdown a { color: var(--accent); }
.markdown ul { padding-left: 1.4em; }
.markdown ol { padding-left: 2em; }
.markdown li > ul, .markdown li > ol, .markdown li > p { margin: 2px 0; }
.markdown li.task { list-style: none; margin-left: -1.2em; }
.markdown li.task input { margin: 0 4px 0 0; vertical-align: -1px; accent-color: var(--accent); }
.markdown code { background: var(--bg-light); color: var(--fg-bright); border-radius: 3px; padding: 0 4px; font-size: 0.95em; }
.markdown pre { background: var(--bg-darker); border: 1px solid var(--bg-light); border-radius: 3px; padding: 8px 10px; }
/* Code keeps its lines and indents, and wraps where a line is longer than the note is wide. */
.markdown pre code { background: none; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.markdown blockquote { border-left: 2px solid var(--muted); padding-left: 10px; color: var(--fg-dim); }
.markdown hr { border: 0; border-top: 1px solid var(--muted); margin: 10px 0; }
.markdown table { border-collapse: collapse; max-width: 100%; }
.markdown td, .markdown th { overflow-wrap: anywhere; }
.markdown th, .markdown td { border: 1px solid var(--bg-light); padding: 2px 8px; text-align: left; }
.markdown th { color: var(--fg-bright); font-weight: 600; }
.note-cards .note-tags { margin-top: auto; font-size: calc(12px * var(--ui)); }
/* A card that is edited takes the width of the grid. */
.note-cards > li.editing { grid-column: 1 / -1; background: var(--bg); }
.note-editor { display: grid; gap: 6px; }
.note-editor input, .note-editor textarea { background: var(--bg); color: var(--fg-bright); border: 1px solid var(--field); border-radius: 3px; padding: 4px 8px; min-width: 0; width: 100%; box-sizing: border-box; font: inherit; }
.note-editor input[data-key="title"] { font-weight: 600; }
.note-editor input[data-key="tags"] { color: var(--accent); }
.note-editor textarea { resize: none; overflow: hidden; min-height: 5em; line-height: 1.45; }
.note-editor input:focus, .note-editor textarea:focus { outline: none; border-color: var(--accent); }
.note-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.note-actions button { padding: 2px 12px; }
.note-actions .error { color: var(--red); }
.note-actions .ok { color: var(--green); }
.note-actions .keys { margin-left: auto; font-size: calc(11px * var(--ui)); }
@media (max-width: 720px) {
  .notepad { padding: 10px; }
  .note-items > li { padding: 10px; }
  .note-list .note-head { flex-wrap: wrap; }
  .note-list .note-head .note-tags { order: 3; flex-basis: 100%; }
  /* A whole note needs the width: on a phone the cards are one under the other. */
  .note-cards { grid-template-columns: minmax(0, 1fr); }
  .note-editor input, .note-actions button { min-height: 40px; }
  .note-actions .keys { display: none; }
  .tools .seg .chip { min-height: 40px; padding: 0 10px; }
}

/* A project's page: its title and fields, a board of three columns, its notes. */
.project { padding: 12px 14px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.proj-title { display: flex; align-items: baseline; gap: 8px 12px; min-width: 0; }
.proj-title b { flex: 1 1 auto; min-width: 0; color: var(--fg-bright); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-title .chip { flex: none; white-space: nowrap; }
.proj-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.proj-fields .field, .card-dialog .field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.proj-fields select { max-width: 100%; }
.proj-desc { flex-basis: 100%; margin: 0; color: var(--fg); }
.project select, .project input, .prospects select, .card-dialog input, .card-dialog select, #note-project, .note-editor select {
  background: var(--bg);
  color: var(--fg-bright);
  border: 1px solid var(--field);
  border-radius: 3px;
  padding: 2px 6px;
  min-width: 0;
  font: inherit;
}
.project select:focus, .project input:focus, .prospects select:focus, .card-dialog input:focus, .card-dialog select:focus, #note-project:focus, .note-editor select:focus { outline: none; border-color: var(--accent); }
.project h3, .prospects h3 { margin: 0 0 6px; display: flex; gap: 8px; color: var(--fg-dim); font-size: calc(11px * var(--ui)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: start; }
.board-col { background: var(--bg-dark); border: 1px solid var(--bg-light); border-radius: 3px; padding: 8px; min-width: 0; display: grid; gap: 6px; }
.board-col.over { border-color: var(--accent); background: var(--selection); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-height: 8px; }
.board-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 3px;
  cursor: grab;
  user-select: none;
}
.board-card:hover, .board-card:focus-visible { border-color: var(--fg-dim); outline: none; }
.board-card:focus-visible { border-color: var(--accent); }
.board-card.ticket { border-left: 3px solid var(--magenta); }
.board-card.dragging { opacity: 0.35; }
.board-card.ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; opacity: 0.9; box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); border-color: var(--accent); cursor: grabbing; }
.board-card .grip { color: var(--fg-dim); touch-action: none; cursor: grab; padding: 0 2px; }
.card-title { color: var(--fg-bright); overflow-wrap: anywhere; }
.board-col[data-col="done"] .card-title { color: var(--fg-dim); text-decoration: line-through; }
.card-move { font-size: calc(12px * var(--ui)); padding: 0 2px; }
.card-meta { grid-column: 2 / -1; font-size: calc(11px * var(--ui)); }
.project button:not(.chip) { padding: 1px 10px; }
.project .card-new { justify-self: start; }
.card-add { display: flex; gap: 6px; flex-wrap: wrap; }
.card-add input { flex: 1 1 10ch; }
.proj-note-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; max-width: 900px; }
.project .proj-note-list button { display: flex; width: 100%; gap: 12px; justify-content: space-between; text-align: left; padding: 4px 10px; }
.proj-note-list b { color: var(--fg-bright); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card-dialog form { display: grid; gap: 10px; min-width: min(420px, 90vw); }
.card-dialog .field { display: grid; grid-template-columns: 7ch minmax(0, 1fr); }
.card-dialog h2, .card-dialog p { margin: 0; }
.card-dialog .card-text { white-space: pre-line; color: var(--fg); }
.card-dialog menu { display: flex; gap: 8px; padding: 0; margin: 4px 0 0; }
.note-project { flex: 0 1 auto; min-width: 0; color: var(--cyan); font-size: calc(12px * var(--ui)); overflow-wrap: anywhere; }
.note-editor select { width: 100%; box-sizing: border-box; padding: 4px 8px; }
.client-projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.client-projects li { display: flex; gap: 10px; align-items: center; }
@media (max-width: 720px) {
  .project { padding: 10px; }
  /* A phone: the columns are one under the other; a card is dragged by its grip, or moved with its menu. */
  .board { grid-template-columns: minmax(0, 1fr); }
  .board-card { padding: 6px 8px; min-height: 44px; }
  .board-card .grip { font-size: calc(20px * var(--ui)); padding: 6px 6px 6px 0; }
  .card-move, .project select, .project input, .card-dialog input, .card-dialog select, #note-project, .note-editor select { min-height: 40px; }
  .project button:not(.chip), .proj-title .chip { min-height: 40px; }
  .proj-title .chip { display: inline-flex; align-items: center; padding: 0 12px; }
  #note-project { flex: 1 1 120px; max-width: 60vw; }
}

/* Archived rows: hidden unless "archived" is on, then dimmed and marked. */
.tools .bulk { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.tools .bulk[hidden] { display: none; }
.rows th.row-pick, .rows td.row-pick { width: 18px; min-width: 18px; max-width: none; padding: 4px 2px 4px 14px; overflow: visible; vertical-align: middle; text-align: left; }
.rows .row-pick input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; vertical-align: middle; cursor: pointer; }
.rows tr.archived td:not(.row-pick) { color: var(--fg-dim); }
.tag-archived { display: inline-block; margin-left: 8px; padding: 0 5px; border: 1px solid var(--muted); border-radius: 3px; color: var(--fg-dim); font-size: calc(11px * var(--ui)); line-height: 16px; vertical-align: 1px; }
.note.archived > .note-head b, .note.archived .note-body { color: var(--fg-dim); }
.detail-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
/* A line on an overview with a word at its end ("done" on a todo, "+1" on a habit): the line opens the record, the word acts. */
.fin-item.has-act { display: flex; align-items: center; gap: 2px; }
.fin-item.has-act > .fin-open { flex: 1; min-width: 0; }
.fin-act { flex: none; align-self: stretch; color: var(--fg-dim); }
.fin-act:disabled { opacity: 0.5; cursor: progress; }
.sum-head .sum-add { margin-left: auto; padding: 0 8px; }
/* The toast with an undo: the message, then the word. */
.toast.has-act { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; }
.toast.has-act .chip { color: var(--accent); flex: none; }
.quick-add label { display: block; color: var(--fg-dim); }
.detail:has(.quick-add) > form[method="dialog"] { display: none; }
.quick-add label input { margin-top: 4px; }
.quick-when { min-height: 1.5em; margin: 8px 0 4px !important; color: var(--fg-bright); }
@media (max-width: 720px) {
  .fin-act { min-width: 48px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; }
  .sum-head .sum-add { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; margin: -10px 0; }
  .toast.has-act .chip { min-height: 40px; min-width: 48px; display: inline-flex; align-items: center; justify-content: center; }
  .detail-actions { gap: 8px; }
}
@media (max-width: 720px) {
  .tools .bulk { flex-wrap: wrap; }
  .tools .bulk .chip { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; }
  .rows th.row-pick, .rows td.row-pick { width: 44px; min-width: 44px; padding: 0; vertical-align: middle; }
  .rows .row-pick input { width: 22px; height: 22px; }
  .rows th.row-pick input { display: block; margin: 0 auto; }
  .rows .pick-box { display: flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; }
}

/* The finance page (finance.js): the period on top, then private, the months, the business and what moved
   between the two. Each part a chart and its numbers under it, as lists that wrap: nothing wider than a phone. */
.fin { padding: 14px; display: grid; gap: 14px; max-width: 1100px; min-width: 0; }
.fin-head { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.fin-nav { display: inline-flex; align-items: center; gap: 6px; }
.fin-head .fin-period { margin: 0; font-size: calc(15px * var(--ui)); color: var(--fg-bright); font-weight: 600; min-width: 14ch; text-align: center; }
.fin-head .chip { min-height: 28px; }
.fin-cards { display: grid; gap: 14px; min-width: 0; }
.fin-cards > .card { min-width: 0; }
.fin-cards.stale { opacity: 0.55; }
.fin .card h3 { margin: 14px 0 6px; font-size: calc(12px * var(--ui)); font-weight: 600; color: var(--fg-light); }
.fin .num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.fin-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(15ch, 1fr)); gap: 8px; }
.fin-figure { display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--bg-light); border-radius: 3px; padding: 6px 10px; min-width: 0; color: var(--fg-dim); }
.fin-figure b { color: var(--fg-bright); font-size: calc(15px * var(--ui)); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-figure b.neg { color: var(--red); }
.fin-figure small { font-size: calc(12px * var(--ui)); font-variant-numeric: tabular-nums; }

/* Bars per group or category: the name, the bar, the amount; a tap opens the line below. */
.fin-hbars { display: grid; gap: 2px; margin: 4px 0 10px; }
.fin-private .fin-hbars, .fin-private .fin-list, .fin-private .fin-fold, .fin-trends > * { max-width: 80ch; }
.fin-hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name value" "track track"; gap: 2px 10px; align-items: baseline; background: none; border: 0; border-radius: 3px; padding: 4px 4px; font: inherit; color: var(--fg); text-align: left; cursor: pointer; min-height: 30px; }
.fin-hbar:hover, .fin-hbar:focus-visible { background: var(--bg); outline: none; }
.fin-hbar:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.fin-hbar .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-bright); }
.fin-hbar .value { grid-area: value; }
.fin-hbar .track { grid-area: track; height: 10px; display: block; }
.fin-hbar .fill { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.fin-hbar.over .fill { background: var(--red); }

/* The numbers: one line per group (name, amount) with what it is compared with under it. */
.fin-list { list-style: none; margin: 0; padding: 0; }
.fin-list.nested { margin: 0 0 4px 16px; }
.fin-item { border-top: 1px solid var(--bg-light); }
.fin-list.nested .fin-item { border-top-color: transparent; }
.fin-open { display: block; width: 100%; background: none; border: 0; padding: 6px 4px; font: inherit; color: var(--fg); text-align: left; cursor: pointer; border-radius: 3px; }
.fin-open:hover, .fin-open:focus-visible { background: var(--bg); outline: none; }
.fin-open:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.fin-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.fin-line .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-bright); }
.fin-open.level-1 .what { color: var(--fg); }
.fin-sub { font-size: calc(12px * var(--ui)); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fin-open .fin-sub { padding-left: 2ch; }
.fin-rows { padding: 0 4px 8px 20px; }
.fin-rows p { margin: 4px 0; }
.fin-txlist { list-style: none; margin: 4px 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.fin-tx .what { color: var(--fg-light); }
.fin-tx .fin-line { font-size: calc(13px * var(--ui)); }
.fin-note { font-size: calc(12px * var(--ui)); margin-top: 8px !important; }
.fin-fold { margin-top: 10px; }
.fin-fold > summary { cursor: pointer; color: var(--fg-light); padding: 4px 0; list-style-position: inside; }
.fin-fold > summary .fin-line { display: inline-flex; width: calc(100% - 2ch); }
.fin-fold > :not(summary) { margin-left: 2ch; }
.fin-csv { display: inline-block; margin: 2px 0 4px; }
.fin-vat .fin-quarter { padding: 6px 4px; border-top: 1px solid var(--bg-light); }

/* Private spending and business profit per month, on one scale, the zero line drawn when profit dips below. */
.fin-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: calc(12px * var(--ui)); color: var(--fg-light); margin-bottom: 6px; }
.fin-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.fin-legend .s1, .fin-month .s1 { background: var(--accent); }
.fin-legend .s2, .fin-month .s2 { background: var(--yellow); }
.fin-columns { height: 150px; padding-bottom: 18px; box-sizing: border-box; }
.fin-columns .plot { position: relative; display: flex; gap: 4px; height: 100%; }
.fin-columns .zero { position: absolute; left: 0; right: 0; height: 1px; background: var(--muted); }
.fin-month { flex: 1 1 0; min-width: 0; position: relative; display: flex; flex-direction: column; }
.fin-month .bars { position: relative; flex: 1; }
.fin-month .bars span { position: absolute; width: calc(50% - 1px); min-height: 1px; border-radius: 2px; opacity: 0.55; }
.fin-month .bars .s1 { left: 0; }
.fin-month .bars .s2 { right: 0; }
.fin-month.now .bars span { opacity: 1; }
.fin-month small { position: absolute; bottom: -18px; left: -4px; right: -4px; text-align: center; font-size: calc(11px * var(--ui)); color: var(--fg-dim); overflow: hidden; white-space: nowrap; }
.fin-month.now small { color: var(--fg-bright); }
.fin-months li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; padding: 2px 4px; font-size: calc(13px * var(--ui)); }
.fin-months li .num { min-width: 11ch; }
.fin-months li.now { color: var(--fg-bright); }

/* The overviews of business and life (overviews.js): the finance page's cards and lines, a card's title the way to
   its page with its totals beside it, tiles two or four abreast (never three and one), and a habit's last seven
   days as marks in the dim text colour, so the accent stays the titles'. */
.sum { align-content: start; }
.sum-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sum-status:empty { display: none; }
.sum-status .card p { margin: 0; }
.sum-status .card p + p { margin-top: 4px; }
.sum .card { container-type: inline-size; }
.sum-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 14px; margin-bottom: 8px; }
.sum-head h2, .sum-head h3 { margin: 0 !important; }
.sum-sub { margin: 14px 0 6px; }
.sum-sub h3 { font-size: calc(12px * var(--ui)); font-weight: 600; color: var(--fg-light); }
.sum-aside { font-size: calc(12px * var(--ui)); font-variant-numeric: tabular-nums; }
.sum-to { color: inherit; text-decoration: none; }
.sum-to:hover { text-decoration: underline; text-underline-offset: 3px; }
.sum-mark { color: var(--fg-dim); margin-left: 1ch; }
.sum .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
@container (min-width: 520px) { .sum .figures:has(> :nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sum-keep { white-space: nowrap; }
.tile.still { cursor: default; }
.tile.still:hover { border-color: var(--bg-light); }
.sum .fin-open .num.yes { color: var(--green); }
.sum .fin-list + .fin-list { margin-top: 4px; }
.sum-habit-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sum-days { display: inline-flex; gap: 3px; }
.sum-days i { width: 9px; height: 9px; border: 1px solid var(--field); border-radius: 2px; box-sizing: border-box; }
.sum-days i.on { background: var(--fg-dim); border-color: var(--fg-dim); }
.sum-days i.today { border-color: var(--fg-bright); }
.sum-projects { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px 2ch; }
.sum-call { margin-bottom: 4px; }
.sum-call .care-item:first-child { padding-top: 0; }
/* Wide: two columns that cards flow down, so a short card leaves no hole beside a long one; the order reads down each. */
@media (min-width: 1100px) {
  .sum .fin-cards { display: block; columns: 2; column-gap: 14px; }
  .sum .fin-cards > .card { break-inside: avoid; margin-bottom: 14px; }
}
@media (max-width: 720px) {
  .sum .tile { min-height: 44px; }
  .sum-projects .chip { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; }
  .sum-to { display: inline-flex; align-items: center; min-height: 40px; }
  .sum-head { margin-bottom: 4px; }
}

/* The care page (care.js): a card per kind of provider, each one a few lines, its numbers and portal as links. */
.care { padding: 14px; display: grid; gap: 14px; max-width: 900px; align-content: start; }
.care-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.care-item { padding: 8px 0; border-top: 1px solid var(--bg-light); display: grid; gap: 6px; }
.care-item:first-child { border-top: 0; padding-top: 0; }
.care-item.archived { opacity: 0.7; }
.care-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.care-who { overflow-wrap: anywhere; }
.care-who b { color: var(--fg-bright); font-weight: 600; margin-right: 8px; }
.care-ways { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.care-link { display: inline-flex; align-items: center; color: var(--accent); border-radius: 3px; padding: 1px 8px; text-decoration: none; font-variant-numeric: tabular-nums; }
.care-link.urgent { color: var(--yellow); }
.care-archived summary { cursor: pointer; padding: 4px 0; }
.care-archived .care-list { margin-top: 8px; }
.care-form { width: min(560px, 92vw); }
.care-form h2 { margin: 0 0 10px; color: var(--accent); font-size: calc(13px * var(--ui)); font-weight: 600; }
.care-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; align-items: baseline; }
.care-fields label { color: var(--fg-dim); }
.care-fields select, .care-fields textarea { width: 100%; background: var(--bg); color: var(--fg-bright); border: 1px solid var(--field); border-radius: 3px; padding: 6px 8px; font: inherit; }
.care-fields select:focus, .care-fields textarea:focus { outline: none; border-color: var(--accent); }
.care-form menu .grow { flex: 1; }
.care-form .error { color: var(--red); margin: 10px 0 0; }
@media (max-width: 720px) {
  .care { padding: 10px 8px; gap: 10px; }
  .care .card { padding: 10px; }
  .care-link, .care .chip { min-height: 40px; padding: 0 12px; display: inline-flex; align-items: center; }
  .care-archived summary { padding: 10px 0; }
  .care-fields { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .care-fields label { margin-top: 6px; }
  .care-fields input, .care-fields select { min-height: 40px; }
  .care-form menu { flex-wrap: wrap; }
  .care-form menu button { min-height: 40px; min-width: 40px; }
}

/* The prospects (prospects.js): a board of four stages; a card whose next step is due is marked on its left. */
.prospects { padding: 12px 14px 24px; display: grid; gap: 14px; min-width: 0; align-content: start; }
.board.stages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.board-col[data-col="lost"] .card-title { color: var(--fg-dim); }
.board-card.prospect { grid-template-columns: auto minmax(0, 1fr); }
.board-card.prospect .card-move { grid-column: 2; justify-self: start; max-width: 100%; }
.board-card.prospect .card-title { overflow-wrap: break-word; }
.card-meta .card-link { color: var(--accent); text-decoration: none; }
.card-meta .card-link:hover { text-decoration: underline; }
.board-card.prospect.due { border-left: 3px solid var(--yellow); }
.card-next { grid-column: 2 / -1; color: var(--fg); overflow-wrap: anywhere; }
.card-next .when { color: var(--fg-dim); font-variant-numeric: tabular-nums; margin-right: 4px; }
.card-next .when.due { color: var(--yellow); }
.prospects .care-archived .cards { margin-top: 8px; }
.prospect-form .care-fields input { width: 100%; }

/* The CV (cv.js): the care page's cards and sheet, an entry a few lines under its title and period; "read" is the CV
   as it is printed, in one column. */
.cv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.cv-bar a.open { white-space: nowrap; padding: 1px 8px; border-radius: 3px; text-decoration: none; }
.cv .care-who b { margin-right: 10px; }
.cv .care-who .dim { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cv-where { color: var(--fg); overflow-wrap: anywhere; }
.cv-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-highlights { margin: 0; padding-left: 18px; overflow-wrap: anywhere; }
.cv-skills { font-size: calc(12px * var(--ui)); overflow-wrap: anywhere; }
.cv-profile .care-head h2 { margin: 0; }
.cv-profile .fields { margin: 6px 0; }
.cv-form input { width: 100%; }
.cv-read { max-width: 760px; display: grid; gap: 6px; padding: 18px 20px; }
.cv-read .cv-name { margin: 0; color: var(--fg-bright); font-size: calc(18px * var(--ui)); overflow-wrap: anywhere; }
.cv-headline { margin: 0; color: var(--fg-bright); overflow-wrap: anywhere; }
.cv-contact { margin: 0; overflow-wrap: anywhere; }
.cv-section { display: grid; gap: 10px; margin-top: 10px; }
.cv-section h3 { margin: 0; padding-bottom: 3px; border-bottom: 1px solid var(--bg-light); color: var(--accent); font-size: calc(11px * var(--ui)); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.cv-entry { display: grid; gap: 3px; }
.cv-entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; }
.cv-entry-head b { color: var(--fg-bright); font-weight: 600; overflow-wrap: anywhere; }
.cv-entry-head .dim { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .cv-bar a.open { min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; }
  .cv-read { padding: 12px; }
  .cv-form textarea { font-size: max(16px, calc(16px * var(--ui))); }
}
@media (max-width: 1000px) and (min-width: 721px) {
  .board.stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .prospects { padding: 10px; }
  .board.stages { grid-template-columns: minmax(0, 1fr); }
  .prospects .card-move { min-height: 40px; }
}

@media (min-width: 1100px) {
  .fin-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .fin-private, .fin-trends { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .fin { padding: 10px 8px; gap: 10px; }
  .fin .card { padding: 10px; }
  .fin-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-figure b { font-size: calc(14px * var(--ui)); }
  .fin-head .chip { min-height: 40px; min-width: 40px; }
  .fin-kinds { flex: 1 1 100%; }
  .fin-kinds .chip { flex: 1; }
  .fin-nav { flex: 1 1 auto; }
  .fin-head .fin-period { flex: 1; min-width: 0; }
  .fin-hbar { min-height: 44px; padding: 5px 4px; }
  .fin-csv { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; }
  .fin-open { padding: 9px 4px; min-height: 44px; }
  .fin-fold > summary { padding: 10px 0; }
  .fin-list.nested { margin-left: 10px; }
  .fin-rows { padding-left: 10px; }
  .fin-fold > :not(summary) { margin-left: 0; }
  .fin-columns { height: 130px; }
  .fin-columns .plot { gap: 2px; }
}

/* What is fixed to the bottom keeps clear of the home indicator (on a phone, of the bar below). */
.toast { bottom: calc(44px + env(safe-area-inset-bottom, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); }

/* The phone bar (phone.js): along the bottom edge, at most five things a thumb reaches for
   most, a drawn icon with a word under it. In the flow, under the main area, so the content
   never runs under it. Not on a desktop: there the bottom bar is the keyboard hints. */
.phone-bar { display: none; }
@media (max-width: 720px) {
  .phone-bar {
    display: flex;
    align-items: stretch;
    flex: none;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding: 0 max(4px, env(safe-area-inset-left, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-right, 0px));
    background: var(--bg-dark);
    border-top: 1px solid var(--rule);
  }
  .phone-bar > * {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin: 4px;
    padding: 0 2px;
    background: transparent;
    color: var(--fg-dim);
    border: 0;
    border-radius: 0;
    font: inherit;
    font-size: calc(11px * var(--ui));
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .phone-bar > *[hidden] { display: none !important; }
  .phone-bar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  .phone-bar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .phone-bar > *:active { color: var(--fg-bright); background: var(--bg-light); }
  /* Where you are: bright, with the accent edge the selected sidebar row has, along the top here. */
  .phone-bar > [aria-current="page"], .phone-bar > [aria-expanded="true"] { color: var(--fg-bright); box-shadow: inset 0 2px 0 var(--accent); }
  /* The one thing the page makes: the accent, as the primary action in a dialog. */
  .phone-bar > [data-act="new"] { color: var(--accent); }
  /* A field is being typed in: the on-screen keyboard has the room. */
  body.typing .phone-bar { display: none; }
  /* What floats above the bottom edge floats above the bar. */
  .toast { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .update { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  body.typing .toast, body.typing .update { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

  /* The chips beside the filter that the bar and its sheet have taken: the row keeps the filter, the count and the selection. */
  .tools > #show-archived, .tools > #archive-closed, .tools > #new-invoice, .tools > #new-note, .tools > #new-contact, .tools > #new-prospect, .tools > #note-project, .tools > #note-view { display: none; }

  /* Dialogs on a phone are sheets on the bottom edge, full width, with their buttons within reach.
     A sheet slides up once. */
  .dialog {
    margin: auto 0 0;
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    max-height: calc(92dvh - env(safe-area-inset-top, 0px));
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .dialog[open] { animation: sheet-up 180ms cubic-bezier(0.16, 1, 0.3, 1); }
  .dialog::backdrop { animation: backdrop-in 180ms ease-out; }
  @keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .dialog[open], .dialog::backdrop { animation: none; } }
  .detail { width: 100vw; }
  .settings { width: 100vw; }
  .card-dialog form { min-width: 0; }

  /* The sheet of the bar's "more" and "period": one row per action, the title in the accent as every dialog's. */
  .sheet h2 { margin: 0 0 8px; color: var(--accent); font-size: calc(13px * var(--ui)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-body { display: grid; gap: 4px; }
  .sheet h3 { margin: 8px 0 2px; color: var(--fg-dim); font-size: calc(11px * var(--ui)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
  .sheet h3:first-child { margin-top: 0; }
  .sheet .sheet-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    min-height: 44px; padding: 0 12px; text-align: left;
    color: var(--fg); background: var(--bg); border: 0; border-radius: 3px;
  }
  .sheet .sheet-row:hover { background: var(--bg); color: var(--fg-bright); }
  .sheet .sheet-row:is([aria-pressed="true"], [aria-checked="true"]) { color: var(--fg-bright); box-shadow: inset 2px 0 0 var(--accent); }
  .sheet .sheet-row[aria-checked="true"] { cursor: default; }
  .sheet-row kbd { font: inherit; font-size: calc(11px * var(--ui)); color: var(--fg-dim); }
  .sheet menu { margin-top: 10px; }
}

/* A new deploy for a page that was open (pwa.js): one line at the bottom, like the toast, until it is taken or put off. */
.update {
  position: fixed;
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, calc(100vw - 28px));
  background: var(--bg-light);
  color: var(--fg-bright);
  border-left: 2px solid var(--accent);
  padding: 4px 6px 4px 12px;
  border-radius: 3px;
}
.update span { flex: 1; min-width: 0; }
.update .chip:first-of-type { color: var(--accent); font-weight: 600; }
@media (max-width: 720px) {
  .update { left: 8px; right: 8px; max-width: none; }
  .update .chip { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; }
}

/* The todos card's filter: a row of segments under its head, the counts in their labels. */
.sum-filter { display: flex; flex-wrap: wrap; margin: 0 0 8px; }
.sum-filter .chip { font-size: calc(12px * var(--ui)); }
@media (max-width: 720px) {
  .sum-filter .chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; }
}
/* The agenda and the company card on an overview page: the agenda's days a column each as far as the card is wide. */
.sum .agenda .home-pin { margin-left: 0; }

/* Home (home.js): the overviews as plain words in the top bar, the one shown bright and underlined; and the
   "home" switch in the head of every overview card, a small house at its right end, filled when the card is on home. */
.ov-nav { display: flex; flex: none; gap: 2px; }
.ov-nav[hidden] { display: none; }
.ov-nav a { color: var(--fg-dim); text-decoration: none; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.ov-nav a:hover, .ov-nav a:focus-visible { color: var(--fg-bright); }
/* The page's name beside the overviews, set apart by a hairline: a page of its own, not one of them. */
.ov-nav + .title { border-left: 1px solid var(--muted); padding-left: 14px; flex: 0 1 auto; }
.ov-nav a[aria-current="page"] { color: var(--fg-bright); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.home-pin { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; padding: 2px; background: none; border: 0; border-radius: 3px; color: var(--fg-dim); cursor: pointer; align-self: center; }
.home-pin svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linejoin: round; }
.home-pin:hover, .home-pin:focus-visible { color: var(--fg-bright); }
.home-pin[aria-pressed="true"] { color: var(--accent); }
.home-pin[aria-pressed="true"] svg { fill: currentColor; }
@media (max-width: 720px) {
  /* The overviews take the row the page's name had, under the logo and the buttons. */
  .bar.top .ov-nav { order: 99; flex: 1 0 100%; margin: 0 -6px; }
  /* Outside the overviews that row is the page's name instead: there is room for one line, and it says where you are.
     The overviews stay a tap away: "you" in the phone bar is home, and home has them. */
  .bar.top:has(.title:not([hidden])) .ov-nav { display: none; }
  .ov-nav + .title { border-left: 0; padding-left: 2px; line-height: 40px; }
  .ov-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; }
  .home-pin { min-width: 40px; min-height: 40px; margin: -10px -12px -10px auto; }
  .home-pin svg { width: 16px; height: 16px; }
  /* The house on the title's row, the totals on a row of their own under both. */
  .sum-head .home-pin { order: 1; }
  .sum-head:has(.home-pin) .sum-aside { order: 2; flex-basis: 100%; }
}

/* Compact mode (settings, kept in the auth account; size.js sets data-compact before the first paint): the same parts,
   closer together. The bars are 28px, rows and cells lose their air, cards and tools come closer. On a phone the
   bar's 44px buttons stay; list rows and cells shrink to 32px and more, full width, so still far above 24px (2.5.8). */
:root[data-compact] .bar { height: calc(28px * var(--ui)); column-gap: 10px; }
:root[data-compact] .bar.top { height: calc(28px * var(--ui) + env(safe-area-inset-top, 0px)); }
:root[data-compact] .bar.bottom { height: calc(28px * var(--ui) + env(safe-area-inset-bottom, 0px)); gap: 14px; }
:root[data-compact] .row { height: calc(24px * var(--ui)); }
:root[data-compact] .group button { padding-top: 2px; padding-bottom: 2px; }
:root[data-compact] .rows th { padding: 3px 10px; }
:root[data-compact] .rows td { padding: 1px 10px; }
:root[data-compact] .rows td.row-pick, :root[data-compact] .rows th.row-pick { padding: 1px 2px 1px 10px; }
:root[data-compact] .tools { padding: 4px 10px; gap: 8px; }
:root[data-compact] :is(.overview, .fin) { padding: 10px; gap: 10px; }
:root[data-compact] .project { padding: 8px 10px 16px; gap: 10px; }
:root[data-compact] .card { padding: 8px 10px; }
@media (max-width: 720px) {
  :root[data-compact] .bar.top { height: auto; min-height: calc(50px + env(safe-area-inset-top, 0px)); padding-top: calc(3px + env(safe-area-inset-top, 0px)); padding-bottom: 3px; column-gap: 6px; }
  :root[data-compact] .rows td { padding-top: 6px; padding-bottom: 6px; }
  :root[data-compact] .row { height: 34px; }
  :root[data-compact] .tools { padding: 6px 8px; }
}
/* ---- The profile button and its menu (profile.js): the same rules in assistent, storage and wolf ----
   The button: the picture, the initials or a person, in a round face. The menu: a dropdown that hangs from the button
   on a desktop (profile.js sets --profile-top and --profile-right), a sheet on the bottom edge at 720px and below. */
.avatar {
  display: inline-grid; place-items: center; flex: none; overflow: hidden;
  width: calc(22px * var(--ui)); height: calc(22px * var(--ui)); border-radius: 50%;
  background: var(--bg-light); color: var(--fg-bright);
  font-size: calc(10px * var(--ui)); font-weight: 600; line-height: 1; letter-spacing: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar svg { width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.bar.top .chip.profile { padding: 1px 3px; min-width: 24px; min-height: 24px; } /* WCAG 2.5.8, also at the small size */
.bar.top .chip.profile[aria-expanded="true"] .avatar { box-shadow: 0 0 0 1.5px var(--accent); }
.profile-menu {
  position: fixed; inset: var(--profile-top, 40px) var(--profile-right, 8px) auto auto; margin: 0;
  width: min(300px, calc(100vw - 16px)); max-width: none; max-height: calc(100dvh - var(--profile-top, 40px) - 8px); overflow: auto;
  padding: 6px; background: var(--bg-dark); color: var(--fg); border: 1px solid var(--bg-light); border-radius: 4px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.4);
  font: calc(13px * var(--ui))/1.5 var(--font);
}
.profile-menu::backdrop { background: transparent; }
.profile-who { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px; }
.profile-who .avatar { width: calc(34px * var(--ui)); height: calc(34px * var(--ui)); font-size: calc(13px * var(--ui)); }
.profile-id { display: grid; min-width: 0; }
.profile-name, .profile-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-name { color: var(--fg-bright); font-weight: 600; }
.profile-email { color: var(--fg-dim); }
.profile-email:empty { display: none; }
.profile-menu h3 { margin: 4px 8px 2px; color: var(--fg-dim); font-size: calc(11px * var(--ui)); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.profile-menu hr { border: 0; border-top: 1px solid var(--bg-light); margin: 4px 0; }
.profile-menu .profile-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: calc(32px * var(--ui)); padding: 0 8px; margin: 0;
  background: transparent; color: var(--fg); border: 0; border-radius: 3px;
  font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.profile-menu .profile-row[hidden] { display: none; }
.profile-menu .profile-row:hover, .profile-menu .profile-row:focus-visible { background: var(--bg-light); color: var(--fg-bright); }
/* Log out: only its mark turns red on the lit row; red text on the lighter panel falls to 3.6:1 in some themes (kanagawa). */
.profile-menu .profile-row.danger:is(:hover, :focus-visible) svg { color: var(--red); }
.profile-row svg { flex: none; width: calc(16px * var(--ui)); height: calc(16px * var(--ui)); fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.profile-row.jyo-app svg { stroke: none; height: calc(14px * var(--ui)); }
.profile-row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-row .value { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.profile-row kbd { font: inherit; font-size: calc(11px * var(--ui)); color: var(--fg-dim); min-width: 1ch; text-align: right; }
/* On the lit row the dim parts take the row's colour: dim on the lighter panel would fall under the contrast floor. */
.profile-row:is(:hover, :focus-visible) :is(.value, kbd) { color: inherit; }
@media (max-width: 720px) {
  .bar.top .chip.profile .avatar { width: 28px; height: 28px; font-size: 11px; }
  .profile-menu {
    inset: auto 0 0 0; width: 100vw; max-height: calc(92dvh - env(safe-area-inset-top, 0px));
    border-width: 1px 0 0; border-radius: 4px 4px 0 0; box-shadow: none;
    padding: 8px max(8px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .profile-menu::backdrop { background: rgb(0 0 0 / 0.55); }
  .profile-menu .profile-row { min-height: 44px; padding: 0 12px; }
  .profile-row kbd { display: none; }
  .profile-menu[open] { animation: profile-up 180ms cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes profile-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) { .profile-menu[open] { animation: none; } }

}

/* Keyboard focus: one mark everywhere, like the border of the focused window
   in Omarchy. A control gets a 1px ring in --focus just outside it; a row that
   runs the full width gets the ring inside it and a 2px bar on its left edge
   (the selected sidebar row's edge), so a scrolling list cannot clip it. Text
   fields keep their own sign, the border turning the accent. */
:focus-visible { outline: 1px solid var(--focus); outline-offset: 1px; }
input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]):focus-visible, textarea:focus-visible { outline: none; }
.rows tbody tr:focus-visible, .row:focus-visible, .agenda-item:focus-visible, .fin-hbar:focus-visible, .fin-open:focus-visible, .note-items > li:focus-visible {
  outline: 1px solid var(--focus); outline-offset: -1px;
}
.rows tbody tr:focus-visible > :first-child, .fin-hbar:focus-visible, .fin-open:focus-visible { box-shadow: inset 2px 0 0 var(--focus); }
.row:focus-visible { border-left-color: var(--focus); }
