:root {
  --bg: #07111f;
  --bg-accent: #12253d;
  --panel: rgba(7, 17, 31, 0.76);
  --panel-strong: rgba(10, 22, 40, 0.92);
  --line: rgba(148, 190, 255, 0.14);
  --text: #eef4ff;
  --muted: #9fb6d3;
  --fresh: #3fd28f;
  --stale: #f6be4f;
  --failing: #ff6b7f;
  --offline: #a8b1c7;
  --unknown: #59b4ff;
  --orion: #3fb3ff;
  --postgres: #ffb44d;
  --glow: rgba(72, 150, 255, 0.18);
  --shadow: 0 28px 90px rgba(3, 10, 22, 0.45);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --font-sans: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(73, 155, 255, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(30, 214, 152, 0.14), transparent 24%),
    linear-gradient(160deg, #06111f 0%, #0c1b2e 48%, #050c16 100%);
  color: var(--text);
  font-family: var(--font-sans);
}

body {
  position: relative;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 0, transparent calc(100% - 1px), rgba(146, 194, 255, 0.05) calc(100% - 1px)),
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(146, 194, 255, 0.04) calc(100% - 1px));
  background-size: 100% 42px, 42px 100%;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 88%);
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.9fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-panel,
.panel,
.summary-card,
.agent-card {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-copy,
.hero-panel,
.panel {
  border-radius: var(--radius-xl);
}

.hero-copy {
  padding: 32px;
}

.hero-panel {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(15, 33, 58, 0.98) 0%, rgba(7, 17, 31, 0.88) 100%);
}

.eyebrow,
.section-kicker,
.hero-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: #78c9ff;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3.5vw, 3.4rem);
  line-height: 0.95;
  max-width: 12ch;
}

.subtitle {
  margin-top: 18px;
  max-width: 64ch;
  color: var(--muted);
  line-height: 1.6;
}

#last-refresh {
  font-size: 1.35rem;
}

.loading-indicator {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.loading-indicator.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.loading-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 190, 255, 0.12);
  border: 1px solid rgba(148, 190, 255, 0.16);
}

.loading-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(63, 179, 255, 0.82), rgba(63, 210, 143, 0.92));
  box-shadow: 0 0 18px rgba(63, 179, 255, 0.28);
  transition: width 0.45s ease;
}

.loading-indicator.is-failed .loading-progress-bar {
  background: linear-gradient(90deg, rgba(255, 107, 127, 0.9), rgba(255, 162, 112, 0.9));
  box-shadow: 0 0 18px rgba(255, 107, 127, 0.28);
}

.loading-progress-label {
  font-size: 0.84rem;
}

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

.summary-grid,
.agents-grid,
.meta-grid,
.connectivity-grid {
  display: grid;
  gap: 16px;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 24px;
}

.age-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 0;
}

.summary-card {
  appearance: none;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.summary-card::after {
  content: "";
  position: absolute;
  inset: auto -10% -40% -10%;
  height: 75px;
  background: linear-gradient(90deg, transparent, var(--glow), transparent);
}

.summary-card:hover {
  transform: translateY(-2px);
  border-color: rgba(120, 201, 255, 0.28);
}

.summary-card.active {
  border-color: rgba(120, 201, 255, 0.5);
  box-shadow: 0 18px 52px rgba(3, 10, 22, 0.5);
}

.summary-card.summary-age::after {
  inset: auto -15% -45% -15%;
  height: 92px;
}

.summary-card:focus-visible,
.field-input:focus-visible,
.ghost-button:focus-visible {
  outline: 2px solid rgba(120, 201, 255, 0.9);
  outline-offset: 2px;
}

.summary-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
}

