/* TierTek Monitoring -- staff UI theme (Task 19d). Tokens from https://www.tiertek.com/ds/colors_and_type.css.
   Self-hosted fonts only (CSP is self-only); licences in /fonts/OFL-*.txt, sources in ASSETS.md. */

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/dm-sans-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('/fonts/playfair-display-latin.woff2') format('woff2');
}

:root {
  --navy: #0b2a58; --navy-dark: #071d3d; --navy-mid: #0d3268; --navy-light: #163d7a;
  --gold: #bc8939; --gold-dark: #9e7130; --gold-light: #d4a455; --gold-pale: #e8c98a;
  --bg-page: #f8f3eb; --bg-section: #f3e8da; --white: #fefefe;
  --text-heading: #0b2a58; --text-body: #2c3e55; --text-muted: #5a6a7e; --text-inverse: #fefefe;
  --border: rgba(11, 42, 88, 0.12); --border-strong: rgba(11, 42, 88, 0.25);
  --success: #1a6e3c; --success-bg: #e8f5ed;
  --warning: #bc8939; --warning-bg: #fdf3e3;
  --error: #a02020; --error-bg: #fde8e8;
  --info: #0b2a58; --info-bg: #e6ecf5;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: Consolas, Menlo, 'Courier New', monospace;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px;
  --shadow-sm: 0 2px 6px rgba(11, 42, 88, 0.08); --shadow-md: 0 4px 16px rgba(11, 42, 88, 0.10);
  --focus: 0 0 0 3px var(--gold-light);
  /* Task 19e: semantic roles, so the dark scheme below only swaps token values (light values = the 19d look). */
  color-scheme: light;
  --surface: var(--white); --row-alt: rgba(243, 232, 218, 0.35);
  --accent: var(--navy); --on-accent: var(--text-inverse); --accent-hover: var(--gold); --on-accent-hover: var(--navy-dark);
  --nav-text: var(--navy); --link: var(--navy-light); --link-hover: var(--gold-dark); --badge-warn-text: var(--gold-dark);
  --logo-panel: transparent; --logo-pad: 0;
}

/* ---- dark scheme (Task 19e): "system" follows the browser; data-theme on <html> is an explicit per-user choice.
   The same token set appears twice because a media query cannot share one rule with a plain selector. Navy
   surfaces, light text, gold accents; body text and button colour pairs meet WCAG AA. tiertek.com publishes no
   light/white logo variant, so the logo sits on a light panel (--logo-panel) rather than being recoloured. ------ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-page: #071d3d; --bg-section: #0d3268; --surface: #0b2a58; --row-alt: rgba(254, 254, 254, 0.04);
    --text-heading: #fefefe; --text-body: #e9eef5; --text-muted: #b3c0d1; --text-inverse: #071d3d;
    --border: rgba(254, 254, 254, 0.14); --border-strong: rgba(254, 254, 254, 0.30);
    --accent: #d4a455; --on-accent: #071d3d; --accent-hover: #e8c98a; --on-accent-hover: #071d3d;
    --nav-text: #fefefe; --link: #e8c98a; --link-hover: #d4a455; --badge-warn-text: #e8c98a;
    --success: #86d9a2; --success-bg: #103a26; --warning: #d4a455; --warning-bg: #3a2c12;
    --error: #ff9e9e; --error-bg: #4a1c1f; --info: #b9cdee; --info-bg: #163d7a;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35); --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --logo-panel: #f8f3eb; --logo-pad: 4px 8px;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #071d3d; --bg-section: #0d3268; --surface: #0b2a58; --row-alt: rgba(254, 254, 254, 0.04);
  --text-heading: #fefefe; --text-body: #e9eef5; --text-muted: #b3c0d1; --text-inverse: #071d3d;
  --border: rgba(254, 254, 254, 0.14); --border-strong: rgba(254, 254, 254, 0.30);
  --accent: #d4a455; --on-accent: #071d3d; --accent-hover: #e8c98a; --on-accent-hover: #071d3d;
  --nav-text: #fefefe; --link: #e8c98a; --link-hover: #d4a455; --badge-warn-text: #e8c98a;
  --success: #86d9a2; --success-bg: #103a26; --warning: #d4a455; --warning-bg: #3a2c12;
  --error: #ff9e9e; --error-bg: #4a1c1f; --info: #b9cdee; --info-bg: #163d7a;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35); --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --logo-panel: #f8f3eb; --logo-pad: 4px 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg-page); color: var(--text-body);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.55;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--text-heading); line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; margin-top: 2rem; }
h3 { font-size: 1.15rem; font-weight: 600; margin-top: 1.5rem; }
h1 small { font-family: var(--font-body); font-size: 1rem; font-weight: 400; color: var(--text-muted); margin-left: .5rem; }
p { margin: 0 0 1rem; }
a { color: var(--link); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus);
}
code { font-family: var(--font-mono); font-size: .9em; background: var(--bg-section); padding: .1em .35em; border-radius: var(--radius-sm); word-break: break-all; }
.muted { color: var(--text-muted); }
.lead { font-size: 1.05rem; color: var(--text-muted); }
.inline { display: inline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header ---------------------------------------------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.site-header .bar {
  max-width: 1100px; margin: 0 auto; padding: .6rem 1.5rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--nav-text); }
.brand img, .auth-page .auth-logo {
  box-sizing: content-box; background: var(--logo-panel); padding: var(--logo-pad); border-radius: var(--radius-md);
}
.brand img { height: 40px; width: auto; display: block; }
.brand .product {
  font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--nav-text);
  border-left: 2px solid var(--gold); padding-left: .75rem;
}
.main-nav { display: flex; align-items: center; gap: 1.25rem; margin-left: auto; flex-wrap: wrap; }
.main-nav a {
  color: var(--nav-text); font-weight: 500; font-size: .95rem; text-decoration: none;
  border-bottom: 2px solid transparent; padding: .25rem 0;
}
.main-nav a:hover { border-bottom-color: var(--gold-light); color: var(--nav-text); }
.main-nav a[aria-current="page"] { border-bottom-color: var(--gold); }

/* ---- page body ------------------------------------------------------------------------------------- */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.subnav { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.5rem; padding: 0; list-style: none; }
.subnav a {
  display: inline-block; padding: .3rem .8rem; border: 1px solid var(--border-strong); border-radius: 999px;
  text-decoration: none; color: var(--nav-text); background: var(--surface); font-size: .9rem;
}
.subnav a:hover { border-color: var(--gold); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 1.5rem; margin: 0 0 1.5rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.site-footer { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 0 1rem 2rem; }

/* ---- centred card pages (sign-in, setup, public links) ------------------------------------------- */
.auth-page { display: flex; flex-direction: column; align-items: center; padding: 3rem 1rem; }
.auth-page .auth-logo { display: block; height: 52px; width: auto; margin: 0 auto 1.5rem; }
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border);
  border-top: 4px solid var(--gold); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2rem;
}
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .auth-signout { margin-top: 1.5rem; }

