:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e6e8eb;
  --border-soft: #f0f1f3;

  --green: #1f9d76;
  --green-soft: #e7f6f0;
  --yellow: #e0a106;
  --yellow-soft: #fdf4e0;
  --red: #e0413f;
  --red-soft: #fdeceb;
  --unknown: #cbd0d6;
  --unknown-soft: #eef0f2;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

/* Header */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner,
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1f9d76, #1565c0);
}

.brand {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s ease;
}

.btn-secondary:hover {
  background: #f3f4f6;
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  border: none;
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(0.95);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-edit {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  margin-left: auto;
  flex-shrink: 0;
}

.btn-edit:hover {
  color: var(--text);
  background: #f3f4f6;
}

.btn-delete {
  border: 1px solid #fecaca;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: #b91c1c;
  flex-shrink: 0;
}

.btn-delete:hover {
  background: #fef2f2;
}

.admin-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.admin-shell {
  width: min(420px, calc(100vw - 32px));
}

.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
}

.admin-brand {
  margin-bottom: 20px;
}

.admin-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.admin-lead {
  margin: 0 0 20px;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-submit {
  width: 100%;
  margin-top: 4px;
}

.admin-footer {
  margin: 20px 0 0;
  text-align: center;
}

.admin-footer a {
  color: var(--muted);
  text-decoration: none;
}

.admin-footer a:hover {
  color: var(--text);
}

.card-row-top {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  gap: 14px;
  align-items: center;
  width: 100%;
}

.card-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.domain-modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.18);
}

.domain-modal::backdrop {
  background: rgba(16, 24, 40, 0.35);
}

.domain-modal-inner {
  padding: 24px;
}

.domain-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.domain-modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--card);
}

.env-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
}

.env-pill.env-production {
  background: #e7f6f0;
  color: #1f9d76;
}

.env-pill.env-staging {
  background: #fdf4e0;
  color: #b07d00;
}

.env-pill.env-development {
  background: #e8f0fe;
  color: #1565c0;
}

.field-hint {
  min-height: 18px;
  margin: 0 0 12px;
}

.domain-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.container {
  padding-top: 28px;
  padding-bottom: 48px;
}

/* Hero (overall status) — BPI style full-width banner */
.status-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: var(--radius);
  padding: 22px 24px;
  color: #fff;
  margin-bottom: 24px;
}

.status-hero.status-operational {
  background: var(--green);
}

.status-hero.status-degraded {
  background: var(--yellow);
}

.status-hero.status-outage {
  background: var(--red);
}

.status-hero.status-unknown {
  background: #8a929c;
}

.hero-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}

.hero-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hero-text p {
  margin: 2px 0 0;
  font-size: 13px;
  opacity: 0.92;
}

/* Incident banner — OpenAI style */
.incident-banner {
  background: var(--yellow-soft);
  border: 1px solid #f1dca0;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.incident-banner.outage {
  background: var(--red-soft);
  border-color: #f3c0bf;
}

.incident-banner h3 {
  margin: 0 0 6px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.incident-banner .incident-meta {
  font-size: 13px;
  color: var(--muted);
}

/* Tabs */
.view-tabs {
  display: inline-flex;
  gap: 4px;
  background: #eceef1;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.view-tab {
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.view-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Section header */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.filter-btn.active {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

/* Cards */
.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-row {
  padding: 16px 20px;
}

.card-row.clickable {
  cursor: pointer;
}

.card-row.clickable:hover {
  background: #fafbfc;
}

.row-title-wrap {
  min-width: 0;
}

.row-title {
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron {
  color: var(--muted);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.card.expanded .chevron {
  transform: rotate(180deg);
}

.uptime-label {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Status dot */
.status-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.status-operational {
  background: var(--green);
}

.status-degraded {
  background: var(--yellow);
}

.status-outage {
  background: var(--red);
}

.status-unknown {
  background: var(--unknown);
}

/* Uptime history bars — OpenAI style */
.history {
  padding: 0 20px 16px;
}

.history-bar {
  display: flex;
  gap: 2px;
  align-items: stretch;
  height: 30px;
}

.history-segment {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: var(--unknown-soft);
}

.history-segment.operational {
  background: var(--green);
}

.history-segment.degraded {
  background: var(--yellow);
}

.history-segment.outage {
  background: var(--red);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

/* Expandable component list */
.card-details {
  border-top: 1px solid var(--border-soft);
  padding: 8px 0 4px;
}

.component-block {
  padding: 0 20px 12px;
  border-top: 1px solid var(--border-soft);
}

.component-block:first-child {
  border-top: none;
}

.component-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 8px 0 10px;
}

.component-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.history-compact {
  padding: 0 0 4px 30px;
}

.history-compact .history-bar {
  height: 20px;
}

.component-name {
  font-size: 13.5px;
  font-weight: 500;
}

.component-domain {
  font-size: 12px;
  color: var(--muted);
}

.component-state {
  font-size: 12.5px;
  font-weight: 500;
}

.component-state.operational {
  color: var(--green);
}

.component-state.degraded {
  color: var(--yellow);
}

.component-state.outage {
  color: var(--red);
}

.component-state.unknown {
  color: var(--muted);
}

/* Infrastructure metrics */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 4px 20px 12px;
}

.metric-card {
  background: #fafbfc;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px;
}

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

.metric-value {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.metric-bar {
  height: 6px;
  background: #e9ebee;
  border-radius: 999px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.metric-bar-fill.operational {
  background: var(--green);
}

.metric-bar-fill.degraded {
  background: var(--yellow);
}

.metric-bar-fill.outage {
  background: var(--red);
}

.metric-bar-fill.unknown {
  background: var(--unknown);
}

.service-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 16px;
}

.service-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: #fafbfc;
  border: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 500;
}

.service-pill .status-dot {
  width: 9px;
  height: 9px;
  font-size: 0;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px;
  font-size: 14px;
}

.card-empty {
  text-align: left;
  padding: 16px 4px 8px 30px;
}

.host-fields {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.host-fields legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.host-fields .field + .field {
  margin-top: 12px;
}

.field-note {
  display: block;
  font-size: 12px;
  margin-top: 6px;
  line-height: 1.4;
}

.infra-setup {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
}

.infra-setup h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.infra-steps {
  margin: 0 0 12px 18px;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.infra-hint {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}

.infra-hint code {
  font-size: 12px;
}

/* Footer */
.footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-dot.operational {
  background: var(--green);
}

.legend-dot.degraded {
  background: var(--yellow);
}

.legend-dot.outage {
  background: var(--red);
}

.legend-dot.unknown {
  background: var(--unknown);
}

.credit {
  margin-top: 4px;
  font-size: 12px;
}

@media (max-width: 640px) {
  .header-inner,
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

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

  .hero-text h1 {
    font-size: 18px;
  }
}
