/* H2Media Sentinel panel. Dark theme; all text colours meet WCAG AA
   (4.5:1) on the surfaces they are used on. */
:root {
  --bg: #0b1016;
  --surface: #121a23;
  --surface-2: #18222e;
  --surface-3: #1f2b39;
  --border: #263445;
  --border-strong: #34475c;
  --text: #e6edf3;
  --muted: #9fb0c1;
  --accent: #5aa9ff;
  --accent-strong: #2f81f7;
  --ok: #4cc38a;
  --ok-bg: rgba(76, 195, 138, .14);
  --warn: #e3b341;
  --warn-bg: rgba(227, 179, 65, .14);
  --danger: #ff7b72;
  --danger-bg: rgba(255, 123, 114, .14);
  --info: #79c0ff;
  --info-bg: rgba(121, 192, 255, .13);
  --neutral-bg: rgba(159, 176, 193, .14);
  --crit: #ffa8a8;
  --crit-bg: rgba(248, 81, 73, .30);
  --radius: 10px;
  --sidebar: 236px;
  --sidebar-collapsed: 64px;
  --focus: 0 0 0 3px rgba(90, 169, 255, .55);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--accent); }
a:hover { color: #8cc4ff; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; word-break: break-word; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--accent-strong); color: #fff; padding: 8px 14px; border-radius: 8px;
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- buttons and form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: #3b8cff; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn svg, .btn svg, .nav svg { width: 18px; height: 18px; flex: none; }

label { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin: 0 0 4px; }
input, select {
  width: 100%; min-height: 38px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font: inherit;
}
input:focus-visible, select:focus-visible { border-color: var(--accent); }
input[type="date"] { color-scheme: dark; }

/* ---------- login ---------- */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 28px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.login-card label { margin-top: 14px; }
.login-card .btn { margin-top: 20px; }
.login-title { font-size: 1.15rem; margin: 22px 0 6px; }
.login-note { margin: 16px 0 0; font-size: .8rem; color: var(--muted); text-align: center; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand-name { font-weight: 650; letter-spacing: .01em; white-space: nowrap; }
.brand-sub { font-size: .8rem; color: var(--muted); }
.brand-lg .brand-name { font-size: 1.1rem; }

/* ---------- application shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.app.collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; z-index: 30;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 14px 16px; min-height: 64px; }
.nav { list-style: none; margin: 4px 0; padding: 0 8px; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-3); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 16px; display: grid; gap: 6px; border-top: 1px solid var(--border); }
.ro-badge {
  justify-self: start; font-size: .75rem; font-weight: 600; letter-spacing: .02em;
  color: var(--ok); background: var(--ok-bg); padding: 2px 8px; border-radius: 999px;
}

.app.collapsed .brand-name, .app.collapsed .nav-label, .app.collapsed .sidebar-foot { display: none; }
.app.collapsed .sidebar-head { flex-direction: column; padding: 12px 8px; }
.app.collapsed .nav a { justify-content: center; padding: 10px; }

.shell { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 24px; background: rgba(11, 16, 22, .92);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.menu-btn { display: none; }
.top-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-width: 0; flex: 1; font-size: .85rem; }
.top-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.top-item strong { color: var(--text); font-weight: 500; }

.user-menu { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px 0 6px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font: inherit; cursor: pointer;
}
.avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase;
}
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 240px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.user-pop-info { font-size: .85rem; color: var(--muted); margin-bottom: 10px; display: grid; gap: 2px; }
.user-pop-info strong { color: var(--text); }

.main { padding: 24px; width: 100%; max-width: 1400px; outline: none; }
/* Focus is moved to <main> on navigation for screen readers; no ring needed. */
.main:focus, .main:focus-visible { box-shadow: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 25; }

/* ---------- cards, grids ---------- */
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 1rem; }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 650; margin-top: 4px; line-height: 1.2; overflow-wrap: anywhere; }
.stat-value.sm { font-size: 1.05rem; }
.stat-sub { margin-top: 6px; font-size: .82rem; color: var(--muted); }
.stat-sub + .stat-sub { margin-top: 2px; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--muted);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-warn { color: var(--warn); background: var(--warn-bg); }
.b-danger { color: var(--danger); background: var(--danger-bg); }
.b-info { color: var(--info); background: var(--info-bg); }
.b-crit { color: var(--crit); background: var(--crit-bg); }
.b-neutral { color: var(--muted); background: var(--neutral-bg); }

/* ---------- meters, bars ---------- */
.meter { display: grid; gap: 6px; }
.meter + .meter { margin-top: 14px; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; font-size: .88rem; }
.meter-top span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.meter-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: inherit; background: var(--accent); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.danger { background: var(--danger); }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 40px; align-items: center; gap: 10px; font-size: .85rem; }
.bar-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
caption { text-align: left; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.ip { display: inline-flex; align-items: center; gap: 4px; }
.copy-btn { width: 28px; height: 28px; border-radius: 6px; }
.copy-btn svg { width: 15px; height: 15px; }
.risk { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.risk-bar { width: 42px; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.risk-bar i { display: block; height: 100%; background: var(--muted); }

/* ---------- filters, pagination, tabs ---------- */
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.filters .actions { display: flex; gap: 8px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: .88rem; color: var(--muted); }
.pager .page-actions { gap: 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--surface-3); color: var(--text); border-color: var(--accent); }
.tab .count { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text); }

/* ---------- states ---------- */
.state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 40px 20px; color: var(--muted); }
.state svg { width: 32px; height: 32px; opacity: .8; }
.state strong { color: var(--text); font-size: 1rem; }
.state.error svg { color: var(--danger); }
.alert { border-radius: 8px; padding: 10px 12px; font-size: .88rem; border: 1px solid; margin-bottom: 12px; }
.alert-danger, .login .alert { color: #ffc1bc; background: var(--danger-bg); border-color: rgba(255, 123, 114, .4); }
.alert-warn { color: #f2d48a; background: var(--warn-bg); border-color: rgba(227, 179, 65, .4); }
.alert-info { color: #b9dcff; background: var(--info-bg); border-color: rgba(121, 192, 255, .35); }
.note { font-size: .82rem; color: var(--muted); border-left: 3px solid var(--border-strong); padding: 2px 0 2px 10px; margin: 12px 0 0; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton + .skeleton { margin-top: 10px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- detail dialog ---------- */
.detail {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.detail::backdrop { background: rgba(0, 0, 0, .6); }
.detail-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.detail-body { padding: 18px; display: grid; gap: 16px; }
.detail-body h3 { margin-bottom: 8px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
pre.json {
  margin: 0; padding: 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
  font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .actions { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); transform: translateX(-100%);
    transition: transform .2s ease; visibility: hidden;
  }
  .app.menu-open .sidebar { transform: none; visibility: visible; }
  .app.collapsed .brand-name, .app.collapsed .nav-label, .app.collapsed .sidebar-foot { display: revert; }
  .app.collapsed .sidebar-head { flex-direction: row; }
  .app.collapsed .nav a { justify-content: flex-start; padding: 9px 12px; }
  .collapse-btn { display: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 8px 16px; }
  .main { padding: 18px 16px; }
}
@media (max-width: 600px) {
  :root { font-size: 14px; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .top-item.optional { display: none; }
  .user-btn .user-name { display: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .card { padding: 14px; }
  /* Tables become stacked cards. */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  table.responsive td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; }
  table.responsive td.num { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .badge, .btn, .card { border: 1px solid CanvasText; }
}

/* Spacing between blocks stacked inside one card. */
.card > div + .kv, .card > .kv + div { margin-top: 12px; }