/* ---- forms ----------------------------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 1rem; max-width: 30rem; }
.stack.wide { max-width: 42rem; }
.stack label, .row label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; color: var(--text-heading); font-size: .95rem; }
.stack label .hint, .row label .hint { font-weight: 400; color: var(--text-muted); font-size: .85rem; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; margin: 0 0 1rem; }
.row label { flex: 1 1 12rem; max-width: 24rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; color: var(--text-body); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: .75rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
legend { font-weight: 600; color: var(--text-heading); padding: 0 .35rem; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
  width: 100%; font: inherit; color: var(--text-body); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: .55rem .7rem; min-height: 2.6rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--link); }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

/* ---- buttons: navy primary with gold hover; outlined secondary ------------------------------------ */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  font-size: .95rem; line-height: 1.2; cursor: pointer; text-decoration: none; min-height: 2.6rem;
  padding: .55rem 1.2rem; border-radius: var(--radius-md); border: 2px solid var(--accent);
  background: var(--accent); color: var(--on-accent); transition: background-color 150ms, border-color 150ms, color 150ms;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent-hover); }
.btn-secondary { background: transparent; color: var(--nav-text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-section); border-color: var(--gold); color: var(--nav-text); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.btn-small { min-height: 2rem; padding: .25rem .7rem; font-size: .85rem; }
.site-header button { min-height: 2.2rem; padding: .35rem .9rem; }

/* ---- callouts ---------------------------------------------------------------------------------------- */
.callout { border: 1px solid; border-left-width: 4px; border-radius: var(--radius-md); padding: .75rem 1rem; margin: 0 0 1.25rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-error { color: var(--error); background: var(--error-bg); border-color: var(--error); }
.callout-success { color: var(--success); background: var(--success-bg); border-color: var(--success); }
.callout-warning { color: var(--text-body); background: var(--warning-bg); border-color: var(--warning); }
.callout-info { color: var(--info); background: var(--info-bg); border-color: var(--info); }

/* ---- tables ------------------------------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin: 0 0 1.5rem; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th { background: var(--bg-section); color: var(--text-heading); font-weight: 600; text-align: left; white-space: nowrap; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--text-muted); padding: 1.5rem; font-style: italic; }
td.actions { white-space: nowrap; }
td.actions form + form { margin-left: .35rem; }
/* Client sign-in rows: one line per command, a rule between them, so each "Type Confirm" box reads with its own
   button, and controls at their natural width instead of the form-wide 100% (Bob 2026-10-28). */
td.commands { min-width: 18rem; }
td.commands form { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; }
td.commands form + form { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }
td.commands select, td.commands input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) { width: auto; min-height: 2rem; padding: .25rem .5rem; }
td code { word-break: break-word; }
/* Staff list: one group per role, each headed by an accent band, with a page-coloured gap between groups so each
   reads as its own box (Bob 2026-10-26). */
tr.group-label th { background: var(--accent); color: var(--on-accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; padding: .45rem .8rem; }
tbody.role-group + tbody.role-group tr.group-label th { border-top: 1.25rem solid var(--bg-page); }

/* ---- status badges ----------------------------------------------------------------------------------- */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--info-bg); color: var(--info); }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--badge-warn-text); }
.badge-bad { background: var(--error-bg); color: var(--error); }

