:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1a2230;
  --muted: #64728a;
  --line: #e3e8ef;
  --primary: #2c4a7c;
  --primary-ink: #1d3663;
  --ok-bg: #e6f6ee; --ok-fg: #0f7a4d;
  --warn-bg: #fdf0d5; --warn-fg: #9a5b00;
  --down-bg: #fde5e2; --down-fg: #b02a20;
  --ticket-bg: #e8eafc; --ticket-fg: #3949c4;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.45; }
a { color: var(--primary); }

.topbar { display: flex; align-items: center; gap: 20px; padding: 0 22px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.beacon { width: 10px; height: 10px; border-radius: 50%; background: var(--ok-fg); box-shadow: 0 0 0 0 rgba(15,122,77,0.5); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(15,122,77,0.45); } 70% { box-shadow: 0 0 0 7px rgba(15,122,77,0); } 100% { box-shadow: 0 0 0 0 rgba(15,122,77,0); } }
.mainnav { display: flex; gap: 4px; }
.mainnav a { padding: 7px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 500; }
.mainnav a.active, .mainnav a:hover { color: var(--primary-ink); background: #eef2f8; }
.spacer { flex: 1; }

.wrap { max-width: 1180px; margin: 22px auto; padding: 0 22px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat.is-danger .n { color: var(--down-fg); }
.stat.is-warn .n { color: var(--warn-fg); }
.stat.is-muted .n { color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.search { flex: 1; max-width: 420px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); font: inherit; }
.search:focus { outline: 2px solid #b9cbe8; border-color: #b9cbe8; }
.hint { color: var(--muted); font-size: 12px; }

.btn { background: var(--primary); color: #fff; border: 0; padding: 9px 14px; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--primary-ink); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fafbfd; cursor: pointer; user-select: none; }
.grid thead th[data-sort]:hover { color: var(--ink); }
.grid tbody tr.crow { cursor: pointer; }
.grid tbody tr.crow:hover { background: #f9fbfe; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tbody tr:last-child td { border-bottom: 0; }

.cust { font-weight: 600; }
.sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }

.chip { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok-fg); }
.chip-warn { background: var(--warn-bg); color: var(--warn-fg); }
.chip-down { background: var(--down-bg); color: var(--down-fg); }
.chip-ticket { background: var(--ticket-bg); color: var(--ticket-fg); }
.chip-none { background: #eef1f5; color: var(--muted); }
.tag { text-decoration: none; }
.tag-unmapped { color: var(--down-fg); font-weight: 600; }

/* Signature element: registration dot strip (NOC glance) */
.dots { display: flex; flex-wrap: wrap; gap: 3px; max-width: 340px; }
.d { width: 9px; height: 9px; border-radius: 2px; background: #cbd5e1; }
.d-on { background: var(--ok-fg); }
.d-off { background: var(--warn-fg); opacity: 0.55; }
.d-down { background: var(--down-fg); }

.detail td { background: #f8fafc; padding: 0 14px 12px; }
.sub-grid { width: 100%; border-collapse: collapse; margin-top: 4px; }
.sub-grid th, .sub-grid td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.sub-grid thead th { font-size: 11px; text-transform: uppercase; color: var(--muted); }

.editor { padding: 6px 0 10px; }
.at-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-width: 520px; }
.at-opt { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 11px; cursor: pointer; font: inherit; }
.at-opt:hover { border-color: var(--primary); background: #f5f8fd; }
.at-name { font-weight: 600; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 20px; transition: 0.15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; }
.switch input:checked + span { background: var(--ok-fg); }
.switch input:checked + span::before { transform: translateX(16px); }

.empty { margin-top: 20px; padding: 28px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hint { display: none; }
}
