:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #11172a;
  --surface-elevated: #18233d;
  --surface-muted: #1a233d;
  --text: #e8edf8;
  --text-muted: #9aa7c4;
  --primary: #7dd3fc;
  --border: #25304e;
  --success: #86efac;
  --danger: #fda4af;
  --warning: #fcd34d;
}

* {
  box-sizing: border-box;
}

/* Ensure the HTML `hidden` attribute is always respected, even when a
   class rule (e.g. display:flex on .checkbox-row) would otherwise win. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  background: #0b1020;
  background-attachment: fixed;
  color: var(--text);
}

a,
.button,
.action-menu-trigger,
.service-cluster,
.monitor-card,
.trend-bar,
.group-icon {
  transition: all 0.2s ease;
}

:focus-visible {
  outline: 2px solid rgba(125, 211, 252, 0.7);
  outline-offset: 2px;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.25;
  margin: 0 0 0.45rem;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.3;
  margin: 0 0 0.35rem;
}

h3 {
  font-size: 1rem;
  line-height: 1.3;
  margin: 0 0 0.3rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.98);
  backdrop-filter: none;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-right: auto;
}

.topbar-live-right {
  margin-left: 0;
  margin-right: 0.45rem;
}

.topbar-dashboard-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.live-connection-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(154, 167, 196, 0.28);
  background: rgba(24, 35, 61, 0.82);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.live-connection-dot {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 50%;
  background: rgba(154, 167, 196, 0.9);
  box-shadow: 0 0 0 2px rgba(154, 167, 196, 0.15);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.live-connection-indicator.is-connected {
  color: #cbf7dc;
  border-color: rgba(134, 239, 172, 0.45);
  background: rgba(22, 57, 43, 0.65);
}

.live-connection-indicator.is-connected .live-connection-dot {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.25);
}

.live-connection-indicator.is-connecting {
  color: #f5e7b4;
  border-color: rgba(252, 211, 77, 0.38);
  background: rgba(71, 52, 16, 0.5);
}

.live-connection-indicator.is-connecting .live-connection-dot {
  background: var(--warning);
  box-shadow: 0 0 0 2px rgba(252, 211, 77, 0.25);
}

.live-connection-indicator.is-disconnected {
  color: #f7c8cf;
  border-color: rgba(253, 164, 175, 0.45);
  background: rgba(73, 27, 36, 0.52);
}

.live-connection-indicator.is-disconnected .live-connection-dot {
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(253, 164, 175, 0.25);
}

.topbar-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.topbar-icon-link {
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.35rem 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.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;
}

.topbar-trend-range .button {
  min-width: 3rem;
  text-align: center;
}

/* ── topbar collapsible & mobile hamburger ─────────────────────────── */
.topbar-collapsible {
  display: none;
  position: absolute;
  top: calc(100% + 0.2rem);
  right: 0.9rem;
  left: auto;
  min-width: 320px;
  max-width: min(520px, calc(100vw - 1.8rem));
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.95rem;
  background: rgba(11, 16, 32, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38);
  z-index: 29;
}

.topbar-collapsible.is-open {
  display: flex;
}

.topbar-hamburger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.44rem 0.5rem;
  margin-left: 0;
  flex-shrink: 0;
  border-radius: 10px;
  background: #72cdf8;
  color: #07111f;
  border: 1px solid rgba(125, 211, 252, 0.35);
  cursor: pointer;
}

.topbar-collapsible .topbar-dashboard-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  width: 100%;
}

.topbar-collapsible .live-connection-indicator {
  align-self: flex-start;
}

.topbar-collapsible .topbar-trend-range {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  width: 100%;
}

.topbar-collapsible .topbar-trend-range .button {
  text-align: center;
  justify-content: center;
  min-width: 0;
}

.topbar-collapsible #open-create-monitor {
  width: 100%;
}

.topbar-collapsible .topbar-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  margin-left: 0;
  padding-left: 0;
  border-left: none;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  width: 100%;
}

.topbar-collapsible .user-pill {
  display: block;
  margin: 0 0 0.15rem;
  padding: 0.1rem 0.85rem;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.topbar-collapsible .topbar-icon-link {
  width: 100%;
  justify-content: flex-start;
  gap: 0.65rem;
  min-height: 0;
  padding: 0.7rem 0.85rem;
}

.topbar-collapsible .topbar-icon-link .sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border: 0;
}

