
/* FlockHA portal styles (derived from ui/mockups v0.1). */
:root {
  --bg: #F3F5F6;
  --surface: #FFFFFF;
  --sunk: #E8ECEE;
  --line: #D3DADE;
  --fg: #16232B;
  --muted: #5B6B74;
  --accent: #1E6F68;      /* verdigris: custody, protection */
  --accent-fg: #FFFFFF;
  --accent-soft: #DCEEEB;
  --nav: #13252C;
  --nav-fg: #D7E3E6;
  --ok: #2E7D4F;  --ok-soft: #DDF0E4;
  --warn: #A3640B; --warn-soft: #F7E9D2;
  --crit: #B3261E; --crit-soft: #F6DEDC;
  --h0: #E8ECEE; --h1: #F3DDB6; --h2: #E6A85A; --h3: #C8641E; --h4: #9E2F14;   /* change heat, none to a lot */
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-head: "IBM Plex Sans Condensed", "Arial Narrow", "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E171C; --surface: #15222A; --sunk: #1B2B34; --line: #2A3C46;
  --fg: #E4ECEF; --muted: #93A6AF; --accent: #4DB3A8; --accent-fg: #06201D; --accent-soft: #163733;
  --nav: #0A1216; --nav-fg: #C4D3D8;
  --ok: #5CC28A; --ok-soft: #173326; --warn: #E0A54A; --warn-soft: #3A2C14; --crit: #F08077; --crit-soft: #3D1A18;
  --h0: #1F313A; --h1: #4A3A1E; --h2: #8A5B22; --h3: #C9762C; --h4: #F0956A;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0E171C; --surface: #15222A; --sunk: #1B2B34; --line: #2A3C46;
  --fg: #E4ECEF; --muted: #93A6AF; --accent: #4DB3A8; --accent-fg: #06201D; --accent-soft: #163733;
  --nav: #0A1216; --nav-fg: #C4D3D8;
  --ok: #5CC28A; --ok-soft: #173326; --warn: #E0A54A; --warn-soft: #3A2C14; --crit: #F08077; --crit-soft: #3D1A18;
  --h0: #1F313A; --h1: #4A3A1E; --h2: #8A5B22; --h3: #C9762C; --h4: #F0956A;
  color-scheme: dark; }

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font-body); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--muted); }
.label { font-family: var(--font-head); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Storyboard bar */
.story { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.story .brand { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; display: flex; gap: 8px; align-items: center; }
.story select { min-width: 0; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.story .grow { flex: 1 1 auto; }
.tag-sample { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--fg); font-weight: 500; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Screens */
.screen[hidden] { display: none !important; }
.wrap { padding-block: 20px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.screen-id { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin-bottom: 14px; }
.screen-id .mono { color: var(--accent); font-weight: 500; }

/* Console shell */
.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.side { background: var(--nav); color: var(--nav-fg); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; }
.side .org { font-family: var(--font-head); font-weight: 600; padding: 4px 10px 14px; font-size: .95rem; }
.side .org small { display: block; font-family: var(--font-body); font-weight: 400; opacity: .7; font-size: .78rem; }
.side a { color: inherit; text-decoration: none; padding: 7px 10px; border-radius: var(--r); font-size: .92rem; }
.side a:hover, .side a.on { background: rgba(255,255,255,.08); }
.side a.on { box-shadow: inset 3px 0 0 var(--accent); }
.main { padding: 22px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.head { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: space-between; align-items: flex-end; }
@media (max-width: 760px) { .shell { grid-template-columns: 1fr; } .side { flex-direction: row; flex-wrap: wrap; } .side .org { width: 100%; padding-bottom: 6px; } .main { padding: 16px; } }

/* Components */
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.panel-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.panel-b { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-family: var(--font-head); font-weight: 500; font-size: .76rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--sunk); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ok { color: var(--ok); background: var(--ok-soft); }
.warn { color: var(--warn); background: var(--warn-soft); }
.crit { color: var(--crit); background: var(--crit-soft); }
.neutral { color: var(--muted); background: var(--sunk); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; border-left: 4px solid var(--line); }
.stat b { display: block; font-family: var(--font-head); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat.s-ok { border-left-color: var(--ok); } .stat.s-warn { border-left-color: var(--warn); } .stat.s-crit { border-left-color: var(--crit); }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .85rem; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.search { flex: 1 1 220px; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); width: 100%; }
.field .hint { font-size: .8rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); font-weight: 500; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.dot { flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
.dot.ok { background: var(--ok-soft); color: var(--ok); } .dot.warn { background: var(--warn-soft); color: var(--warn); }
.code { font-family: var(--font-mono); font-size: 1.6rem; letter-spacing: .12em; padding: 14px 18px; background: var(--sunk); border-radius: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label { display: flex; gap: 6px; align-items: center; padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.radio-row input:checked + span { font-weight: 600; color: var(--accent); }
.note { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--fg); font-size: .9rem; display: flex; gap: 10px; }
.note.warn { background: var(--warn-soft); }
.timer { font-family: var(--font-mono); font-size: 2rem; font-variant-numeric: tabular-nums; }
.log { font-family: var(--font-mono); font-size: .82rem; background: var(--sunk); border-radius: 6px; padding: 10px 12px; overflow-x: auto; white-space: pre; }

/* Homeowner (phone) */
.phone-stage { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.phone { width: 100%; max-width: 380px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); overflow: hidden; }
.phone-top { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.phone-top b { font-family: var(--font-head); }
.phone-b { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.req { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; justify-content: center; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.toggle input { width: 40px; height: 22px; accent-color: var(--accent); }
.sms { background: var(--sunk); border-radius: 16px 16px 16px 4px; padding: 12px 14px; max-width: 290px; }
.ha-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ha-card .ha-h { padding: 12px 16px; background: var(--sunk); display: flex; gap: 10px; align-items: center; }
.ha-card .ha-b { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sign-card { max-width: 420px; margin: 24px auto; }
.flow-next { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* App additions */
.flash { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); }
.flash.err { background: var(--crit-soft); color: var(--crit); }
form.inline { display: inline; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.login-wrap { padding-block: 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.tabs a.tabbtn { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a.tabbtn.on { color: var(--fg); border-bottom-color: var(--accent); font-weight: 500; }
.side form .btn { background: transparent; color: var(--nav-fg); border-color: rgba(255,255,255,.2); }

/* Password checklist (#28): neutral until typing, then pass or fail per item. */
.pw-row { display: flex; gap: 8px; align-items: stretch; }
.pw-row input { flex: 1; min-width: 0; }
.pw-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .92rem; color: var(--muted); }
.pw-checks li { display: flex; align-items: center; gap: 8px; }
.pw-checks .mark { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; }
.pw-checks li.pass { color: var(--fg); }
.pw-checks li.pass .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.pw-checks li.pass .mark::after { content: "✓"; }
.pw-checks li.fail .mark { border-color: var(--crit); color: var(--crit); }
.pw-checks li.fail .mark::after { content: "✕"; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Switch: an on/off setting that acts at once (docs/ui-style.md). A form button, so it works
   without JavaScript; the knob position and colour show the state. */
.switch { position: relative; flex: none; width: 40px; height: 24px; padding: 0; border-radius: 99px; border: 1px solid var(--line); background: var(--sunk); cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.setting { display: flex; align-items: center; gap: 10px; }
.setting .cap { font-size: .85rem; color: var(--muted); }
.setting .cap.warn { color: var(--warn); }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

/* Sites list: a status mark and change-heat bars per site; the panel (dialog) has the detail. */
.sites td { vertical-align: middle; padding: 12px; }
.sites tbody tr { cursor: pointer; } .sites tbody tr:hover td { background: var(--sunk); }
.sites td:first-child, .sites th:first-child { width: 28px; padding-right: 0; }
.sites .heat-h, .sites td:last-child { width: 1%; text-align: center; }
.site-link { font-weight: 500; color: var(--fg); text-decoration: none; }
.site-link:hover { text-decoration: underline; }
.site-addr { display: block; font-size: .8rem; }
a.chip { text-decoration: none; color: var(--fg); }
.chip.alert span { color: var(--crit); font-weight: 600; }
/* Status: shape and colour, so it never relies on colour alone. */
.mark { display: inline-block; width: 12px; height: 12px; vertical-align: middle; background: var(--muted); border-radius: 50%; }
.mark.online { background: var(--ok); }
.mark.degraded { background: var(--warn); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 14px; height: 13px; }
.mark.offline { background: var(--crit); border-radius: 2px; }
.mark.pending, .mark.suspended, .mark.removed { background: none; box-shadow: inset 0 0 0 2px var(--muted); }
/* Change heat: one bar settled, two changed lately, three just changed. */
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle; }
.bars i { width: 4px; background: var(--line); border-radius: 1px; }
.bars i:nth-child(1) { height: 6px; } .bars i:nth-child(2) { height: 10px; } .bars i:nth-child(3) { height: 14px; }
.bars.settled i:nth-child(1) { background: var(--ok); }
.bars.warm i:nth-child(-n+2) { background: var(--warn); }
.bars.hot i { background: var(--crit); }
.legend { font-size: .8rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.legend .mark, .legend .bars { margin-left: 8px; }
.legend .bars { margin-left: 16px; }
/* The panel: a sheet from the right (from the bottom on phones); Close, Esc, Back or a click outside returns. */
dialog.sheet { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(420px, 100vw); border: 0; padding: 0;
  background: var(--surface); color: var(--fg); box-shadow: -8px 0 24px rgb(0 0 0 / .18); }
dialog.sheet::backdrop { background: rgb(0 0 0 / .3); }
@media (max-width: 600px) { dialog.sheet .peek { min-height: 0; } dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; height: auto; max-height: 85dvh; border-radius: 12px 12px 0 0; } }
.peek { display: flex; flex-direction: column; min-height: 100%; }
.peek > * { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.peek h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.peek-h { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; position: sticky; top: 0; background: var(--surface); }
.peek-f { margin-top: auto; display: flex; gap: 8px; border-bottom: 0; position: sticky; bottom: 0; background: var(--surface); }
.peek-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: .85rem; }
.peek-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; }
.peek-list li > .muted { white-space: nowrap; }
.peek-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.peek-btn:hover { background: var(--sunk); border-color: var(--accent); }
@media (max-width: 600px) { .peek-btn { min-width: 44px; min-height: 44px; } }
a.pill { text-decoration: none; }
/* Lists that stay readable at phone width (#44): what it is, the versions, then its state. */
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); }
.items-what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.items-what .muted { font-size: .8rem; }
.items-ver { font-size: .85rem; white-space: nowrap; }
@media (max-width: 600px) { .items li { grid-template-columns: minmax(0, 1fr) auto; } .items-ver { grid-row: 2; white-space: normal; } }
details.more > summary { padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; color: var(--accent); }
.btn.icon { padding: 4px 10px; min-width: 32px; justify-content: center; }
.strip, .axis { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; }
.strip > span { height: 22px; border-radius: 2px; background: var(--h0); }
.strip .l1 { background: var(--h1); } .strip .l2 { background: var(--h2); }
.strip .l3 { background: var(--h3); } .strip .l4 { background: var(--h4); }
.axis { font-size: .7rem; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.axis span:first-child { grid-column: 1 / span 7; } .axis span:last-child { grid-column: 8 / span 7; justify-self: end; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; margin-bottom: 4px; }
/* App sign-in (#43): one focused step, sized for a phone. */
.link-step { max-width: 440px; margin: 24px auto; }
.link-step .panel-b { padding: 22px; }
.btn.big { justify-content: center; padding: 12px 16px; font-size: 1rem; min-height: 44px; }
.link-step .btn { justify-content: center; }
