:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1b2430; --muted: #657186; --line: #e2e6ec;
  --brand: #1f5fd1; --brand-ink: #ffffff; --ok: #15803d; --ok-bg: #dcfce7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --warn: #92400e; --warn-bg: #fef3c7; --none: #d6dbe3; --hover: #f0f4fb;
  --radius: 8px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b; --panel: #1a2029; --ink: #e6ebf2; --muted: #9aa6b8; --line: #2b3441;
    --brand: #5b8def; --ok: #4ade80; --ok-bg: #12301f; --bad: #f87171; --bad-bg: #3a1717;
    --warn: #fbbf24; --warn-bg: #3a2c0c; --none: #3a4352; --hover: #222a36;
  }
}
:root[data-theme="dark"] {
  --bg: #11151b; --panel: #1a2029; --ink: #e6ebf2; --muted: #9aa6b8; --line: #2b3441;
  --brand: #5b8def; --ok: #4ade80; --ok-bg: #12301f; --bad: #f87171; --bad-bg: #3a1717;
  --warn: #fbbf24; --warn-bg: #3a2c0c; --none: #3a4352; --hover: #222a36;
}
:root { color-scheme: light dark; } :root[data-theme="light"] { color-scheme: light; } :root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0 12px; } h2 { font-size: 17px; margin: 16px 0 8px; } h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; }
.err { color: var(--bad); } .empty { text-align: center; color: var(--muted); padding: 24px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); } .brand span, .login h1 span { color: var(--brand); font-weight: 600; }
.topbar nav { display: flex; gap: 4px; } .topbar nav a { padding: 6px 12px; border-radius: 6px; color: var(--ink); }
.topbar nav a.on { background: var(--hover); color: var(--brand); font-weight: 600; }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); }
main { padding: 16px 20px; } main.center { display: grid; place-items: center; min-height: 80vh; }
main.with-side { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.login { width: min(360px, 100%); display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
button.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--hover); }
.pill.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.okbox { background: var(--ok-bg); color: var(--ok); padding: 8px 12px; border-radius: 6px; }
.warnbox { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 6px; }