.topbar-hamburger:hover {
  filter: brightness(1.06);
}

.hamburger-line {
  display: block;
  width: 1.05rem;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.topbar-hamburger[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.topbar-hamburger[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.topbar-hamburger[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-logo {
  width: 92px;
  height: auto;
  display: block;
}

.subtitle {
  color: var(--text-muted);
  margin-left: 0.75rem;
}

.container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 1.4rem 1.1rem 3.2rem;
}

.hero, .stats-grid {
  margin-bottom: 1.25rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.hero-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: var(--primary);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stats-grid-wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(260px, 0.8fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  background: rgba(17, 23, 42, 0.96);
  border: 1px solid rgba(73, 91, 134, 0.28);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: none;
}

.stat-card {
  min-height: 0;
  padding: 0.65rem 0.8rem;
}

.stat-card h2 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.stat-card .metric {
  font-size: 1.35rem;
  line-height: 1.2;
}

.stat-card-primary {
  background: rgba(20, 31, 56, 0.96);
}

.stat-card-soft {
  background: rgba(20, 31, 56, 0.96);
}

.stat-card-incident {
  border-color: rgba(253, 164, 175, 0.4);
}

.stack > :first-child {
  margin-top: 0;
}

.stack > :last-child {
  margin-bottom: 0;
}

.narrow {
  max-width: 460px;
}

.login-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding-top: 1.35rem;
}

.login-card {
  width: min(560px, 100%);
  background: linear-gradient(170deg, rgba(22, 32, 58, 0.96), rgba(17, 23, 42, 0.96));
  margin-top: 0;
  padding: 1.35rem 1.2rem 1.1rem;
}

.login-card.stack {
  display: grid;
  gap: 0.9rem;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  margin: 0;
}

.login-brand-logo {
  width: clamp(170px, 27vw, 240px);
  max-width: 100%;
  height: auto;
  display: block;
}

.login-card h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.login-card .eyebrow {
  margin-bottom: 0.45rem;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

.login-card .muted {
  font-size: 0.95rem;
  line-height: 1.45;
}

.login-actions {
  display: grid;
  gap: 0.7rem;
}

.login-actions .button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 0.62rem;
}

.login-form label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.login-form .button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.login-form .button-secondary {
  width: auto;
  justify-self: center;
  padding: 0.25rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-form .button-secondary:hover {
  color: var(--text);
  background: transparent;
  border: 0;
  filter: none;
}

.login-divider {
  position: relative;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid rgba(154, 167, 196, 0.25);
}

.login-divider span {
  position: relative;
  padding: 0 0.65rem;
  background: rgba(18, 25, 46, 0.96);
}

.no-tenant-shell {
  min-height: calc(100vh - 2.5rem);
  justify-content: center;
}

.no-tenant-brand-logo {
  width: clamp(240px, 34vw, 360px);
}

.no-tenant-card {
  text-align: center;
}

.no-tenant-card h1,
.no-tenant-card p {
  text-align: center;
}

.metric {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--primary);
}

.metric-small {
  font-size: 1.25rem;
}

.metric-danger {
  color: var(--danger);
}

.notice {
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 0.94rem;
  line-height: 1.4;
}

.notice.warning {
  border-color: rgba(252, 211, 77, 0.35);
  color: var(--warning);
}

.notice.error {
  border-color: rgba(253, 164, 175, 0.35);
  color: var(--danger);
}

.notice.success {
  margin-bottom: 1.25rem;
  border-color: rgba(125, 211, 252, 0.35);
  color: var(--primary);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0.62rem 0.85rem;
  background: #72cdf8;
  color: #07111f;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  border: 1px solid rgba(125, 211, 252, 0.35);
}

.button:hover {
  transform: none;
  filter: brightness(1.04);
}

.button-secondary {
  background: rgba(11, 16, 32, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
}

.button-secondary:hover {
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(18, 27, 49, 0.85);
}

.user-pill {
  margin-right: 0.75rem;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}

.break-all {
  word-break: break-all;
}

.form-grid label,
.form-grid input,
.form-grid select,
.form-grid button {
  width: 100%;
}

.form-grid label span {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.inline-grid.inline-grid-http-target {
  grid-template-columns: minmax(110px, 0.5fr) minmax(0, 1fr) minmax(110px, 0.45fr);
}

.inline-grid .field-compact {
  max-width: 100%;
}

.inline-grid .field-port-compact {
  max-width: 160px;
}

input {

  border: 1px solid var(--border);
  background: rgba(9, 14, 28, 0.9);
  color: var(--text);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

select {
  border: 1px solid var(--border);
  background: rgba(9, 14, 28, 0.9);
  color: var(--text);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

button {
  border: 0;
  cursor: pointer;
}

.button-danger {
  background: rgba(253, 164, 175, 0.14);
  color: var(--danger);
  border: 1px solid rgba(253, 164, 175, 0.35);
}

.button-small {
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
}

.button-tiny {
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
}

.reorder-button {
  min-width: 2.2rem;
  text-align: center;
}

.reorder-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.compact {
  margin-top: 0;
}

.input-small {
  font-size: 0.85rem;
  padding: 0.55rem 0.65rem;
}

.trend-range-toggle {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dashboard-board {
  display: grid;
  gap: 1.25rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.monitor-group {
  display: grid;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(37, 48, 78, 0.75);
}

.monitor-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.service-group-list {
  display: grid;
  gap: 1rem;
}

.service-cluster {
  overflow: visible;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 75, 116, 0.35);
  background: rgba(9, 14, 28, 0.58);
}

.service-cluster[open] {
  background: rgba(12, 19, 36, 0.68);
  border-color: rgba(73, 91, 134, 0.42);
}

.service-cluster:hover {
  border-color: rgba(97, 120, 172, 0.5);
}

.service-cluster-header {
  display: block;
  cursor: pointer;
  list-style: none;
}

.service-summary {
  display: grid;
  gap: 0.65rem;
}

.service-summary-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.service-summary-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.service-summary-trend {
  border: 0;
  background: transparent;
  padding: 0;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
}

.service-summary-trend .trend-bars {
  margin: 0;
  height: 1rem;
}

.service-summary-trend .trend-bar {
  height: 100%;
}

.service-cluster-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.group-icon {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.18rem;
  border: 1px solid rgba(125, 211, 252, 0.22);
  box-shadow: none;
}

.service-cluster-header::-webkit-details-marker {
  display: none;
}

.service-cluster-header h4,
.monitor-card-header h5 {
  margin: 0 0 0.25rem;
}

.service-cluster .monitor-grid {
  margin-top: 1rem;
}

.service-trend-trigger {
  margin-top: 0.8rem;
}

.service-cluster.is-dragging,
.monitor-card.is-dragging {
  opacity: 0.45;
}

.service-cluster.drop-target,
.monitor-card.drop-target {
  border-color: rgba(125, 211, 252, 0.7);
  box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.18);
}

.service-count {
  min-width: 1.65rem;
  height: 1.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: rgba(125, 211, 252, 0.08);
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 700;
}

.group-count {
  min-width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.15);
  color: var(--primary);
  font-weight: 700;
}

.group-problem .group-count {
  background: rgba(253, 164, 175, 0.18);
  color: var(--danger);
}

.group-healthy .group-count {
  background: rgba(74, 222, 128, 0.16);
  color: #86efac;
}

.group-pending .group-count {
  background: rgba(252, 211, 77, 0.16);
  color: var(--warning);
}

.group-paused .group-count {
  background: rgba(154, 167, 196, 0.18);
  color: var(--text-muted);
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.monitor-card {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 1rem;
  min-height: 100%;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(17, 24, 43, 0.9), rgba(11, 17, 33, 0.86));
}

.monitor-card:hover {
  border-color: rgba(125, 211, 252, 0.42);
}

.monitor-card.status-UP {
  border-color: rgba(74, 222, 128, 0.24);
}

.monitor-card.status-DOWN {
  border-color: rgba(253, 164, 175, 0.28);
}

.monitor-card.status-DEGRADED {
  border-color: rgba(252, 211, 77, 0.3);
}

.monitor-card.status-UNKNOWN,
.monitor-card.status-PAUSED {
  border-color: rgba(154, 167, 196, 0.24);
}

.monitor-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.monitor-header-right {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.monitor-cycle-indicator {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  border: 2px solid rgba(154, 167, 196, 0.4);
  border-top-color: rgba(154, 167, 196, 0.92);
  opacity: 0.35;
  flex-shrink: 0;
}

button.monitor-cycle-indicator {
  padding: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

button.monitor-cycle-indicator:disabled {
  cursor: wait;
}

.monitor-cycle-indicator.is-active {
  opacity: 1;
  animation: monitor-cycle-spin 0.8s linear infinite;
}

.monitor-card.status-UP .monitor-cycle-indicator {
  border-color: rgba(103, 219, 169, 0.35);
  border-top-color: rgba(103, 219, 169, 1);
}

.monitor-card.status-DEGRADED .monitor-cycle-indicator {
  border-color: rgba(255, 184, 102, 0.35);
  border-top-color: rgba(255, 184, 102, 1);
}

.monitor-card.status-DOWN .monitor-cycle-indicator {
  border-color: rgba(255, 110, 128, 0.35);
  border-top-color: rgba(255, 110, 128, 1);
}

.monitor-card.status-UNKNOWN .monitor-cycle-indicator,
.monitor-card.status-PAUSED .monitor-cycle-indicator {
  border-color: rgba(154, 167, 196, 0.3);
  border-top-color: rgba(154, 167, 196, 0.75);
}

@keyframes monitor-cycle-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .monitor-cycle-indicator.is-active {
    animation: none;
  }
}

.monitor-summary-trend {
  border: 1px solid rgba(37, 48, 78, 0.56);
  background: rgba(8, 12, 24, 0.34);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  width: 100%;
  min-height: 2rem;
}

.monitor-summary-trend .trend-bars {
  margin: 0;
  height: 1rem;
}

.monitor-summary-trend .trend-bar {
  height: 100%;
}

.monitor-card-header h4,
.monitor-card-header h5 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.compact-stack {
  display: grid;
  gap: 0.8rem;
}

.monitor-card-body {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.info-row {
  display: grid;
  gap: 0.25rem;
}

.monitor-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(5.1rem, auto);
  gap: 0.75rem;
  min-height: calc(5.1rem * 2 + 0.75rem);
}

.monitor-metric {
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(37, 48, 78, 0.5);
  min-height: 5.1rem;
}

.monitor-metric strong {
  display: block;
  margin-top: 0.25rem;
}

.monitor-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: auto;
  justify-content: flex-end;
  align-items: center;
}

.monitor-card-actions form {
  margin: 0;
}

.trend-panel {
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(37, 48, 78, 0.6);
  background: rgba(9, 14, 28, 0.42);
}

.trend-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.55rem;
}

.trend-trigger {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.trend-trigger:hover .trend-bar,
.trend-trigger:focus-visible .trend-bar {
  outline: 1px solid rgba(125, 211, 252, 0.55);
  outline-offset: 1px;
}

.trend-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(4px, 1fr);
  gap: 0.18rem;
  margin-bottom: 0;
  min-width: 132px;
  height: 1rem;
  align-items: stretch;
}

.trend-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: rgba(154, 167, 196, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.trend-up {
  background: linear-gradient(180deg, rgba(134, 239, 172, 0.95), rgba(74, 222, 128, 0.9));
}

.trend-degraded {
  background: linear-gradient(180deg, rgba(254, 240, 138, 0.95), rgba(252, 211, 77, 0.9));
}

.trend-down {
  background: linear-gradient(180deg, rgba(254, 202, 202, 0.95), rgba(253, 164, 175, 0.9));
}

.trend-none {
  background: rgba(154, 167, 196, 0.25);
}

.status-pill.status-UNKNOWN {
  background: rgba(154, 167, 196, 0.18);
  color: var(--text-muted);
}

.status-pill.status-PAUSED {
  background: rgba(154, 167, 196, 0.18);
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
}

.modal-close-button {
  width: 2.15rem;
  height: 2.15rem;
  min-width: 2.15rem;
  min-height: 2.15rem;
  max-width: 2.15rem;
  max-height: 2.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(9, 14, 28, 0.78);
  color: var(--text);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 2px 8px 0 rgba(0,0,0,0.08);
  transition: background 0.15s, border-color 0.15s;
}

.modal-close-button:hover {
  border-color: rgba(125, 211, 252, 0.48);
  background: rgba(20, 31, 56, 0.86);
}

.monitor-modal {
  width: min(640px, calc(100vw - 2rem));
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(17, 23, 42, 0.98);
  color: var(--text);
  padding: 1rem;
}

.group-modal {
  width: min(560px, calc(100vw - 2rem));
}

.group-icon-preview-panel {
  display: grid;
  gap: 0.65rem;
}

.group-icon-preview-frame {
  width: 4.25rem;
  height: 4.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: rgba(9, 14, 28, 0.55);
  border: 1px solid rgba(37, 48, 78, 0.7);
}

.group-icon-preview-frame img {
  width: 2.7rem;
  height: 2.7rem;
  object-fit: contain;
}

.group-icon-results {
  display: grid;
  gap: 0.6rem;
  max-height: 16rem;
  overflow-y: auto;
}

.group-icon-result {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(37, 48, 78, 0.75);
  background: rgba(9, 14, 28, 0.46);
  color: var(--text);
  text-align: left;
}

.group-icon-result:hover,
.group-icon-result:focus-visible,
.group-icon-result.is-selected {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(16, 25, 46, 0.85);
}

.group-icon-result img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  flex-shrink: 0;
}

.group-icon-result-body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.group-icon-result-body strong,
.group-icon-result-body span {
  overflow-wrap: anywhere;
}

.monitor-modal::backdrop {
  background: rgba(5, 8, 18, 0.72);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.trend-detail-modal {
  width: min(860px, calc(100vw - 2rem));
}

.trend-detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.trend-detail-card {
  padding: 0.85rem 1rem;
}

.trend-detail-card strong {
  display: block;
  margin-top: 0.35rem;
}

.trend-bars-large {
  min-width: 0;
  height: 1.25rem;
}

.trend-detail-latency-chart {
  margin-top: 0.35rem;
}

.trend-detail-latency-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}

.trend-detail-latency-ranges {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.trend-detail-latency-plot {
  position: relative;
  height: 132px;
  border: 1px solid rgba(37, 48, 78, 0.75);
  border-radius: 0.65rem;
  background: rgba(11, 16, 32, 0.5);
  overflow: hidden;
}

.latency-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0.45rem;
}

.latency-slot {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
}

.latency-slot.is-hovered {
  outline: 1px solid rgba(232, 237, 248, 0.92);
  outline-offset: -1px;
  box-shadow: 0 0 0 1px rgba(11, 16, 32, 0.65) inset;
}

.latency-slot-value {
  background: rgba(125, 211, 252, 0.75);
}

.latency-slot-degraded {
  background: rgba(252, 211, 77, 0.75);
}

.latency-slot-down {
  height: 100%;
  background: rgba(253, 164, 175, 0.45);
}

.latency-slot-empty {
  background: transparent;
}

.trend-detail-latency-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.3rem;
  align-items: stretch;
}

.trend-detail-latency-axis {
  font-size: 0.72rem;
  color: rgba(232, 237, 248, 0.78);
}

.trend-detail-latency-axis-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 3rem;
  text-align: right;
  padding: 0.1rem 0;
  line-height: 1.1;
}

.trend-detail-latency-axis-x {
  margin-top: 0.12rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.15rem 0.5rem;
  line-height: 1.1;
}

#trend-detail-latency-y-max {
  text-align: right;
}

#trend-detail-latency-y-mid {
  text-align: right;
}

#trend-detail-latency-y-min {
  text-align: right;
}

