/* unslop direction, by unslop (Damir Sokolovsky, CC BY 4.0).
   Product: one person running a family lawn route, tracking who owes what.
   Character: plainspoken, tidy, early-morning.
   World: a truck's clipboard before sunrise and a freshly mowed lawn.
   Moments: the billed and collected chart on mown stripes, the unpaid slips.
   Signature: the mow stripe, on worked days, the chart and invoices.
   Graphite ramp, one accent per work tab, 4px grid. */
@font-face { font-family: 'Instrument Sans'; src: url('fonts/InstrumentSans.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('fonts/IBMPlexMono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  color-scheme: dark;
  --accent: #5BBF7F;
  --on-accent: #0F0F10;
  --deepest: #0F0F10;
  --page: #141415;
  --card: #19191B;
  --raised: #232325;
  --ink: #EDEDED;
  --secondary: #A1A1A6;
  --muted: #85858B;
  --line: rgba(237, 237, 237, .08);
  --line-strong: rgba(237, 237, 237, .16);
  --positive: #4CC38A;
  --negative: #E5484D;
  --caution: #D9A53A;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --sans: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 400 14px/20px var(--sans); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-weight: 500; margin: 0; }
h1 { font-size: 32px; line-height: 40px; }
h2 { font-size: 15px; line-height: 20px; }
a { color: inherit; }
p { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; line-height: 20px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.owed { color: var(--negative); }
.credit { color: var(--positive); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Frame ---------- */
.layout { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 16px 12px; display: flex; flex-direction: column;
  background: var(--deepest); border-right: 1px solid var(--line); overflow-y: auto;
}
/* Window buttons, drawn by the page because the app has no title bar of its own. */
.win-bar { display: flex; align-items: center; gap: 8px; height: 16px; margin: 0 8px 12px; }
.light { position: relative; width: 12px; height: 12px; padding: 0; border: 0; border-radius: 50%; cursor: default; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .24); }
.light::before { content: ''; position: absolute; inset: -4px; }
.light.close { background: #FF5F57; }
.light.min { background: #FEBC2E; }
.light.full { background: #28C840; }
.light svg { position: absolute; inset: 2px; width: 8px; height: 8px; fill: none; stroke: rgba(0, 0, 0, .64); stroke-width: 1.25; stroke-linecap: round; opacity: 0; }
.light svg .fill { fill: rgba(0, 0, 0, .64); stroke: none; }
.win-bar:hover .light svg, .light:focus-visible svg { opacity: 1; }
.light:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 50%; }
#win-edges i { position: fixed; z-index: 20; }
body[data-win="max"] #win-edges, body[data-win="full"] #win-edges { display: none; }
.edge-t { top: 0; left: 8px; right: 0; height: 4px; cursor: ns-resize; }
.edge-b { bottom: 0; left: 8px; right: 0; height: 4px; cursor: ns-resize; }
.edge-l { left: 0; top: 8px; bottom: 8px; width: 4px; cursor: ew-resize; }
.edge-tl { top: 0; left: 0; width: 8px; height: 8px; cursor: nwse-resize; }
.edge-bl { bottom: 0; left: 0; width: 8px; height: 8px; cursor: nesw-resize; }
.brand { display: flex; align-items: center; gap: 8px; height: 32px; margin: 0 8px 20px; font-weight: 600; font-size: 16px; text-decoration: none; }
.brand svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.navlink, .worktab {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 8px; border-radius: 8px; width: 100%;
  text-decoration: none; color: var(--secondary); border: 0; background: none; text-align: left; font: 400 14px/20px var(--sans); cursor: pointer;
  transition: background-color .14s var(--ease), color .14s var(--ease);
}
.navlink svg, .worktab svg, .crumb svg, .btn svg { width: 16px; height: 16px; flex: none; }
.navlink svg, .worktab svg { color: var(--muted); }
.navlink:hover, .worktab:hover { background: var(--card); color: var(--ink); }
.navlink.on, .worktab[aria-selected="true"] { background: var(--raised); color: var(--ink); font-weight: 500; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }
.navlink.on svg { color: var(--ink); }
.side-label { margin: 24px 8px 8px; font-size: 13px; color: var(--muted); }
.worktabs { display: flex; flex-direction: column; gap: 2px; }
.worktab i { width: 8px; height: 8px; margin: 0 4px; flex: none; border-radius: 2px; }
.worktab .nm { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.worktab .count { font: 400 12px/16px var(--mono); color: var(--muted); }
.worktab.add { color: var(--muted); }
.savestate { margin-top: auto; padding: 16px 8px 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.savestate.bad { color: var(--negative); font-weight: 500; }
.savestate.sync { margin-top: 0; padding-top: 4px; }
.savestate.sync:empty { display: none; }
.tabbar, .tabselect { display: none; }

.content { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 56px; padding: 8px 32px; background: var(--page); border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; color: var(--secondary); }
.crumb svg { color: var(--muted); }
main { padding: 32px 32px 64px; max-width: 1520px; min-width: 0; }

.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 4px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--raised); color: var(--ink);
  font: 500 14px/20px var(--sans); text-decoration: none; white-space: nowrap;
  transition: background-color .14s var(--ease), border-color .14s var(--ease), transform .14s var(--ease);
}
.btn svg { color: var(--secondary); }
.btn:hover { background: #2C2C2F; border-color: var(--line-strong); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn.primary svg { color: var(--on-accent); }
.btn.primary:hover { background: #FFFFFF; border-color: #FFFFFF; }
.btn.big { min-height: 44px; }
.btn.sm { min-height: 28px; padding: 4px 8px; border-radius: 6px; font-size: 13px; }
.btn.danger { color: var(--negative); }
.btn.danger:hover { background: rgba(229, 72, 77, .12); border-color: var(--negative); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--secondary); }
.btn.ghost:hover { background: var(--raised); color: var(--ink); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.quiet-link { color: var(--secondary); font-size: 13px; text-decoration: none; }
.quiet-link:hover { color: var(--ink); text-decoration: underline; }

.field { display: block; margin-bottom: 16px; }
.field > span.lab { display: block; font-weight: 500; font-size: 13px; margin-bottom: 4px; color: var(--secondary); }
.field .opt { font-weight: 400; color: var(--muted); }
.field .hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 36px; padding: 8px 12px; font: 400 14px/20px var(--sans); color: var(--ink);
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px;
}
input::placeholder, textarea::placeholder { color: var(--secondary); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 72px; }
.moneybox { position: relative; display: block; }
.moneybox::before { content: '$'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--secondary); }
.moneybox input { padding-left: 24px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }
.form-error { color: var(--negative); font-weight: 500; margin-bottom: 12px; }
.form-error:empty { display: none; }

/* ---------- Cards ---------- */
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; }
.panel + .panel { margin-top: 16px; }
.card > h2, .panel > h2 { margin-bottom: 12px; }
.panel.empty-big { padding: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 28px; }
.sect > h2 { margin-bottom: 12px; }
.sect { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.cols.side-right { grid-template-columns: minmax(0, 1fr) 344px; gap: 16px; }
.stack > * + * { margin-top: 16px; }

/* ---------- Home ---------- */
.stats { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { position: relative; overflow: hidden; min-height: 128px; }
.lab { color: var(--secondary); font-size: 14px; }
.fig { font-size: 32px; line-height: 40px; font-weight: 500; margin-top: 4px; font-variant-numeric: tabular-nums; }
.change { font: 400 12px/16px var(--mono); color: var(--muted); margin-top: 8px; }
.change b { font-weight: 400; color: var(--secondary); }
.change b.up { color: var(--positive); }
.change b.down { color: var(--negative); }

/* The rendered object: a stack of unpaid slips, built in code. */
.slips { position: absolute; right: 24px; top: 12px; width: 176px; height: 140px; pointer-events: none; }
.slip { position: absolute; width: 152px; height: 128px; border-radius: 4px; background: linear-gradient(170deg, #F6F3EC, #E7E3D9); box-shadow: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4); }
.slip.back { right: 0; top: 8px; transform: rotate(7deg); background: linear-gradient(170deg, #CFCBC1, #BDB9AF); }
.slip.front { right: 16px; top: 8px; transform: rotate(-5deg); padding: 12px; color: #1B1B1A; }
.slip-mown { display: flex; height: 6px; margin-bottom: 8px; border-radius: 1px; overflow: hidden; }
.slip-mown i { flex: 1; background: var(--deep); }
.slip-mown i:nth-child(even) { background: color-mix(in srgb, var(--deep) 75%, white); }
.slip-name { font-size: 11px; line-height: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slip-lines { margin: 4px 0 8px; }
.slip-lines i { display: block; height: 2px; margin-bottom: 4px; background: rgba(27, 27, 26, .16); }
.slip-lines i:last-child { width: 60%; }
.slip-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; line-height: 16px; border-top: 1px solid rgba(27, 27, 26, .3); padding-top: 4px; }
.slip-total b { font-size: 13px; font-weight: 600; }

/* The main chart */
.main-row { display: grid; grid-template-columns: minmax(0, 1fr) 344px; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.work-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 24px; margin-bottom: 20px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--secondary); }
.legend-row span { display: inline-flex; align-items: center; gap: 8px; }
.legend-row i { width: 8px; height: 8px; border-radius: 50%; }
.legend-row b { font-weight: 500; color: var(--ink); }
.plot-wrap { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: 320px auto; }
.y-axis { position: relative; font: 400 12px/16px var(--mono); color: var(--muted); }
.y-axis span { position: absolute; right: 8px; transform: translateY(-50%); }
.plot { position: relative; border-radius: 8px; overflow: hidden; }
.mown { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.mown i { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.mown i:nth-child(even) { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.plot svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plot svg .base { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.plot svg .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.plot svg .line.lead { stroke: var(--accent); }
.plot svg .line.quiet { stroke: var(--muted); }
.plot-empty { position: absolute; left: 50%; top: 25%; transform: translate(-50%, -50%); width: max-content; max-width: 80%; color: var(--secondary); text-align: center; }
.hits { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.hit { position: relative; }
.hit:hover, .hit:focus-visible { background: rgba(237, 237, 237, .06); outline: none; }
.hit:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.hit .dot { position: absolute; left: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; box-shadow: 0 0 0 2px var(--card); opacity: 0; }
.hit .dot.lead { background: var(--accent); }
.hit .dot.quiet { background: var(--muted); }
.hit:hover .dot, .hit:focus-visible .dot { opacity: 1; }
.tip { position: absolute; z-index: 2; top: 12px; left: calc(50% + 12px); width: 168px; padding: 8px 12px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); font-size: 13px; opacity: 0; visibility: hidden; transition: opacity .14s var(--ease); pointer-events: none; }
.hit.flip .tip { left: auto; right: calc(50% + 12px); }
.hit:hover .tip, .hit:focus-visible .tip { opacity: 1; visibility: visible; }
.tip-t { color: var(--muted); margin-bottom: 4px; }
.tip div:not(.tip-t) { display: flex; justify-content: space-between; color: var(--secondary); }
.tip b { font-weight: 500; color: var(--ink); }
.x-axis { grid-column: 2; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin-top: 8px; font: 400 12px/16px var(--mono); color: var(--muted); }
.x-axis span { text-align: center; white-space: nowrap; }

/* Empty Home: mown stripes up to where setup has reached, rough grass after that. */
.lawn { position: relative; overflow: hidden; padding: 0; min-height: 360px; display: flex; align-items: flex-end; }
.lawn-field { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.lawn-field i { background: color-mix(in srgb, var(--accent) 2%, transparent); }
.lawn-field i:nth-child(even) { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.lawn-field i.cut { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lawn-field i.cut:nth-child(even) { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.lawn-copy { position: relative; padding: 24px; }
.lawn-copy h2 { font-size: 24px; line-height: 32px; }
.lawn-copy p { margin-top: 4px; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.steps .t { font-weight: 500; }
.stepno { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--raised); font: 400 12px/16px var(--mono); color: var(--secondary); }
.stepno svg { width: 16px; height: 16px; }
.steps .done .stepno { background: var(--accent); color: var(--on-accent); }
.steps .done .t { color: var(--secondary); }

.meter { display: block; height: 4px; margin-top: 8px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.meter b { display: block; height: 100%; border-radius: 2px; background: var(--secondary); }
.owing .line { display: flex; justify-content: space-between; gap: 12px; }
.row-actions { display: flex; gap: 4px; margin: 4px 0 0 -8px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list .who { min-width: 0; flex: 1 1 160px; }
.list .who a { font-weight: 500; text-decoration: none; }
.list .who a:hover { text-decoration: underline; }
.list .btns { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; flex: none; align-items: center; }
.side-right .list > li { flex-wrap: wrap; }
.empty { color: var(--muted); padding: 12px 0; border-top: 1px solid var(--line); }
.panel .empty { border-top: 0; padding: 4px 0; }
.empty-big p { margin: 8px 0 16px; color: var(--secondary); max-width: 56ch; }

/* ---------- Status: a dot and a word ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; color: var(--secondary); }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.pill.paid::before { background: var(--positive); }
.pill.owed { color: var(--ink); }
.pill.owed::before { background: var(--negative); }
.pill.part::before { background: var(--caution); }
.pill.none::before { background: var(--line-strong); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font: 400 13px/20px var(--sans); color: var(--muted); padding: 0 12px 8px 0; white-space: nowrap; }
table.data td { padding: 12px 12px 12px 0; border-top: 1px solid var(--line); vertical-align: middle; }
table.data th.right, table.data td.right { text-align: right; }
table.data tr.go { cursor: pointer; transition: background-color .14s var(--ease); }
table.data tr.go:hover td { background: rgba(237, 237, 237, .03); }
table.data td:last-child, table.data th:last-child { padding-right: 0; }
table.data th.gap-left, table.data td.gap-left { padding-left: 24px; }
table.data a.name { font-weight: 500; text-decoration: none; }
table.data a.name:hover { text-decoration: underline; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 320px; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--deepest); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; min-height: 28px; padding: 4px 12px; border-radius: 6px; font: 400 13px/20px var(--sans); color: var(--secondary); cursor: pointer; transition: background-color .14s var(--ease), color .14s var(--ease); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--ink); font-weight: 500; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }

/* ---------- Client profile ---------- */
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 8px; font-size: 13px; }
.back:hover { color: var(--ink); text-decoration: underline; }
.profile-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; align-items: center; margin-bottom: 24px; }
.client-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.contact-list { margin: 0; padding-top: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; }
.contact-list dt { color: var(--muted); }
.contact-list dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }

/* ---------- Calendar ---------- */
.cal-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { min-width: 160px; text-align: center; font-size: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin-bottom: 12px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 16px; height: 12px; border-radius: 2px; display: inline-block; }
.swatch.mown { background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--accent) 40%, transparent) 0 4px, color-mix(in srgb, var(--accent) 16%, transparent) 4px 8px); }
.swatch.open { border: 1px solid var(--line-strong); }
.swatch.done { background: var(--accent); }
.swatch.missed { border: 1px dashed var(--negative); }
.cal { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--line); display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.cal .dow { background: var(--card); padding: 8px; font-size: 13px; color: var(--muted); }
.day {
  background: var(--card); border: 0; min-height: 112px; padding: 4px 4px 8px; text-align: left; cursor: pointer;
  font: inherit; color: inherit; display: flex; flex-direction: column; gap: 4px; min-width: 0; position: relative;
  transition: background-color .14s var(--ease);
}
.day:hover { background: var(--raised); }
.day:focus-visible { outline-offset: -3px; }
.day.other { background: var(--page); color: var(--muted); }
.day.worked { background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, var(--card)) 0 16px, color-mix(in srgb, var(--accent) 7%, var(--card)) 16px 32px); }
.day.sel { box-shadow: inset 0 0 0 1px var(--secondary); }
.day .top { display: flex; justify-content: space-between; align-items: center; gap: 4px; min-height: 24px; padding-right: 4px; }
.day .date { font: 400 12px/24px var(--mono); min-width: 24px; text-align: center; }
.day.today .date { background: var(--accent); color: var(--on-accent); border-radius: 50%; height: 24px; }
.day .sum { font: 400 12px/16px var(--mono); color: var(--ink); }
.chip { display: block; font-size: 12px; line-height: 16px; padding: 2px 4px; border-radius: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: var(--raised); }
.chip.open { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip.done { background: var(--accent); color: var(--on-accent); }
.chip.missed { background: transparent; outline: 1px dashed var(--negative); outline-offset: -1px; color: var(--ink); }
.chip.more { background: transparent; color: var(--muted); padding: 0 4px; }

/* ---------- Invoice builder and preview ---------- */
.invoice-wrap { display: grid; grid-template-columns: 368px minmax(0, 1fr); gap: 16px; align-items: start; }
.preview { width: 100%; height: 1000px; border: 0; border-radius: 4px; background: #fff; display: block; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.pick { list-style: none; margin: 0 0 16px; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 320px; overflow: auto; }
.pick li + li { border-top: 1px solid var(--line); }
.pick label { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 12px; cursor: pointer; }
.pick label:hover { background: var(--raised); }
.pick input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.notice { background: var(--raised); color: var(--secondary); border-radius: 8px; padding: 8px 12px; margin-bottom: 16px; font-size: 13px; }
.notice a { font-weight: 500; color: var(--ink); }
.total-line { display: flex; justify-content: space-between; align-items: baseline; font-weight: 500; margin-bottom: 16px; }
.total-line .num { font-size: 32px; line-height: 40px; font-weight: 500; }

/* ---------- Settings ---------- */
.colors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.colors label { cursor: pointer; }
.colors input { position: absolute; opacity: 0; width: 0; height: 0; }
.colors i { display: flex; width: 100%; align-items: center; gap: 8px; padding: 4px 12px 4px 8px; min-height: 32px; border: 1px solid var(--line); background: var(--raised); border-radius: 8px; font-style: normal; font-size: 13px; }
.colors b { width: 16px; height: 16px; border-radius: 4px; display: block; flex: none; }
.colors input:checked + i { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 500; }
.colors input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.logo-prev { max-height: 64px; max-width: 200px; display: block; margin-bottom: 8px; background: #fff; border-radius: 4px; padding: 4px; }

/* ---------- Dialog and messages ---------- */
dialog { border: 1px solid var(--line-strong); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); color: var(--ink); background: var(--card); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-head { padding: 20px 24px 0; }
.dlg-head h2 { font-size: 18px; line-height: 24px; }
.dlg-body { padding: 16px 24px 4px; max-height: calc(100vh - 168px); overflow-y: auto; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 24px 20px; align-items: center; }
.dlg-foot .spacer { flex: 1; }
.dlg-foot .btn.primary { background: var(--ink); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 16px; background: var(--raised); color: var(--ink); border: 1px solid var(--line-strong); padding: 8px 8px 8px 16px; min-height: 48px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast button { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px; min-height: 28px; padding: 4px 8px; font: 500 13px/20px var(--sans); cursor: pointer; white-space: nowrap; }
.toast button:hover { background: rgba(255, 255, 255, .08); }
.banner { background: var(--negative); color: #fff; padding: 8px 32px; font-weight: 500; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.banner .btn { background: #fff; color: #111; }
.fatal { max-width: 560px; margin: 12vh auto; }
.fatal h1 { margin-bottom: 12px; font-size: 28px; line-height: 32px; }

/* ---------- Smaller screens ---------- */
@media (max-width: 1240px) {
  .main-row, .work-row, .invoice-wrap, .cols, .cols.side-right { grid-template-columns: minmax(0, 1fr); }
  .lawn { min-height: 240px; }
}
@media (max-width: 800px) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; }
  .layout { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .side, .crumb { display: none; }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 16px 8px; gap: 8px; }
  .tabselect { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
  .tabselect i { position: absolute; left: 12px; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; }
  .tabselect select { padding-left: 28px; min-height: 44px; font-weight: 500; text-overflow: ellipsis; }
  .topbar .actions { flex: none; flex-wrap: nowrap; }
  .btn.pay span { display: none; }
  .btn.pay { width: 44px; padding: 0; }
  main { padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); }
  h1 { font-size: 28px; line-height: 32px; }
  .tabbar {
    position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 4px 4px env(safe-area-inset-bottom); background: var(--deepest); border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; font-size: 11px; line-height: 16px; color: var(--muted); text-decoration: none; }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar a.on { color: var(--ink); }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; padding: 4px 12px; }
  .seg button { min-height: 36px; }
  input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea { min-height: 44px; font-size: 16px; }
  .toolbar input[type=search] { max-width: none; }
  .head .actions, .head .actions .btn { flex: 1 1 auto; }
  .list .btns { justify-content: flex-start; }
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-width: 1px 0 0; border-radius: 16px 16px 0 0; }
  .dlg-body { max-height: calc(100dvh - 200px); }
  .dlg-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1; }
  .cal { border-radius: 12px; }
  .cal .dow { padding: 4px; text-align: center; font-size: 12px; }
  .cal-nav h2 { min-width: 0; flex: 1; }
  .cal-top { flex-wrap: nowrap; }
  .preview { height: 640px; }
  .stats, .client-stats { grid-template-columns: minmax(0, 1fr); }
  .slips { right: 0; transform: scale(.85); transform-origin: top right; }
  .plot-wrap { grid-template-rows: 220px auto; }
  .x-axis span:nth-child(4n+2) { visibility: hidden; }
  .x-axis { font-size: 11px; }
  .day { min-height: 64px; padding: 2px; align-items: stretch; }
  .day .top { justify-content: center; padding: 0; }
  /* Too narrow for names: each job is a small bar, and tapping the day lists them. */
  .chip { font-size: 0; line-height: 0; height: 4px; padding: 0; border-radius: 2px; }
  .chip.open { background: var(--muted); box-shadow: none; }
  .chip.missed { background: var(--negative); outline: 0; }
  .chip.more { display: none; }
  .day .sum { display: none; }
  .hide-sm { display: none; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .list > li { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: rise .2s var(--ease); }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  .side, .topbar, .tabbar, #toast, #win-edges, main > :not(.preview) { display: none !important; }
  html, body, main { background: #fff; padding: 0; margin: 0; }
  .preview { box-shadow: none; }
}
