/* Design tokens. Warm paper, deep pine, amber accent. */
:root {
  --bg: #f6f3ec; --surface: #fffdf8; --sunk: #efeadf; --ink: #1d2a27; --muted: #5b6a65; --line: #d9d2c2;
  --pine: #17463f; --pine-soft: #dcebe6; --on-pine: #fdfbf5; --amber: #9a5a0c; --amber-soft: #f7e6c8;
  --bad: #9c2f28; --bad-soft: #f6dedb; --ok: #24603f; --ok-soft: #dcefe2; --blue: #1f5673; --blue-soft: #dbe9f1;
  --radius: 10px; --shadow: 0 1px 2px rgb(29 42 39 / 8%), 0 4px 14px rgb(29 42 39 / 5%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111917; --surface: #18221f; --sunk: #0d1412; --ink: #e9e5da; --muted: #9eaca6; --line: #2d3b37;
    --pine: #2f7d6f; --pine-soft: #1c3631; --on-pine: #fdfbf5; --amber: #e3ab57; --amber-soft: #3a2d15;
    --bad: #ee8f87; --bad-soft: #3d1d1a; --ok: #86cfa2; --ok-soft: #173224; --blue: #8cc3e0; --blue-soft: #152c38;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 0.3rem; }
p { margin: 0.5rem 0; }
a { color: var(--pine); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { a { color: #7fd0bd; } }
code { font: 0.9em ui-monospace, Consolas, monospace; background: var(--sunk); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--pine); color: var(--on-pine); padding: 1.25rem 0.9rem; display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
@media (prefers-color-scheme: dark) { .rail { background: #10302b; } }
.brand { display: flex; align-items: center; gap: 0.6rem; font: 600 1.3rem var(--serif); color: inherit; text-decoration: none; }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail a { color: inherit; text-decoration: none; }
.rail li a { display: block; padding: 0.55rem 0.75rem; border-radius: 8px; opacity: 0.86; }
.rail li a:hover { background: rgb(255 255 255 / 10%); opacity: 1; }
.rail li a[aria-current] { background: var(--on-pine); color: #17463f; opacity: 1; font-weight: 600; }
.rail-foot { margin-top: auto; display: grid; gap: 0.4rem; font-size: 0.9rem; border-top: 1px solid rgb(255 255 255 / 18%); padding-top: 1rem; }
.who { display: grid; }
.who span { opacity: 0.75; font-size: 0.8rem; }
.rail .linkish { color: inherit; }
main { padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1280px; width: 100%; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }   /* minmax: a wide table scrolls inside its card instead of widening the page */
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.75rem; }
  .rail ul { display: flex; flex-wrap: wrap; }
  .rail-foot { margin: 0; border: 0; padding: 0; display: flex; gap: 1rem; align-items: center; }
  .who span { display: none; }
}

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.crumb { margin: 0 0 0.2rem; font-size: 0.9rem; }
.crumb a::before { content: "‹ "; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.card > h2:first-child, .card-head h2, .card > fieldset > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 1.25rem; align-items: start; }
.two-col .card { margin-bottom: 0; }
.two-col { margin-bottom: 1.25rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.banner { background: var(--blue-soft); border-left: 4px solid var(--blue); padding: 0.7rem 1rem; border-radius: 6px; margin: 0 0 1rem; }
.banner ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.banner.warn, .banner.note { background: var(--amber-soft); border-color: var(--amber); }
.banner.bad { background: var(--bad-soft); border-color: var(--bad); }
.banner.ok { background: var(--ok-soft); border-color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; text-decoration: none; color: inherit; display: grid; }
.stat b { font: 600 2rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.88rem; }
.stat.alert { border-color: var(--amber); background: var(--amber-soft); }
.stat:hover { border-color: var(--pine); }

.feed, .timeline, .tasklist, .flags, .legend, .m-tasks { list-style: none; margin: 0; padding: 0; }
.feed li { border-left: 4px solid var(--line); padding: 0.45rem 0.8rem; margin-bottom: 0.4rem; background: var(--sunk); border-radius: 0 6px 6px 0; }
.feed li.bad { border-color: var(--bad); }
.feed li.warn { border-color: var(--amber); }
.feed a, .timeline a { color: inherit; text-decoration: none; display: block; }
.timeline li { border-bottom: 1px solid var(--line); }
.timeline li:last-child { border: 0; }
.timeline a { display: grid; grid-template-columns: 9.5rem 1fr auto; gap: 0.75rem; align-items: center; padding: 0.55rem 0.25rem; }
.timeline a:hover { background: var(--sunk); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .timeline a { grid-template-columns: 1fr; gap: 0.1rem; } }
.tasklist li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.flags li { color: var(--amber); font-size: 0.9rem; }
.flags li::before { content: "⚑ "; }
.facts { display: grid; grid-template-columns: 9rem 1fr; gap: 0.4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.reveal { display: grid; grid-template-columns: 14rem 1fr; gap: 0.3rem 1rem; background: var(--amber-soft); padding: 0.75rem 1rem; border-radius: 6px; }
.reveal dd { margin: 0; font: 600 1rem ui-monospace, Consolas, monospace; }
.note { border-top: 1px solid var(--line); padding: 0.75rem 0; }
.note header { color: var(--muted); font-size: 0.9rem; }
.note p { white-space: pre-wrap; }

/* ---- chips ---- */
.chip { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--sunk); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; }
.chip.s-open, .chip.s-lead, .chip.s-applicant { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.chip.s-in_progress { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.chip.s-draft, .chip.s-partial { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.chip.s-issued { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.chip.s-paid, .chip.s-final { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
.chip.s-overdue { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.chip.s-void { color: var(--muted); text-decoration: line-through; }
.list tfoot th, .list tfoot td { padding: 0.6rem; border-top: 2px solid var(--line); border-bottom: 0; text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--ink); }
.stat b { overflow-wrap: anywhere; }
.list td.right, .list th.right { white-space: nowrap; }

.chip.s-current { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
.chip.s-expiring, .chip.s-upcoming { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.chip.s-expired { color: var(--muted); }
meter.use { display: block; width: min(220px, 100%); height: 0.7rem; margin-bottom: 0.2rem; }
meter.use::-webkit-meter-bar { background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; height: 0.7rem; }
meter.use::-webkit-meter-optimum-value { background: var(--ok); border-radius: 999px; }
meter.use.over::-webkit-meter-optimum-value { background: var(--bad); }
meter.use::-moz-meter-bar { background: var(--ok); border-radius: 999px; }
meter.use.over::-moz-meter-bar { background: var(--bad); }
.use-text { font-size: 0.9rem; }
.over-text { color: var(--bad); }
.list tr.past td { color: var(--muted); }
.dialog.wide { width: min(760px, calc(100vw - 2rem)); }

/* ---- import ---- */
.list.match select { min-width: min(100%, 26rem); max-width: 100%; }
.list.match td:first-child { width: 42%; }
.problems { margin: 0.4rem 0 1rem; padding-left: 1.2rem; max-height: 18rem; overflow-y: auto; font-size: 0.92rem; }
.problems.bad li { color: var(--bad); }
form.actions { justify-content: space-between; }

/* ---- reports ---- */
.report-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.6rem; }
.report-list a { display: grid; gap: 0.15rem; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none; height: 100%; }
.report-list a:hover { border-color: var(--pine); background: var(--sunk); }
.report-list span { color: var(--muted); font-size: 0.9rem; }
.list.report td, .list.report th { font-size: 0.92rem; padding: 0.45rem 0.6rem; }
.list.report td { font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 26rem; overflow: hidden; text-overflow: ellipsis; }
.print-only { display: none; }
@media print {
  .print-only { display: block; }
  .filters, .crumb { display: none !important; }
  main { padding: 0; max-width: none; }
  main > .list { border: 0; overflow: visible; display: table; }
  .list.report td, .list.report th { font-size: 9pt; padding: 3pt 5pt; white-space: normal; }
}

/* ---- leads and applicants ---- */
.chip.s-lost, .chip.s-not_hired { color: var(--muted); }
.pipeline-panel { border-left: 5px solid var(--amber); }
.pipeline-panel .two-col { margin-bottom: 0; }
.ticks { list-style: none; margin: 0.4rem 0; padding: 0; display: grid; gap: 0.45rem; }
.list select { min-height: 34px; padding: 0.25rem 0.5rem; min-width: 11rem; }
.dialog h3 { margin-top: 1rem; }

/* ---- messages ---- */
.badge { display: inline-block; min-width: 1.4rem; padding: 0 0.4rem; border-radius: 999px; background: var(--amber); color: #fff; font: 700 0.78rem/1.4rem var(--sans); text-align: center; }
@media (prefers-color-scheme: dark) { .badge { color: #111917; } }
.inbox { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 760px) { .inbox { grid-template-columns: 1fr; } }
.threads { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-height: 72vh; overflow-y: auto; }
.threads a { display: grid; gap: 0.1rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; border-left: 4px solid transparent; }
.threads a:last-child { border-bottom: 0; }
.threads a:hover { background: var(--sunk); }
.threads a[aria-current] { border-left-color: var(--amber); background: var(--sunk); }
.thread-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.thread-last { color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.threads time { color: var(--muted); font-size: 0.78rem; }
.conversation { margin-bottom: 0; }
.bubbles { list-style: none; margin: 0 0 1rem; padding: 0.25rem; display: flex; flex-direction: column; gap: 0.6rem; max-height: 52vh; overflow-y: auto; }
.bubbles li { max-width: min(85%, 560px); padding: 0.55rem 0.8rem; border-radius: 14px; background: var(--sunk); border: 1px solid var(--line); align-self: flex-start; }
.bubbles li.mine { align-self: flex-end; background: var(--pine-soft); border-color: transparent; }
.bubbles li.announce { border-left: 4px solid var(--amber); }
.bubbles li.none { align-self: center; background: none; border: 0; color: var(--muted); }
.bubbles p { margin: 0 0 0.2rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubbles small { color: var(--muted); font-size: 0.78rem; }
.reply .actions { margin-top: 0.5rem; }
.board-bar .banner { margin: 0; }
.m-links { display: flex; gap: 1.1rem; align-items: center; }
.phone .bubbles { max-height: none; }
.phone .reply { display: grid; gap: 0.6rem; position: sticky; bottom: 0; }

/* ---- forms and signatures ---- */
.door.wide { width: min(820px, 100%); max-width: 820px; }
.form-body { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem; margin: 1rem 0 1.5rem; line-height: 1.6; }
.sign-form h2 { margin-top: 0; }
.pad { display: block; width: 100%; height: 170px; background: #fff; border: 2px dashed var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; }
.signature { border-top: 2px solid var(--line); margin-top: 1.5rem; padding-top: 0.5rem; }
.signature img { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; max-width: 100%; height: auto; margin-bottom: 1rem; }
.typed-signature { font: italic 2rem var(--serif); border-bottom: 1px solid var(--ink); width: fit-content; padding: 0 1.5rem 0.2rem 0.2rem; margin-bottom: 1rem; }
.secret { white-space: pre-wrap; }
.door .paper-bar { margin: 0 0 1rem; padding: 0; max-width: none; }
@media print {
  .plain { display: block; padding: 0; }
  .door { border: 0; box-shadow: none; padding: 0; max-width: none; width: auto; }
  .door > .brand, .door .banner { display: none !important; }
  .form-body { border: 0; padding: 0; background: none; }
}

/* ---- printable invoice ---- */
.paper-page { background: var(--sunk); }
.paper-bar { max-width: 8.5in; margin: 1rem auto 0; padding: 0 1rem; justify-content: space-between; }
.paper { background: #fff; color: #1d2a27; max-width: 8.5in; margin: 1rem auto 3rem; padding: 0.75in; box-shadow: var(--shadow); position: relative; }
.paper a { color: inherit; }
.paper .list th { color: #5b6a65; border-color: #d9d2c2; }
.paper .list td, .paper .list tfoot th, .paper .list tfoot td { border-color: #d9d2c2; color: #1d2a27; }
.paper .list tbody tr:hover { background: none; }
.paper-head { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.paper-head .facts { grid-template-columns: auto auto; }
.paper-head .facts dt { color: #5b6a65; }
.paper-to { margin-bottom: 1.5rem; }
.paper-to h2 { font: 600 0.8rem var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: #5b6a65; margin: 0; }
.paper-note { margin-top: 1.5rem; white-space: pre-wrap; color: #5b6a65; }
.stamp { border: 3px solid #9c2f28; color: #9c2f28; font-weight: 700; letter-spacing: 0.08em; padding: 0.3rem 0.8rem; width: fit-content; margin: 0 0 1rem; }
@media print {
  .paper-bar { display: none !important; }
  .paper-page { background: #fff; }
  .paper { box-shadow: none; margin: 0; padding: 0; max-width: none; }
}

.chip.s-completed { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.chip.s-approved, .chip.s-active { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
.chip.s-missed, .chip.s-terminated { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.chip.s-cancelled, .chip.s-discharged, .chip.s-on_hold { color: var(--muted); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 40px; padding: 0.45rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 0.95rem var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--pine); }
.btn.primary { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 0.2rem 0.7rem; font-size: 0.85rem; }
.btn.big { width: 100%; min-height: 64px; font-size: 1.3rem; border-radius: 14px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.linkish { background: none; border: 0; padding: 0.2rem 0.3rem; color: var(--pine); font: inherit; text-decoration: underline; cursor: pointer; }
@media (prefers-color-scheme: dark) { .linkish { color: #7fd0bd; } }
.linkish.danger { color: var(--bad); }
.actions { display: flex; gap: 0.6rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.actions.left { justify-content: flex-start; }
.actions.sticky { position: sticky; bottom: 0; background: var(--surface); padding: 0.75rem 0; border-top: 1px solid var(--line); }
.form-error { color: var(--bad); font-weight: 600; margin: 0.5rem 0; flex: 1; }

/* ---- forms ---- */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.9rem 1rem; align-items: start; }
.grid.one { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 0.25rem; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span, legend { font-size: 0.88rem; font-weight: 600; }
.field small { color: var(--muted); }
.req { color: var(--bad); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.65rem; width: 100%; min-height: 40px; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.15rem; height: 1.15rem; min-height: 0; accent-color: var(--pine); flex: none; margin-top: 0.2rem; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: var(--sunk); }
.check { display: flex; gap: 0.5rem; align-items: flex-start; }
.check small { display: block; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.checks.column { flex-direction: column; }
.checks legend { margin-bottom: 0.3rem; padding: 0; }
.filters { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .grow { flex: 1 1 240px; }
.stack { display: grid; gap: 0.9rem; }
.steps li { margin-bottom: 0.75rem; }
.qr { display: block; margin: 0.5rem 0; background: #fff; border-radius: 8px; }

/* ---- tables ---- */
table { border-collapse: collapse; width: 100%; }
.list th { text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.5rem 0.6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.list th.right { text-align: right; }
.list th.center { text-align: center; }
.list td { padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tbody tr:hover { background: var(--sunk); }
.list tr.off { opacity: 0.55; }
main > .list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: block; overflow-x: auto; }
.card { overflow-x: auto; }

.tabs, .seg { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tabs { border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; }
.tabs a { padding: 0.55rem 0.9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a[aria-current] { color: var(--ink); border-color: var(--amber); }
.seg { background: var(--sunk); padding: 3px; border-radius: 10px; border: 1px solid var(--line); width: fit-content; }
.seg a, .seg button { padding: 0.35rem 0.8rem; border-radius: 7px; border: 0; background: none; color: var(--ink); font: 600 0.9rem var(--sans); text-decoration: none; cursor: pointer; min-height: 36px; }
.seg a[aria-current], .seg button[aria-pressed="true"] { background: var(--pine); color: var(--on-pine); }
.seg.wide { width: 100%; }
.seg.wide button { flex: 1; min-height: 46px; }
.seg button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- schedule board ---- */
.board-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.legend { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.9rem; }
.board-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.board { min-width: 980px; table-layout: fixed; }
.board th, .board td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0.4rem; vertical-align: top; }
.board thead th { background: var(--sunk); font-size: 0.85rem; text-align: left; position: sticky; top: 0; }
.board thead th span { font-weight: 400; color: var(--muted); }
.board tbody th { text-align: left; font-weight: 600; width: 150px; background: var(--surface); position: sticky; left: 0; }
.board th:first-child { width: 150px; }
.board th:last-child, .board td:last-child { width: 64px; border-right: 0; font-variant-numeric: tabular-nums; }
.board .is-today { background: color-mix(in srgb, var(--amber-soft) 55%, transparent); }
.board .open-row th, .board .open-row td { background: color-mix(in srgb, var(--amber-soft) 35%, var(--surface)); }
.visit { display: grid; gap: 0.05rem; padding: 0.3rem 0.45rem; margin-bottom: 0.3rem; border-radius: 6px; border-left: 4px solid var(--muted); background: var(--sunk); color: var(--ink); text-decoration: none; font-size: 0.82rem; line-height: 1.3; }
.visit:hover { outline: 2px solid var(--pine); }
.visit time { font-weight: 600; font-variant-numeric: tabular-nums; }
.visit span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit em { font-style: normal; font-size: 0.72rem; color: var(--muted); }
.visit.s-open { border-color: var(--amber); background: var(--amber-soft); border-left-style: dashed; }
.visit.s-in_progress { border-color: var(--blue); background: var(--blue-soft); }
.visit.s-completed { border-color: var(--ok); background: var(--ok-soft); }
.visit.s-approved { border-color: var(--pine); background: var(--pine-soft); }
.visit.s-missed { border-color: var(--bad); background: var(--bad-soft); }
.visit.s-cancelled { opacity: 0.55; text-decoration: line-through; }

/* ---- dialogs ---- */
.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; width: min(540px, calc(100vw - 2rem)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
.dialog::backdrop { background: rgb(15 25 22 / 55%); }
.dialog h2 { margin-top: 0; }
.secret { display: block; font: 600 1.15rem ui-monospace, Consolas, monospace; background: var(--amber-soft); padding: 0.9rem; border-radius: 8px; overflow-wrap: anywhere; user-select: all; }

/* ---- sign-in and account pages ---- */
.plain { display: grid; place-items: start center; min-height: 100vh; padding: clamp(1rem, 6vh, 4rem) 1rem; }
.door { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 2rem; width: min(440px, 100%); max-width: 440px; box-shadow: var(--shadow); }
.door .brand { color: var(--pine); margin-bottom: 1.25rem; }
@media (prefers-color-scheme: dark) { .door .brand { color: var(--ink); } }
.door h1 { font-size: 1.6rem; margin-bottom: 0.75rem; }

/* ---- caregiver phone app ---- */
.phone { padding-bottom: env(safe-area-inset-bottom); }
.m-top { background: var(--pine); color: var(--on-pine); display: flex; justify-content: space-between; align-items: center; padding: 0.7rem 1rem; padding-top: calc(0.7rem + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 5; }
.m-top a { color: inherit; text-decoration: none; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.m-top .brand { font-size: 1.1rem; }
.m-main { padding: 1rem 1rem 3rem; max-width: 640px; margin: 0 auto; }
.m-main h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.m-main h1 small { font: 400 1rem var(--sans); color: var(--muted); }
.m-main h2 { margin-top: 0; }
.m-when { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; color: var(--muted); }
.m-day h2 { font: 600 0.85rem var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1.4rem 0 0.5rem; }
.m-visit, .m-now { display: grid; gap: 0.15rem; padding: 0.9rem 1rem; margin-bottom: 0.6rem; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--muted); border-radius: 12px; color: inherit; text-decoration: none; }
.m-visit time { font-weight: 700; font-variant-numeric: tabular-nums; }
.m-visit strong { font-size: 1.1rem; }
.m-visit span:not(.chip) { color: var(--muted); }
.m-visit .chip { justify-self: start; margin-top: 0.3rem; }
.m-visit.s-in_progress { border-left-color: var(--blue); }
.m-visit.s-completed { border-left-color: var(--ok); }
.m-visit.s-approved { border-left-color: var(--pine); }
.m-visit.s-missed { border-left-color: var(--bad); }
.m-now { background: var(--blue-soft); border-color: var(--blue); }
.m-now em { font-style: normal; font-weight: 600; }
.m-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; margin: 1rem 0; }
.m-clocked { font-size: 1.1rem; }
.m-tasks li { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.m-tasks li:last-child { border: 0; }
.m-foot { margin-top: 2rem; text-align: center; }
.phone .btn { min-height: 48px; }
.phone input, .phone textarea { font-size: 1.05rem; }

@media print {
  .rail, .actions, .btn, .tabs, .banner.warn { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* ---- a person's calendar (day, week, month) ---- */
.cal-title { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.cal-title h2 { margin: 0 0.25rem; min-width: 11ch; text-align: center; }
.cal-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.cal { width: 100%; min-width: 900px; table-layout: fixed; border-collapse: collapse; }
.cal th { background: var(--sunk); font-size: 0.85rem; text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); }
.cal td { vertical-align: top; padding: 0.35rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); height: 6.5rem; }
.cal-week td { height: 16rem; }
.cal tr:last-child td { border-bottom: 0; }
.cal .cal-sum { width: 9.5rem; border-right: 0; background: color-mix(in srgb, var(--sunk) 60%, var(--surface)); font-size: 0.82rem; line-height: 1.4; }
.cal .cal-sum ul { margin: 0.3rem 0 0; padding: 0; list-style: none; color: var(--muted); }
.cal .is-today { background: color-mix(in srgb, var(--amber-soft) 55%, transparent); }
.cal .is-outside { background: color-mix(in srgb, var(--sunk) 45%, var(--surface)); }
.cal .is-outside .cal-date a, .cal .is-outside .visit { opacity: 0.6; }
.cal-date { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 0.3rem; font-size: 0.85rem; }
.cal-date a { font-weight: 700; color: var(--ink); text-decoration: none; padding: 0 0.3rem; border-radius: 6px; }
.cal-date a:hover { background: var(--pine); color: var(--on-pine); }
.cal .is-today .cal-date a { background: var(--pine); color: var(--on-pine); }
.cal-date span { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.cal-service { color: var(--muted); }
.cal-legend { margin: 0.8rem 0 0; padding: 0; list-style: none; }
@media print {
  .cal-legend, .cal-card ~ .card { display: none !important; }
  .cal { min-width: 0; }
  .cal-wrap { overflow: visible; }
}

/* ---- availability and time off ---- */
.off-day { display: block; margin-bottom: 0.3rem; padding: 0.15rem 0.45rem; border-radius: 6px; font-size: 0.78rem; font-weight: 600; background: var(--bad-soft); color: var(--bad); border: 1px dashed var(--bad); }
.off-day.waiting { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
.chip.s-requested { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.chip.s-denied { color: var(--muted); }
.hours-grid { display: grid; grid-template-columns: 7.5rem repeat(2, minmax(0, 1fr)); gap: 0.5rem 1rem; align-items: center; max-width: 46rem; }
.hours-grid .hours-day { font-weight: 600; }
.hours-grid .hours-pair { display: flex; align-items: center; gap: 0.4rem; }
.hours-grid .hours-pair input { min-width: 0; flex: 1; }
.hours-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1.2rem; margin: 0 0 1rem; }
.hours-list dt { font-weight: 600; }
.hours-list dd { margin: 0; }
@media (max-width: 560px) {
  .hours-grid { grid-template-columns: 1fr; gap: 0.3rem; }
  .hours-grid .hours-day { margin-top: 0.6rem; }
}

/* ---- caregiver matching and open shifts ---- */
.match-list { list-style: none; margin: 0; padding: 0; }
.match { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 1rem; align-items: start; padding: 0.7rem 0.2rem; border-bottom: 1px solid var(--line); }
.match:last-child { border-bottom: 0; }
.match-who { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.match-why { grid-column: 1; list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.match-why li { padding-left: 1.3rem; position: relative; }
.match-why li::before { position: absolute; left: 0; font-weight: 700; }
.match-why .plus::before { content: "+"; color: var(--ok); }
.match-why .minus::before { content: "!"; color: var(--bad); }
.match > .btn, .match > .chip { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.match-more { margin-top: 0.8rem; }
.match-more summary { cursor: pointer; font-weight: 600; padding: 0.4rem 0; }
.m-tabs { display: flex; gap: 0.3rem; padding: 0.5rem 1rem 0; max-width: 640px; margin: 0 auto; }
.m-tabs a { flex: 1; text-align: center; padding: 0.5rem 0.3rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.m-tabs a[aria-current] { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
@media (max-width: 560px) {
  .match { grid-template-columns: 1fr; }
  .match > .btn, .match > .chip { grid-column: 1; grid-row: auto; justify-self: start; }
}
@media print { .m-tabs { display: none !important; } }

.map-point .btn { margin-left: 0.5rem; }

/* ---- incident reports ---- */
.facts { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: 0.4rem 1.2rem; margin: 0; }
.facts dt { font-weight: 600; color: var(--muted); }
.facts dd { margin: 0; }
.pre { white-space: pre-wrap; }
img.sig { max-width: 320px; max-height: 120px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts dt { margin-top: 0.4rem; } }

/* ---- phone app: the visit page as a list of sections ---- */
.m-list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 0.8rem; overflow: hidden; }
.m-row { border-bottom: 1px solid var(--line); }
.m-row:last-child { border-bottom: 0; }
.m-row > summary { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.95rem 1rem; cursor: pointer;
  list-style: none; font-size: 1.05rem; min-height: 52px; }
.m-row > summary::-webkit-details-marker { display: none; }
.m-row > summary::after { content: "›"; font-size: 1.5rem; color: var(--muted); transition: transform 0.15s; }
.m-row[open] > summary::after { transform: rotate(90deg); }
.m-row > :not(summary) { margin: 0 1rem 0.9rem; }
.m-row-title { font-weight: 600; flex: 1; }
.m-row-meta { color: var(--muted); font-size: 0.9rem; }
.m-past { border-left: 3px solid var(--line); padding-left: 0.7rem; margin-bottom: 0.6rem; }
.m-past p { margin: 0.1rem 0; }
.m-line { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.m-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.m-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.m-screen legend { font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; }
.m-screen .seg.wide { width: 100%; }
.m-screen .seg .check { flex: 1; justify-content: center; padding: 0.6rem; border-radius: 8px; }
.m-visit-head h1 { margin: 0 0 0.2rem; }