#trend-detail-latency-x-start {
  grid-column: 1;
  text-align: left;
}

#trend-detail-latency-x-end {
  grid-column: 2;
  text-align: right;
}

.trend-detail-latency-tooltip {
  position: absolute;
  z-index: 4;
  max-width: 220px;
  padding: 0.25rem 0.4rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(37, 48, 78, 0.95);
  background: rgba(17, 23, 42, 0.95);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

#trend-detail-latency-caption:empty {
  display: none;
}

.latency-bar {
  border-radius: 2px;
  background: rgba(125, 211, 252, 0.75);
}

.latency-avg-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(252, 211, 77, 0.95);
  pointer-events: none;
  transition: border-top-color 0.15s ease, border-top-width 0.15s ease;
}

.latency-avg-line.is-hovered {
  border-top-width: 2px;
  border-top-color: rgba(252, 211, 77, 1);
}

.latency-avg-hit {
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  background: transparent;
  cursor: help;
}

.latency-avg-label {
  position: absolute;
  right: 0.35rem;
  z-index: 3;
  padding: 0.08rem 0.28rem;
  border-radius: 0.3rem;
  border: 1px solid rgba(252, 211, 77, 0.8);
  background: rgba(11, 16, 32, 0.8);
  color: rgba(252, 211, 77, 0.98);
  font-size: 0.68rem;
  line-height: 1;
  pointer-events: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.9rem 0.75rem;
  border-top: 1px solid rgba(37, 48, 78, 0.75);
  vertical-align: top;
}

