/* CareHub. Tokens first; dark mode redefines them. No external fonts or CSS. */
:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef2f3;
  --border: #d9e0e3;
  --text: #17242b;
  --muted: #5a6b73;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d7f0ec;
  --accent: #1d4ed8;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --warn: #854d0e;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info-soft: #dbeafe;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1719; --surface: #162125; --surface-2: #1d2a2f; --border: #2c3c42; --text: #e4ecee; --muted: #97a8ae;
    --brand: #2dd4bf; --brand-ink: #062b27; --brand-soft: #123c37; --accent: #93b4ff;
    --ok: #4ade80; --ok-soft: #12321f; --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3d1717; --info-soft: #172a4d;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1719; --surface: #162125; --surface-2: #1d2a2f; --border: #2c3c42; --text: #e4ecee; --muted: #97a8ae;
  --brand: #2dd4bf; --brand-ink: #062b27; --brand-soft: #123c37; --accent: #93b4ff;
  --ok: #4ade80; --ok-soft: #12321f; --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3d1717; --info-soft: #172a4d;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: .5rem 0; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 4px 8px 16px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.org-name { font-size: .8rem; color: var(--muted); font-weight: 500; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--text); }
.nav a .ico { width: 20px; text-align: center; }
.side-foot { margin-top: auto; padding: 8px; font-size: .85rem; }
main { padding: 24px 28px 96px; min-width: 0; max-width: 1280px; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .topbar .brand { padding: 0; }
  main { padding: 16px 16px 96px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; }
  .tabbar a { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: .72rem; color: var(--muted); text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--brand); font-weight: 600; }
  .tabbar .ico { font-size: 1.2rem; }
}

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat a { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 8px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.n, th.n { text-align: right; white-space: nowrap; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--surface-2); }