.summary-helper {
  display: block;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.summary-card.summary-lt3h {
  border-color: rgba(63, 210, 143, 0.24);
  background:
    linear-gradient(180deg, rgba(10, 36, 29, 0.92) 0%, rgba(7, 17, 31, 0.88) 100%);
}

.summary-card.summary-lt3h::after {
  background: linear-gradient(90deg, transparent, rgba(63, 210, 143, 0.26), transparent);
}

.summary-card.summary-lt6h {
  border-color: rgba(74, 212, 194, 0.24);
  background:
    linear-gradient(180deg, rgba(8, 34, 40, 0.92) 0%, rgba(7, 17, 31, 0.88) 100%);
}

.summary-card.summary-lt6h::after {
  background: linear-gradient(90deg, transparent, rgba(74, 212, 194, 0.24), transparent);
}

.summary-card.summary-lt12h {
  border-color: rgba(89, 180, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(10, 28, 48, 0.92) 0%, rgba(7, 17, 31, 0.88) 100%);
}

.summary-card.summary-lt12h::after {
  background: linear-gradient(90deg, transparent, rgba(89, 180, 255, 0.26), transparent);
}

.summary-card.summary-lt24h {
  border-color: rgba(255, 184, 92, 0.28);
  background:
    linear-gradient(180deg, rgba(48, 30, 8, 0.92) 0%, rgba(7, 17, 31, 0.88) 100%);
}

.summary-card.summary-lt24h::after {
  background: linear-gradient(90deg, transparent, rgba(255, 184, 92, 0.28), transparent);
}

.summary-card.summary-gt24h {
  border-color: rgba(255, 107, 127, 0.38);
  background:
    linear-gradient(180deg, rgba(52, 13, 21, 0.96) 0%, rgba(13, 18, 32, 0.92) 100%);
}

.summary-card.summary-gt24h::after {
  background: linear-gradient(90deg, transparent, rgba(255, 107, 127, 0.38), transparent);
}

.panel {
  padding: 24px;
  margin-bottom: 24px;
}

.filters-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) repeat(3, minmax(170px, 0.7fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.field-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.field-input {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(148, 190, 255, 0.14);
  background: rgba(8, 18, 34, 0.88);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
}

.field-input::placeholder {
  color: rgba(159, 182, 211, 0.7);
}

.filter-note {
  margin-bottom: 18px;
  min-height: 1.2em;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.connectivity-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.service-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  background: rgba(10, 22, 40, 0.84);
  border: 1px solid rgba(148, 190, 255, 0.12);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.service-card.service-orion {
  border-color: rgba(63, 179, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(10, 34, 58, 0.95) 0%, rgba(6, 17, 31, 0.92) 100%);
}

.service-card.service-postgres {
  border-color: rgba(255, 180, 77, 0.24);
  background:
    linear-gradient(180deg, rgba(50, 32, 10, 0.94) 0%, rgba(11, 18, 28, 0.92) 100%);
}

.service-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.service-title {
  font-size: 1.18rem;
}

.service-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.service-body {
  display: grid;
  gap: 10px;
}

.service-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6, 14, 24, 0.38);
  border: 1px solid rgba(148, 190, 255, 0.08);
}

.service-row-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.service-row-value {
  text-align: right;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.service-note {
  margin-top: 6px;
}

.meta-item {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(15, 29, 50, 0.62);
  border: 1px solid rgba(148, 190, 255, 0.08);
}

.meta-item-label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

.meta-item-value {
  font-size: 1rem;
  line-height: 1.45;
  word-break: break-word;
}

.agents-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.agent-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  display: grid;
  gap: 18px;
  align-content: start;
  background:
    linear-gradient(180deg, rgba(12, 28, 48, 0.92) 0%, rgba(6, 17, 31, 0.9) 100%);
}

.agent-topline {
  display: grid;
  gap: 10px;
}

.agent-topline > div {
  min-width: 0;
}

.agent-name {
  font-size: 1.18rem;
  overflow-wrap: anywhere;
}

.agent-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.agent-image {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-statuses,
.metric-list,
.detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid transparent;
  max-width: 100%;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

.pill.fresh {
  color: var(--fresh);
  background: rgba(63, 210, 143, 0.2);
  border-color: rgba(63, 210, 143, 0.34);
}

.pill.stale {
  color: var(--stale);
  background: rgba(246, 190, 79, 0.2);
  border-color: rgba(246, 190, 79, 0.34);
}

.pill.failing {
  color: var(--failing);
  background: rgba(255, 107, 127, 0.24);
  border-color: rgba(255, 107, 127, 0.4);
}

.pill.offline,
.pill.off {
  color: var(--offline);
  background: rgba(168, 177, 199, 0.12);
  border-color: rgba(168, 177, 199, 0.2);
}

.pill.unknown,
.pill.on,
.pill.neutral {
  color: var(--unknown);
  background: rgba(89, 180, 255, 0.18);
  border-color: rgba(89, 180, 255, 0.32);
}

.pill.target-orion {
  color: #d8f2ff;
  background: linear-gradient(135deg, rgba(34, 124, 255, 0.9), rgba(35, 188, 255, 0.7));
  border-color: rgba(108, 201, 255, 0.5);
}

.pill.target-postgres {
  color: #fff4da;
  background: linear-gradient(135deg, rgba(255, 154, 0, 0.88), rgba(255, 198, 92, 0.72));
  border-color: rgba(255, 198, 92, 0.55);
}

.agent-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(8, 18, 34, 0.86);
  border: 1px solid rgba(148, 190, 255, 0.08);
}

.metric.metric-emphasis {
  background: linear-gradient(180deg, rgba(9, 31, 55, 0.96) 0%, rgba(8, 18, 34, 0.9) 100%);
  border-color: rgba(93, 188, 255, 0.34);
}

.metric-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.metric.metric-emphasis .metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #d8f4ff;
}

.metric.metric-emphasis.metric-age-lt3h {
  border-color: rgba(63, 210, 143, 0.32);
  background: linear-gradient(180deg, rgba(10, 42, 31, 0.96) 0%, rgba(8, 18, 34, 0.9) 100%);
}

.metric.metric-emphasis.metric-age-lt3h .metric-value {
  color: #92ffd0;
}