th {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  min-width: 7.2rem;
  text-align: center;
  flex-shrink: 0;
  border: 1px solid rgba(154, 167, 196, 0.25);
  text-transform: uppercase;
}

.action-menu {
  position: relative;
  margin-left: auto;
}

.service-summary-top .action-menu,
.monitor-header-right .action-menu {
  margin-left: 0;
}

.action-menu-trigger {
  list-style: none;
  width: 2.05rem;
  height: 2.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(9, 14, 28, 0.78);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.action-menu-trigger:hover {
  border-color: rgba(125, 211, 252, 0.48);
  background: rgba(20, 31, 56, 0.86);
}

.action-menu-trigger::-webkit-details-marker {
  display: none;
}

.action-menu[open] .action-menu-trigger {
  border-color: rgba(125, 211, 252, 0.45);
}

.action-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 20;
  min-width: 180px;
  white-space: nowrap;
  padding: 0.35rem;
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(11, 16, 32, 0.98);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.notification-events-card {
  margin-top: 1.6rem;
}

.state-events-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(170px, 1fr) auto auto;
  gap: 0.65rem;
  align-items: center;
}

.state-events-toolbar > label {
  margin: 0;
}

.state-events-toolbar input,
.state-events-toolbar select {
  width: 100%;
}

.state-events-toolbar .checkbox-row {
  width: auto;
  white-space: nowrap;
  justify-self: start;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.85rem;
}

