/* Studio Manager's read-only screen, in loco-bot's design system. The rules are in DESIGN.md: 9 colours (each with a light and a dark value), 4 sizes (12, 14, 18, 24), 2 weights (400, 600),
   one shadow (--raise, for cards), two radii (10 for a card, 6 inside one), phone first. Wide-window layout is added at the end. Fields are 16px on touch screens only,
   because iOS zooms the page on a smaller one. */

@font-face { font-family: "Geist"; src: url("/static/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --bg: light-dark(#f4f2ed, #121110); --surface: light-dark(#fefdfb, #1b1a18); --text: light-dark(#1f1d1a, #edebe6); --muted: light-dark(#6b665d, #a29e95); --line: light-dark(#e9e5de, #2d2b28);
  --accent: light-dark(#1f4fd8, #7c9eff); --danger: light-dark(#b3261e, #ff7b6e); --warn: light-dark(#8a5300, #f0b24a); --good: light-dark(#1d7a3e, #6fcf8a); --practice: light-dark(#7b2cbf, #c79bf2);
  /* A card: a faint ring and the least shadow that still lifts it off the page. In the dark it is a ring only. */
  --raise: 0 0 0 1px light-dark(rgb(0 0 0 / .05), rgb(255 255 255 / .07)), 0 1px 2px light-dark(rgb(0 0 0 / .04), transparent);
  /* Light or dark comes from the device, until the switch in the corner names one (data-theme, kept in a cookie). */
  color-scheme: light dark;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); font: 14px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; font-synthesis: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.page { max-width: 1080px; margin: 0 auto; padding: 0 16px 64px; }
a { color: var(--accent); text-decoration-thickness: .09em; text-underline-offset: .2em; text-decoration-skip-ink: auto; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
h1 { margin: 28px 0 0; font-size: 24px; line-height: 1.2; font-weight: 600; text-wrap: balance; overflow-wrap: break-word; }
h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
/* A card: every section of a page is one. Only cards and key figures sit on the lighter surface. */
main section, .figure { border-radius: 10px; background: var(--surface); box-shadow: var(--raise); }
main section { margin-top: 16px; padding: 14px 16px 6px; }
main section > :last-child { margin-bottom: 8px; }
main section > :is(table, .changes):last-child { margin-bottom: 0; }
p { margin: 8px 0; }
strong, .strong { font-weight: 600; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted, .unknown { color: var(--muted); }
.small, .hint, .sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.sub { display: block; }
.hint { max-width: 65ch; text-wrap: pretty; }
.danger { color: var(--danger); font-weight: 600; }
/* A status: a pill in the colour of its state (the tones are named in ui/lib/html.mjs). */
.pill { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 400; line-height: 1.5; white-space: nowrap; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.pill.is-warn { --tone: var(--warn); } .pill.is-accent { --tone: var(--accent); } .pill.is-good { --tone: var(--good); } .pill.is-danger { --tone: var(--danger); } .pill.is-muted { --tone: var(--muted); }
.warn { color: var(--warn); }
.nowrap, .money { white-space: nowrap; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
kbd { font: inherit; padding: 0 5px; border: 1px solid var(--line); border-radius: 6px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 3; padding: 8px 12px; background: var(--bg); }

/* ---------- Frame ---------- */
.is-practice { --stick: 34px; }
.practice { position: sticky; top: 0; z-index: 2; min-height: 34px; padding: 6px 16px; text-align: center; color: var(--practice); background: color-mix(in srgb, var(--practice) 12%, var(--bg)); border-bottom: 1px solid var(--practice); }
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-self: center; color: var(--text); }
.brand { font-weight: 600; text-decoration: none; }
nav { display: flex; flex-wrap: wrap; gap: 0 18px; }
nav a, .tabs a { display: inline-block; padding: 8px 0; color: var(--muted); text-decoration: none; }
nav a:hover, .tabs a:hover { color: var(--text); }
nav a[aria-current], .tabs a[aria-current] { color: var(--text); font-weight: 600; }
.jump { margin-left: auto; padding: 8px 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.jump:hover { color: var(--text); }
.foot { margin-top: 56px; padding-top: 12px; border-top: 1px solid var(--line); }
/* The light and dark switch: one quiet icon. On a narrow window it leads the foot; a wide one has room in the corner. */
.theme { padding: 12px 12px 12px 0; margin: -12px 0; border: 0; background: none; color: var(--muted); vertical-align: middle; cursor: pointer; }
.theme:hover { color: var(--text); }
.theme svg { display: block; }
.bar { margin: 16px 0 0; padding: 10px 12px; border: 1px solid var(--tone); border-radius: 6px; background: color-mix(in srgb, var(--tone) 8%, var(--bg)); }
.bar p { margin: 0; }
.bar-error { --tone: var(--danger); }
.bar-warn { --tone: var(--warn); }
.bar-asof { --tone: var(--accent); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.step { white-space: nowrap; }

/* ---------- Page head ---------- */
.meta { margin: 6px 0 0; color: var(--muted); }
.lead { max-width: 65ch; }
.last { margin: 6px 0 0; }

/* ---------- Key figures: at most four on a page ---------- */
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0 0; }
.figure { min-width: 0; padding: 12px 16px; color: inherit; text-decoration: none; }
.figure > span { display: block; }
.figure .value { font-size: 18px; line-height: 1.3; font-weight: 600; }
a.figure:hover .value { text-decoration: underline; text-decoration-thickness: .09em; text-underline-offset: .2em; }
.figure.is-danger .value { color: var(--danger); }

/* ---------- Tables. On a phone a row is two lines; a wide window gets real columns. ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
/* The column heads and the total stay in view on a long list. */
thead th { position: sticky; top: var(--stick, 0px); z-index: 1; background: var(--surface); }
tfoot :is(th, td) { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
tbody:last-child tr:last-child td { border-bottom: 0; }
/* A column head that sorts. The arrow shows on the sorted column, and faintly on the one under the pointer. */
.sort { display: inline-flex; gap: 4px; color: inherit; text-decoration: none; }
.num .sort { flex-direction: row-reverse; }
.sort .arrow { visibility: hidden; }
th[aria-sort] .sort { color: var(--text); }
th[aria-sort] .arrow { visibility: visible; color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .sort:hover { color: var(--text); } th:not([aria-sort]) .sort:hover .arrow { visibility: visible; } }
/* What the agent just changed: tinted, then back to plain. */
[data-changed] { animation: changed 6s ease-out; }
@keyframes changed { 0%, 60% { background-color: color-mix(in srgb, var(--accent) 12%, transparent); } 100% { background-color: transparent; } }
th { font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; vertical-align: bottom; }
th, td { padding: 9px 16px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
:is(th, td):last-child { padding-right: 0; }
tfoot :is(th, td) { border-bottom: 0; font-size: 14px; font-weight: 600; color: var(--text); }
tfoot th { font-weight: 400; color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.name a { color: var(--text); font-weight: 600; }
/* A link to one row (a cost from the Costs page) lands below the practice bar and marks the row. */
[id] { scroll-margin-top: 48px; }
tr:target { background: color-mix(in srgb, var(--accent) 8%, transparent); }
tr.is-cancelled td, tr.is-cancelled .name a { color: var(--muted); }
tr.is-cancelled .money { text-decoration: line-through; }
@media (max-width: 719.98px) {
  .wide { display: none; }
  .list, .list tbody, .list tfoot { display: block; }
  .list thead { display: none; }
  .list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  .list tfoot tr, .list tbody:last-child tr:last-child { border-bottom: 0; }
  .list :is(td, th) { display: none; padding: 0; border: 0; }
  .list .p1 { display: block; grid-area: 1 / 1; }
  .list .p2 { display: block; grid-area: 1 / 2; text-align: right; }
  .list .p3 { display: block; grid-area: 2 / 1; }
  .list .p4 { display: block; grid-area: 2 / 2; text-align: right; }
  .list :is(.p3, .p4), .list :is(.p3, .p4) .sub { font-size: 12px; color: var(--muted); }
  .list :is(.p2, .p4)[data-label]:not(:empty)::before { content: attr(data-label) " "; font-size: 12px; font-weight: 400; color: var(--muted); }
  .list .p4 .sub { display: inline; }
  .list .p4 .sub:not(:empty)::before { content: " · "; }
}

/* ---------- Tabs: links that narrow a list; years and the filter field sit to the right ---------- */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; margin: -8px 0 0; border-bottom: 1px solid var(--line); }
h2 + .tabs { margin-top: 0; }
.tabs [role=group], .tabs-right { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; }
.tabs-right { margin-left: auto; }
.filter { width: 132px; padding: 4px 0; border: 0; border-bottom: 1px solid transparent; border-radius: 0; background: none; font: inherit; color: var(--text); }
.filter::placeholder { color: var(--muted); }
.filter:focus { outline: none; border-bottom-color: var(--accent); }

/* ---------- Numbers that copy, the jump box ---------- */
.copy { position: relative; padding: 0; border: 0; background: none; font-weight: inherit; cursor: copy; }
@media (hover: hover) and (pointer: fine) { .copy:hover { text-decoration: underline dotted; text-decoration-color: var(--muted); text-underline-offset: .2em; } }
.copy[data-copied]::after { content: "Copied"; position: absolute; left: 50%; bottom: 100%; translate: -50% 0; padding: 0 6px; border-radius: 6px; background: var(--surface); box-shadow: var(--raise); font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--muted); white-space: nowrap; }
.jumper { width: min(520px, calc(100vw - 32px)); margin-top: 12vh; padding: 0; border: 1px solid var(--muted); border-radius: 10px; background: var(--surface); color: var(--text); }
.jumper::backdrop { background: color-mix(in srgb, var(--text) 30%, transparent); }
.jumper input { display: block; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; font: inherit; color: inherit; }
.jumper input:focus { outline: none; }
.jumper ul { margin: 0; padding: 6px; list-style: none; }
.jumper li a { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.jumper li[aria-selected=true] a { background: color-mix(in srgb, var(--text) 8%, transparent); }
.jumper .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jumper .none { padding: 8px; }

/* ---------- Details ---------- */
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 24px; margin: 8px 0; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.totals { max-width: 360px; }
.totals dd { text-align: right; }
.totals .grand { font-size: 18px; line-height: 1.3; font-weight: 600; }
ul.plain { margin: 8px 0 0; padding: 0; list-style: none; }
ul.plain li { padding: 3px 0; }

/* ---------- Changes ---------- */
.changes { margin: 0; padding: 0; list-style: none; }
.changes > li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.changes > li:last-child { border-bottom: 0; }
.changes time { color: var(--muted); white-space: nowrap; }
.changes .summary { color: var(--text); font-weight: 600; }
.changes .is-undone .summary { color: var(--muted); text-decoration: line-through; }
.changes p, .changes ul { margin: 2px 0 0; padding: 0; list-style: none; overflow-wrap: anywhere; }
/* Folds. On a record page the Changes section is closed until asked for: closed it names the last change, open it
   lists the headlines, and a click on a headline unfolds that change. */
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
.fold > summary { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; padding-right: 20px; }
.fold > summary::after { content: ""; position: absolute; right: 3px; top: 5px; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; rotate: 45deg; }
.fold[open] > summary::after { top: 9px; rotate: 225deg; }
.fold-last { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fold[open] .fold-last { display: none; }
.changes summary time { display: block; }
.changes summary .summary { text-decoration: underline; text-decoration-thickness: .09em; text-underline-offset: .2em; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.before { color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 24px; }

/* ---------- Notes (Markdown) ---------- */
.prose { max-width: 65ch; }
.prose :is(h1, h2, h3, h4, h5, h6) { margin: 16px 0 4px; font-size: 14px; font-weight: 600; }
.prose :is(ul, ol) { margin: 8px 0; padding-left: 20px; }
.prose blockquote { margin: 8px 0; padding-left: 12px; border-left: 2px solid var(--line); }

/* ---------- Sign-in and the foot's sign-out: one field and one button, in the screen's own colours ---------- */
.narrow { max-width: 440px; }
form.inline { display: inline; }
.link { padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; }
.ask label { display: block; color: var(--muted); }
.ask input[type=email] { width: 100%; margin: 4px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font: inherit; color: var(--text); }
.primary { padding: 8px 14px; border: 0; border-radius: 6px; background: var(--accent); color: var(--surface); font-weight: 600; cursor: pointer; }

/* ---------- Touch: links in menus get a full-height target ---------- */
@media (pointer: coarse) {
  nav a, .tabs a, .jump { padding: 12px 0; }
  input { font-size: 16px; }
  kbd { display: none; }
  .name a { display: inline-block; padding-block: 6px; margin-block: -6px; }
}

/* ---------- Wide window: real table columns, four figures in a row ---------- */
@media (min-width: 720px) {
  .page { padding-inline: 32px; }
  .figures { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .phone { display: none; }
  .changes > li, .changes summary { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 0 16px; }
  .changes details { grid-column: 1 / -1; }
  .changes details > div { margin-left: 148px; }
  .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .theme { position: fixed; left: 0; bottom: 0; margin: 0; padding: 12px; }
}
/* A short cross-fade between pages, for those who have not asked for less motion. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root) { animation-duration: 150ms; }
}
@media (prefers-reduced-motion: reduce) {
  [data-changed] { animation: none; background-color: color-mix(in srgb, var(--accent) 12%, transparent); }
}
@media print {
  .top, .practice, .foot, .tabs { display: none; }
  main section, .figure { box-shadow: none; }
}
