/* Navitrends Infra dashboard — light + dark, no framework */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f1f4; --border: #e3e5ea; --border-strong: #cfd3db;
  --text: #16181d; --muted: #646a76; --accent: #3b46d6; --accent-2: #eef0ff; --on-accent: #ffffff;
  --green: #12814f; --green-bg: #e2f4ea; --red: #c2362c; --red-bg: #fbe8e6; --red-soft: #f0a49d;
  --orange: #b0620a; --orange-bg: #fdf0dc; --grey: #8a909b; --grey-bg: #eaecf0;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 2px 8px rgba(16,24,40,.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --border: #2a2f38; --border-strong: #3a404b;
  --text: #e7e9ee; --muted: #9aa1ad; --accent: #8e95ff; --accent-2: #23264a; --on-accent: #0f1115;
  --green: #3ccf8e; --green-bg: #12322a; --red: #ff6b60; --red-bg: #3a1c1a; --red-soft: #8f3a33;
  --orange: #f2a640; --orange-bg: #3a2b14; --grey: #7c8390; --grey-bg: #242832;
  --shadow: none; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --border: #2a2f38; --border-strong: #3a404b;
    --text: #e7e9ee; --muted: #9aa1ad; --accent: #8e95ff; --accent-2: #23264a; --on-accent: #0f1115;
    --green: #3ccf8e; --green-bg: #12322a; --red: #ff6b60; --red-bg: #3a1c1a; --red-soft: #8f3a33;
    --orange: #f2a640; --orange-bg: #3a2b14; --grey: #7c8390; --grey-bg: #242832;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 12px; }
pre { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; margin: 8px 0 0; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 20px 0 10px; }
h2 a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
th.num { text-align: right; }
.bad-text { color: var(--red); font-weight: 600; }
.ok-text { color: var(--green); }

