
:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2430; --muted: #5c6675; --line: #d9dde4; --accent: #1f5fbf;
  --ok: #16784a; --warn: #9a5b00; --alert: #b3261e; --warn-bg: #fff4dc; --alert-bg: #fde7e5; --chip: #eef1f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f; --panel: #1c222c; --text: #e8ebf0; --muted: #a2acba; --line: #2f3846; --accent: #7aa7f0;
    --ok: #5fd197; --warn: #f0b24b; --alert: #ff8f86; --warn-bg: #3b2f14; --alert-bg: #3f1d1a; --chip: #252d3a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.page { max-width: 1280px; margin: 0 auto; padding: 16px; }
header.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h1 { font-size: 1.35rem; margin: 0; }
.sync { color: var(--muted); font-size: .95rem; }
.actions { display: flex; gap: 8px; align-items: center; }
button, select, input[type=search], input[type=text], input[type=password] { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-height: 40px; }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.banner { border-radius: 8px; padding: 10px 14px; margin: 0 0 10px; border: 1px solid var(--line); background: var(--panel); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--text); }
.banner.alert { background: var(--alert-bg); border-color: var(--alert); }
.summary { font-weight: 600; margin: 4px 0 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; flex: 1 1 150px; max-width: 260px; }
.filters label:nth-child(3) { flex: 2 1 200px; max-width: 320px; }
.filters select, .filters input { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--chip); border-radius: 999px; padding: 6px 14px; min-height: 36px; }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .8; margin-left: 6px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.past td { color: var(--muted); }
td.time, td.when { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.patient { min-width: 8.5rem; font-weight: 600; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .alert { color: var(--alert); } .muted { color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.note { color: var(--muted); font-size: .9rem; margin: 8px 0; }
.more { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.more .note { margin: 0; }
.card { max-width: 520px; width: calc(100% - 24px); margin: 12vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.card h1 { margin-bottom: 8px; }
.card .subtitle { color: var(--muted); margin: 0 0 18px; }
.card form label { display: block; font-size: .85rem; color: var(--muted); margin: 14px 0 4px; }
.card form input[type=text], .card form input[type=password] { width: 100%; }
.card .form-error { color: var(--alert); background: var(--alert-bg); border-radius: 8px; padding: 8px 12px; margin: 14px 0 0; }
.card button.wide { width: 100%; margin-top: 18px; }
.card .secondary-form { margin-top: 14px; }
@media (max-width: 820px) {
  .filters label, .filters label:nth-child(3) { flex: 1 1 100%; max-width: none; }
  table { min-width: 0; }
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  tr:last-child { border-bottom: 0; }
  td { padding: 0; border: 0; min-width: 0; }
  td::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); font-weight: 400; }
  td:empty { display: none; }
  td.time { font-weight: 600; }
  td.error-cell { grid-column: 1 / -1; }
  td.patient { min-width: 0; }
}
@media (max-width: 640px) { .page { padding: 10px; } h1 { font-size: 1.15rem; } .actions { width: 100%; } .actions > * { flex: 1; } }