.table-pagination-summary {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.table-pagination-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.section-footer-link {
  font-size: 0.9rem;
  padding-top: 0.5rem;
  text-align: right;
}

.table-pagination-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.85rem;
}

.action-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font: inherit;
  cursor: pointer;
}

.action-menu-item:hover {
  background: rgba(125, 211, 252, 0.14);
}

.action-menu-item-danger {
  color: var(--danger);
}

.action-menu-form {
  margin: 0;
}

.service-cluster-actions {
  justify-content: flex-end;
}

.status-pill.status-UP {
  background: rgba(134, 239, 172, 0.16);
  color: var(--success);
  border-color: rgba(134, 239, 172, 0.34);
}

.status-pill.status-DOWN {
  background: rgba(253, 164, 175, 0.15);
  color: var(--danger);
  border-color: rgba(253, 164, 175, 0.34);
}

.status-pill.status-DEGRADED {
  background: rgba(252, 211, 77, 0.15);
  color: var(--warning);
  border-color: rgba(252, 211, 77, 0.34);
}

.status-pill.status-UNKNOWN,
.status-pill.status-PAUSED {
  border-color: rgba(154, 167, 196, 0.28);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

a {
  color: var(--primary);
}

li + li {
  margin-top: 0.4rem;
}

@media (max-width: 880px) {
  .hero,
  .split-grid,
  .inline-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .section-header,
  .service-cluster-header,
  .trend-panel-header,
  .modal-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .section-header,
  .service-cluster-header,
  .trend-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .monitor-card-header {
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .monitor-card-header > :first-child {
    min-width: 0;
    flex: 1 1 220px;
  }

  .monitor-header-right {
    margin-left: auto;
    justify-content: flex-end;
    align-self: flex-start;
    flex-wrap: wrap;
  }

  .monitor-metrics {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .state-events-toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar-collapsible {
    top: 100%;
    left: 0;
    right: 0;
    max-width: none;
    min-width: 0;
    border-radius: 0;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(11, 16, 32, 0.99);
    border: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38);
    z-index: 29;
  }

  .topbar-collapsible .live-connection-indicator {
    align-self: flex-start;
  }

  .topbar-live-right {
    margin-left: 0.38rem;
    margin-right: 0.3rem;
    padding: 0.3rem 0.46rem;
    gap: 0.35rem;
  }

  .topbar-live-right .live-connection-text {
    font-size: 0.72rem;
  }

}

@media (max-width: 600px) {
  .container {
    padding: 1rem 0.9rem 3rem;
  }

  .topbar {
    padding: 0.9rem;
  }

  .card,
  .monitor-modal {
    padding: 1rem;
  }

  .monitor-grid {
    grid-template-columns: 1fr;
  }

  .monitor-card-actions {
    flex-direction: column;
  }

  .service-cluster-actions {
    flex-direction: column;
  }

  .monitor-card-actions .button,
  .monitor-card-actions form,
  .monitor-card-actions button,
  .service-cluster-actions .button,
  .service-cluster-actions form,
  .service-cluster-actions button {
    width: 100%;
  }

  .trend-range-toggle {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trend-range-toggle .button {
    text-align: center;
  }

  .service-summary-top {
    align-items: flex-start;
  }

  .service-summary-right {
    margin-left: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .button,
  .hero-actions .notice {
    width: 100%;
  }

  .state-events-toolbar {
    grid-template-columns: 1fr;
  }

  .table-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .table-pagination-actions {
    width: 100%;
    justify-content: space-between;
  }

  .notification-events-card table {
    font-size: 0.92rem;
  }

  .notification-events-card th,
  .notification-events-card td {
    padding: 0.7rem 0.55rem;
  }

  .event-message-cell,
  .notification-endpoint-cell,
  .notification-result-cell,
  .notification-error-cell {
    max-width: 16rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
  }
}

.admin-section {
  display: grid;
  gap: 1.1rem;
}

.admin-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem;
}

.admin-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.admin-nav-link:hover {
  color: var(--text);
  border-color: rgba(125, 211, 252, 0.25);
  background: rgba(125, 211, 252, 0.08);
}

.admin-nav-link.is-active {
  color: var(--primary);
  border-color: rgba(125, 211, 252, 0.35);
  background: rgba(125, 211, 252, 0.12);
}

.admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-header h1 {
  margin: 0;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-card-header-pad {
  padding: 1rem 1rem 0;
}

.table-card-filter-pad {
  padding: 0 1rem 1rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  border: 0;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table thead th {
  background: rgba(17, 23, 42, 0.92);
  color: var(--text-muted);
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tbody tr:nth-child(odd) {
  background: rgba(17, 23, 42, 0.56);
}

.admin-table tbody tr:hover {
  background: rgba(125, 211, 252, 0.12);
}

.admin-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inline-form {
  margin: 0;
}

.remote-node-log {
  border: 1px solid rgba(73, 91, 134, 0.42);
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  background: rgba(11, 16, 32, 0.35);
}

.remote-node-log > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.remote-node-log-list {
  margin: 0.45rem 0 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.45rem;
}

.remote-node-log-list li {
  margin: 0;
}

.admin-form {
  max-width: 760px;
  background: linear-gradient(180deg, rgba(20, 31, 56, 0.7), rgba(17, 23, 42, 0.92));
}

.form-group {
  display: grid;
  gap: 0.35rem;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.form-actions-align-end {
  align-items: flex-end;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.2;
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: var(--primary);
  background: rgba(125, 211, 252, 0.12);
}

.status-badge-success {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.35);
  background: rgba(134, 239, 172, 0.12);
}

.status-badge-muted {
  color: var(--text-muted);
  border-color: rgba(154, 167, 196, 0.25);
  background: rgba(154, 167, 196, 0.1);
}

.settings-grid {
  max-width: 920px;
}

.settings-card {
  max-width: none;
}

.settings-card-header,
.settings-channel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.settings-add-menu {
  margin-left: 0;
}

.settings-channel-list {
  display: grid;
  gap: 0.9rem;
}

.settings-channel-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(73, 91, 134, 0.28);
  background: rgba(11, 16, 32, 0.36);
}

.settings-empty-state {
  padding: 1rem;
  border-radius: 14px;
  border: 1px dashed rgba(154, 167, 196, 0.25);
  background: rgba(11, 16, 32, 0.22);
}

.settings-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.action-menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.action-menu-item:disabled:hover {
  background: transparent;
}

@media (max-width: 860px) {
  .admin-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-card {
    overflow-x: auto;
  }
  .admin-table {
    min-width: 760px;
  }
}
