/* Insight-IoT portal — Pacewave look, after Insight ACS (Bootstrap 5 style: navy
 * headers, cards). Hand-written, no third-party assets and nothing from a CDN
 * (PW-IOT-013 §8). Light and dark themes: <html data-theme="light|dark">, set
 * by /static/js/theme-init.js before first paint and toggled by portal.js.
 *
 * Palette (Insight ACS): navy #001a33, card header / nav #003366, border
 * #004080, accent #66b3ff, text #212529, light #f8f9fa, success #198754,
 * warning #ffc107, danger #dc3545, muted #6c757d.
 */

:root {
  --pw-navy: #001a33; --pw-header: #003366; --pw-border: #004080; --pw-accent: #66b3ff;
  --pw-text: #212529; --pw-light: #f8f9fa; --pw-success: #198754; --pw-warning: #ffc107;
  --pw-danger: #dc3545; --pw-muted: #6c757d;

  /* light theme (default) */
  --bg: #eef2f6; --surface: #ffffff; --surface-2: var(--pw-light); --ink: var(--pw-text);
  --muted: #5c6670; --line: #cfd8e3; --link: #004080; --link-hover: #001a33;
  --primary: #004080; --primary-hover: #003366; --primary-ink: #ffffff;
  --focus: #1a73e8; --input-bg: #ffffff;
  /* outline of form fields: at least 3:1 on every surface (WCAG 1.4.11; R2 UX2-4).
     --line stays for decorative rules and table borders. */
  --field-border: var(--pw-muted);
  --ok-bg: #d1e7dd; --ok-ink: #0a3622; --warn-bg: #fff3cd; --warn-ink: #664d03;
  --bad-bg: #f8d7da; --bad-ink: #58151c; --info-bg: #e3effb; --info-ink: #002a55;
  --code-bg: #eef1f4; --shadow: 0 1px 2px rgba(0, 26, 51, .08), 0 2px 8px rgba(0, 26, 51, .06);
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
}

