/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: #0d1117;
  color: #e6edf3;
  -webkit-font-smoothing: antialiased;
}
a { color: #388bfd; text-decoration: none; }
a:hover { color: #58a6ff; text-decoration: underline; }

/* ── Variables ────────────────────────────────────────── */
:root {
  --surface: #161b22;
  --raised:  #1c2128;
  --border:  #30363d;
  --line:    #21262d;
  --text:    #e6edf3;
  --muted:   #8b949e;
  --dim:     #6e7681;
  --accent:  #388bfd;
  --green:   #3fb950;
  --yellow:  #e3b341;
  --red:     #f85149;
  --orange:  #d29922;
}

/* ── Topbar ───────────────────────────────────────────── */
/* ── Top bar shell ───────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 20px;
  gap: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  flex-shrink: 0;
}
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  object-fit: contain;
}
.brand-div { color: var(--border); font-weight: 300; font-size: 18px; margin: 0 -2px; }
.brand-sub { font-weight: 400; color: var(--muted); }

/* Thin vertical separator between brand and nav */
.topnav-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 12px;
}

/* Nav links row */
.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.topnav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--dim);
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, color .12s;
  line-height: 1;
}
.topnav-link:hover   { background: rgba(255,255,255,.06); color: var(--text); }
.topnav-active       { color: #58a6ff !important; }
.topnav-active:hover { background: rgba(88,166,255,.08); }

/* Alert count badge */
.nav-alert-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f85149;
  flex-shrink: 0;
  vertical-align: middle;
  margin-left: 5px;
  margin-bottom: 1px;
}

/* Right group: admin/user links — auto margin pushes it to far right */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.topnav-right-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--dim);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 5px;
  transition: color .12s;
}
.topnav-right-link:hover { color: var(--text); }
.topnav-username {
  font-size: 12px;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}
.topnav-signout {
  height: 26px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: border-color .12s, color .12s;
}
.topnav-signout:hover { border-color: var(--muted); color: var(--text); }
.live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.live-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 0%,100%{ opacity:1; } 50%{ opacity:.35; } }

/* ── Page body ────────────────────────────────────────── */
.page { padding: 20px 24px 64px; }

/* ── Stats strip ──────────────────────────────────────── */
.stats-strip {
  display: flex;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--surface);
}
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sdot-open { background: var(--red); }
.sdot-ack  { background: var(--yellow); }
.sdot-res  { background: var(--green); }

/* ── Tabs ─────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none !important;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-n {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  line-height: 18px;
  min-width: 20px;
  text-align: center;
}
.tab.active .tab-n { color: #79a8ff; background: #1c2d54; border-color: #2d4a96; }

/* ── Toolbar / Filters ────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar input[type=text],
.toolbar input[type=number],
.toolbar select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 0 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.toolbar select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236e7681'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.toolbar select option { background: #1c2128; color: #e6edf3; }
.toolbar input::placeholder { color: var(--dim); }
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,139,253,.12);
}
.in-status   { width: 150px; }
.in-priority { width: 140px; }
.in-search   { width: 230px; }
.in-limit    { width: 68px; }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; flex-shrink: 0; }

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  transition: background .1s, border-color .1s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); border-color: var(--muted); }
.btn-primary { background: #1f6feb; border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); }

/* ── Count line ───────────────────────────────────────── */
.count-line { font-size: 12px; color: var(--dim); margin-bottom: 10px; }

