:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #374151;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --gray: #6b7280;
  --blue: #2563eb;
}
* { box-sizing: border-box; }
.hidden { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
  font-size: 11px;
}
body.loggedOut header,
body.loggedOut main {
  display: none;
}
.loginScreen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.loginPanel {
  width: 320px;
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.loginPanel h1 { margin-bottom: 4px; }
body.alertFlash header {
  animation: alertPulse 700ms ease-in-out 5;
}
body.dashboardDisconnected header {
  background: #7f1d1d;
  border-bottom-color: #fecaca;
}
body.dashboardDisconnected #subtitle {
  color: #fee2e2;
}
@keyframes alertPulse {
  0%, 100% { background: #020617; }
  50% { background: #7f1d1d; }
}
header {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  background: #020617;
}
h1 { margin: 0; font-size: 16px; line-height: 18px; letter-spacing: 0; }
#subtitle { color: var(--muted); margin-top: 1px; font-size: 10px; }
.actions { display: flex; gap: 4px; align-items: center; }
#userBadge {
  color: var(--muted);
  padding-right: 4px;
}
button, .button, input, select, textarea {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
}
textarea {
  width: 100%;
  resize: vertical;
}
button:hover, .button:hover { filter: brightness(1.15); cursor: pointer; }
.button { text-decoration: none; display: inline-block; }
main {
  padding: 4px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 6px 290px;
  height: calc(100vh - 40px);
  gap: 0;
}
#eventsResizeGrip {
  cursor: row-resize;
  min-height: 6px;
  position: relative;
}
#eventsResizeGrip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 2px;
  height: 1px;
  background: var(--line);
}
#eventsResizeGrip:hover::after,
body.resizingRows #eventsResizeGrip::after {
  height: 3px;
  top: 1px;
  background: rgba(147,197,253,.55);
}
body.resizingRows {
  cursor: row-resize;
  user-select: none;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-height: 0;
}
.tableHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 6px;
  border-bottom: 1px solid var(--line);
  min-height: 26px;
}
h2 { margin: 0; font-size: 12px; line-height: 14px; }
.monitorFilters {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
#filter { width: 320px; max-width: 35vw; height: 22px; }
#nodeFilter,
#ownerFilter {
  width: 116px;
  height: 22px;
}
.tableWrap { overflow: auto; height: calc(100% - 26px); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; table-layout: fixed; }
th, td {
  padding: 1px 4px;
  border-bottom: 1px solid rgba(55,65,81,.8);
  text-align: left;
  line-height: 16px;
  height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
}
th {
  position: sticky;
  top: 0;
  background: #111827;
  z-index: 1;
  color: #d1d5db;
  font-weight: 600;
  padding-top: 2px;
  padding-bottom: 2px;
}
th .resizeGrip {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}
th .resizeGrip:hover,
body.resizingCols th .resizeGrip {
  background: rgba(147,197,253,.28);
}
body.resizingCols {
  cursor: col-resize;
  user-select: none;
}
tr:hover td { background: rgba(255,255,255,.035); }
tbody tr { cursor: default; }
tr.lossRateRow td { background: rgba(202,138,4,.12); }
tr.lossRateRow:hover td { background: rgba(202,138,4,.18); }
.badge {
  display: inline-block;
  min-width: 46px;
  text-align: center;
  padding: 0 4px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 10px;
  line-height: 14px;
}
.flashBadge {
  animation: badgeAlertPulse 700ms ease-in-out 5;
}
@keyframes badgeAlertPulse {
  0%, 100% { background: rgba(220,38,38,.25); color: #fecaca; }
  50% { background: #fef2f2; color: #7f1d1d; }
}
.UP { background: rgba(22,163,74,.2); color: #86efac; }
.LOSS { background: rgba(202,138,4,.32); color: #fde68a; }
.DOWN { background: rgba(220,38,38,.25); color: #fecaca; }
.UNKNOWN { background: rgba(202,138,4,.25); color: #fde68a; }
.SUSPENDED, .DISABLED { background: rgba(107,114,128,.25); color: #d1d5db; }
.eventDOWN { color: #fecaca; font-weight: 800; }
.eventUP { color: #86efac; font-weight: 800; }
.eventSUSPENDED, .eventRESUMED, .eventCOUNTERS_RESET { color: #bfdbfe; font-weight: 700; }
.smallBtn {
  padding: 1px 4px;
  border-radius: 3px;
  margin-right: 2px;
  line-height: 14px;
}
.dangerBtn { color: #fecaca; border-color: rgba(220,38,38,.55); }
.clipCell,
.noteCell,
.addrCell { overflow: hidden; text-overflow: ellipsis; }
.expiredAddedCell {
  background: rgba(220,38,38,.28) !important;
  color: #fecaca;
  font-weight: 700;
}
.noteCell { max-width: 170px; }
.addrCell { max-width: 220px; }
.dim { color: var(--muted); }
#monitorTable th:nth-child(1), #monitorTable td:nth-child(1) { width: 56px; }
#monitorTable th:nth-child(2), #monitorTable td:nth-child(2) { width: 82px; }
#monitorTable th:nth-child(3), #monitorTable td:nth-child(3) { width: 210px; }
#monitorTable th:nth-child(4), #monitorTable td:nth-child(4) { width: 78px; }
#monitorTable th:nth-child(5), #monitorTable td:nth-child(5) { width: 86px; }
#monitorTable th:nth-child(6), #monitorTable td:nth-child(6) { width: 62px; }
#monitorTable th:nth-child(7), #monitorTable td:nth-child(7) { width: 160px; }
#monitorTable th:nth-child(8), #monitorTable td:nth-child(8) { width: 62px; }
#monitorTable th:nth-child(9), #monitorTable td:nth-child(9) { width: 104px; }
#monitorTable th:nth-child(10), #monitorTable td:nth-child(10),
#monitorTable th:nth-child(11), #monitorTable td:nth-child(11),
#monitorTable th:nth-child(12), #monitorTable td:nth-child(12) { width: 48px; }
#monitorTable th:nth-child(13), #monitorTable td:nth-child(13) { width: 62px; }
#monitorTable th:nth-child(14), #monitorTable td:nth-child(14) { width: 76px; }
#monitorTable th:nth-child(15), #monitorTable td:nth-child(15) { width: 176px; }
#eventTable th:nth-child(1), #eventTable td:nth-child(1) { width: 74px; }
#eventTable th:nth-child(2), #eventTable td:nth-child(2) { width: 76px; }
#eventTable th:nth-child(3), #eventTable td:nth-child(3) { width: 340px; }
#eventTable th:nth-child(4), #eventTable td:nth-child(4),
#eventTable th:nth-child(5), #eventTable td:nth-child(5),
#eventTable th:nth-child(6), #eventTable td:nth-child(6),
#eventTable th:nth-child(7), #eventTable td:nth-child(7),
#eventTable th:nth-child(8), #eventTable td:nth-child(8) { width: 76px; }
@media (max-width: 1200px) {
  body { font-size: 10px; }
  main { grid-template-rows: minmax(0, 1fr) 6px 245px; }
  th, td { padding: 1px 3px; line-height: 15px; height: 17px; }
  #filter { width: 260px; }
  #nodeFilter, #ownerFilter { width: 96px; }
}
dialog {
  width: 620px;
  max-width: calc(100vw - 24px);
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
#ownersForm,
#usersForm {
  padding: 8px;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
#addMonitorForm { padding: 8px; }
.dialogHeader,
.dialogActions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dialogHeader {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.dialogActions {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.formGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 0;
}
label {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
}
label input {
  width: 100%;
  height: 23px;
  color: var(--text);
}
label select {
  width: 100%;
  min-height: 23px;
}
.usersList {
  display: grid;
  gap: 3px;
  max-height: 180px;
  overflow: auto;
  padding: 8px 0;
}
.userRow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(55,65,81,.7);
}
.ownerChecklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 8px;
  padding: 5px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 4px;
}
.ownerChecklist label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ownerChecklist input {
  width: auto;
  height: auto;
}
.flagGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 8px;
}
.flagGrid label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.flagGrid input {
  width: auto;
  height: auto;
}
.span2 { grid-column: span 2; }
#formMessage {
  min-height: 14px;
  color: #fde68a;
}