:root[data-theme="dark"] {
  --bg: var(--pw-navy); --surface: #00264d; --surface-2: #002142; --ink: #e9eef5;
  --muted: #a9b8c8; --line: var(--pw-border); --link: var(--pw-accent); --link-hover: #a8d4ff;
  --primary: var(--pw-accent); --primary-hover: #99ccff; --primary-ink: #001a33;
  --focus: #ffd24d; --input-bg: #001f3d;
  --field-border: #5c8fc4;
  --ok-bg: #0f3d2a; --ok-ink: #9be3bf; --warn-bg: #4a3b00; --warn-ink: #ffe08a;
  --bad-bg: #4d1219; --bad-ink: #ffb3bb; --info-bg: #06325e; --info-ink: #cfe6ff;
  --code-bg: #001a33; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); line-height: 1.5;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
code, pre, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: var(--code-bg); padding: .05em .3em; border-radius: 3px; }
pre { background: var(--code-bg); padding: .75rem 1rem; border-radius: 6px; overflow-x: auto; }
pre code { background: none; padding: 0; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; font-weight: 600; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; font-weight: 600; }
img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* Focus: always visible for keyboard users. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.navbar :focus-visible { outline-color: #ffd24d; }
/* R5 A11Y-1: the menus inside the navbar sit on --surface (white in the light theme),
   where the navbar's yellow is about 1.4:1; they take the page's own focus colour. */
.navbar .dropdown-menu :focus-visible { outline-color: var(--focus); }

.skip-link {
  position: absolute; left: .5rem; top: -3rem; z-index: 100; padding: .5rem 1rem;
  background: #ffd24d; color: #001a33; font-weight: 700; border-radius: 0 0 6px 6px;
}
.skip-link:focus { top: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
html:not(.js) .js-only { display: none !important; }
html.js .no-js-only { display: none !important; }

/* ---------------------------------------------------------------- banners */
.env-banner, .maint-banner { text-align: center; padding: .45rem 1rem; font-weight: 600; font-size: .9rem; }
.env-banner { background: var(--pw-danger); color: #fff; }
.maint-banner { background: var(--pw-warning); color: #212529; }

/* ----------------------------------------------------------------- navbar */
.navbar { background: var(--pw-header); color: #fff; border-bottom: 3px solid var(--pw-border); }
.navbar-inner {
  max-width: 90rem; margin: 0 auto; padding: .4rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.navbar a { color: #fff; text-decoration: none; }
.navbar-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.1rem; }
/* Logos sit on the navy header in both themes, so both use the dark-background artwork (logo-dark.png), as Insight ACS does on dark backgrounds. */
.navbar-brand img { width: 175px; height: 70px; }
@media (max-width: 520px) { .navbar-brand img { width: 125px; height: 50px; } }
.navbar-brand .brand-name { border-left: 1px solid rgba(255, 255, 255, .35); padding-left: .6rem; }
.navbar-nav-wrap { flex: 1; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.navbar-nav { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav-dropdown { position: relative; }
.nav-dropdown > summary {
  list-style: none; cursor: pointer; padding: .45rem .75rem; border-radius: 4px;
  color: #e6f0fa; user-select: none;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after { content: " ▾"; font-size: .8em; opacity: .8; }
.nav-dropdown > summary:hover, .nav-dropdown[open] > summary, .nav-dropdown.active > summary {
  background: rgba(255, 255, 255, .12); color: #fff;
}
.nav-dropdown.active > summary { box-shadow: inset 0 -2px 0 var(--pw-accent); }
.dropdown-menu {
  list-style: none; margin: .25rem 0 0; padding: .35rem 0; position: absolute; left: 0; top: 100%;
  min-width: 13rem; z-index: 50; background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 6px 24px rgba(0, 26, 51, .25);
}
.navbar .dropdown-item { display: block; padding: .45rem 1rem; color: var(--ink); }
.navbar .dropdown-item:hover { background: var(--surface-2); color: var(--ink); }
.navbar .dropdown-item[aria-current="page"] { font-weight: 700; border-left: 3px solid var(--pw-accent); padding-left: calc(1rem - 3px); }
.navbar-user { display: flex; align-items: center; gap: .6rem; font-size: .9rem; flex-wrap: wrap; }
.user-chip { color: #d6e6f5; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.user-chip { text-decoration: underline; text-underline-offset: 3px; }
a.user-chip:hover { color: #ffffff; }
.role-chip { font-size: .75rem; padding: .1rem .45rem; border: 1px solid rgba(255, 255, 255, .4); border-radius: 999px; color: #d6e6f5; }
.navbar button.nav-button {
  background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .45);
  padding: .3rem .7rem; font-size: .85rem; border-radius: 4px;
}
.navbar button.nav-button:hover { background: rgba(255, 255, 255, .14); }
/* ACS navbar: outlined light buttons with icons, an icon-only theme toggle, a red Logout */
.navbar-brand .brand-name { font-size: 1.25rem; font-weight: 700; }
.nav-dropdown > summary { display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid rgba(248, 249, 250, .85); border-radius: .375rem; color: #f8f9fa; }
.nav-dropdown > summary:hover, .nav-dropdown[open] > summary { background: #f8f9fa; color: #003366; }
.navbar button.nav-button { display: inline-flex; align-items: center; gap: .35rem; padding: .375rem .75rem;
  font-size: 1rem; border-radius: .375rem; border-color: rgba(248, 249, 250, .85); }
.navbar button.icon-button:hover { background: #f8f9fa; color: #003366; }
.navbar button.logout-button { background: #dc3545; border-color: #dc3545; color: #fff; }
.navbar button.logout-button:hover { background: #bb2d3b; border-color: #b02a37; }
.navbar button.navbar-toggler { display: none; }
@media (max-width: 860px) { html.js .navbar button.navbar-toggler { display: inline-flex; } }
@media (min-width: 861px) { .navbar-nav { justify-content: flex-end; } }
.navbar-toggler { display: none; margin-left: auto; }
.toggler-bars { display: inline-block; width: 1.25rem; height: 2px; background: #fff; position: relative; vertical-align: middle; }
.toggler-bars::before, .toggler-bars::after { content: ""; position: absolute; left: 0; width: 100%; height: 2px; background: #fff; }
.toggler-bars::before { top: -6px; }
.toggler-bars::after { top: 6px; }

@media (max-width: 860px) {
  html.js .navbar-toggler { display: inline-block; }
  html.js .navbar-nav-wrap { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; }
  html.js .navbar-nav-wrap.open { display: flex; }
  .navbar-nav { flex-direction: column; }
  .dropdown-menu { position: static; box-shadow: none; margin: 0 0 .25rem .75rem; }
  .navbar-user { padding: .5rem 0; border-top: 1px solid rgba(255, 255, 255, .2); }
}

/* ------------------------------------------------------------------ layout */
main { flex: 1; width: 100%; }
main:focus { outline: none; }
.page { max-width: 90rem; margin: 1.5rem auto; padding: 0 1rem; }
.narrow { max-width: 34rem; margin: 2rem auto; padding: 0 1rem; }
.auth { max-width: 30rem; margin: 2.5rem auto; padding: 0 1rem; }
/* As the Insight ACS footer: three columns (who · product and company · time) */
.footer {
  color: var(--muted); font-size: .82rem; padding: .6rem 1rem; background: var(--surface-2);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 2fr 1fr; gap: .4rem 1rem;
  align-items: center;
}
.footer-centre { text-align: center; line-height: 1.5; }
.footer-company { font-weight: 700; }
.footer-right { text-align: right; }
.footer .user-chip { color: var(--muted); }
.footer .role-chip { color: var(--muted); border-color: var(--line); }
@media (max-width: 700px) { .footer { grid-template-columns: 1fr; text-align: center; } .footer-right { text-align: center; } }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-header h1 { margin: 0; }
.page-title-row { display: flex; align-items: center; gap: .1rem; flex-wrap: wrap; }
.page-header .subtitle { color: var(--muted); margin: .25rem 0 0; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.help-link {
  display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem;
  margin-left: .5rem; border-radius: 50%; border: 2px solid var(--link); color: var(--link);
  font-size: .95rem; font-weight: 700; text-decoration: none; vertical-align: middle;
}
.help-link:hover { background: var(--link); color: var(--surface); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.two-col { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem 1.25rem; margin: 0 0 1rem; box-shadow: var(--shadow); overflow-wrap: anywhere;
}
/* A card's first heading is its navy header band (Insight ACS style). */
.card > h2:first-child, .card > .card-header {
  margin: -1rem -1.25rem 1rem; padding: .65rem 1.25rem; background: var(--pw-header); color: #fff;
  border-radius: 7px 7px 0 0; font-size: 1.05rem; border-bottom: 1px solid var(--pw-border);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-header h2 { margin: 0; font-size: 1.05rem; color: #fff; }
.card-header a { color: #fff; }
.card.highlight { border: 2px solid var(--pw-accent); }
.card.danger-zone { border: 2px solid var(--pw-danger); }
/* -------------------------------------------- sign-in splash (Insight ACS login page)
   Black page, Pacewave splash logo centred behind a dimmed, blurred overlay, one white card.
   The card keeps the light palette in both themes, as ACS does. body.splash-intro (first view
   of /login only) plays the ACS opening: logo alone for 2 s, then overlay and card fade in.
   Pure CSS, so it needs no script and works under the strict CSP. */
body.splash {
  /* the ACS original, unscaled: a downscaled copy thins the fine lines and looks dim */
  background: #000 url("/static/img/logo-splash.png") center / 30% auto no-repeat fixed;
}
@media (max-width: 860px) { body.splash { background-size: 85% auto; } }
body.splash::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
body.splash .navbar, body.splash .footer { display: none; }
/* warnings stay above the dimmed overlay and readable */
body.splash .env-banner, body.splash .maint-banner { position: relative; z-index: 2; }
body.splash main.auth {
  position: relative; z-index: 1; max-width: none; margin: 0; padding: 2rem 1rem;
  display: flex; align-items: center; justify-content: center;
}
.splash .auth-card {
  --surface: #ffffff; --surface-2: #f8f9fa; --ink: #212529; --muted: #5c6670; --line: #cfd8e3;
  --link: #004080; --link-hover: #001a33; --focus: #1a73e8; --input-bg: #ffffff; --field-border: #6c757d;
  --primary: #004080; --primary-hover: #003366; --primary-ink: #ffffff;
  --ok-bg: #d1e7dd; --ok-ink: #0a3622; --warn-bg: #fff3cd; --warn-ink: #664d03;
  --bad-bg: #f8d7da; --bad-ink: #58151c; --info-bg: #e3effb; --info-ink: #002a55; --code-bg: #eef1f4;
  color-scheme: light; color: var(--ink);
  width: 100%; max-width: 26rem; margin: 0; padding: 2.5rem 2.25rem 1.5rem;
  background: rgba(255, 255, 255, .95); border: 0; border-radius: 15px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.auth-card .auth-head { text-align: center; margin-bottom: 1.5rem; }
.auth-card .auth-head img { width: 337px; max-width: 100%; height: auto; margin-bottom: .75rem; }
.auth-card .auth-title { margin: 0; font-size: 1.75rem; font-weight: 700; color: #333; text-shadow: 1px 1px 2px rgba(0, 0, 0, .1); }
.auth-card .auth-body h1 { font-size: 1.2rem; text-align: center; }
.auth-card .auth-foot { margin: 1.5rem 0 0; text-align: center; color: var(--muted); font-size: .8rem; }
/* ACS sign-in button: purple gradient. Bold 1.2rem counts as large text, so white on #667eea passes 3:1. */
.auth-card button[type="submit"]:not(.secondary):not(.link):not(.btn-link) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: 0; color: #fff;
  padding: .7rem 1rem; font-weight: 700; font-size: 1.2rem; transition: transform .2s, box-shadow .2s;
  width: 100%; justify-content: center; text-align: center;
}
.auth-card button[type="submit"]:not(.secondary):not(.link):not(.btn-link):hover {
  transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, .2); color: #fff;
}
.auth-card input:focus { border-color: #667eea; box-shadow: 0 0 0 .2rem rgba(102, 126, 234, .25); }
/* ACS login card details (Bootstrap 5 form look) */
.icon { display: inline-block; width: 1em; height: 1em; vertical-align: -.125em; flex: none; }
.acs-login { gap: 1rem; }
.auth-card .acs-field label { display: flex; flex-direction: row; align-items: center; gap: .35rem;
  font-weight: 400; margin-bottom: .5rem; }
.auth-card .acs-field input { width: 100%; padding: .375rem .75rem; font-size: 1rem; line-height: 1.5;
  border: 1px solid #dee2e6; border-radius: .375rem; background: #fff; color: #212529; }
.input-group { display: flex; }
.input-group input { flex: 1; min-width: 0; border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.input-group .input-addon { display: inline-flex; align-items: center; padding: .375rem .75rem; margin: 0;
  border: 1px solid #6c757d; border-left: 0; border-radius: 0 .375rem .375rem 0; background: transparent;
  color: #6c757d; font-size: 1rem; cursor: pointer; }
.input-group .input-addon:hover { background: #6c757d; color: #fff; }
.auth-card button[type="submit"].acs-login-button:not(.secondary) { display: inline-flex; gap: .35rem; align-items: center; justify-content: center;
  margin-top: .5rem; padding: .75rem; font-size: 1rem; border-radius: .375rem; }
.acs-request { text-align: center; margin: 1rem 0 0; font-size: .875rem; }
.acs-request a { color: #6610f2; text-decoration: none; }
.acs-request a:hover { text-decoration: underline; }
.acs-hint { margin: .75rem 0 0; color: #6c757d; font-size: .75rem; text-align: center; }
.acs-notice { margin-top: 1rem; padding: .5rem .75rem; font-size: .75rem; line-height: 1.4; color: #212529;
  background: #e2e3e5; border: 1px solid #c4c8cb; border-radius: .375rem; }
.auth-card .acs-legal { margin-top: .75rem; color: #495057; font-size: .875rem; line-height: 1.4; }
.auth-card .acs-legal span { font-size: .7rem; }
body.splash-intro::before { animation: splash-dim .5s ease 2s both; }
body.splash-intro .auth-card { animation: splash-card .5s ease 2s both; }
@keyframes splash-dim {
  from { background: rgba(0, 0, 0, 0); -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); }
  to { background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
}
@keyframes splash-card { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  body.splash-intro::before, body.splash-intro .auth-card { animation: none; }
}
.stat { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ------------------------------------------------------------------- forms */
.stack { display: flex; flex-direction: column; gap: .85rem; }
.stack label, .field label, label.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.form-grid { display: grid; gap: .85rem 1rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.form-hint, .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--input-bg); padding: .45rem .65rem;
  border: 1px solid var(--field-border); border-radius: 5px; min-height: 2.4rem; max-width: 100%;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
textarea { min-height: 8rem; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--pw-danger); }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters label { font-weight: 600; font-size: .85rem; display: flex; flex-direction: column; gap: .2rem; }

button, .button {
  font: inherit; font-weight: 500; padding: .5rem 1rem; border: 1px solid var(--primary); border-radius: 5px;
  background: var(--primary); color: var(--primary-ink); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem; line-height: 1.3; min-height: 2.4rem;
}
button:hover, .button:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
button.secondary, .button.secondary { background: transparent; color: var(--link); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); color: var(--link); }
button.danger, .button.danger { background: var(--pw-danger); border-color: var(--pw-danger); color: #fff; }
button.danger:hover { background: #b02a37; border-color: #b02a37; }
button.small, .button.small { padding: .2rem .6rem; font-size: .85rem; min-height: 1.9rem; }
button.link { background: none; border: 0; color: inherit; padding: 0; text-decoration: underline; min-height: 0; }
form.inline { display: inline-flex; gap: .3rem; align-items: center; margin: 0 .3rem .3rem 0; flex-wrap: wrap; }

/* ------------------------------------------------------------ alerts/badges */
.alert { padding: .65rem .9rem; border-radius: 6px; border: 1px solid transparent; border-left-width: 5px; margin: 0 0 1rem; }
.alert-error, .alert-danger { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--pw-danger); }
.alert-ok, .alert-success { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--pw-success); }
.alert-warning { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--pw-warning); }
.alert-info { background: var(--info-bg); color: var(--info-ink); border-color: var(--primary); }
.alert a { color: inherit; font-weight: 600; }
.badge {
  display: inline-block; padding: .12rem .5rem; font-size: .78rem; font-weight: 600; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; vertical-align: middle;
}
.badge-primary { background: var(--pw-border); color: #fff; }
.badge-info { background: var(--info-bg); color: var(--info-ink); border-color: var(--primary); }
.badge-success { background: var(--pw-success); color: #fff; }
.badge-warning { background: var(--pw-warning); color: #212529; }
.badge-danger { background: var(--pw-danger); color: #fff; }
.badge-muted { background: var(--pw-muted); color: #fff; }
.badge-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.label-chip { display: inline-block; padding: 0 .45rem; margin: 0 .2rem .2rem 0; border-radius: 4px; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.muted { color: var(--muted); }
.small-text { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 1rem; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap .table { margin: 0; }
.table th, .table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.table thead th { background: var(--pw-header); color: #fff; font-weight: 600; border-bottom: 2px solid var(--pw-border); white-space: nowrap; }
.table tbody tr:nth-child(even) { background: var(--surface-2); }
.table tbody tr:hover { background: var(--info-bg); }
.table td.num, .table th.num { text-align: right; }
.actions { white-space: normal; }

/* ----------------------------------------------------- auth pages, MFA */
.qr { display: block; background: #fff; border: 1px solid var(--line); padding: 6px; }
.secret { word-break: break-all; font-size: 1.05rem; }
.codes { columns: 2; font-size: 1.1rem; }

/* -------------------------------------------------------- to-do tracker */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .25rem 0 .75rem 1rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .55rem; width: 11px; height: 11px; border-radius: 50%; background: var(--pw-border); }
.comment { border: 1px solid var(--line); border-radius: 6px; padding: .6rem .9rem; margin-bottom: .75rem; background: var(--surface-2); }
.comment-meta { font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.meta-list dt { font-weight: 600; color: var(--muted); }
.meta-list dd { margin: 0; }

/* ----------------------------------------------------------------- help */
.help-layout { display: grid; gap: 1.5rem; grid-template-columns: 15rem minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .help-layout { grid-template-columns: minmax(0, 1fr); } }
.help-toc { list-style: none; margin: 0; padding: 0; }
.toc-title { font-weight: 700; font-size: 1.1rem; margin: 0 0 .5rem; }
.help-toc li { margin: 0; }
.help-toc a { display: block; padding: .3rem .5rem; border-radius: 4px; text-decoration: none; }
.help-toc a[aria-current="page"] { background: var(--pw-header); color: #fff; }
.help-toc .sub { padding-left: 1.25rem; font-size: .88rem; }
.help-body { max-width: 52rem; }
.help-body h1 { margin-top: 0; }
.help-body h2 { border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.help-body table { width: 100%; border-collapse: collapse; margin: .75rem 0 1rem; }
.help-body th, .help-body td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; vertical-align: top; }
.help-body th { background: var(--pw-header); color: #fff; }
.help-body blockquote { margin: 1rem 0; padding: .5rem 1rem; border-left: 4px solid var(--pw-accent); background: var(--info-bg); color: var(--info-ink); }

/* --------------------------------------------------------- estate screens */
.stats .stat-card { margin: 0; }
.stat-card p { margin: .4rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.stat-card a { text-decoration: none; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin: -.25rem 0 1rem; }
.pager-links { display: inline-flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.text-danger { color: var(--pw-danger); font-weight: 600; }
:root[data-theme="dark"] .text-danger { color: #ff8a95; }
.text-warning { color: var(--warn-ink); font-weight: 600; }
code.mac { font-size: .82rem; letter-spacing: .02em; }
code.hex { display: inline-block; max-width: 28rem; font-size: .78rem; word-break: break-all; white-space: normal; }
ul.compact { list-style: none; margin: .3rem 0 0; padding: 0; }
ul.compact li { margin: .15rem 0; }
.compact-form { gap: .35rem; min-width: 12rem; }
.compact-form select, .compact-form input { min-height: 2rem; padding: .25rem .45rem; font-size: .88rem; }
.table tbody tr.row-error { background: var(--bad-bg); }
.table tbody tr.row-gap td { text-align: center; font-style: italic; }
label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 600; flex-wrap: wrap; }
label.check input { min-height: 0; }
details > summary { cursor: pointer; color: var(--link); }
details[open] > summary { margin-bottom: .4rem; }
.spark { margin: .5rem 0 1rem; }
.sparkline { display: block; width: 100%; height: 8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; }
.spark-line { fill: none; stroke: var(--primary); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-axis { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--primary); }
.card.highlight .alert { margin-top: .25rem; }

@media print {
  .navbar, .footer, .skip-link, .help-link, .page-actions, form { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------ monitoring screens */
.status-row.status-green td:first-child { box-shadow: inset 4px 0 0 var(--pw-success); }
.status-row.status-amber td:first-child { box-shadow: inset 4px 0 0 var(--pw-warning); }
.status-row.status-red td:first-child { box-shadow: inset 4px 0 0 var(--pw-danger); }
.status-row.status-none td:first-child { box-shadow: inset 4px 0 0 var(--pw-muted); }
.status-row.status-few td:first-child { box-shadow: inset 4px 0 0 var(--pw-muted); }
.status-card { border-left-width: 5px; }
.status-card.status-green { border-left-color: var(--pw-success); }
.status-card.status-amber { border-left-color: var(--pw-warning); }
.status-card.status-red { border-left-color: var(--pw-danger); }
.status-card.status-none { border-left-color: var(--pw-muted); }
.status-card > .card-header .badge { border: 1px solid rgba(255, 255, 255, .5); }
.health-grid { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); margin-bottom: 1rem; }
.health-grid .card { margin: 0; }
.status-badge { min-width: 6.5rem; text-align: center; }
ol.stage-ticks { list-style: none; display: flex; gap: 3px; margin: 0; padding: 0; }
ol.stage-ticks li, .stage-legend .tick {
  width: .9rem; height: .9rem; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--pw-success); background: var(--pw-success);
}
.stage-legend .tick { display: inline-block; vertical-align: -.1rem; }
/* not reached: no fill AND a dashed outline (second cue), >= 3:1 against the surface */
ol.stage-ticks li.missing, .stage-legend .tick.missing {
  background: transparent; border: 2px dashed var(--muted);
}
code.trace-id { font-size: .8rem; }
.trace-steps { list-style: none; margin: 0; padding: 0; }
.trace-step { border-left: 3px solid var(--pw-success); padding: .35rem 0 .75rem 1rem; position: relative; }
.trace-step::before { content: ""; position: absolute; left: -7px; top: .6rem; width: 11px; height: 11px; border-radius: 50%; background: var(--pw-success); }
.trace-step.trace-error { border-left-color: var(--pw-danger); }
.trace-step.trace-error::before { background: var(--pw-danger); }
.trace-step-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.table tbody tr.row-gap { background: var(--warn-bg); color: var(--warn-ink); }
svg.bars { display: block; width: 100%; height: 8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; }
svg.bars .bar-ok { fill: var(--primary); }
svg.bars .bar-bad { fill: var(--pw-danger); }
.hidden-empty { display: none; }

/* ------------------------------------------------------ form errors (A11Y) */
.field-error { display: block; color: var(--bad-ink); font-weight: 600; font-size: .85rem; margin-top: .2rem; }
[aria-invalid="true"] { border-color: var(--pw-danger); box-shadow: 0 0 0 1px var(--pw-danger); }
.error-summary ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.error-summary p { margin: 0; }

/* self-refreshing pages (R2 UX2-1) */
.refresh-note { margin-top: 1.5rem; }
button.btn-link { background: none; border: 0; color: var(--link); padding: 0; min-height: 0; text-decoration: underline; font-weight: 400; }
button.btn-link:hover { background: none; color: var(--link-hover); }

/* R6: empty lists with a next step; notes on the gateway page */
.empty-state p { margin: 0 0 .5rem; }
.empty-state p:last-child { margin-bottom: 0; }
.status-note { margin-top: .25rem; color: var(--muted); }
.support-contact { margin-top: 1rem; }
.table tbody tr.row-done { background: var(--ok-bg); }

/* ------------------------------------------------------------- trend charts (charts.py) */
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: .375rem; overflow: hidden; }
.segmented a { padding: .25rem .75rem; text-decoration: none; color: var(--ink); font-size: .9rem; }
.segmented a + a { border-left: 1px solid var(--line); }
.segmented a[aria-current="true"] { background: var(--primary); color: var(--primary-ink); }
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); gap: 1rem; }
.trend-figure { margin: 0; }
.trend-figure figcaption { font-size: .9rem; margin-bottom: .25rem; }
.trend-latest { float: right; font-weight: 700; }
svg.trend { display: block; height: auto; background: var(--surface-2); border-radius: 4px; }
svg.trend.compact { height: auto; }
svg.trend .line { fill: none; stroke: #1a73e8; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
svg.trend .band { fill: rgba(26, 115, 232, .16); stroke: none; }
svg.trend .dot { fill: #1a73e8; }
svg.trend .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.trend .axis { fill: var(--muted); font-size: 10px; }
svg.trend .zone-ok { fill: rgba(25, 135, 84, .14); }
svg.trend .zone-warn { fill: rgba(255, 193, 7, .28); }
svg.trend .zone-bad { fill: rgba(220, 53, 69, .28); }
.two-col > .span-all { grid-column: 1 / -1; }
html[data-theme="dark"] svg.trend .line { stroke: #66b3ff; }
html[data-theme="dark"] svg.trend .band { fill: rgba(102, 179, 255, .18); }
html[data-theme="dark"] svg.trend .dot { fill: #66b3ff; }
.trend-state { margin: .25rem 0 .75rem; }
.equipment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1rem; }
.equipment-card h2 { font-size: 1.05rem; margin: 0 0 .15rem; }
.equipment-card p { margin: .35rem 0; }
.compact-list { font-size: .85rem; margin-top: .5rem; }
.filter-row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }

/* Onward streaming, new destination (PW-IOT-015 §7.2a): show only the chosen kind's
   settings. Without :has() support both fieldsets show, each labelled with its kind. */
form:has([data-kind-select] .kind-opt-web:checked) .kind-kafka,
form:has([data-kind-select] .kind-opt-kafka:checked) .kind-web { display: none; }
.kind-fields { margin: 0; }
