/* NGBMonitor portal — self-contained stylesheet (CSP: style-src 'self') */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e2e7ec;
  --text: #17212b;
  --text-2: #5b6875;
  --text-3: #8a96a3;
  --primary: #0f766e;
  --primary-2: #0d9488;
  --primary-soft: #e6f4f2;
  --side-bg: #0f1a24;
  --side-text: #b8c4cf;
  --side-text-strong: #ffffff;
  --side-hover: #18283a;
  --side-active: #1d3347;
  --crit: #c2253a; --crit-soft: #fde8eb;
  --high: #d9480f; --high-soft: #fff0e6;
  --med: #b7791f;  --med-soft: #fff7e0;
  --low: #2b6cb0;  --low-soft: #e8f1fb;
  --ok: #15803d;   --ok-soft: #e7f6ec;
  --muted-soft: #eef1f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1219; --surface: #121c26; --surface-2: #0f1821; --border: #223140;
    --text: #e4eaf0; --text-2: #9fb0bf; --text-3: #6f8293;
    --primary: #2dd4bf; --primary-2: #5eead4; --primary-soft: #0f2e2c;
    --side-bg: #070d13; --side-hover: #101b26; --side-active: #15283a;
    --crit: #f87171; --crit-soft: #3a1418; --high: #fb923c; --high-soft: #3a2010;
    --med: #fbbf24; --med-soft: #33280c; --low: #60a5fa; --low-soft: #11243b;
    --ok: #4ade80; --ok-soft: #10291a; --muted-soft: #1a2633;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.sprite { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: var(--side-text-strong); font-weight: 650; font-size: 16px; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: #2dd4bf; background: rgba(45,212,191,.12); border-radius: 7px; padding: 3px; }
.brand-mark.lg { width: 44px; height: 44px; padding: 6px; border-radius: 12px; color: var(--primary); background: var(--primary-soft); }
.nav-section { padding: 6px 10px 10px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7c8c; padding: 10px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
  color: var(--side-text); font-size: 13.5px; margin-bottom: 1px;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--side-hover); color: var(--side-text-strong); text-decoration: none; }
.nav-item.active { background: var(--side-active); color: var(--side-text-strong); box-shadow: inset 3px 0 0 #2dd4bf; }
.nav-badge { margin-left: auto; background: #c2253a; color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.nav-badge.info { background: #2b6cb0; }
.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid #1a2836; }
.version { font-size: 11px; color: #5f7183; padding: 8px 10px 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 17px; font-weight: 650; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.menu-btn { display: none; }
.customer-switch select { min-width: 200px; }
.org-name { font-weight: 600; color: var(--text-2); }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11.5px; color: var(--text-3); }
.content { padding: 24px; max-width: 1500px; width: 100%; }
.loading { color: var(--text-3); padding: 40px; text-align: center; }

@media (max-width: 960px) {
  .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s; }
  .shell.nav-open .sidebar { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-grid; }
  .user-meta { display: none; }
  .content { padding: 16px; }
  .customer-switch select { min-width: 130px; }
}

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 14.5px; margin: 0; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }
.stack > * + * { margin-top: 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 1100px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.stat { padding: 16px 18px; display: block; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-3); font-size: 12px; }
.stat.crit .value { color: var(--crit); }
.stat.warn .value { color: var(--high); }
.stat.ok .value { color: var(--ok); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=time], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 36px;
}
textarea { min-height: 80px; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 1px; }
input[type=search] { min-width: 240px; }

