/* PHI Hub Admin: colors and layout from the dashboard mockup (purple #392974, orange #f7941d). */
:root {
  --purple: #392974; --purple-dark: #241a4d; --orange: #f7941d;
  --ink: #1c2230; --ink-2: #43495a; --muted: #64748a; --faint: #8a90a0;
  --line: #e2e5ea; --line-2: #eef0f3; --ground: #f4f6f8; --card: #ffffff;
  --ok-bg: #e7f6ee; --ok: #137a45; --bad-bg: #fdeceb; --bad: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", system-ui, sans-serif; background: var(--ground); color: var(--ink); }
a { color: var(--purple); }
a:hover { color: var(--purple-dark); }

.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 36px 32px; box-shadow: 0 10px 30px rgba(28, 34, 48, 0.06); }
.card.wide { max-width: 520px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; text-align: center; }
.brand img { width: 48px; height: 48px; border-radius: 12px; }
.brand .title { font-size: 17px; font-weight: 700; color: var(--purple); }
.brand .sub { font-size: 12px; color: var(--faint); }

form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid #d7dbe2; border-radius: 8px; font-size: 14px; font-family: inherit;
}
input:focus { outline: 2px solid var(--purple); outline-offset: 1px; }
input.code { letter-spacing: 6px; text-align: center; font-size: 18px; font-weight: 700; }
.primary { width: 100%; min-height: 44px; padding: 11px; border: none; border-radius: 8px; background: var(--purple); color: #ffffff; font-size: 14px; font-weight: 700; cursor: pointer; }
.primary:hover { background: var(--purple-dark); }
.button-link { display: block; text-align: center; text-decoration: none; color: #ffffff; }
.button-link:hover { color: #ffffff; }
.linkish { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; text-align: center; padding: 8px; min-height: 44px; }
p { font-size: 13px; line-height: 1.5; color: var(--ink-2); margin: 0; }
.note { margin-top: 22px; font-size: 11px; color: var(--faint); text-align: center; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.ok { background: var(--ok-bg); color: var(--ok); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.qr { display: flex; justify-content: center; margin: 4px 0; }
.qr img { width: 200px; height: 200px; }
.key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; background: var(--ground); border-radius: 8px; padding: 10px 12px; text-align: center; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; margin: 6px 0; padding: 0; list-style: none; }
.codes li { background: var(--ground); border-radius: 8px; padding: 8px; text-align: center; }

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { width: 220px; flex: 0 0 220px; background: var(--card); border-right: 1px solid var(--line); padding: 24px 14px; display: flex; flex-direction: column; gap: 4px; }
.side .logo { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; }
.side .logo img { width: 30px; height: 30px; border-radius: 8px; }
.side .logo span { font-size: 15px; font-weight: 700; color: var(--purple); }
.side .who { margin-top: auto; padding: 10px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--line-2); }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 36px; display: flex; flex-direction: column; gap: 24px; }
.main h1 { margin: 0; font-size: 22px; font-weight: 700; }
.main h1 .dot { color: var(--orange); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
@media (max-width: 640px) {
  .side { width: 100%; flex-basis: 100%; border-right: none; border-bottom: 1px solid var(--line); }
  .main { padding: 20px 16px; }
  .card { padding: 28px 20px; }
}

/* Signed-in pages */
.side > a { display: block; padding: 9px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.side > a:hover { background: var(--ground); color: var(--purple); }
.side > a[aria-current="page"] { background: #efeaf9; color: var(--purple); }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.asof { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.button { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 8px; background: var(--purple); color: #ffffff; font-size: 13px; font-weight: 700; text-decoration: none; }
.button:hover { background: var(--purple-dark); color: #ffffff; }
.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.panel h3 { margin: 16px 0 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.panel > p + .tiles, .panel > p { margin-bottom: 10px; }
.hint { margin-top: 10px; font-size: 12px; color: var(--muted); }
.faint { color: var(--faint); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: #fff3e0; color: #9a5b00; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--ground); border-radius: 10px; padding: 12px 14px; font-size: 12px; }
.tile .label { font-weight: 600; color: var(--muted); }
.tile .value { margin: 4px 0 2px; font-size: 22px; font-weight: 700; color: var(--ink); }
.tile .of { font-size: 13px; font-weight: 600; color: var(--muted); }
.meter-row { display: grid; grid-template-columns: 170px minmax(80px, 1fr) 110px; align-items: center; gap: 12px; padding: 6px 0; font-size: 13px; color: var(--ink-2); }
.meter { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; background: var(--purple); }
.fill.w0 { width: 0%; } .fill.w5 { width: 5%; } .fill.w10 { width: 10%; } .fill.w15 { width: 15%; } .fill.w20 { width: 20%; } .fill.w25 { width: 25%; } .fill.w30 { width: 30%; } .fill.w35 { width: 35%; } .fill.w40 { width: 40%; } .fill.w45 { width: 45%; } .fill.w50 { width: 50%; } .fill.w55 { width: 55%; } .fill.w60 { width: 60%; } .fill.w65 { width: 65%; } .fill.w70 { width: 70%; } .fill.w75 { width: 75%; } .fill.w80 { width: 80%; } .fill.w85 { width: 85%; } .fill.w90 { width: 90%; } .fill.w95 { width: 95%; } .fill.w100 { width: 100%; }
.meter-num { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
  .meter-row { grid-template-columns: 1fr; gap: 4px; }
  .meter-num { text-align: left; }
}
.tile .value.small { font-size: 15px; line-height: 1.4; margin: 8px 0 4px; }
.control { display: inline-block; margin: 2px 6px 2px 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.control:hover { border-color: var(--purple); }
.panel.narrow { max-width: 560px; display: flex; flex-direction: column; gap: 14px; }
.inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline label { margin: 0; }
.inline input[type="date"], .filters input, .filters select { padding: 8px 10px; border: 1px solid #d7dbe2; border-radius: 8px; font-size: 14px; font-family: inherit; }
.small { min-height: 36px; padding: 0 14px; border: none; border-radius: 8px; background: var(--purple); color: #ffffff; font-size: 13px; font-weight: 700; cursor: pointer; }
.filters { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filters > div { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 8px; }
.tab { padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 700; text-decoration: none; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); }
.tab[aria-current="page"] { color: var(--purple); border-color: var(--purple); background: #efeaf9; }
.ids { margin: 6px 0 0; padding-left: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: normal; }
details summary { cursor: pointer; }
.notice { background: #efeaf9; color: var(--purple-dark); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.picks { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 12px; }
.picks select { padding: 8px 10px; border: 1px solid #d7dbe2; border-radius: 8px; font-size: 14px; font-family: inherit; max-width: 260px; }

/* The guide behind the book icon, top right of every signed-in page (no script: <details>). */
.guide { position: relative; }
.guide > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--purple); font-size: 13px; font-weight: 700; }
.guide > summary::-webkit-details-marker { display: none; }
.guide > summary:hover, .guide[open] > summary { border-color: var(--purple); background: #efeaf9; }
.guide > summary:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }
.guide-body { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(440px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: 0 10px 30px rgba(28, 34, 48, 0.12); color: var(--ink-2); font-size: 13px; line-height: 1.5; white-space: normal; }
.guide-body h2 { margin: 0 0 4px; font-size: 15px; color: var(--ink); }
.guide-body h3 { margin: 14px 0 4px; font-size: 13px; font-weight: 700; color: var(--purple); }
.guide-body ul, .guide-body ol { margin: 0; padding-left: 20px; }
.guide-body li { margin: 3px 0; }
.guide-body .signs { list-style: none; padding-left: 0; }
.swatch { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
@media (max-width: 640px) {
  .guide-body { position: fixed; left: 16px; right: 16px; top: 72px; width: auto; }
}

/* Patients: "View all data" opens as an overlay (drawn open by the server, closed by a link; no script). */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(28, 34, 48, 0.45); display: flex; justify-content: center; align-items: flex-start; padding: 32px 16px; overflow-y: auto; }
.overlay-box { width: 100%; max-width: 980px; background: var(--card); border-radius: 14px; padding: 22px 24px; box-shadow: 0 20px 50px rgba(28, 34, 48, 0.25); display: flex; flex-direction: column; gap: 16px; }
.overlay-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.overlay-head h2 { margin: 0; font-size: 18px; }
.overlay-head h2 .dot { color: var(--orange); }
.all-section { border-top: 1px solid var(--line); padding-top: 12px; }
.all-section h3 { margin: 0 0 10px; font-size: 14px; }
.record { background: var(--ground); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.record-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
table.fields th { text-transform: none; letter-spacing: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; width: 1%; vertical-align: top; }
table.fields td { white-space: normal; word-break: break-word; }
.raw pre { margin: 6px 0 0; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 640px) { .overlay { padding: 12px 8px; } .overlay-box { padding: 16px 14px; } }
.check { display: flex; align-items: flex-start; gap: 8px; }
.check input { margin-top: 3px; }
.check label { font-weight: 500; }