.tree { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
.tree a, .tree summary { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px; color: var(--ink); }
.tree summary { cursor: pointer; } .tree summary a { padding: 0; flex: 1; font-weight: 600; }
.tree a.st { padding-left: 22px; font-size: 13px; }
.tree a.on, .tree-all.on { background: var(--hover); color: var(--brand); }
.tree b { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12px; }
.tree .ratio { font-style: normal; font-size: 11px; color: var(--ok); min-width: 28px; text-align: right; }
.tree-all { font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: var(--ink); display: grid; }
.stat b { font-size: 22px; } .stat b.small { font-size: 13px; } .stat span { color: var(--muted); font-size: 12px; }
.stat.online b { color: var(--ok); } .stat.offline b { color: var(--bad); } .stat.failed b { color: var(--warn); }
.stat:hover { text-decoration: none; border-color: var(--brand); } .stat.meta:hover { border-color: var(--line); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.filters .grow { flex: 1 1 260px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
.chip.on { border-color: var(--brand); color: var(--brand); } .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 10px; position: sticky; top: 56px; z-index: 3; }
.selbar .muted { margin-left: auto; }

.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); }
.grid th, .grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--panel); position: sticky; top: 0; }
.grid tbody tr:hover { background: var(--hover); }
.grid.compact td, .grid.compact th { padding: 5px 8px; }
td.ck, th.ck { width: 32px; } .w40 { width: 30%; }
td.mono { white-space: nowrap; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.st-online { background: var(--ok-bg); color: var(--ok); } .st-offline { background: var(--bad-bg); color: var(--bad); }
.st-check_failed { background: var(--warn-bg); color: var(--warn); } .st-unknown, .st-none { background: var(--hover); color: var(--muted); }
.geo { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 700; }
.geo.ok { background: var(--ok-bg); color: var(--ok); } .geo.bad { background: var(--warn-bg); color: var(--warn); } .geo.none { color: var(--muted); }
.mapbtn { border: 1px solid var(--line); background: var(--panel); color: var(--brand); border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; padding: 3px 7px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0; }

.mappanel { position: fixed; right: 16px; top: 72px; width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 14px; z-index: 10; }
.mappanel .close { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.mappanel h3 { margin: 0 24px 4px 0; }
.mapframe { width: 100%; aspect-ratio: 4 / 3; background: var(--hover); border-radius: 6px; margin: 8px 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 8px; }
.mapframe iframe { width: 100%; height: 100%; border: 0; border-radius: 6px; }

.detail { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 12px 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.strip { display: flex; gap: 3px; flex-wrap: wrap; } .day { display: inline-block; width: 14px; height: 22px; border-radius: 3px; }
.strip .st-online, .legend .st-online { background: var(--ok); } .strip .st-offline, .legend .st-offline { background: var(--bad); }
.strip .st-check_failed, .legend .st-check_failed { background: var(--warn); } .strip .st-none, .legend .st-none { background: var(--none); }
.legend .day { width: 10px; height: 10px; vertical-align: middle; margin-left: 8px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.head-row { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
meter { width: 70%; height: 14px; vertical-align: middle; }
.retitle { display: flex; gap: 8px; align-items: end; margin-bottom: 12px; } .retitle label { flex: 1; max-width: 520px; }
.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; margin-bottom: 16px; }

@media (max-width: 900px) {
  main.with-side, .detail, .cols { grid-template-columns: 1fr; }
  .tree { position: static; max-height: 260px; }
  main { padding: 12px 16px; }
  .selbar { position: static; }
}
@media print {
  .topbar, .foot, .noprint, .selbar, .mappanel { display: none !important; }
  body, .report, table.grid { background: #fff; color: #000; }
  .report { border: 0; padding: 0; }
  .grid th, .grid td { border-bottom: 1px solid #ccc; font-size: 11px; }
}

/* ---- v0.2 redesign: header logo, dashboard, sites page ---- */
.brand { display: inline-flex; align-items: center; }
.brand .logo { height: 34px; width: auto; display: block; }
.logo-text { font-size: 17px; color: var(--ink); } .logo-text b { color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 10px; }
.card-stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: grid; gap: 2px; }
.card-stat b { font-size: 28px; line-height: 1.1; } .card-stat span { color: var(--muted); } .card-stat i { font-style: normal; font-size: 12px; color: var(--muted); }
.card-stat.online b { color: var(--ok); } .card-stat.offline b { color: var(--bad); } .card-stat.failed b { color: var(--warn); }
.card-stat:hover { border-color: var(--brand); text-decoration: none; }
.placeholder { border-style: dashed; }
.tree-search { width: 100%; margin-bottom: 6px; }
.tree-legend { padding: 6px; } .ok-ink { color: var(--ok); }
.chips .count { margin-right: 6px; }
th a.sort { color: inherit; display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
th a.sort .arrow { opacity: .45; font-size: 10px; } th a.sort.on { color: var(--brand); } th a.sort.on .arrow { opacity: 1; }
th a.sort:hover { text-decoration: none; color: var(--ink); }
#results.loading { opacity: .55; transition: opacity .15s; }
.filters input[list] { width: 170px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.st-stale { background: var(--hover); color: var(--muted); }
@media (max-width: 900px) { .filters input[list] { width: 100%; } .brand .logo { height: 28px; } }

/* ---- login page: logo + PACE TECHNOLOGY watermark ---- */
.login-page { position: relative; overflow: hidden; }
.watermark {
  position: fixed; inset: -50%; z-index: 0; pointer-events: none; transform: rotate(-24deg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='700' height='190'><text x='20' y='115' font-family='Segoe UI, Arial, sans-serif' font-size='44' font-weight='800' letter-spacing='6' fill='%235b8def' fill-opacity='0.07'>PACE TECHNOLOGY</text></svg>");
  background-repeat: repeat;
}
.login { position: relative; z-index: 1; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-brand { text-align: center; display: grid; gap: 6px; margin-bottom: 4px; }
.login-logo { max-width: 220px; max-height: 70px; width: auto; height: auto; margin: 0 auto; display: block; }
.login-wordmark { font-weight: 800; font-size: 26px; letter-spacing: .12em; color: var(--ink); }
.login-wordmark span { color: var(--brand); }
.login-brand h1 { font-size: 16px; font-weight: 600; color: var(--muted); margin: 0; letter-spacing: .04em; }

/* approved navy logo is used unaltered; on dark backgrounds it sits on a white plate for contrast */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo { background: #ffffff; padding: 4px 10px; border-radius: 6px; box-sizing: content-box; }
}
:root[data-theme="dark"] .brand .logo { background: #ffffff; padding: 4px 10px; border-radius: 6px; box-sizing: content-box; }
.login-logo { max-width: 240px; }

/* ---- login v2 (styled after the Pace GPS portal) ---- */
.login-page { min-height: calc(100vh - 60px); }
.login-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 30% 20%, #23303f 0%, #141a22 55%, #0c1016 100%); }
.login-page .watermark { z-index: 0; }
.login { position: relative; z-index: 1; width: min(560px, calc(100vw - 32px)); background: #1b1b1b; color: #f2f2f2;
  border-radius: 18px; padding: 28px 44px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.45); display: grid; gap: 14px; border: 0; }
.login-brand { text-align: center; display: grid; gap: 8px; margin-bottom: 6px; }
.login-page .login-logo { max-width: 300px; width: 70%; height: auto; margin: 0 auto 6px; display: block;
  background: none !important; padding: 0 !important; filter: brightness(0) invert(1); }
.login-brand h1 { font-size: 30px; font-weight: 500; color: #fff; margin: 4px 0 0; letter-spacing: 0; }
.login-brand p { margin: 0; font-size: 17px; color: #e8e8e8; }
.login label { color: #f2f2f2; font-size: 17px; font-weight: 500; gap: 6px; }
.login input[name=username], .login input[name=password] { background: #fff; color: #111; border: 1px solid #cfd6df;
  border-radius: 4px; padding: 10px 12px; font-size: 17px; }
.login input:focus { outline: 2px solid #2f6fd0; outline-offset: 0; }
.login .remember { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 17px; margin-top: 4px; cursor: pointer; }
.login .remember input { width: 18px; height: 18px; accent-color: #f2f2f2; }
.login-rule { border: 0; border-top: 2px solid #8a6d3b; margin: 6px -14px 2px; }
.login-btn { justify-self: center; min-width: 240px; padding: 12px 24px; border: 0; border-radius: 10px; cursor: pointer;
  background: #eef3f7; color: #1769aa; font-size: 22px; font-weight: 700; }
.login-btn:hover { background: #ffffff; }
.login-sub { text-align: center; margin: 2px 0 0; color: #bfc6cf; font-size: 15px; }
.login-err { background: #4a1f1f; color: #ffb4b4; border-radius: 6px; padding: 8px 12px; margin: 0; text-align: center; }
@media (max-width: 600px) { .login { padding: 22px 20px; } .login-brand h1 { font-size: 24px; } .login-btn { min-width: 0; width: 100%; } }

/* ---- v0.2.2 fixes ---- */
[hidden] { display: none !important; }   /* author display rules must never override the hidden attribute */
.tree summary { list-style: none; } .tree summary::-webkit-details-marker { display: none; }
.tree .chev { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; font-size: 11px; }
.tree details[open] > summary .chev { transform: rotate(90deg); }
.tree .abbr { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.tree-tools { font-size: 12px; color: var(--muted); padding: 0 6px 6px; }
.gear { font-size: 20px; line-height: 1; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.gear:hover, .gear.on { color: var(--brand); background: var(--hover); text-decoration: none; }
.integrations { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.integ { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 6px; }
.integ h3 { margin: 0; font-size: 15px; } .integ .small { color: var(--muted); }
.report-builder { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }
.span2 { grid-column: 1 / -1; }

/* ---- gear button + theme picker ---- */
.gear { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); color: var(--ink); }
.gear svg { width: 20px; height: 20px; }
.gear:hover, .gear.on { border-color: var(--brand); color: var(--brand); background: var(--hover); }
.theme-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-pick label { display: flex; flex-direction: row; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; background: var(--panel); }
.theme-pick input { accent-color: var(--brand); }
.theme-pick label:has(input:checked) { border-color: var(--brand); color: var(--brand); }
.actions-cell { white-space: nowrap; } .small-btn { padding: 3px 8px; font-size: 12px; }
.filters .count { margin-left: auto; color: var(--muted); }

/* search-term highlight: strong for ~4 s, then fades out */
mark.hit { background: #ffd54a; color: #111; border-radius: 3px; padding: 0 1px; transition: background-color 1.2s ease, color 1.2s ease; }
mark.hit.fade { background: transparent; color: inherit; }
.pagesize { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 400; color: var(--muted); margin-right: auto; }
.pager { flex-wrap: wrap; }

/* ---- bulk actions + site state ---- */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; } .menu > summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 220px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 4px; display: grid; }
.menu-items button { text-align: left; background: none; border: 0; color: var(--ink); padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.menu-items button:hover { background: var(--hover); }
.menu.disabled > summary { opacity: .5; pointer-events: none; }
.pill.ops-maintenance { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.pill.ops-retired { background: var(--hover); color: var(--muted); font-weight: 600; text-decoration: line-through; }
.act-dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); width: min(460px, calc(100vw - 32px)); padding: 20px; }
.act-dialog::backdrop { background: rgba(0,0,0,.45); }
.act-dialog h3 { margin-top: 0; } .act-dialog textarea { width: 100%; font-family: inherit; font-size: 14px; }

/* ---- floating jump to top / bottom ---- */
.jump { position: fixed; right: 18px; bottom: 18px; z-index: 30; display: grid; gap: 8px; }
.jump button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer; display: grid; place-items: center; padding: 0; }
.jump button:hover { border-color: var(--brand); color: var(--brand); }
.jump svg { width: 22px; height: 22px; }
@media print { .jump { display: none !important; } }

/* ---- site workspace: tabs, notes, notifications ---- */
.site-head h1 { margin-bottom: 2px; } .site-head h2 { margin: 0 0 2px; } .site-head p { margin: 0 0 8px; }
.tabcount { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--hover); color: var(--muted); font-size: 11px; text-align: center; }
.kv-wide { grid-template-columns: 240px 1fr; }
.notes .note-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.note { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); max-width: 820px; }
.note.mine { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.note-meta { display: flex; gap: 6px; align-items: baseline; } .note-del { margin-left: auto; }
.note-body { margin-top: 4px; white-space: normal; word-break: break-word; }
.mention { color: var(--brand); font-weight: 600; background: var(--hover); border-radius: 4px; padding: 0 3px; }
.note-form textarea { width: 100%; max-width: 820px; font-family: inherit; font-size: 14px; }
.note-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; max-width: 820px; }
.note-tools .btn { margin-left: auto; } .mention-pick { cursor: pointer; font: inherit; }
.bell { position: relative; }
.badge-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
tr.unread td { font-weight: 600; } .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; }
.upload { margin-top: 12px; }
