:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dde1e7;
  --accent: #2a5bd7;
  --accent-text: #ffffff;
  --blocking: #b42318;
  --blocking-bg: #fdecea;
  --major: #b54708;
  --major-bg: #fdf1e3;
  --advisory: #3b5bab;
  --advisory-bg: #e9eefb;
  --ok: #18794e;
  --ok-bg: #e5f4ec;
  --neutral-bg: #eceff3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #181c21;
    --surface-2: #20252c;
    --text: #e6e9ed;
    --muted: #9aa4b1;
    --border: #2c333c;
    --accent: #7ea2ff;
    --accent-text: #0d1117;
    --blocking: #ff8a80;
    --blocking-bg: #3a1d1b;
    --major: #ffb870;
    --major-bg: #3a2a17;
    --advisory: #a9bcff;
    --advisory-bg: #1f2945;
    --ok: #6fd3a3;
    --ok-bg: #16322a;
    --neutral-bg: #262c34;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.01em; }
a.brand { color: inherit; text-decoration: none; border-radius: 6px; }
a.brand:hover { opacity: 0.85; }
a.brand:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.brand .abbr { color: var(--muted); font-weight: 500; font-size: 13px; }
@media (max-width: 560px) { .brand .name { display: none; } .brand .abbr { color: inherit; font-weight: 700; font-size: 15px; letter-spacing: 0.04em; } }
.mark { width: 24px; height: 24px; display: block; flex: none; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }

.btn {
  display: inline-flex; align-items: center; border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn:focus-visible, .agent:focus-visible, .tab:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.login {
  max-width: 420px; margin: 10vh auto 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 6px; font-size: 22px; }
.login p { margin: 0 0 18px; color: var(--muted); }
.login label { display: block; font-weight: 600; margin-bottom: 6px; }
.login input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  margin-bottom: 14px;
}
.error-text { color: var(--blocking); min-height: 1.5em; margin: 0 0 8px; }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.agents { padding: 8px; }
.agents h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 10px; }
.agent {
  display: block; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 8px;
  padding: 10px; cursor: pointer;
}
.agent:hover { background: var(--surface-2); }
.agent[aria-current="true"] { background: var(--surface-2); border-color: var(--border); }
.agent .name { font-weight: 600; display: block; overflow-wrap: anywhere; }
.agent .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; align-items: center; }

.pill {
  display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; font-weight: 600;
  background: var(--neutral-bg); color: var(--muted); white-space: nowrap;
}
.pill.blocking, .pill.notPassed, .pill.belowStandard, .pill.scanWithheld { background: var(--blocking-bg); color: var(--blocking); }
.pill.major, .pill.needsAttention, .pill.underReview, .pill.notFinalised { background: var(--major-bg); color: var(--major); }
.pill.advisory { background: var(--advisory-bg); color: var(--advisory); }
.pill.passed, .pill.meetsStandard, .pill.scanEligible { background: var(--ok-bg); color: var(--ok); }

.detail { padding: 20px; min-width: 0; }
.detail-head { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: space-between; align-items: flex-start; }
.detail-head h1 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.detail-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-width: 100%; }
.outcome { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.outcome .pill { font-size: 14px; padding: 4px 12px; }

.reasons { margin: 14px 0 0; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); }
.reasons h3 { margin: 0 0 6px; font-size: 14px; }
.reasons ul { margin: 0; padding-left: 18px; }
.reasons li { margin: 2px 0; }
.reasons .code { color: var(--muted); font-size: 13px; margin-right: 6px; }
.reasons .why { color: var(--muted); display: block; font-size: 13.5px; }

