/* RMM dashboard styles. No external fonts or libraries, so it works on a locked-down network. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #182033;
  --muted: #667085;
  --border: #e3e7ee;
  --brand: #3566d6;
  --brand-ink: #ffffff;
  --brand-soft: #e8eefc;
  --ok: #12a150;      --ok-soft: #dcf5e6;
  --warn: #c76a05;    --warn-soft: #fdeccd;
  --bad: #d12b22;     --bad-soft: #fbdad7;
  --info-soft: #e8eefc;
  --side: #121a2b;
  --side-text: #aab4c8;
  --side-active: #ffffff;
  --side-active-bg: rgba(255, 255, 255, .09);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131c;
    --surface: #161d29;
    --surface-2: #1b2331;
    --text: #e7ebf3;
    --muted: #93a0b8;
    --border: #263145;
    --brand: #6f98ff;
    --brand-ink: #0b1220;
    --brand-soft: #1f2c4a;
    --ok: #3ddc84;     --ok-soft: #12301f;
    --warn: #f5a524;   --warn-soft: #3a2a0c;
    --bad: #ff7a72;    --bad-soft: #3d1816;
    --info-soft: #1f2c4a;
    --side: #0a0f18;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); font-weight: 800; font-size: 15px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; opacity: .6; }
.nav a, .nav button.link {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); font-size: 14px; background: none; border: 0; cursor: pointer; text-align: left; font-family: inherit;
}
.nav a:hover, .nav button.link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active-bg); color: var(--side-active); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, .14); color: #fff; }
.nav .count.crit { background: var(--bad); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.who { padding: 8px 12px 4px; font-size: 13px; color: #fff; }
.who span { display: block; font-size: 12px; color: var(--side-text); }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1180px; margin: 0 auto; padding: 28px 28px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; margin-bottom: 8px; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .card + .section { margin-top: 18px; }
.grid > .card, .grid > .card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px 18px; }
.section { margin-top: 26px; }
.section > .section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.stat { padding: 16px 18px; display: block; color: inherit; position: relative; }
a.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.stat .label svg { width: 16px; height: 16px; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.stat .value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.stat .hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat.good .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.card > .table-wrap > table th:first-child, .card > table th:first-child { border-top-left-radius: var(--radius); }
td .sub { color: var(--muted); font-size: 12.5px; }
.cell-main { font-weight: 600; white-space: nowrap; }
td .sub { white-space: nowrap; }
.row-link { color: var(--text); }

/* ---------- badges, dots, bars ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.online, .badge.success, .badge.installed { background: var(--ok-soft); color: var(--ok); }
.badge.offline, .badge.critical, .badge.failed, .badge.timeout, .badge.revoked { background: var(--bad-soft); color: var(--bad); }
.badge.warning, .badge.pending, .badge.sent, .badge.held, .badge.approved, .badge.installing { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--brand); }
.badge.plain::before { display: none; }

.meter { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.meter .bar { flex: 1; height: 7px; border-radius: 4px; background: var(--border); overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.meter.mid .bar i { background: var(--warn); }
.meter.high .bar i { background: var(--bad); }
.meter span { font-size: 12.5px; width: 40px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- forms & buttons ---------- */
.btn, button {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; border-radius: 8px;
  padding: 7px 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px; line-height: 1.3;
}
.btn:hover, button:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary, button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
.btn.danger, button.danger { color: var(--bad); }
.btn.small, button.small { padding: 4px 10px; font-size: 12.5px; }
.btn svg, button svg { width: 16px; height: 16px; flex: none; }
.inline { display: inline; margin: 0; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=search], select, textarea {
  font: inherit; width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
textarea { font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.field label, label.field-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13.5px; }
.check { display: flex; align-items: center; gap: 9px; margin: 8px 0; font-weight: 500; }
.check input { width: 16px; height: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar input[type=search], .toolbar input[type=text] { max-width: 300px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; cursor: pointer; font-weight: 500; }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- messages, empty states ---------- */
.msg { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; background: var(--info-soft); border: 1px solid var(--border); }
.msg.success { background: var(--ok-soft); color: var(--ok); }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.warning { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: 8px; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- alerts ---------- */
.alert-row { display: grid; grid-template-columns: 4px 1fr auto; gap: 14px; align-items: center; padding: 14px 18px 14px 0; border-bottom: 1px solid var(--border); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .stripe { align-self: stretch; border-radius: 0 4px 4px 0; background: var(--muted); }
.alert-row.critical .stripe { background: var(--bad); }
.alert-row.warning .stripe { background: var(--warn); }
.alert-row .title { font-weight: 600; }
.alert-row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- device detail ---------- */
.device-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.metric { padding: 14px 18px; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.metric svg { display: block; width: 100%; height: 44px; margin-top: 6px; }
.metric polyline { stroke: var(--brand); }
pre.terminal { background: #0c111b; color: #d7e0f2; padding: 14px 16px; border-radius: 9px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 13px; margin: 0; max-height: 520px; }
pre.script { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ---------- auth pages (login, MFA setup) ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
body.auth .app { display: block; min-height: 0; width: 100%; max-width: 440px; }
body.auth .sidebar, body.auth .topbar { display: none; }
body.auth .content { padding: 0; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 20px; margin-bottom: 18px; }
.auth-card { padding: 28px; }
.auth-card h1, .auth-card .wizard-title { font-size: 21px; margin-bottom: 6px; }
.auth-card table { width: 100%; }
.auth-card table tr:hover td { background: none; }
.auth-card th, .auth-card td { display: block; padding: 0; background: none; border: 0; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); font-weight: 600; width: 100%; }
.auth-card th { margin-top: 12px; margin-bottom: 5px; }
.auth-card .errorlist { list-style: none; padding: 0; margin: 4px 0; color: var(--bad); font-size: 13px; font-weight: 500; }
.auth-card button[type=submit] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); margin-top: 16px; }
.auth-card button[name=wizard_goto_step] { margin-right: 8px; }
.auth-card img { max-width: 100%; }
.auth-card ul { padding-left: 20px; }
.auth-card button[type=button] { display: none; }  /* the inert 'Back' on the first step */

/* ---------- small screens ---------- */
.nav-toggle { display: none; }
@media (max-width: 880px) {
  .app { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--side); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 20; }
  .topbar label { cursor: pointer; padding: 4px 8px; font-size: 22px; line-height: 1; }
  .sidebar { display: none; position: fixed; inset: 46px 0 0 0; height: auto; z-index: 15; }
  .nav-toggle:checked ~ .app .sidebar { display: flex; }
  .content { padding: 18px 14px 50px; }
  .kv { grid-template-columns: 1fr; }
  td, th { padding: 10px 12px; }
}