/* ── header ─────────────────────────────────────────────── */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-sub { color: var(--muted); font-weight: 500; }
.logo { width: 28px; height: 28px; flex: none; }
.logo rect { fill: var(--accent); }
.logo path { fill: none; stroke: var(--on-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.brand.big { font-size: 20px; justify-content: center; margin-bottom: 20px; }
.brand.big .logo { width: 36px; height: 36px; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav a { color: var(--muted); padding: 6px 11px; border-radius: 8px; font-weight: 500; }
nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
nav a[aria-current="page"] { color: var(--accent); background: var(--accent-2); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.who form { margin: 0; }
.lastrun { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.lastrun.stale { color: var(--red); font-weight: 600; }
.lastrun.stale .pulse { background: var(--red); }
.themesw { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.themesw button { font: inherit; font-size: 12px; padding: 4px 9px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.themesw button + button { border-left: 1px solid var(--border); }
.themesw button[aria-pressed="true"] { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.user { display: inline-flex; flex-direction: column; line-height: 1.15; color: var(--text); font-weight: 600; }
.user small { color: var(--muted); font-weight: 400; font-size: 11px; }
.btn-ghost { font: inherit; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.btn-ghost:hover { border-color: var(--border-strong); }

.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 24px 32px; }
.foot { max-width: 1320px; margin: 0 auto; padding: 0 24px 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; margin: 10vh auto; }
.scroll { overflow-x: auto; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-bottom: 14px; }
.pagehead p { margin: 0; flex-basis: 100%; }
.subnav { display: flex; flex-wrap: wrap; gap: 4px; }
.subnav a { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

/* ── banner + cards ─────────────────────────────────────── */
.banner { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-radius: var(--radius);
  margin-bottom: 16px; border: 1px solid transparent; }
.banner-ok { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.banner-bad { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.banner-icon { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff; }
.banner-ok .banner-icon { background: var(--green); }
.banner-bad .banner-icon { background: var(--red); }
.banner-title { font-size: 18px; font-weight: 700; }
.banner-sub { color: var(--muted); font-size: 13px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.statcard { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--green); color: var(--text); box-shadow: var(--shadow); }
.statcard:hover { text-decoration: none; border-color: var(--accent); }
.statcard.bad { border-top-color: var(--red); }
.statcard.warn { border-top-color: var(--orange); }
.statcard-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.statcard-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.statcard-value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.statcard-foot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot-bad, .dot-warn, .dot-muted { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-bad { background: var(--red); } .dot-warn { background: var(--orange); } .dot-muted { background: var(--grey); }

.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid3 .card { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tile { padding: 4px 9px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.tile:hover { text-decoration: none; outline: 2px solid var(--accent); }
.t-ok, .t-up { background: var(--green-bg); color: var(--green); }
.t-fail, .t-down { background: var(--red-bg); color: var(--red); }
.t-late, .t-warn, .t-expiring { background: var(--orange-bg); color: var(--orange); }
.t-unknown { background: var(--grey-bg); color: var(--grey); }
.t-muted { opacity: .55; text-decoration: line-through; }

.problems { list-style: none; margin: 0; padding: 0; }
.problems li { padding: 9px 0; border-top: 1px solid var(--border); }
.problems li:first-child { border-top: 0; padding-top: 0; }
.problems li.is-muted { opacity: .65; }
.prob-meta { margin-top: 2px; }

/* ── pills, tables ──────────────────────────────────────── */
.pill { display: inline-block; min-width: 52px; text-align: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.pill-ok, .pill-up { background: var(--green-bg); color: var(--green); }
.pill-fail, .pill-down { background: var(--red-bg); color: var(--red); }
.pill-late, .pill-warn, .pill-expiring { background: var(--orange-bg); color: var(--orange); }
.pill-unknown, .pill-muted { background: var(--grey-bg); color: var(--grey); }
.pill-muted { min-width: 0; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; vertical-align: top; }
.tbl tbody.item, .tbl tbody > tr { border-top: 1px solid var(--border); }
.tbl tbody.item > tr { border-top: 0; }
.tbl thead + tbody { border-top: 0; }
.tbl tr.detail td { padding-top: 0; }
.tbl.compact td { padding: 6px 8px; }
.tbl tbody.inactive td { opacity: .5; }
td.late { color: var(--orange); font-weight: 600; }
details summary { cursor: pointer; }

/* 30-day calendar strip */
.hist { display: flex; gap: 2px; }
.cell { width: 8px; height: 20px; border-radius: 2px; background: var(--grey-bg); display: inline-block; flex: none; }
.c-OK { background: var(--green); }
.c-FAIL { background: var(--red); }
.c-missing { background: var(--red-soft); }
.c-pending { background: var(--grey-bg); outline: 1px dashed var(--grey); outline-offset: -1px; }
.c-none { background: var(--grey-bg); }
.legend .cell { vertical-align: middle; margin: 0 4px 0 12px; height: 12px; }

/* sparkline + uptime + ssl */
.spark { display: block; color: var(--accent); }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: currentColor; }
.up { display: inline-flex; gap: 8px; font-variant-numeric: tabular-nums; font-size: 12px; }
.up small { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.up-good { color: var(--green); } .up-mid { color: var(--orange); } .up-bad { color: var(--red); font-weight: 700; } .up-na { color: var(--muted); }
.ssl { display: inline-block; font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 7px; border-radius: 6px; font-size: 12px; }
.ssl-ok { background: var(--green-bg); color: var(--green); }
.ssl-warn { background: var(--orange-bg); color: var(--orange); }
.ssl-bad { background: var(--red-bg); color: var(--red); }

.port { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 12px; font-family: var(--mono); margin-right: 4px; }
.p-ok { background: var(--green-bg); color: var(--green); }
.p-bad { background: var(--red-bg); color: var(--red); }
.p-na { background: var(--grey-bg); color: var(--grey); }

.disk { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.disk meter { width: 180px; height: 12px; }
.disk.bad strong { color: var(--red); }

/* filter bar */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filterbar input[type=search] { flex: 1 1 260px; max-width: 420px; }
.hidden-by-filter { display: none; }

/* ── forms ──────────────────────────────────────────────── */
input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form label input, .form label select { color: var(--text); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; align-items: start; }
.grid-form .wide { grid-column: span 2; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 16px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.inline { display: inline; margin: 0; }
.pwreset { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pwreset input { width: 140px; }
.addrow input { margin: 2px 4px 2px 0; }
.check, .check-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; }
.secret { display: flex; gap: 8px; align-items: center; }
.secret input { flex: 1; }
.dots { letter-spacing: 2px; color: var(--text); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.form { display: grid; gap: 12px; }
.card .form:not(.grid-form):not(.inline-form) { max-width: 420px; }

.btn, .btn-secondary, .btn-small { font: inherit; font-weight: 600; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.btn { padding: 9px 16px; background: var(--accent); color: var(--on-accent); }
.btn:hover { filter: brightness(1.07); }
.btn-secondary { padding: 8px 14px; background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn-small { padding: 4px 10px; font-size: 12px; background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-small:hover { border-color: var(--border-strong); }
.btn-danger { color: var(--red); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* toggle switch (checkbox) */
.toggle { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:disabled + span { opacity: .5; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid var(--border); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-warn { background: var(--orange-bg); color: var(--text); }
.flash-ok { background: var(--green-bg); color: var(--text); }

/* login */
.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { padding: 10px 12px; }

/* ── mobile ─────────────────────────────────────────────── */
@media (max-width: 760px) {
  .top { padding: 10px 14px; gap: 8px 12px; }
  .who { margin-left: 0; width: 100%; justify-content: space-between; }
  nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .wrap { padding: 14px; }
  .foot { padding: 0 14px 18px; }
  .statcard-value { font-size: 24px; }
  .banner-title { font-size: 16px; }
  .grid-form .wide { grid-column: auto; }
  .tbl td, .tbl th { padding-left: 6px; padding-right: 6px; }
}