.metric.metric-emphasis.metric-age-lt6h {
  border-color: rgba(74, 212, 194, 0.28);
  background: linear-gradient(180deg, rgba(8, 38, 40, 0.96) 0%, rgba(8, 18, 34, 0.9) 100%);
}

.metric.metric-emphasis.metric-age-lt6h .metric-value {
  color: #9effea;
}

.metric.metric-emphasis.metric-age-lt12h {
  border-color: rgba(89, 180, 255, 0.28);
}

.metric.metric-emphasis.metric-age-lt24h {
  border-color: rgba(255, 184, 92, 0.36);
  background: linear-gradient(180deg, rgba(48, 30, 8, 0.96) 0%, rgba(8, 18, 34, 0.9) 100%);
}

.metric.metric-emphasis.metric-age-lt24h .metric-value {
  color: #ffd8a0;
}

.metric.metric-emphasis.metric-age-gt24h,
.metric.metric-emphasis.metric-age-unknown {
  border-color: rgba(255, 107, 127, 0.42);
  background: linear-gradient(180deg, rgba(58, 16, 27, 0.96) 0%, rgba(8, 18, 34, 0.9) 100%);
}

.metric.metric-emphasis.metric-age-gt24h .metric-value,
.metric.metric-emphasis.metric-age-unknown .metric-value {
  color: #ffb2be;
}

.agent-footer {
  display: grid;
  gap: 12px;
}

.agent-detail {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 190, 255, 0.08);
  background: rgba(8, 18, 34, 0.52);
  line-height: 1.55;
  overflow-wrap: anywhere;
  display: grid;
  gap: 8px;
}

.agent-detail strong {
  display: block;
}

.detail-emphasis {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-summary {
  line-height: 1.5;
}

.detail-empty {
  color: var(--muted);
}

.detail-probe-error {
  color: #ffb2be;
  font-size: 0.82rem;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(72, 13, 23, 0.55);
  border: 1px solid rgba(255, 107, 127, 0.2);
}

.last-sync {
  border-color: rgba(82, 181, 255, 0.22);
  background: linear-gradient(180deg, rgba(6, 28, 50, 0.76) 0%, rgba(8, 18, 34, 0.54) 100%);
}

.last-sync .detail-emphasis {
  color: #8ae0ff;
}

.last-error {
  border-color: rgba(255, 107, 127, 0.18);
}

.last-error .detail-emphasis {
  color: #ff9dae;
}

.agent-card.status-failing {
  border-color: rgba(255, 107, 127, 0.42);
  box-shadow:
    0 0 0 1px rgba(255, 107, 127, 0.12),
    0 28px 90px rgba(35, 5, 12, 0.44);
  background:
    linear-gradient(180deg, rgba(34, 16, 28, 0.95) 0%, rgba(10, 18, 33, 0.92) 100%);
}

.agent-card.status-failing .last-error {
  border-color: rgba(255, 107, 127, 0.36);
  background: linear-gradient(180deg, rgba(65, 19, 30, 0.8) 0%, rgba(30, 11, 18, 0.72) 100%);
}

.agent-card.status-failing .last-sync {
  border-color: rgba(82, 181, 255, 0.3);
}

.agent-card.status-stale {
  border-color: rgba(246, 190, 79, 0.28);
}

.agent-card.age-gt24h:not(.status-failing) {
  border-color: rgba(255, 107, 127, 0.3);
  background:
    linear-gradient(180deg, rgba(38, 14, 22, 0.94) 0%, rgba(8, 17, 31, 0.9) 100%);
}

.agent-card.age-lt24h:not(.status-failing):not(.status-stale) {
  border-color: rgba(255, 184, 92, 0.2);
}

.ghost-button {
  appearance: none;
  border: 1px solid rgba(120, 201, 255, 0.22);
  background: rgba(89, 180, 255, 0.1);
  color: #dff1ff;
  border-radius: 999px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.ghost-button:hover {
  transform: translateY(-1px);
  background: rgba(89, 180, 255, 0.16);
  border-color: rgba(120, 201, 255, 0.34);
}

.last-error .ghost-button {
  margin-top: 12px;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 18, 0.72);
  backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  width: min(860px, calc(100% - 24px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  border-radius: var(--radius-xl);
  background: rgba(10, 22, 40, 0.96);
  border: 1px solid rgba(148, 190, 255, 0.16);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 18px;
  overflow: hidden;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.modal-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.modal-message {
  margin: 0;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(4, 12, 24, 0.9);
  border: 1px solid rgba(148, 190, 255, 0.08);
  color: #dbe7f8;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.empty-state {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: rgba(12, 28, 48, 0.6);
  border: 1px dashed rgba(148, 190, 255, 0.18);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .service-head,
  .service-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1240px);
    padding-top: 20px;
  }

  .hero-copy,
  .hero-panel,
  .panel {
    padding: 20px;
  }

  .modal-panel {
    width: calc(100% - 16px);
    margin: 8px auto;
    max-height: calc(100vh - 16px);
    padding: 18px;
  }

  .modal-head {
    flex-direction: column;
  }

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