.btn {
  font: inherit; font-weight: 550; border-radius: 8px; padding: 7px 14px; min-height: 36px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #062a27; } }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--crit); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-sm { padding: 3px 10px; min-height: 28px; font-size: 12.5px; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--text-2); cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px; text-align: center; color: var(--text-3); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate.narrow { max-width: 220px; }
.truncate.mid { max-width: 320px; }
.truncate { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--muted-soft); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.critical, .badge.revoked, .badge.rejected, .badge.quarantined, .badge.high-risk { background: var(--crit-soft); color: var(--crit); }
.badge.high, .badge.error, .badge.offline, .badge.audit_failure { background: var(--high-soft); color: var(--high); }
.badge.medium, .badge.warning, .badge.pending_approval, .badge.pending, .badge.invited, .badge.expiring { background: var(--med-soft); color: var(--med); }
.badge.low, .badge.info, .badge.information, .badge.acknowledged, .badge.audit_success { background: var(--low-soft); color: var(--low); }
.badge.active, .badge.online, .badge.ok, .badge.approved, .badge.resolved { background: var(--ok-soft); color: var(--ok); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 550; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.notice { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--border); background: var(--surface-2); }
.notice.warn { background: var(--med-soft); border-color: transparent; color: var(--text); }
.notice.danger { background: var(--crit-soft); border-color: transparent; }
.notice.ok { background: var(--ok-soft); border-color: transparent; }
.secret { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--primary); padding: 12px; border-radius: 8px; word-break: break-all; user-select: all; }
.diff-changed { color: var(--crit); font-weight: 600; }
.muted { color: var(--text-3); }
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 340px; overflow: auto; margin: 0; }

/* hourly bars */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; border-radius: 3px 3px 0 0; overflow: hidden; background: var(--muted-soft); }
.bar span { display: block; }
.bar .s-critical { background: var(--crit); }
.bar .s-error { background: var(--high); }
.bar .s-warning { background: var(--med); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .s-critical { background: var(--crit); } .legend .s-error { background: var(--high); } .legend .s-warning { background: var(--med); }

/* forms in modals */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(620px, 94vw); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal::backdrop { background: rgba(8, 15, 22, .55); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--text-3); font-size: 12px; }
.field .err { color: var(--crit); font-size: 12.5px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field input, .field select { width: 100%; }
.field.check input { width: auto; margin: 0; flex: none; }
.field.check label { font-weight: 500; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 420px; }
.toast.error { background: var(--crit); color: #fff; }

/* groups & rules matrix */
.matrix-wrap { max-height: calc(100vh - 230px); overflow: auto; }
.matrix { border-collapse: separate; border-spacing: 0; }
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); vertical-align: bottom; text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--text); }
.matrix .rule-col { min-width: 300px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix thead .rule-col { z-index: 3; }
.matrix .grp-col { text-align: center; min-width: 108px; }
.matrix .grp-col input { width: 17px; height: 17px; cursor: pointer; }
.matrix .grp-col input:disabled { cursor: not-allowed; opacity: .55; }
.matrix tr.module-row th, .matrix tr.module-row td { background: var(--surface-2); font-weight: 700; padding-top: 10px; padding-bottom: 10px; }
.matrix tr.module-row th { position: sticky; left: 0; z-index: 1; text-align: left; }
.matrix tbody tr:not(.module-row):hover td { background: var(--surface-2); }
.tag { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 4px; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); vertical-align: 1px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent, #0f766e); cursor: pointer; font-size: 12px; text-decoration: underline; }
.nowrap { white-space: nowrap; }
.btn-row.nowrap { flex-wrap: nowrap; }
.btn-danger.btn-sm { padding-inline: 10px; }

/* approvals */
.approval { border-left: 4px solid var(--med); }
.approval.high { border-left-color: var(--crit); }
.approval .meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--text-2); font-size: 13px; }