/* ---- theme picker (Task 19e) ------------------------------------------------------------------------- */
.theme-picker { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.theme-picker label { display: inline-flex; flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; font-weight: 500; color: var(--nav-text); }
.theme-picker select { width: auto; min-height: 2.2rem; padding: .3rem .5rem; }
.js .js-hide { display: none; }

/* ---- public alarm acknowledgement (Task 19e) ---------------------------------------------------------- */
.reading { font-size: 1.3rem; font-weight: 700; color: var(--text-heading); margin: 0 0 1rem; }
.ack-action, .ack-result { margin-top: 1.5rem; }

/* ---- definition list (My account) ------------------------------------------------------------------ */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0; }
dl.facts dt { font-weight: 600; color: var(--text-heading); }
dl.facts dd { margin: 0; }

/* ---- authenticator enrolment (setup + reset) ------------------------------------------------------- */
.enrol { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; margin: 0 0 1.25rem; }
.enrol .qr { width: 220px; height: 220px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: #ffffff; }
.enrol .manual { flex: 1 1 14rem; min-width: 0; }
.secret-key { display: block; font-family: var(--font-mono); font-size: 1.1rem; letter-spacing: .05em; background: var(--bg-section); padding: .5rem .7rem; border-radius: var(--radius-md); word-spacing: .3em; }
.otp-link { font-size: .85rem; }

@media (max-width: 700px) {
  h1 { font-size: 1.6rem; }
  .site-header .bar { padding: .6rem 1rem; gap: .75rem; }
  .brand img { height: 32px; }
  .main-nav { margin-left: 0; width: 100%; gap: .9rem; }
  .container { padding: 1.25rem 1rem 3rem; }
  .stack, .stack.wide { max-width: none; }
  .row label { flex-basis: 100%; max-width: none; }
  .auth-page { padding: 1.5rem .75rem; }
  .auth-card { padding: 1.25rem; }
  .enrol .qr { width: 100%; max-width: 260px; height: auto; margin: 0 auto; }
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dd { margin-bottom: .5rem; }
}
.subnav a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.card > p.muted:last-child { margin: 1.25rem 0 0; }

/* Audit log (Bob 2026-10-27): plain-words entries, small grey codes, field lists instead of JSON; cards on phones. */
.audit-filters label.check { flex: 0 0 auto; flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; }
table.audit td { vertical-align: top; }
.audit-code { color: var(--text-muted); font-size: .8rem; margin-top: .15rem; overflow-wrap: anywhere; }
.audit-changes { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.audit-changes li { overflow-wrap: anywhere; }
.pager { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }
@media (max-width: 760px) {
  table.audit thead { display: none; }
  table.audit, table.audit tbody, table.audit tr, table.audit td { display: block; width: 100%; }
  table.audit tr { border-bottom: 1px solid var(--border-strong); padding: .5rem 0; }
  table.audit td { border: 0; padding: .15rem .8rem; }
  table.audit td::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
}

/* ---- public advertisement page (design 2026-10-28): own tokens only, nothing from outside ------------------ */
.main-nav a.btn { border: 2px solid var(--border-strong); padding: .35rem .9rem; }
.main-nav a.btn:hover { border-color: var(--gold); }
.public .hero { padding: 2.5rem 0 1rem; max-width: 46rem; }
.public .hero h1 { font-size: 2.4rem; }
.public .steps ol { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; padding-left: 1.25rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.25rem; }
.product-grid .product h3 { margin-bottom: .25rem; }
.product-grid .product ul { padding-left: 1.25rem; margin-bottom: 0; }
@media (max-width: 640px) { .public .hero h1 { font-size: 1.8rem; } .product-grid { grid-template-columns: 1fr; } }

/* ---- DEV banner: on every page when Monitoring:Banner is set (dev only) ------------------------------------- */
.env-banner { background: var(--warning-bg); color: var(--text-heading); border-bottom: 3px solid var(--warning); text-align: center; font-weight: 700; letter-spacing: .12em; padding: .3rem 1rem; }