.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.tile .n { font-size: 24px; font-weight: 700; line-height: 1.2; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.blocking .n { color: var(--blocking); }
.tile.major .n { color: var(--major); }
.tile.advisory .n { color: var(--advisory); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 6px; overflow-x: auto; }
.tab {
  border: none; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { margin-left: 6px; font-size: 12px; background: var(--neutral-bg); border-radius: 999px; padding: 0 7px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13.5px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.search { flex: 1 1 200px; min-width: 0; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td .title { font-weight: 600; }
td .ref { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
td .outcomes { margin: 6px 0 0; padding-left: 18px; color: var(--blocking); font-size: 13.5px; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date { font-variant-numeric: tabular-nums; min-width: 9em; }
.msg { display: block; min-width: 16ch; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; overflow-wrap: break-word; color: var(--muted); }

.areas { display: grid; gap: 8px; margin-top: 14px; }
.area-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 120px; gap: 12px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
@media (max-width: 640px) { .area-row { grid-template-columns: minmax(0, 1fr) auto; } .area-row .bar { display: none; } }
.bar { height: 6px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

.timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 640px) { .timeline li { grid-template-columns: 1fr; gap: 2px; } }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13.5px; }

.empty { padding: 28px; text-align: center; color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin-top: 18px; }

/* testing key (client) */
.keybox { margin: 16px 0 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.keybox h3 { margin: 0 0 4px; font-size: 15px; }
.keybox .sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 10px; }
.keyline { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 6px; }
.keyform { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; align-items: end; }
@media (max-width: 640px) { .keyform { grid-template-columns: 1fr; } }
.keyform .field { display: grid; gap: 4px; min-width: 0; }
.keyform .field.wide { grid-column: 1 / -1; }
.keyform label { font-weight: 600; font-size: 13.5px; }
.keyform input, .keyform select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.keyform .check { grid-column: 1 / -1; font-weight: 400; display: flex; gap: 8px; align-items: center; }
.keyform .check input { width: auto; }
.keyform .error-text, .keyform .head-actions { grid-column: 1 / -1; }
.pill.keyon { background: var(--advisory-bg); color: var(--advisory); }
.btn.danger { color: var(--blocking); border-color: var(--blocking); }

/* admin */
.integrity { margin: 8px 0 0; font-size: 13.5px; }
.integrity.ok { color: var(--ok); }
.integrity.bad { color: var(--blocking); font-weight: 600; }
.linkish { border: none; background: none; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; }
.linkish:hover { text-decoration: underline; }
.section-title { margin: 22px 0 8px; font-size: 16px; }
h2.section-title { font-size: 18px; }
.toolbar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-width: 100%; }


/* admin: access keys */
details.keybox > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.keybox > summary::-webkit-details-marker { display: none; }
details.keybox > summary::before { content: "+"; font-weight: 700; color: var(--accent); width: 1em; }
details.keybox[open] > summary::before { content: "\2212"; }
details.keybox > summary h3 { margin: 0; }
details.keybox[open] > summary { margin-bottom: 8px; }
.keybox details > summary { cursor: pointer; color: var(--accent); margin: 10px 0 6px; }
.keybox .table-wrap { background: var(--surface); }
.keydialog {
  max-width: 560px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 22px; box-shadow: 0 12px 40px rgba(16, 24, 40, 0.25);
}
.keydialog::backdrop { background: rgba(16, 24, 40, 0.55); }
.keydialog h2 { margin: 0 0 6px; font-size: 19px; }
.keydialog p { margin: 0 0 10px; }
.keydialog .warn { color: var(--major); background: var(--major-bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.keydialog .secret {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px;
}
.keydialog .sub { color: var(--muted); font-size: 13.5px; min-height: 1.4em; margin: 6px 0 12px; }

/* sign-up, sign-in and agent setup */
button, input, select, textarea { font: inherit; color: inherit; }
.login-tabs { margin: -8px 0 16px; }
.login .sub { color: var(--muted); font-size: 13.5px; margin: 12px 0 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.banner { margin: 0 0 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--advisory-bg); color: var(--text); border: 1px solid var(--border); }
.onboarding { max-width: 860px; margin: 0 auto; }
.onboarding h1 { margin: 0 0 4px; font-size: 22px; }
.steps { margin: 16px 0 18px; padding-left: 22px; display: grid; gap: 6px; }
ul.plain { margin: 6px 0 0; padding-left: 18px; }
.addagent { display: grid; gap: 6px; max-width: 520px; margin: 8px 0 4px; }
.addagent label { font-weight: 600; font-size: 13.5px; }
.addagent input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.addagent .btn { justify-self: start; }
.addagent .error-text { margin: 0; min-height: 0; }
.addagent.compact { margin: 12px 10px 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.setup .keybox h3 { margin-bottom: 8px; }
.subbox { margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); }
.subbox h4 { margin: 0 0 6px; font-size: 14px; }
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
legend, .keyform .label { font-weight: 600; font-size: 13.5px; padding: 0; margin-bottom: 6px; }
.choices { display: grid; gap: 6px; margin: 6px 0 14px; }
.choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.choice input { margin-top: 4px; }
.choice .pill { margin-left: 8px; }
.choice.off { opacity: 0.55; cursor: not-allowed; }
.ref.block { display: block; margin-top: 2px; }
.keyform textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); resize: vertical; }
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.row > input { grid-column: 1; }
.row > .inline { grid-column: 1; }
.row > .btn { grid-column: 2; grid-row: 1; }
.row:has(> input + input) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.row:has(> input + input) > input + input { grid-column: 2; grid-row: 1; }
.row:has(> input + input) > .btn { grid-column: 3; }
.rows > .btn { justify-self: start; }
.inline { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.stack { display: grid; gap: 6px; }
.keyform .inline .check, .keyform .stack .check { grid-column: auto; }
.ok-text { color: var(--ok); margin: 10px 0 0; }
.head-actions.end { justify-content: flex-end; margin-top: 16px; }
@media (max-width: 640px) {
  .row:has(> input + input) { grid-template-columns: 1fr auto; }
  .row:has(> input + input) > input + input { grid-column: 1; grid-row: 2; }
  .row:has(> input + input) > .btn { grid-column: 2; grid-row: 1; }
}
.subbox .sensorid { overflow-wrap: anywhere; max-width: 12ch; }
