/* Dena Home Care — Dena's design language (packages/ui tokens, direction B) with Home Care's terracotta brand
   (packages/homecare-core/src/brand.ts). Sizes are in rem so the "larger text" switch and the browser's own text
   size both scale everything; no size depends on the viewport width. */
:root {
  --brand: #8C3B1F; --brand-hover: #76311A; --brand-pressed: #5F2715; --brand-soft: #F7E9E2; --on-brand: #FFFFFF; --on-brand-soft: #F3D9CD;
  --nav: #3A1E14;
  --canvas: #F6F4EF; --surface: #FFFFFF; --sunken: #EEEBE4; --text: #1B1F21; --text2: #434B4F; --text3: #5E676B;
  --divider: #DDD8CE; --control: #79817F; --focus: #1F5FD1;
  --success: #2B6A2F; --success-bg: #E8F3E6; --warning: #7A4A00; --warning-bg: #FBF0D9; --danger: #A32E2E; --danger-bg: #FBEAEA; --info: #3B4A9E; --info-bg: #ECEEFA;
  --rehab: #0B5563; --rehab-soft: #E0EEF1;
  --radius: 0.75rem;
}
* { box-sizing: border-box; }
html { font-size: 100%; }
html.large { font-size: 125%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--brand); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------ header and navigation */
header.top { background: var(--nav); color: #fff; }
.top-row { max-width: 72rem; margin: 0 auto; padding: 0.625rem 1rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.mark { width: 2.25rem; height: 2.25rem; border-radius: 0.625rem; background: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.product { font-weight: 700; font-size: 1.125rem; line-height: 1.15; }
.product small { display: block; font-weight: 400; font-size: 0.8125rem; color: var(--on-brand-soft); }
.spacer { flex: 1; }
.who { font-size: 0.875rem; color: #fff; text-align: right; }
.who b { display: block; font-size: 0.9375rem; }
.top button { background: transparent; color: #fff; border: 1px solid #ffffff99; border-radius: 0.5rem; min-height: 2.75rem; padding: 0 0.75rem; font: inherit; cursor: pointer; }
.top button:hover { background: #ffffff1f; }
nav.tabs { background: var(--surface); border-bottom: 1px solid var(--divider); }
nav.tabs ul { list-style: none; margin: 0 auto; padding: 0 0.5rem; max-width: 72rem; display: flex; gap: 0.25rem; overflow-x: auto; }
nav.tabs a { display: inline-flex; align-items: center; gap: 0.375rem; min-height: 3rem; padding: 0 0.875rem; color: var(--text2); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
nav.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }
nav.tabs .count { background: var(--brand); color: var(--on-brand); border-radius: 999px; font-size: 0.75rem; padding: 0 0.45rem; min-width: 1.4rem; text-align: center; }

/* ------------------------------------------------------------ layout */
main { max-width: 72rem; margin: 0 auto; padding: 1rem; }
main:focus { outline: none; }
h1 { font-size: 1.5rem; margin: 0.25rem 0 0.75rem; line-height: 1.25; }
h2 { font-size: 1.1875rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.0625rem; margin: 0 0 0.25rem; }
p { margin: 0.375rem 0; }
.grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.card { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 0.875rem 1rem; min-width: 0; }
.card.accent { border-left: 0.375rem solid var(--brand); }
.card.warn { border-left: 0.375rem solid var(--warning); }
.card.bad { border-left: 0.375rem solid var(--danger); }
.muted { color: var(--text2); }
.small { font-size: 0.875rem; color: var(--text3); }
.label { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text3); margin: 0.75rem 0 0.125rem; font-weight: 600; }
ul.plain { list-style: none; padding: 0; margin: 0.25rem 0; }
ul.plain > li { padding: 0.25rem 0; }
ul.plain.lines > li { border-top: 1px solid var(--divider); padding: 0.5rem 0; }
ul.plain.lines > li:first-child { border-top: 0; }
ul.plain > li.card { padding: 0.875rem 1rem; }
.kpis { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); margin: 0.5rem 0 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 0.625rem 0.75rem; }
.kpi b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 0.875rem; color: var(--text2); }
.kpi.alert b { color: var(--danger); }
.next-action { background: var(--brand-soft); color: var(--brand-pressed); border-radius: 0.625rem; padding: 0.625rem 0.75rem; margin: 0.625rem 0 0; font-weight: 600; }
.next-action::before { content: "→ "; }

/* ------------------------------------------------------------ status marks */
.pill { display: inline-block; border-radius: 999px; padding: 0.0625rem 0.625rem; font-size: 0.875rem; background: var(--sunken); color: var(--text2); white-space: nowrap; }
.pill.ok { background: var(--success-bg); color: var(--success); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.brand { background: var(--brand-soft); color: var(--brand-pressed); }
.notice, .error, .okay, .caution { border-radius: 0.625rem; padding: 0.625rem 0.75rem; margin: 0.5rem 0; }
.notice { background: var(--info-bg); color: var(--info); }
.error { background: var(--danger-bg); color: var(--danger); }
.okay { background: var(--success-bg); color: var(--success); }
.caution { background: var(--warning-bg); color: var(--warning); }
.coverage { border-radius: 0.625rem; padding: 0.5rem 0.75rem; margin: 0 0 0.75rem; font-size: 0.9375rem; background: var(--sunken); color: var(--text2); }
.coverage.closed { background: var(--warning-bg); color: var(--warning); }
.synthetic { background: var(--warning-bg); color: var(--warning); font-size: 0.875rem; text-align: center; padding: 0.25rem 1rem; }
.checks { list-style: none; padding: 0; margin: 0.25rem 0; }
.checks li { padding: 0.125rem 0 0.125rem 1.25rem; position: relative; font-size: 0.9375rem; }
.checks li::before { position: absolute; left: 0; font-weight: 700; }
.checks li.block { color: var(--danger); } .checks li.block::before { content: "✕"; }
.checks li.overridable { color: var(--warning); } .checks li.overridable::before { content: "!"; left: 0.25rem; }
.checks li.note { color: var(--text2); } .checks li.note::before { content: "·"; left: 0.25rem; }

/* ------------------------------------------------------------ controls */
button, .button { font: inherit; cursor: pointer; }
button.primary, .button.primary { background: var(--brand); color: var(--on-brand); border: 0; border-radius: 0.625rem; min-height: 3rem; padding: 0 1.125rem; font-weight: 600; }
button.primary:hover { background: var(--brand-hover); }
button.primary:active { background: var(--brand-pressed); }
button.secondary { background: var(--surface); color: var(--brand); border: 2px solid var(--brand); border-radius: 0.625rem; min-height: 3rem; padding: 0 1rem; font-weight: 600; }
button.quiet { background: var(--surface); color: var(--text); border: 1px solid var(--control); border-radius: 0.625rem; min-height: 2.75rem; padding: 0 0.875rem; }
button.danger { background: var(--surface); color: var(--danger); border: 2px solid var(--danger); border-radius: 0.625rem; min-height: 2.75rem; padding: 0 0.875rem; font-weight: 600; }
button.link { background: none; border: 0; color: var(--brand); text-decoration: underline; padding: 0; min-height: 2rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
label.field { display: block; margin: 0.625rem 0; font-weight: 600; }
label.field > span.hint { display: block; font-weight: 400; font-size: 0.875rem; color: var(--text3); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], input[type=datetime-local], select, textarea {
  display: block; width: 100%; margin-top: 0.25rem; font: inherit; font-weight: 400; padding: 0.625rem; border: 1px solid var(--control); border-radius: 0.5rem; background: var(--surface); color: var(--text); min-height: 3rem;
}
textarea { min-height: 5rem; resize: vertical; }
fieldset { border: 1px solid var(--divider); border-radius: 0.625rem; margin: 0.625rem 0; padding: 0.5rem 0.75rem 0.75rem; min-width: 0; }
legend { font-weight: 600; padding: 0 0.25rem; }
.choices { display: flex; gap: 0.375rem; flex-wrap: wrap; margin: 0.25rem 0; }
.choices label { border: 2px solid var(--control); border-radius: 0.625rem; padding: 0.375rem 0.75rem; min-height: 3rem; display: inline-flex; align-items: center; gap: 0.375rem; cursor: pointer; background: var(--surface); font-weight: 400; }
.choices label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-pressed); font-weight: 600; }
.choices input { width: 1.25rem; height: 1.25rem; accent-color: var(--brand); margin: 0; }
.task { border-top: 1px solid var(--divider); padding: 0.625rem 0; }
.task:first-of-type { border-top: 0; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--divider); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { overflow-wrap: normal; word-break: normal; text-align: left; padding: 0.5rem 0.625rem; border-bottom: 1px solid var(--divider); vertical-align: top; }
th { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text3); background: var(--sunken); }
tr:last-child td { border-bottom: 0; }
td button { white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ Dena Rehab's program (read-only, in Rehab's colour) */
.rehab { border: 2px solid var(--rehab); border-radius: var(--radius); padding: 0.75rem 0.875rem; background: var(--rehab-soft); margin-top: 0.75rem; }
.rehab .source { color: var(--rehab); font-weight: 700; }
.rehab.held { background: var(--warning-bg); border-color: var(--warning); }
.rehab.held .source { color: var(--warning); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.125rem 0.75rem; margin: 0.375rem 0; font-size: 0.9375rem; }
.facts dt { color: var(--text3); }
.facts dd { margin: 0; }

/* ------------------------------------------------------------ the phone's queue (care worker) */
.sendbar { border-radius: 0.625rem; padding: 0.625rem 0.75rem; margin: 0 0 0.75rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; background: var(--success-bg); color: var(--success); }
.sendbar.waiting { background: var(--warning-bg); color: var(--warning); }
.sendbar.offline { background: var(--danger-bg); color: var(--danger); }
.sendbar .spacer { flex: 1; }

/* ------------------------------------------------------------ dialogs and messages */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); color: var(--text); background: var(--surface); }
dialog::backdrop { background: #1b1f2199; }
dialog form { padding: 1rem 1.125rem 1.125rem; }
dialog h2 { margin-top: 0; }
#status { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); max-width: calc(100vw - 2rem); z-index: 20; }
#status:empty { display: none; }
#status > div { background: var(--text); color: #fff; border-radius: 0.625rem; padding: 0.625rem 1rem; box-shadow: 0 4px 16px #0003; }
.signin { max-width: 28rem; margin: 1.5rem auto; }
.accounts button { display: block; width: 100%; text-align: left; min-height: 3.5rem; margin: 0.25rem 0; background: var(--surface); border: 1px solid var(--divider); border-radius: 0.625rem; padding: 0.5rem 0.75rem; }
.accounts button b { display: block; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 1.125rem; letter-spacing: 0.08em; background: var(--sunken); padding: 0.5rem 0.75rem; border-radius: 0.5rem; }
.copyline { font-family: ui-monospace, Menlo, monospace; font-size: 0.875rem; background: var(--sunken); padding: 0.5rem; border-radius: 0.5rem; }
footer { max-width: 72rem; margin: 0 auto; padding: 1rem; color: var(--text3); font-size: 0.875rem; }
.empty { color: var(--text2); background: var(--surface); border: 1px dashed var(--divider); border-radius: var(--radius); padding: 0.875rem 1rem; }
.bar { height: 0.625rem; background: var(--sunken); border-radius: 999px; overflow: hidden; margin-top: 0.25rem; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.bar.over > i { background: var(--danger); }
@media (max-width: 30rem) {
  .who { text-align: left; width: 100%; order: 5; }
  h1 { font-size: 1.3125rem; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: 0.25rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
