/* OA Portal client, after the mock-up canvas's Portal boards: a navy top bar, sections down the side, white cards on a
   light ground. Brand: navy #111B2E / #142440, blue #1E4E9E, light blue #8CC5EE. Classes only: the portal's content
   security policy allows no inline style. */
:root {
  --navy: #111B2E;
  --navy-2: #142440;
  --navy-3: #1A2C4D;
  --blue: #1E4E9E;
  --light: #8CC5EE;
  --ground: #F4F6F9;
  --card: #FFFFFF;
  --line: #D7DEE8;
  --line-2: #E3E8EF;
  --field: #C9D2DE;
  --text: #142440;
  --body: #3F4B5E;
  --muted: #5A6578;
  --red: #B42318;
  --red-bg: #FDECEC;
  --amber: #8A4B00;
  --amber-bg: #FFF4E0;
  --green: #1D6B39;
  --green-bg: #E9F5EC;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 10px; font-weight: 650; color: var(--text); }
h3 { font-size: 15px; margin: 12px 0 8px; font-weight: 650; color: var(--body); }
p { margin: 0 0 14px; }
a { color: var(--blue); }
a:hover { color: var(--navy-2); }
.small { font-size: 13.5px; color: var(--muted); }
.block { display: block; }
.strong { font-weight: 600; text-decoration: none; }
.spaced { margin-top: 24px; }
.num { font-family: "Cascadia Mono", ui-monospace, Consolas, monospace; font-size: 13.5px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- The top bar ------------------------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 10px 20px;
  background: var(--navy-2);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand img { width: 34px; height: 34px; }
.brand .word { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { font-size: 10px; letter-spacing: 0.16em; color: var(--light); }
.brand strong { font-size: 18px; font-weight: 650; }
.topbar-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; margin-left: auto; }
.menu { position: relative; display: flex; align-items: center; gap: 10px; }
.topbar button.switcher { width: auto; min-height: 40px; padding: 8px 14px; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 500; }
.topbar button.ghost { width: auto; min-height: 40px; padding: 8px 14px; border-radius: 10px; background: transparent; border: 1px solid #3E5078; color: #fff; font-weight: 500; white-space: nowrap; }
.menu-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 300px;
  max-width: min(420px, 92vw);
  padding: 6px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(17, 27, 46, 0.18);
}
.menu-pop.right { left: auto; right: 0; }
.menu-pop.wide { width: 420px; max-height: 75vh; overflow-y: auto; }
.menu-pop > p { margin: 6px 10px 8px; }
.menu-pop a, .menu-pop button.persona {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  background: none;
  text-align: left;
  text-decoration: none;
  font-weight: 500;
}
.menu-pop a:hover, .menu-pop button.persona:hover { background: var(--ground); }
.menu-pop button.persona[aria-pressed="true"] { background: #E6EEF9; }
.menu-pop button.persona .small, .menu-pop a .small { font-weight: 400; }
.viewing { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; padding: 6px 12px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); font-size: 14px; font-weight: 600; }
.viewing button.link { color: var(--amber); }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--light);
  color: var(--navy-2);
  font-weight: 650;
  text-decoration: none;
}

/* QA only: the strip across the top of every screen. */
p.qa-banner {
  margin: 0;
  padding: 7px 16px;
  text-align: center;
  font-size: 13.5px;
  color: var(--amber);
  background: var(--amber-bg);
  border-bottom: 1px solid #F0C27A;
}
p.qa-banner a { color: var(--amber); }

