/* Servility Software Portal: light look (Brad, 30 Oct 2026: white is easier on the eye), per the Servility Brand
   Identity Guidelines v1.0. Montserrat (Arial fallback), Servility Dark text, Primary Blue for actions, Signal Teal
   (darkened for reading on white) for labels, Accent Purple used sparingly. The logo is the supplied full-colour
   horizontal artwork; the name is never typed as a logo. */
:root {
  color-scheme: light;
  --bg: #F4F6F9; --rail: #FFFFFF; --panel: #FFFFFF; --panel-2: #F4F6F9; --line: #DFE4EB;
  --teal: #7AA2A1; --teal-2: #6B7280; --grey: #6B7280;
  --fg: #131720; --muted: #5B6476; --menu: #3D4656; --sel: #E6F0FF;
  --blue: #3B8CFF; --blue-2: #1F6FE0; --purple: #954ECA; --purple-2: #6E2FA3;
  --ok: #2F8B57; --ok-t: #1E6E43; --warn: #D68800; --warn-t: #8A5A00; --bad: #C94343; --bad-t: #A12C2C; --off: #9AA3B2;
  --off-t: #4B5466; --input-bg: #FFFFFF; --alarm-bg: #FDF1F1; --alarm-ack-bg: #FFF8EA; --btn-primary-fg: #131720;
  --shadow: 0 1px 2px rgba(19,23,32,.05); --backdrop: rgba(19,23,32,.45); --glow: none;
  --font: "Montserrat", Arial, Helvetica, sans-serif; --mono: Consolas, "Courier New", monospace;
}
/* Dark look (Brad, 2 Nov 2026): night shift and control-room screens. Chosen with Light / Dark / Auto under the menu;
   Auto follows the phone or computer. Deep navy with Servility blue, like the control-room designs. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #131720; --rail: #131720; --panel: #1A1F2B; --panel-2: #161B26; --line: #2A3142;
  --teal: #83B8B7; --teal-2: #83B8B7; --grey: #6B7280;
  --fg: #E6EDF7; --muted: #93A3BC; --menu: #B8C4D6; --sel: #12305A;
  --blue: #3B8CFF; --blue-2: #79B4FF; --purple: #954ECA; --purple-2: #C9A6EE;
  --ok: #3FBF7F; --ok-t: #7FD8A9; --warn: #E0A100; --warn-t: #F1C565; --bad: #E5534B; --bad-t: #FF8A80; --off: #5E6E86;
  --off-t: #B4BFCF; --input-bg: #161B26; --alarm-bg: #2A1418; --alarm-ack-bg: #2B2414; --btn-primary-fg: #08111F;
  --shadow: 0 6px 20px rgba(0,0,0,.35); --backdrop: rgba(0,0,0,.6); --glow: 0 0 0 1px rgba(59,140,255,.10), 0 0 24px rgba(59,140,255,.08);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131720; --rail: #131720; --panel: #1A1F2B; --panel-2: #161B26; --line: #2A3142;
  --teal: #83B8B7; --teal-2: #83B8B7; --grey: #6B7280;
  --fg: #E6EDF7; --muted: #93A3BC; --menu: #B8C4D6; --sel: #12305A;
  --blue: #3B8CFF; --blue-2: #79B4FF; --purple: #954ECA; --purple-2: #C9A6EE;
  --ok: #3FBF7F; --ok-t: #7FD8A9; --warn: #E0A100; --warn-t: #F1C565; --bad: #E5534B; --bad-t: #FF8A80; --off: #5E6E86;
  --off-t: #B4BFCF; --input-bg: #161B26; --alarm-bg: #2A1418; --alarm-ack-bg: #2B2414; --btn-primary-fg: #08111F;
  --shadow: 0 6px 20px rgba(0,0,0,.35); --backdrop: rgba(0,0,0,.6); --glow: 0 0 0 1px rgba(59,140,255,.10), 0 0 24px rgba(59,140,255,.08);
}
/* The full-colour logo on light, the reversed (white) logo on dark. */
.logo.on-dark { display: none !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo.on-light { display: none !important; } :root:not([data-theme="light"]) .logo.on-dark { display: block !important; } }
:root[data-theme="dark"] .logo.on-light { display: none !important; }
:root[data-theme="dark"] .logo.on-dark { display: block !important; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; }
h1 { font-size: 26px; font-weight: 800; margin: 0; } h2 { font-size: 18px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); font-size: 13px; }
.err { color: var(--bad-t); font-size: 13px; margin: 0; min-height: 1em; }

.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.card { box-shadow: var(--shadow), var(--glow); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.narrow { width: 100%; max-width: 380px; }
label { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--teal-2); }
input, select, textarea { background: var(--input-bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }

.brand { display: flex; flex-direction: column; }
.brand { gap: 14px; } /* clear space around the logo (guidelines section 05) */
.brand .logo { width: 200px; max-width: 100%; height: auto; display: block; }
.brand span { font-size: 10px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--teal-2); padding-left: 2px; }