/* Controls */
button, .btn { font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.big { width: 100%; min-height: 56px; font-size: 1.1rem; justify-content: center; }
button.small, .btn.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: none; background: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 500; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 40px; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; vertical-align: middle; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.inline-fields { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields .field { margin-bottom: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; }
legend { font-weight: 700; padding: 0 6px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--accent); }
.alert { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; border: 1px solid; }
.alert.warn { background: var(--warn-soft); border-color: var(--warn); }
.alert.bad { background: var(--bad-soft); border-color: var(--bad); }
.alert.ok { background: var(--ok-soft); border-color: var(--ok); }
.alert.info { background: var(--info-soft); border-color: var(--accent); }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { white-space: nowrap; border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
/* F-90: Settings tabs in groups */
.tabgroups { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-bottom: 16px; }
.tabgroup .tabs { margin-bottom: 0; flex-wrap: wrap; }
.tabgroup-name { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 4px; }

/* Roster */
.roster-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.roster { display: grid; grid-template-columns: 160px repeat(7, minmax(128px, 1fr)); min-width: 1060px; }
.roster > div { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; min-height: 64px; }
.roster .rh { background: var(--surface-2); font-weight: 600; font-size: .85rem; min-height: 0; position: sticky; top: 0; }
.roster .rh.today { background: var(--brand-soft); }
.roster .wname { font-weight: 600; font-size: .9rem; background: var(--surface); position: sticky; left: 0; z-index: 1; }
.roster .cell.drop { background: var(--brand-soft); }
.roster .add { opacity: 0; font-size: .8rem; border: 1px dashed var(--border); background: none; width: 100%; min-height: 26px; padding: 0; margin-top: 4px; color: var(--muted); }
.roster .cell:hover .add, .roster .add:focus-visible { opacity: 1; }
.chip { display: block; width: 100%; text-align: left; border-radius: 6px; padding: 4px 6px; margin-bottom: 4px; font-size: .78rem; line-height: 1.3; border: 1px solid var(--border); border-left: 4px solid var(--brand); background: var(--surface); cursor: grab; min-height: 0; font-weight: 500; }
.chip strong { display: block; font-size: .8rem; }
.chip[style*="--c"] { border-left-color: var(--c); }
.chip.open { border-left-color: var(--warn); background: var(--warn-soft); }
.chip.in_progress { border-left-color: var(--accent); }
.chip.completed { border-left-color: var(--ok); }
.chip.cancelled, .chip.cancelled_billable { border-left-color: var(--muted); background: var(--surface-2); text-decoration: line-through; }
.chip.flagged { box-shadow: inset 0 0 0 1px var(--bad); }

/* Budget bars use <meter>, styled per engine */
meter { width: 100%; height: 12px; }
td meter { width: 90px; vertical-align: middle; }
.head .row select, .head .row input[type="search"], .head .inline-fields select { width: auto; max-width: 240px; }

/* Worker app */
.shift-card { display: block; text-decoration: none; color: inherit; }
.shift-card .time { font-weight: 700; font-size: 1.05rem; }
.shift-card.now { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.daylabel { font-weight: 700; margin: 18px 0 6px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 6px; } }
.sig { border: 2px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; width: 100%; height: 160px; display: block; }
.note { border-left: 3px solid var(--brand); padding: 4px 0 4px 10px; margin: 10px 0; white-space: pre-wrap; }
.pre { white-space: pre-wrap; }

/* Dialog */
dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / .3); }
dialog::backdrop { background: rgb(10 20 25 / .5); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
dialog .dlg-head h2 { margin: 0; }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
dialog .dlg-body { padding: 16px 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
dialog .dlg-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(480px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); pointer-events: auto; }
.toast.bad { background: var(--bad); color: #fff; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); padding: 28px; }
.login .brand { justify-content: center; font-size: 1.3rem; }

/* Print */
@media print { .side, .topbar, .tabbar, .no-print { display: none !important; } main { padding: 0; } .shell { display: block; } }

/* Fixes from screenshot review */
.grid > .card + .card { margin-top: 0; }
.grid + .card, .grid + details, .grid + .table-wrap { margin-top: 12px; }
details > summary { cursor: pointer; }
@media (max-width: 860px) { .roster { grid-template-columns: 104px repeat(7, minmax(120px, 1fr)); min-width: 944px; } }
.demo-banner { background: var(--warn-soft); color: var(--text); border-bottom: 1px solid var(--warn); text-align: center; padding: 6px 16px; font-size: .85rem; font-weight: 600; }
/* Keep rows at their natural height while a page is still loading (phone header stretched otherwise). */
.shell { align-content: start; }

/* Scrollable regions are focusable (set by render() in ui.js) so keyboard users can scroll them. */
.table-wrap:focus-visible, .roster-wrap:focus-visible, .dlg-body:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

/* Roles: permission matrix */
.perm-group { margin-bottom: 12px; }
.perm-group h4 { margin: 0 0 4px; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.perm-group .check { padding: 4px 0; font-weight: 400; }

/* Plans (F-93) */
.eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.plan-panel details { margin-top: 12px; }
.plan-panel summary { cursor: pointer; font-weight: 600; }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.plan-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.plan-col.current { border-color: var(--brand); background: var(--brand-soft); }
.plan-col h4 { margin: 0 0 4px; }
.plan-col ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.plan-col li.off { color: var(--muted); }
.plan-notice { text-align: center; padding: 32px; }
.plan-notice h2 { margin-top: 10px; }
@media (max-width: 900px) { .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .plan-grid { grid-template-columns: 1fr; } }

/* Notifications (F-76) */
.bell { position: relative; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; min-height: 40px; width: 44px; padding: 0; font-size: 1.1rem; cursor: pointer; }
.side-foot .bell { margin-bottom: 10px; }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: start; }
.notif-list li.unread { font-weight: 600; }
.notif-list li.read { font-weight: 400; }
.notif-list li .ico { font-size: 1.2rem; }
.notif-list li a { color: var(--text); text-decoration: none; }
.notif-list li a:hover { text-decoration: underline; }

/* Audit log (F-96) */
.audit-details { margin-top: 4px; }
.audit-details summary { cursor: pointer; font-size: .85rem; color: var(--accent); }
.audit-details ul { margin: 4px 0; padding-left: 18px; font-size: .85rem; color: var(--muted); }

/* Roster views (F-01) */
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; margin: 8px 0; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c, var(--brand)); margin-right: 6px; }
.roster.cols-1 { grid-template-columns: 160px 1fr; min-width: 0; }
.roster.cols-14 { grid-template-columns: 160px repeat(14, minmax(118px, 1fr)); min-width: 1900px; }
.roster .rh.weekend { background: var(--surface-2); }
.roster .rh.today { background: var(--brand-soft); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; min-height: 36px; padding: 6px 12px; }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--text); font-weight: 700; }
.weekday-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday-picks label { border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-weight: 500; cursor: pointer; }
.weekday-picks input { width: 14px; height: 14px; margin-right: 4px; }
@media (max-width: 860px) { .roster.cols-1 { grid-template-columns: 104px 1fr; } .roster.cols-14 { grid-template-columns: 104px repeat(14, minmax(118px, 1fr)); min-width: 1760px; } }
@media print {
  .side, .topbar, .tabbar, .demo-banner, .no-print, .roster-toolbar, .roster .add, #toast { display: none !important; }
  .shell { display: block; } main { padding: 0; }
  .roster-wrap { overflow: visible; border: none; }
  .roster { min-width: 0 !important; font-size: 10px; }
  .roster.cols-14 { grid-template-columns: 90px repeat(14, 1fr); }
  .roster > div { min-height: 36px; padding: 3px; }
  .chip { break-inside: avoid; font-size: 9px; cursor: default; }
  .print-head { display: block !important; margin-bottom: 8px; }
  @page { size: landscape; margin: 10mm; }
}
.print-head { display: none; }
.field .label, .field legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
fieldset.scope { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
fieldset.scope .check { padding: 3px 0; font-weight: 400; }
input[type="radio"], input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; flex: none; }
@media (max-width: 600px) { dialog .dlg-foot button { padding: 6px 10px; min-height: 36px; font-size: .9rem; } }
.badge.split { padding: 0 5px; font-size: .7rem; line-height: 1.4; vertical-align: 1px; }
.badge.group { background: var(--brand-soft); color: var(--text); }
/* House coverage (F-06) */
.coverage { margin-bottom: 12px; }
.covbar { position: relative; height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.covbar .cov { position: absolute; top: 0; bottom: 0; background: var(--brand); opacity: .85; }
.covbar .cov.sleepover { background: var(--accent); }
.covbar .cov.active_night { background: var(--warn); }
.covbar .cov.open { background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 6px, var(--warn-soft) 6px, var(--warn-soft) 12px); }
.covbar .gap { position: absolute; top: 0; bottom: 0; background: var(--bad); }
.covscale { display: flex; justify-content: space-between; font-size: .75rem; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; } ul.plain li { padding: 3px 0; }
/* Drafts (F-08) */
.chip.draft { background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 6px, var(--surface-2) 6px, var(--surface-2) 12px); border-style: dashed; }
.badge.draft { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--border); }
.chip .ok { color: var(--ok); font-weight: 700; }
.muted-card { border-style: dashed; } /* an out-of-reach vacancy: dashed, never faded (contrast) */
.bad { color: var(--bad); }
.warn-text { color: var(--warn, #b45309); font-weight: 700; }
.badge.ph { background: #fde68a; color: #78350f; }
.check { display: block; margin: 4px 0; }
ul.changes { margin: 4px 0 2px; padding-left: 18px; font-size: .9em; }
.notif-list ul.changes li { display: list-item; border: 0; padding: 0; margin: 2px 0; background: none; }

/* F-26 pay periods above the timesheet list */
.periods { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.period { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 150px; }
.period.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.period .badge { align-self: flex-start; }

/* F-25 sync bar: the bar and the screen share the shell's content column */
.content { min-width: 0; }
.sync { margin: 0; padding: 8px 16px; font-size: .95rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 4; }
.sync.warn { background: var(--warn-soft); }
.sync.info { background: var(--info-soft); }
.sync.bad { background: var(--bad-soft); }
.sync button { margin-left: 8px; }

/* F-27 office on a phone: More menu, timesheet cards, a sticky action bar, tap targets */
button.link { min-height: 24px; }
.tabbar .more { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: .72rem; color: var(--muted); background: none; border: none; border-radius: 0; min-height: 0; }
.tabbar .more[aria-current="page"] { color: var(--brand); font-weight: 600; }
.menu-sheet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.menu-sheet a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); text-align: center; }
.menu-sheet a[aria-current="page"] { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.menu-sheet .ico { font-size: 1.4rem; }
@media (max-width: 700px) {
  .ts-table thead { display: none; }
  .ts-table, .ts-table tbody { display: block; }
  .ts-table tr { display: grid; grid-template-columns: 32px 1fr; gap: 2px 8px; padding: 12px; border-bottom: 1px solid var(--border); }
  .ts-table td { display: block; grid-column: 2; padding: 0; border: none; text-align: left; }
  .ts-table td.pick { grid-column: 1; grid-row: 1 / span 3; padding-top: 2px; }
  .ts-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  .ts-table td[data-label="Date"]::before, .ts-table td[data-label="Worker"]::before { content: none; }
  .ts-table td:empty { display: none; }
  .ts-table td.n { text-align: left; }
  .ts-actions { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; background: var(--bg); padding: 8px 0; flex-wrap: wrap; gap: 8px; }
  .head { flex-wrap: wrap; }
  .inline-fields { flex-wrap: wrap; }
}

.today-list { list-style: none; margin: 0; padding: 0; }
.today-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.today-list li:first-child { border-top: none; }

/* F-34 note coach */
.coach { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: var(--surface); }
.coach ul { margin: 6px 0 0; padding-left: 20px; }

/* F-31 care plan tasks on the visit */
ul.tasks { list-style: none; padding: 0; margin: 8px 0; }
ul.tasks li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
ul.tasks li small { flex-basis: 100%; }

/* F-32 goal picker on the visit note */
fieldset.goal-pick { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
fieldset.goal-pick legend { font-weight: 600; padding: 0 4px; }

/* F-35 Care Signals */
.signal { padding: 10px 0; border-top: 1px solid var(--border); }
.signal mark { background: var(--warn-soft); color: var(--text); padding: 0 2px; border-radius: 3px; font-weight: 600; }

/* F-36 the month's administration record */
.mar table { font-size: .8rem; }
.mar td.n, .mar th.n { padding: 4px 3px; text-align: center; min-width: 22px; }
.mar td.gap { background: var(--warn-soft); }
@media print { .mar table { font-size: 8px; } .mar td.n, .mar th.n { min-width: 0; padding: 1px; } }

/* F-38: a section of a dialog outside its form */
.dlg-extra { padding: 0 20px 16px; border-top: 1px solid var(--border); }

/* F-40 the risk heat grid */
table.heat { width: auto; }
table.heat td, table.heat th { min-width: 44px; text-align: center; }
.heat-low { background: var(--ok-soft, #e7f6ec); }
.heat-medium { background: #fdf3d6; }
.heat-high { background: #fde4cc; }
.heat-extreme { background: #f9d3d3; }

/* F-42 health items */
.health-items { margin: 4px 0; padding-left: 18px; }

/* F-43 summary lines */
ul.summary { margin: 6px 0; padding-left: 18px; }
ul.summary li { margin: 3px 0; }
/* F-71: a pay-run visit on a phone: the amount top right, the rest stacked, so overtime notes have room */
@media (max-width: 560px) {
  .pay-shifts tr { display: grid; grid-template-columns: 1fr auto; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .pay-shifts td { grid-column: 1; padding: 2px 12px; border: 0; }
  .pay-shifts td:last-child { grid-column: 2; grid-row: 1; font-weight: 600; }
}
/* F-70: a list table on a phone: each row stacks, its action top right */
@media (max-width: 560px) {
  table.rows-stack thead { display: none; }
  table.rows-stack tr { display: grid; grid-template-columns: 1fr auto; padding: 8px 0; border-bottom: 1px solid var(--border); }
  table.rows-stack td { grid-column: 1; padding: 2px 12px; border: 0; text-align: left; }
  table.rows-stack td:last-child { grid-column: 2; grid-row: 1 / span 3; align-self: start; }
  table.rows-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }   /* F-85: a figure on a phone says what it is */
}
/* F-69: an hour with more open visits than available workers */
.coverage-grid td.short { background: var(--warn-soft); }
.coverage-grid th[scope=row] { white-space: nowrap; }
/* F-68: the training matrix: people down the side, courses across */
.matrix th[scope=row] { text-transform: none; letter-spacing: 0; font-size: inherit; font-weight: 600; white-space: nowrap; }
.matrix th[scope=col] { min-width: 120px; }
/* F-77: conversations */
.thread-row { color: inherit; text-decoration: none; padding: 6px 0; border-bottom: 1px solid var(--border); }
.thread-row:last-child { border-bottom: 0; }
.bubbles { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px 0 8px; }
.bubble { max-width: min(560px, 85%); background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; align-self: flex-start; }
.bubble.mine { align-self: flex-end; background: var(--brand-soft, #eef4ff); }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: grid; gap: 6px; margin-top: 12px; }
.composer textarea { width: 100%; }
.pick-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px; max-height: 40vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.menu-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad, #b42318); color: #fff; font-size: .75rem; font-weight: 700; line-height: 20px; text-align: center; }
.tabbar .menu-count { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; }
.tabbar a { position: relative; }
/* F-81: a new token, shown once */
code.token { display: block; padding: 8px; background: var(--surface-2); border-radius: 6px; word-break: break-all; user-select: all; }
/* F-83: the allied calendar */
.appt-grid td { vertical-align: top; min-width: 120px; }
.appt-grid th[scope=row] { white-space: nowrap; }
.appt { display: block; width: 100%; text-align: left; margin: 0 0 4px; padding: 4px 6px; border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 6px; background: var(--surface); font-size: .85rem; }
.appt.off { color: var(--muted); border-left-color: var(--muted); text-decoration: line-through; }   /* no opacity: it failed axe colour-contrast on the chip */
.event-band { margin: 0 0 4px; padding: 3px 6px; border-radius: 6px; font-size: .8rem; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface) 6px, var(--surface) 12px); border: 1px dashed var(--border); }
.event-band.blocked, .event-band.out_of_office { border-color: var(--bad, #b42318); }