/* --- Workspace: sections down the side, the screen beside them ------------------------------------------- */
.workspace { display: flex; align-items: flex-start; gap: 24px; max-width: 1440px; margin: 0 auto; padding: 24px; }
nav.side { position: sticky; top: 84px; flex: 0 0 230px; display: flex; flex-direction: column; gap: 3px; }
nav.side .side-title { display: flex; flex-direction: column; margin: 0 0 10px; padding: 0 14px; font-weight: 650; }
nav.side a { display: block; padding: 10px 14px; border-radius: 10px; color: var(--body); text-decoration: none; border: 1px solid transparent; }
nav.side a:hover { background: #EAEFF5; }
nav.side a[aria-current="page"] { background: var(--card); border-color: var(--line); color: var(--text); font-weight: 600; }
nav.side .side-note { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: #E6EEF9; font-size: 13px; color: var(--blue); }
.page { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.solo { max-width: 640px; margin: 40px auto; padding: 0 16px; }
.crumbs { font-size: 13.5px; color: var(--muted); }

@media (max-width: 880px) {
  .workspace { flex-direction: column; align-items: stretch; padding: 14px; gap: 14px; }
  nav.side { position: static; flex: none; width: 100%; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; }
  nav.side .side-title, nav.side .side-note { display: none; }
  nav.side a { white-space: nowrap; }
  .topbar { padding: 10px 14px; }
  .brand small { display: none; }
}

@media (max-width: 520px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 26px; }
  .topbar-end { flex-wrap: nowrap; width: 100%; }
  .topbar button.switcher { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .viewing { padding: 5px 10px; font-size: 13px; }
  .hide-narrow { display: none; }
  .hero, .card { padding: 14px; }
  .phone { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
}

/* --- Cards, headings, numbers ------------------------------------------------------------------------------ */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; }
.page-head h1 { margin: 0 0 4px; }
.page-head p { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; min-width: 0; }
.card.dark { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.card.dark h2 { color: #fff; }
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.card-head h2 { margin: 0; }
.card-head a { font-size: 14px; }
.cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.cols > .wide { flex: 999 1 540px; min-width: 0; }
.cols > .narrow { flex: 1 1 300px; min-width: 0; }
.column { display: flex; flex-direction: column; gap: 18px; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.kpi .label { font-size: 13.5px; color: var(--muted); }
.kpi .value { font-size: 32px; font-weight: 650; line-height: 1.15; }
.kpi .value.small-value { font-size: 17px; font-weight: 600; padding-top: 8px; }
.kpi.alert .value { color: var(--red); }
.kpi.dark { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.kpi.dark .label { color: #B8C7DD; }
.note { margin: 0; padding: 10px 14px; border-radius: 10px; background: #E6EEF9; color: var(--blue); font-size: 14px; }
.sample { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 600; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 8px 0; border-top: 1px solid var(--line-2); color: var(--body); }
ul.plain li:first-child { border-top: 0; }
ul.plain li strong { display: inline-block; min-width: 170px; color: var(--text); }
.mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 10px; }
.mini-grid > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: var(--ground); }
.mini-grid strong { font-size: 22px; }
dl.facts-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
dl.facts-list dt { color: #B8C7DD; font-size: 13.5px; }
dl.facts-list dd { margin: 0; font-weight: 600; }

/* --- Tables, chips, segmented filter ------------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
table.data th { padding: 8px 6px; text-align: left; font-weight: 600; color: var(--muted); }
table.data td { padding: 10px 6px; border-top: 1px solid var(--line-2); vertical-align: top; }
table.data .num { text-align: right; }
table.data th.num { font-family: inherit; }
table.data td.hot { color: var(--red); font-weight: 700; }
.chip { display: inline-block; margin: 0 4px 4px 0; padding: 2px 8px; border-radius: 8px; font-size: 12.5px; }
.chip.residential { background: #E6EEF9; color: var(--blue); }
.chip.care { background: var(--red-bg); color: #9F1D1D; }
.chip.home { background: var(--green-bg); color: var(--green); }
.chip.grounds { background: var(--amber-bg); color: var(--amber); }
.chip.agriculture { background: #F1ECFB; color: #5B3E9E; }
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; }
.facts .chip { margin: 0; }
.good { color: var(--green); }
.warn-text { color: var(--amber); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--line-2); border-radius: 12px; }
.seg button { width: auto; min-height: 38px; padding: 0 16px; border-radius: 9px; background: transparent; color: var(--text); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--navy-2); color: #fff; }

/* --- Alerts in dashboards ---------------------------------------------------------------------------------- */
.alert-row { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-2); color: var(--text); text-decoration: none; }
.alert-row:first-of-type { border-top: 0; }
.alert-row:hover strong { text-decoration: underline; }
.dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--blue); }
.dot.critical { background: var(--red); }
.dot.warning { background: #B45309; }
.device { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.device:first-of-type { border-top: 0; }

/* --- Units by floor ------------------------------------------------------------------------------------------- */
section.building { padding: 6px 0 10px; }
section.building + section.building { border-top: 1px solid var(--line-2); }
.floor-row { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; }
.floor { flex: 0 0 60px; font-size: 13px; color: var(--muted); }
ul.units { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
ul.units li {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 2px 4px;
  border-radius: 8px;
  border: 1px solid #9FD3AF;
  background: var(--green-bg);
  color: var(--green);
  font: 13px "Cascadia Mono", ui-monospace, Consolas, monospace;
  text-align: center;
}
ul.units li.warn { background: var(--amber-bg); border-color: #F0C27A; color: var(--amber); }
ul.units li.alert { background: var(--red-bg); border-color: #F3A6A6; color: #9F1D1D; font-weight: 700; }
ul.units li.vacant { background: #EEF1F5; border: 1px dashed #AEB9C8; color: var(--muted); }
ul.units li.offline { background: #EEF1F5; border-color: var(--field); color: var(--muted); }
ul.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--body); }
ul.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid #9FD3AF; background: var(--green-bg); }
.swatch.warn { background: var(--amber-bg); border-color: #F0C27A; }
.swatch.alert { background: var(--red-bg); border-color: #F3A6A6; }
.swatch.vacant { background: #EEF1F5; border: 1px dashed #AEB9C8; }
.swatch.offline { background: #EEF1F5; border-color: var(--field); }

/* --- Work board ---------------------------------------------------------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.board-col { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: #E9EDF3; }
.board-col h2 { margin: 0; font-size: 15px; }
a.work { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); text-decoration: none; font-size: 14px; }
a.work:hover { border-color: var(--blue); }

/* --- A resident's home --------------------------------------------------------------------------------------- */
.hero { padding: 22px 24px; border-radius: 16px; background: var(--navy-2); color: #fff; }
.hero h1 { margin: 4px 0 6px; font-size: 30px; }
.hero .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: #B8C7DD; }
.hero .hero-line { margin: 0; color: var(--light); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tiles.four { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 10px; }
.tile { display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.tile strong { font-size: 19px; font-weight: 650; }

/* --- A family member's phone view ---------------------------------------------------------------------------- */
.phone { width: 100%; max-width: 420px; margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--ground); box-shadow: 0 10px 30px rgba(17, 27, 46, 0.12); }
.phone-head { display: flex; flex-direction: column; gap: 4px; padding: 20px 20px 22px; background: var(--navy-2); color: #fff; }
.phone-brand { font-size: 16px; font-weight: 650; }
.phone-place { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 14px; color: #B8C7DD; }
.phone-head h1 { margin: 0; font-size: 28px; }
.phone-line { margin: 0; font-size: 14px; color: var(--light); }
.phone-body { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
a.care-alert { display: block; padding: 12px 14px; border-radius: 14px; border: 1px solid #F0C27A; background: var(--amber-bg); color: var(--amber); text-decoration: none; }
a.care-alert.critical { border-color: #F3A6A6; background: var(--red-bg); color: #9F1D1D; }
ol.timeline { list-style: none; margin: 0; padding: 0; }
ol.timeline li { display: flex; gap: 10px; padding: 5px 0; font-size: 14px; }
ol.timeline li .num { flex: 0 0 52px; color: var(--muted); }
a.button { display: flex; align-items: center; justify-content: center; min-height: 50px; border-radius: 14px; background: var(--blue); color: #fff; font-weight: 600; text-decoration: none; }

/* --- Meters (SVG bars) --------------------------------------------------------------------------------------- */
.meter { display: inline-flex; align-items: center; gap: 8px; min-width: 150px; }
.meter svg { width: 90px; height: 8px; }
.meter .track { fill: var(--line-2); }
.meter .fill { fill: var(--green); }
.meter .fill.partial { fill: #B45309; }
.bar-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; }

/* --- Forms, buttons, lists ----------------------------------------------------------------------------------- */
label { display: block; margin: 0 0 6px; font-size: 14px; color: var(--body); }
input, select {
  width: 100%;
  margin: 0 0 14px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--field);
  border-radius: 10px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
input.code { font-size: 24px; letter-spacing: 0.4em; text-align: center; }
button {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--navy-2);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
button.auto { width: auto; }
button.secondary { background: #fff; border: 1px solid var(--field); color: var(--text); }
button.link { width: auto; min-height: 0; padding: 0; background: none; color: var(--blue); font-weight: 400; text-decoration: underline; }
button.link.danger { color: var(--red); }
button:disabled { opacity: 0.6; cursor: wait; }
fieldset { margin: 0 0 14px; padding: 0; border: 0; }
legend { margin: 0 0 6px; font-size: 14px; color: var(--body); }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0 16px 6px 0; color: var(--text); font-size: 15px; }
label.check input { width: auto; margin: 0; }
form.inline { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
form.inline input { flex: 1; margin: 0; }
form.inline button { width: auto; white-space: nowrap; }
form.row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 12px 0 0; }
form.row-form > div { flex: 1 1 200px; }
form.row-form button { width: auto; margin: 0 0 14px; }
.stack > * + * { margin-top: 10px; }
ul.items { list-style: none; margin: 0 0 14px; padding: 0; }
ul.items li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
ul.items li:last-child { border-bottom: 0; }
ul.items li span.small { margin: 0; }
ul.items.log li { align-items: flex-start; }
.tags { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: none; }
.confirm { display: inline-flex; flex: none; gap: 12px; }
p.hint { margin: -8px 0 14px; }

/* Screens that predate the cards (team, access log, alerts, the operator console) get a card look from the shell. */
.page > ul.items, .page > form, .page > section:not(.card):not(.hero):not(.building), .page > ol.ladder + ul, .page > .key-box {
  margin: 0;
  padding: 6px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.page > form { padding: 16px 18px; }
.page > h1 { margin: 0; }
.page > h2 { margin: 6px 0 -6px; }
.page > p { margin: 0; }

.badge { flex: none; display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 999px; }
.badge.ok { color: var(--green); background: var(--green-bg); }
.badge.waiting { color: var(--amber); background: var(--amber-bg); }
.badge.denied { color: var(--red); background: var(--red-bg); }
.badge.failed { color: var(--amber); background: var(--amber-bg); }
.badge.info { color: var(--blue); background: #E6EEF9; }
.badge.category { color: var(--muted); background: transparent; border: 1px solid var(--field); }
.badge.simulated { color: var(--blue); background: #F0F5FC; border: 1px dashed #7FA6DB; }
ol.ladder { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; }
ol.ladder li { padding: 4px 10px; font-size: 14px; border-radius: 999px; border: 1px solid var(--field); color: var(--muted); }
ol.ladder li.passed { color: var(--text); background: var(--line-2); border-color: var(--line-2); }
ol.ladder li.current { color: #fff; background: var(--navy-2); border-color: var(--navy-2); font-weight: 600; }
.key-box { margin: 0 0 14px; padding: 12px; border-radius: 10px; background: var(--green-bg); }
.key-box p { margin: 0 0 8px; color: var(--green); }
.key-box input { margin: 0 0 8px; font-family: "Cascadia Mono", ui-monospace, Consolas, monospace; font-size: 13px; }
p.banner { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; font-size: 14px; color: var(--blue); background: #E6EEF9; border: 1px dashed #7FA6DB; }
nav.tenant { margin: 0; }
nav.tenant p { margin: 0; }

#status { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: #E6EEF9; color: var(--blue); }
#status[data-kind="error"] { color: var(--red); background: var(--red-bg); }
#status[data-kind="ok"] { color: var(--green); background: var(--green-bg); }
.card #status { margin: 0 0 12px; }

/* --- Signing in, joining, recovering, your own account: one card under the top bar --------------------------- */
main.narrow {
  width: calc(100% - 32px);
  max-width: 460px;
  margin: 32px auto;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(17, 27, 46, 0.06);
}
main.narrow h2 { margin-top: 22px; font-size: 16px; }
main.narrow #status { margin: 0 0 14px; }

/* Before the client starts (index.html). */
header.boot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; background: var(--navy-2); color: var(--light); font-size: 13px; font-weight: 600; letter-spacing: 0.12em; }
header.boot img { width: 28px; height: 28px; }
main.boot { max-width: 460px; margin: 32px auto; padding: 0 16px; }

/* Blazor shows this bar when the client hits an error it can't recover from. */
#blazor-error-ui {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--red);
  background: var(--red-bg);
  text-align: center;
}
