/*
  Serenity Census
  Palette: paper #F5F7F8 / surface #FFFFFF / ink #1D2B36 / muted #5E6E7A / line #DCE3E8 / tide #1F6F78
  Type: system UI stack, tabular numerals for every count; no web fonts (no third-party requests on a PHI app).
  One bold element: the census board (big counts + level-of-care bars). Everything else stays quiet.
*/
:root {
  --paper: #F5F7F8; --surface: #FFFFFF; --ink: #1D2B36; --muted: #5E6E7A; --line: #DCE3E8;
  --tide: #1F6F78; --tide-soft: #E3F0F1; --alert: #B42318; --alert-soft: #FDECEA; --warn: #8A5A0B; --warn-soft: #FBF1DE;
  --ok: #2F6B3A; --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.5; }
a { color: var(--tide); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid #7FB7BD; outline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; font-weight: 650; }
p { margin: 0 0 12px; }
.num, td.num, .count { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }

/* top bar */
.topbar { background: var(--ink); color: #fff; }
.topbar .inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; height: 54px; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand span { color: #8CC7CC; font-weight: 500; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: #C9D4DC; padding: 6px 10px; border-radius: var(--radius); white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.on { color: #fff; background: rgba(255,255,255,.14); }
.who { color: #C9D4DC; font-size: .87rem; white-space: nowrap; }
.who a { color: #fff; margin-left: 10px; }
.demo-flag { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 6px; font-size: .87rem; }

main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.notice { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; background: var(--tide-soft); color: var(--tide); }
.notice.error { background: var(--alert-soft); color: var(--alert); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

/* census board: the one bold element */
.headline { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.headline .big { font-size: 3.2rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.headline .what { font-size: 1.15rem; }
.facts { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); }
.facts b { color: var(--ink); font-variant-numeric: tabular-nums; }
.facts a { color: inherit; }
.board { width: 100%; border-collapse: collapse; margin-top: 8px; }
.board td { padding: 14px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.board tr:first-child td { border-top: 0; }
.board .fac { width: 30%; }
.board .fac a { color: var(--ink); font-weight: 600; font-size: 1.02rem; }
.board .count { width: 90px; text-align: right; font-size: 2rem; font-weight: 700; line-height: 1; }
.board .delta { width: 130px; font-size: .87rem; color: var(--muted); white-space: nowrap; }
.board .delta.up { color: var(--ok); }
.board .delta.down { color: var(--alert); }
.board .bar { width: 38%; }
.board .bar svg { display: block; width: 100%; height: 22px; }
.board .side { font-size: .87rem; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .87rem; color: var(--muted); margin: 4px 0 6px; }
.legend svg { vertical-align: -1px; margin-right: 5px; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 7px; border-radius: 99px; background: #EEF2F5; color: var(--muted); margin-left: 6px; font-weight: 500; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.alert { background: var(--alert-soft); color: var(--alert); }
.tag.ok { background: #E6F2E8; color: var(--ok); }

.trend svg { width: 100%; height: auto; display: block; }
.trend .line { fill: none; stroke: var(--tide); stroke-width: 2.25; }
.trend .axis { stroke: var(--line); }
.trend text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.trend .val { fill: var(--ink); font-weight: 650; font-size: 12px; }

/* tables */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th { text-align: left; font-weight: 600; font-size: .87rem; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #FAFBFC; }
table.data td.r, table.data th.r { text-align: right; }
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.codes { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* filters + forms */
form.filters select { max-width: 320px; }
form.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
label { display: block; font-size: .87rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, input[type=file] {
  max-width: 100%;
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #C5D0D8; border-radius: var(--radius); padding: 7px 10px; min-width: 0;
}
input[type=search] { width: 260px; }
.field { margin-bottom: 14px; }
.field input:not([type=checkbox]), .field select { width: 100%; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 1rem; margin-bottom: 8px; }
button, .button { font: inherit; font-weight: 600; background: var(--tide); color: #fff; border: 0; border-radius: var(--radius); padding: 8px 16px; cursor: pointer; display: inline-block; }
button:hover, .button:hover { background: #185960; text-decoration: none; }
button.quiet, .button.quiet { background: #fff; color: var(--ink); border: 1px solid #C5D0D8; }
button.quiet:hover, .button.quiet:hover { background: #F0F3F5; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; color: var(--muted); }

/* patient */
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 24px; }
.facts-grid div span { display: block; font-size: .87rem; color: var(--muted); }
.facts-grid div b { font-weight: 600; }
.section { margin-top: 20px; }

/* sign in */
.auth { max-width: 400px; margin: 9vh auto; }
.auth .panel { padding: 28px; }
.auth h1 { margin-bottom: 6px; }
.auth .brand-line { color: var(--tide); font-weight: 700; margin-bottom: 18px; }
.qr { display: flex; justify-content: center; margin: 14px 0; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; word-break: break-all; background: #F0F3F5; padding: 8px; border-radius: var(--radius); font-size: .9rem; }

details.user { border-top: 1px solid var(--line); padding: 10px 0; }
details.user summary { cursor: pointer; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
details.user form { margin-top: 12px; max-width: 560px; }
.facility-picks { columns: 2; margin-bottom: 12px; }
@media (max-width: 760px) {
  .topbar .inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 6px 12px; }
  .nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
}
@media (max-width: 640px) { main { padding: 20px 16px 48px; }
  .board .bar, .board .side { display: none; } .board .delta { width: auto; white-space: normal; } .headline .big { font-size: 2.6rem; }
  input[type=search] { width: 100%; } .facility-picks { columns: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* sign-in, documents, eligibility */
.button.sso { display: block; text-align: center; margin: 8px 0 4px; }
.or-line { text-align: center; margin: 12px 0; }
.doc-cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.doc-cta h2, .doc-cta p { margin-bottom: 0; }
.doc dl { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 8px 20px; margin: 0; }
.doc dt { color: var(--muted); font-size: .87rem; }
.doc dd { margin: 0; white-space: pre-wrap; }
@media (max-width: 640px) { .doc dl { grid-template-columns: 1fr; } .doc dd { margin-bottom: 8px; } }
form.inline { display: inline; }
.small-btn { padding: 3px 10px; font-size: .87rem; margin-top: 4px; }
details.elig-check { border-top: 1px solid var(--line); padding: 10px 0; }
details.elig-check summary { cursor: pointer; }
details.elig-check ul { margin: 8px 0 0 18px; padding: 0; }