.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.rail { flex: 1 1 220px; background: var(--rail); border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
/* Wild Guardian picture (or initials) */
.guardian-me { all: unset; cursor: pointer; flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--panel-2); color: var(--fg); font-weight: 700; box-shadow: 0 0 0 2px var(--blue); }
.guardian-me img { width: 100%; height: 100%; object-fit: cover; display: block; }
.guardian-me:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
dialog.guardians { width: min(860px, calc(100vw - 32px)); }
.guardian-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: min(60vh, 560px); overflow-y: auto; padding: 2px; }
.guardian-card { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 10px 8px; border-radius: 10px; border: 1px solid var(--line); }
.guardian-card:hover, .guardian-card:focus-visible { background: var(--panel-2); }
.guardian-card.on { box-shadow: inset 0 0 0 2px var(--blue); }
.guardian-card img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu button { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 8px; color: var(--menu); display: flex; justify-content: space-between; gap: 8px; }
.menu button:hover { background: var(--panel-2); }
.menu button[aria-current="true"] { background: var(--sel); color: var(--fg); font-weight: bold; box-shadow: inset 0 0 0 1px var(--blue); }
.menu .soon { font-size: 11px; color: var(--muted); white-space: nowrap; align-self: center; }
.rail > .btn { margin-top: auto; }
main { flex: 999 1 560px; min-width: 0; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 900px) { main { padding: 24px 32px 48px; } }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 14px; }
.tabs button[aria-selected="true"] { border-color: var(--blue); background: var(--sel); font-weight: 700; }
.tabs button.help[aria-selected="true"] { border-color: var(--teal); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.stat.bad { border-color: var(--bad); } .stat.warn { border-color: var(--warn); }
.grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .grid { grid-template-columns: minmax(0, 1fr); } }

.btn { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; }
.btn:hover:not(:disabled) { border-color: var(--blue); }
/* Brand guidelines: blue is for graphics and large text, so button text is Servility Dark on blue (contrast about 5.5:1). */
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--btn-primary-fg); font-weight: 700; }
.btn.danger { border-color: var(--bad); color: var(--bad-t); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

.pill { display: inline-block; font-size: 12px; font-weight: bold; padding: 1px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: rgba(47,139,87,.14); color: var(--ok-t); } .pill.warn { background: rgba(214,136,0,.16); color: var(--warn-t); }
.pill.bad { background: rgba(201,67,67,.13); color: var(--bad-t); } .pill.off { background: rgba(107,114,128,.16); color: var(--off-t); }
.pill.purple { background: rgba(149,78,202,.13); color: var(--purple-2); } .pill.blue { background: rgba(59,140,255,.13); color: var(--blue-2); }

.strip { display: flex; gap: 4px; flex-wrap: wrap; }
.seg { cursor: pointer; flex: 1 1 90px; min-height: 54px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); padding: 6px 8px; border-top: 5px solid var(--off); text-align: left; }
.seg.ok { border-top-color: var(--ok); } .seg.warn { border-top-color: var(--warn); } .seg.bad { border-top-color: var(--bad); }
.seg.dis { border-top-color: var(--purple); } .seg.sel { box-shadow: 0 0 0 2px var(--blue); }
.seg small { display: block; color: var(--muted); font-size: 11px; }

.alarm { border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: 10px; padding: 12px; background: var(--alarm-bg); display: flex; flex-direction: column; gap: 8px; }
.alarm.ack { border-left-color: var(--warn); background: var(--alarm-ack-bg); }
.empty { color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 620px; }
th { text-align: left; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--panel-2); border: 1px solid var(--blue); border-radius: 10px; padding: 10px 14px; max-width: calc(100vw - 32px); }
.help p, .help ul { max-width: 68ch; }
#pdBody { display: flex; flex-direction: column; gap: 16px; }
.pw { position: relative; }
.pw input { padding-right: 46px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center;
  width: 38px; height: 34px; background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer; }
.pw-eye:hover { color: var(--fg); background: var(--panel-2); }

/* People & cards */
ul.plain { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.inline-form select, .inline-form input { flex: 1 1 180px; width: auto; }
.inline-form .err { width: 100%; margin: 0; }

/* Sign-in: forgotten password help */
.forgot summary { cursor: pointer; color: var(--blue-2); font-weight: 600; }
.forgot p { margin: 8px 0 0; }

/* Module screens: a row of filter buttons (role="group"), not the fence-zone tiles above. */
.seg[role="group"] { display: flex; flex-wrap: wrap; gap: 6px; flex: none; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; cursor: auto; }
.seg[role="group"] button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 14px; }
.seg[role="group"] button[aria-pressed="true"] { border-color: var(--blue); background: var(--sel); font-weight: 700; }
div.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
div.kv:last-child { border-bottom: 0; }
.stat span { display: block; }

