:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #16202c; --muted: #5d6b7a; --line: #e2e6eb;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e6f4f2;
  --up: #15803d; --up-bg: #e7f6ec; --warn: #a16207; --warn-bg: #fdf4dc;
  --down: #b91c1c; --down-bg: #fdeaea; --unknown: #5d6b7a; --unknown-bg: #eef1f4;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
/* Theme: "auto" follows the computer's setting; people can also pick light or dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #0f1419; --panel: #171e26; --text: #e6ebf0; --muted: #98a6b5; --line: #2a3440;
  --accent: #2dd4bf; --accent-ink: #062a26; --accent-soft: #123a36;
  --up: #4ade80; --up-bg: #12301f; --warn: #fbbf24; --warn-bg: #3a2e0e;
  --down: #f87171; --down-bg: #3d1717; --unknown: #98a6b5; --unknown-bg: #222c37;
  --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419; --panel: #171e26; --text: #e6ebf0; --muted: #98a6b5; --line: #2a3440;
  --accent: #2dd4bf; --accent-ink: #062a26; --accent-soft: #123a36;
  --up: #4ade80; --up-bg: #12301f; --warn: #fbbf24; --warn-bg: #3a2e0e;
  --down: #f87171; --down-bg: #3d1717; --unknown: #98a6b5; --unknown-bg: #222c37;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: baseline; gap: .6rem; }
code, .mono, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; overflow-x: auto; white-space: pre; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: 400; }
.nowrap { white-space: nowrap; }
.problem { color: var(--down); }

/* header */
.top { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand.big { font-size: 1.6rem; justify-content: center; margin-bottom: 1.25rem; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: url(/static/favicon.svg) center/cover; display: inline-block; }
.top nav { display: flex; gap: .25rem; align-items: center; flex: 1; }
.top nav > a, .menu > summary { padding: .4rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; color: var(--muted); }
.top nav > a:hover, .menu > summary:hover { background: var(--bg); }
.top nav > a[aria-current], .menu.current > summary { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu { position: relative; }
.menu-items { position: absolute; top: 2.3rem; left: 0; z-index: 10; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .35rem; min-width: 220px; display: grid; }
.menu-items a { padding: .5rem .7rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.menu-items a:hover { background: var(--bg); }
.who { display: flex; gap: .75rem; align-items: center; color: var(--muted); font-size: .9rem; }
.role { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 0 .5rem; font-size: .75rem; }

/* layout */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
main.bare { max-width: 440px; padding-top: 12vh; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.crumbs { margin: 0 0 .4rem; color: var(--muted); font-size: .9rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 0 0 1rem; box-shadow: var(--shadow); overflow-x: auto; }
.card > p:last-child { margin-bottom: 0; }
.banner { border-radius: var(--radius); padding: .7rem 1rem; margin: 0 0 1rem; border: 1px solid; }
.banner.ok { background: var(--up-bg); border-color: var(--up); }
.banner.err { background: var(--down-bg); border-color: var(--down); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn); }

/* summary tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--unknown); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tile .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile.down { border-left-color: var(--down); } .tile.warn { border-left-color: var(--warn); } .tile.up { border-left-color: var(--up); }
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); } main { padding: 1rem; } .top { padding: .6rem 1rem; }
  table.devices th:nth-child(3), table.devices td:nth-child(3) { display: none; }
  .pill { min-width: 0; }
}

/* status */
.pill, .chip { display: inline-block; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill { padding: .1rem .6rem; min-width: 5.2rem; text-align: center; }
.chip { padding: 0 .5rem; margin: 0 .25rem .15rem 0; font-weight: 500; }
.up { color: var(--up); background: var(--up-bg); }
.warn { color: var(--warn); background: var(--warn-bg); }
.down { color: var(--down); background: var(--down-bg); }
.unknown { color: var(--unknown); background: var(--unknown-bg); }
.pill.down::before { content: "● "; }
.all-good { color: var(--up); font-weight: 600; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
table.devices td { vertical-align: middle; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { padding: .45rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.alert-list li:last-child { border-bottom: 0; }

/* sparkline */
.spark { display: block; }
.spark-line { stroke: var(--accent); stroke-width: 1.5; }
.spark-fail { fill: var(--down); }

/* forms */
.form { display: grid; gap: .9rem; max-width: 640px; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input:not([type=checkbox]):not([type=radio]), select { font: inherit; font-weight: 400; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.short { max-width: 9rem; }
fieldset { border: 1px dashed var(--line); border-radius: var(--radius); padding: .8rem 1rem; display: grid; gap: .8rem; margin: 0; }
legend { font-weight: 600; color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
.js fieldset[data-for].hidden, .js [data-for].hidden { display: none; }
.row { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 200px; }
.row > input, .row > select { flex: 1; min-width: 200px; width: auto; }
.actions { display: flex; gap: 1rem; align-items: center; }
button, .button { white-space: nowrap; font: inherit; font-weight: 600; border-radius: 8px; padding: .5rem .9rem; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--muted); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.primary:hover { filter: brightness(1.08); border-color: var(--accent); }
button.wide { width: 100%; padding: .65rem; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
.danger { color: var(--down); }
button.danger:not(.link) { border-color: var(--down); background: var(--panel); }
.danger-zone { border-color: var(--down-bg); }
form.inline { display: inline; }
.copy-btn { margin-top: -.25rem; }

/* sign-in */
.login .card { display: grid; gap: .9rem; }
.login h1 { font-size: 1.25rem; }
.help pre { white-space: pre-wrap; word-break: break-all; }
.steps ol { padding-left: 1.3rem; margin: 0; display: grid; gap: .9rem; }
.refresh-note { text-align: right; }

/* theme switch in the header */
.theme-switch button { background: none; border: 1px solid var(--line); border-radius: 99px; padding: .15rem .6rem; font-weight: 500; font-size: .85rem; color: var(--muted); }

/* compact dashboard */
.compact td { padding: .3rem .6rem; }
.compact .card { padding: .8rem 1rem; }

/* my settings */
.widget-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.widget-list li { display: flex; align-items: center; gap: .75rem; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; }
.widget-list li label.check { flex: 1; }
.widget-list select { width: auto; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .4rem; }
.options { display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* wallboard (a screen on the wall of the office or NOC) */
body.wall { background: var(--bg); }
.wall main { max-width: none; padding: 1.25rem 2rem; }
.wall-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1rem; }
.wall-head h1 { font-size: 2rem; }
.wall .tiles .n { font-size: 3.5rem; }
.wall .tile { padding: 1rem 1.25rem; font-size: 1.2rem; }
.wall-problems { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .5rem; }
.wall-problems li { font-size: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-left: 8px solid var(--down); border-radius: var(--radius); padding: .6rem 1rem; display: flex; gap: 1rem; align-items: baseline; }
.wall-problems li.warn { border-left-color: var(--warn); }
.wall-problems .muted { font-size: 1rem; }
.wall-ok { font-size: 2rem; color: var(--up); font-weight: 700; text-align: center; padding: 2rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.5rem; }
.wall-site h2 { font-size: 1.2rem; margin: 1rem 0 .5rem; }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem; }
.wall-grid div { border-radius: 8px; padding: .5rem .7rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.steps-list { padding-left: 1.3rem; margin: 0 0 .75rem; display: grid; gap: .6rem; }
pre.wrap { white-space: pre-wrap; word-break: break-all; }

.js [data-for-login].hidden { display: none; }
textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%; }
form.test-mail { gap: .4rem; margin-bottom: .35rem; flex-wrap: nowrap; }
form.test-mail input { min-width: 12rem; }

/* devices and discovery lists */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters input[name=q] { flex: 2; min-width: 14rem; width: auto; }
.filters select { flex: 1; min-width: 9rem; width: auto; }
.bulk { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .75rem; }
.bulk.row { display: flex; }
tr.retired td { opacity: .6; }
.row-actions { display: flex; gap: .75rem; align-items: center; }
.row-actions form { margin: 0; }
button.link[disabled] { color: var(--muted); cursor: default; }
.facts dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem 1.25rem; margin: 0; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }
.facts .notes { white-space: pre-wrap; margin: .8rem 0 0; }
h3.sub { font-size: .9rem; color: var(--muted); margin: 1rem 0 .4rem; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
ul.plain li { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.tabs-row { justify-content: space-between; margin-bottom: .75rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.tabs a { padding: .35rem .7rem; border-radius: 8px; text-decoration: none; color: var(--text); border: 1px solid var(--line); }
.tabs a[aria-current] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tabs .count { color: var(--muted); font-size: .8rem; margin-left: .2rem; }
.clip { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { flex-wrap: wrap; }
table.device-list td, table.host-list td { vertical-align: middle; }
@media (max-width: 640px) {
  table.device-list th:nth-child(n+5), table.device-list td:nth-child(n+5) { display: none; }
  table.device-list th:last-child, table.device-list td:last-child { display: table-cell; }
  table.host-list th:nth-child(4), table.host-list td:nth-child(4),
  table.host-list th:nth-child(6), table.host-list td:nth-child(6) { display: none; }
  .clip { max-width: 12rem; }
}
.top nav { flex-wrap: wrap; }
@media (max-width: 640px) {
  .top nav > a, .menu > summary { padding: .35rem .5rem; }
  .menu-items { left: auto; right: 0; }
}

.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem 1.25rem; margin: 0 0 1rem; }
.facts-grid dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.facts-grid dd { margin: 0; overflow-wrap: anywhere; }