/* ── Data table ───────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 8px 12px;
  background: var(--raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.025); }

/* ── Cell types ───────────────────────────────────────── */
.cell-id a {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.cell-id a:hover { color: var(--accent); text-decoration: none; }
.cell-owner  { color: var(--muted); }
.cell-source { color: var(--muted); }
.cell-title  { max-width: 280px; }
.cell-time   { color: var(--dim); font-size: 12px; white-space: nowrap; font-family: ui-monospace, monospace; }

/* ── Badges / indicators ──────────────────────────────── */
.pri {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: .02em;
}
.pri-p1 { background: rgba(248,81,73,.14);  color: #ff7b72; border: 1px solid rgba(248,81,73,.3); }
.pri-p2 { background: rgba(227,179,65,.14); color: #e3b341; border: 1px solid rgba(227,179,65,.3); }
.pri-p3 { background: rgba(63,185,80,.12);  color: #56d364; border: 1px solid rgba(63,185,80,.28); }
.pri-p4 { background: rgba(56,139,253,.12); color: #79a8ff; border: 1px solid rgba(56,139,253,.28); }

.sev {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: capitalize;
}
.sev-critical { background: rgba(248,81,73,.14);  color: #ff7b72; }
.sev-high     { background: rgba(227,179,65,.14); color: #e3b341; }
.sev-medium   { background: rgba(210,153,34,.11); color: #d29922; }
.sev-low      { background: rgba(56,139,253,.1);  color: #79a8ff; }
.sev-info     { background: rgba(139,148,158,.1); color: #8b949e; }

.cat {
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
  font-family: ui-monospace, monospace;
}

.status-ind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
}
.status-ind .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.si-open         .dot { background: var(--red); }
.si-open              { color: #ff7b72; }
.si-acknowledged .dot { background: var(--yellow); }
.si-acknowledged      { color: var(--yellow); }
.si-resolved     .dot { background: var(--green); }
.si-resolved          { color: var(--green); }

/* ── Row action buttons ───────────────────────────────── */
.row-acts { display: flex; gap: 5px; }
.row-acts form { margin: 0; }
.btn-xs {
  height: 24px;
  padding: 0 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--dim);
  transition: all .12s;
}
.btn-xs:hover { background: #0d1117; color: var(--text); border-color: var(--muted); }
.btn-xs-ack:hover    { border-color: var(--yellow); color: var(--yellow); }
.btn-xs-resolve:hover { border-color: var(--green);  color: var(--green);  }

/* ── Pagination ───────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.pager-info { font-size: 12px; color: var(--dim); }
.pager-nav  { display: flex; gap: 6px; }
.pager-btn {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none !important;
  transition: background .1s, color .1s;
}
.pager-btn:hover { background: var(--raised); color: var(--text); }
.pager-btn.off { opacity: .35; pointer-events: none; }

/* ── Footer ───────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 10px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .05em;
}

/* ── Checkbox column ──────────────────────────────────── */
.col-check { width: 36px; padding: 0 6px 0 12px !important; }
input[type=checkbox] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
  vertical-align: middle;
}

/* ── Bulk action bar ──────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.btn-sm {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
}
.bulk-count { font-size: 12px; color: var(--muted); }

/* ── Auto-refresh indicator ───────────────────────────── */
.refresh-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}
.refresh-count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.btn-ghost {
  height: 26px;
  padding: 0 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  transition: all .12s;
}
.btn-ghost:hover { border-color: var(--border); color: var(--muted); }

/* ── Note form ────────────────────────────────────────── */
.note-form { display: flex; gap: 10px; align-items: flex-start; }
.note-form textarea {
  flex: 1;
  min-height: 72px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
.note-form textarea::placeholder { color: var(--dim); }
.note-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,139,253,.12);
}
.note-form .btn { align-self: flex-end; height: 36px; }

/* ── Event note content ───────────────────────────────── */
.event-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

/* ── Detail page ──────────────────────────────────────── */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.breadcrumb .sep { margin: 0 7px; color: var(--border); }

.alert-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.alert-header-left { flex: 1; min-width: 0; }
.alert-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}
.alert-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.alert-header-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: flex-start;
}

.section-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 14px;
  overflow: hidden;
}
.section-head {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--raised);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.section-body { padding: 14px; }

.kv-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.kv-grid dt { color: var(--muted); font-weight: 500; }
.kv-grid dd { color: var(--text); word-break: break-word; }

.metrics-row { display: flex; gap: 10px; margin-bottom: 14px; }
.metric-box {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--raised);
  padding: 12px 14px;
}
.metric-box .mk {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}
.metric-box .mv {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.accounts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.account-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--raised);
  overflow: hidden;
}
.account-box-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}
.account-a .account-box-head {
  color: #56d364;
  border-bottom-color: rgba(63,185,80,.3);
  background: rgba(63,185,80,.06);
}
.account-b .account-box-head {
  color: #ff7b72;
  border-bottom-color: rgba(248,81,73,.3);
  background: rgba(248,81,73,.06);
}
.account-box-body { padding: 10px 12px; }
.account-box-body .kv-grid { font-size: 12px; gap: 5px 10px; }

.flag-list { list-style: none; }
.flag-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.flag-list li:last-child { border-bottom: none; }
.flag-list li::before { content: '⚑'; color: var(--red); font-size: 10px; margin-top: 3px; flex-shrink: 0; }
.flag-none { color: var(--dim); font-size: 13px; font-style: italic; }

.time-meta { font-size: 12px; color: var(--dim); font-family: ui-monospace, monospace; }

/* ── Panel (shared across RMS, users, analytics) ─────── */
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-title {
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

/* ── Filter tab buttons (shared: analytics, RMS) ──────── */
.tab-group { display: flex; gap: 4px; }
.ftab {
  padding: 5px 13px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--dim);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.ftab:hover { color: var(--text); }
.ftab.active { background: var(--surface); border-color: var(--line); color: var(--text); }
.filter-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 880px) {
  .stats-strip { flex-wrap: wrap; width: 100%; }
  .stat { flex: 1; min-width: 90px; }
  .accounts-grid { grid-template-columns: 1fr; }
  .metrics-row { flex-direction: column; }
  .toolbar { flex-wrap: wrap; }
  .in-search { width: 160px; }
  .page { padding: 14px 14px 40px; }
  .alert-header { flex-direction: column; }
  .alert-header-right { flex-direction: row; }
}