/* Device key box */
.keyline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.keyline .mono { font-size: 16px; letter-spacing: .04em; word-break: break-all; padding: 6px 10px; background: var(--panel-2); border-radius: 8px; }

/* Gate photos next to an entry */
.gc-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.gc-photo { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.gc-photo.big { width: 240px; height: 240px; max-width: calc(100vw - 64px); }
.gc-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 10px; }
.gc-group { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.gc-group h4 { margin: 0 0 6px; font-size: 13px; }
.gc-group dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
.gc-group dt { color: var(--muted); }
.gc-group dd { margin: 0; overflow-wrap: anywhere; }

/* Password window for locked details */
dialog.ask { border: 0; padding: 0; background: transparent; width: min(420px, calc(100vw - 32px)); }
dialog.ask::backdrop { background: var(--backdrop); }
.locked { display: inline-flex; align-items: center; gap: 6px; }
.revealed { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border: 1px dashed var(--line); font-size: 13px; }

.version { margin: 0; font-size: 11px; text-align: center; }

/* Light / Dark / Auto switch under the menu */
.theme { display: flex; border: 1px solid var(--line); border-radius: 99px; padding: 2px; gap: 2px; }
.theme button { flex: 1 1 0; border: 0; background: none; border-radius: 99px; padding: 5px 8px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.theme button[aria-pressed="true"] { background: var(--sel); color: var(--fg); box-shadow: inset 0 0 0 1px var(--blue); }

/* Dashboard (home): status cards, fence ring, recent events, sites and devices, today per module */
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.dash-head .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--teal-2); }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; box-shadow: var(--shadow), var(--glow); }
.dcard .k { grid-column: 1; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.dcard .v { grid-column: 1; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.dcard .s { grid-column: 1; font-size: 12px; color: var(--muted); }
.dcard .ic { grid-column: 2; grid-row: 1 / span 3; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--panel-2); border: 1px solid var(--line); }
.dcard .ic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dcard.ok .v, .dcard.ok .ic { color: var(--ok-t); } .dcard.warn .v, .dcard.warn .ic { color: var(--warn-t); }
.dcard.bad { border-color: var(--bad); } .dcard.bad .v, .dcard.bad .ic { color: var(--bad-t); } .dcard.blue .ic { color: var(--blue-2); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1180px) { .dash-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .dash-grid > .wide { grid-column: 1 / -1; } }
@media (max-width: 760px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.card h2.k { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--teal-2); }
.ring { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring svg { width: 140px; height: 140px; flex: 0 0 auto; }
.ring .legend { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.ring .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--c); vertical-align: middle; }
.feed { display: flex; flex-direction: column; }
.feed .ev { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: start; }
.feed .ev:last-child { border-bottom: 0; }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--off); }
.feed .dot.Alarm { background: var(--bad); } .feed .dot.Warning { background: var(--warn); } .feed .dot.Info { background: var(--blue); }
.feed .t { font-weight: 600; font-size: 14px; } .feed .m { font-size: 12px; color: var(--muted); }
.sitelist { display: flex; flex-direction: column; gap: 8px; }
.site { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.site .devs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.devdot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); }
.devdot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.devdot.on::before { background: var(--ok); }
.mods { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.mod { all: unset; box-sizing: border-box; cursor: pointer; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.mod:hover { border-color: var(--blue); } .mod:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; }
.mod b { font-size: 22px; font-variant-numeric: tabular-nums; } .mod span { font-size: 12px; color: var(--muted); }

/* Sign-in: which program this is (CC-006), under the logo, in Montserrat */
.who-prog { display: flex; flex-direction: column; gap: 0; margin-top: -4px; }
.who-prog b { font-size: 17px; font-weight: 800; }
a { color: var(--blue-2); }

/* ---- Servility Client Portal (Portal:Edition=ClientPortal) ---- */
.cp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cp-tile { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 6px; padding: 18px; }
.cp-tile:hover, .cp-tile:focus-visible { border-color: var(--blue); }
.cp-tile .k, .cp-rel .k { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.cp-tile b { font-size: 18px; }
.cp-rel { margin-bottom: 14px; }
.cp-rel h2 { margin: 4px 0 2px; }
.cp-notes { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--panel-2); border-radius: 10px; padding: 12px 14px; max-height: 260px; overflow: auto; }
.cp-files { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.cp-file { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--fg); min-height: 44px; }
.cp-file:hover, .cp-file:focus-visible { border-color: var(--blue); }
.cp-name { overflow-wrap: anywhere; }
.cp-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.cp-form label { display: flex; flex-direction: column; gap: 6px; }
.cp-form .wide { grid-column: 1 / -1; }
.cp-add summary { cursor: pointer; min-height: 32px; }