/* auth pages */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px; max-width: 440px; text-align: center; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 20px; margin: 16px 0 8px; }
.auth-card p { color: var(--text-2); margin: 0 0 22px; }
/* 2.11.1: the portal's own sign-in pages */
.auth-card { width: 100%; }
.auth-card.wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 17px; }
.auth-form, .auth-help, .auth-section, .auth-other, .auth-key { text-align: left; }
.auth-form { margin: 0 0 14px; }
.auth-form .btn-block, .btn-block { width: 100%; justify-content: center; }
.auth-second-btn { margin-top: 8px; }
.auth-msg { margin: 0 0 16px; text-align: left; }
.auth-links { margin: 6px 0 0 !important; }
.auth-foot { font-size: 12px; margin: 18px 0 0 !important; }
.auth-help { color: var(--text-2); font-size: 13px; padding-left: 20px; margin: 0 0 16px; }
.auth-help li { margin-bottom: 4px; }
.auth-steps { display: flex; justify-content: center; gap: 6px; list-style: none; padding: 0; margin: 4px 0 14px; font-size: 12px; counter-reset: st; }
.auth-steps { flex-wrap: wrap; }
.auth-steps li { white-space: nowrap; counter-increment: st; color: var(--text-3); padding: 3px 9px; border-radius: 999px; background: var(--surface-2); }
.auth-steps li::before { content: counter(st) ". "; }
.auth-steps li.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.auth-steps li.done { color: var(--ok); }
.auth-section { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin: 0 0 14px; }
.auth-section.ok { border-color: var(--ok); }
.auth-section h2 { font-size: 15px; margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.auth-section p { margin: 0 0 12px; text-align: left; }
.auth-key { margin: 0 0 14px; font-size: 13px; }
.auth-key summary { cursor: pointer; color: var(--primary); }
.auth-key p { font-size: 13px; margin: 8px 0; }
.qr { display: flex; justify-content: center; margin: 4px 0 12px; }
.qr img { width: 200px; height: 200px; image-rendering: pixelated; border-radius: 6px; background: #fff; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.inline-form .field { flex: 1; margin-bottom: 0; }
.code-input { font-family: var(--mono); letter-spacing: .15em; font-size: 17px; }
.auth-other { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 12px; font-size: 13.5px; }
.auth-actions { display: flex; justify-content: space-between; gap: 10px; }
.backup-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 16px; }
.backup-codes code { font-family: var(--mono); font-size: 15px; padding: 8px; background: var(--surface-2); border-radius: 6px; user-select: all; }
@media (max-width: 480px) { .auth-card { padding: 24px 18px; } .inline-form { flex-direction: column; align-items: stretch; } }

/* updates & reboots badges in tables */
.badge-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* 2.4 alert rules: multi-select lists, form section headings, shut-down badge */
.multi { border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.multi-list { max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.multi-item { display: flex; align-items: center; gap: 6px; font-weight: normal; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.multi-item:hover { background: var(--surface-2); }
.form-heading { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.form-heading .help { text-transform: none; letter-spacing: 0; font-weight: normal; }
.badge.shut_down { background: var(--muted-soft); color: var(--text-2); }
.kind-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.kind-pick button { text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; color: inherit; }
.kind-pick button:hover { border-color: var(--primary); }
.kind-pick .k-label { font-weight: 600; display: block; }
.kind-pick .k-help { font-size: 12px; color: var(--text-2); }
.multi .multi-item { justify-content: flex-start; text-align: left; margin: 0; font-size: 14px; font-weight: 400; color: var(--text); }
.multi .multi-item input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 0; }
.multi input[type="search"] { width: 100%; }

/* 2.11.0: row selection in lists (Alerts) */
table.data th.sel, table.data td.sel { width: 34px; padding-right: 0; }
table.data th.sel input, table.data td.sel input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.select-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 18px;
  background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.select-bar[hidden] { display: none; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 3px 4px; text-decoration: underline; cursor: pointer; }

/* 2.11.1: My Account → Sign-In & Security */
.sec-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sec-row:last-of-type { border-bottom: 0; }
.sec-row .cell-sub { max-width: 46ch; }
@media (max-width: 640px) { .sec-row { flex-direction: column; align-items: flex-start; } }
/* 2.12.0: Group Policy tab, Security Baselines */
.modal.wide { width: min(940px, 96vw); }
table.data.compact td, table.data.compact th { padding: 7px 10px; }
table.data tr.group-row th { background: var(--surface); color: var(--text-2); font-size: 12px; padding-top: 14px; }
table.data td select, table.data td input.num-sm { min-width: 0; }
input.num-sm { width: 110px; }
