/* Light theme by default. */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --card-2: #fafbfc;
  --border: #e6e8ec;
  --text: #1a1d21;
  --muted: #6b7280;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --accent: #4f46e5;

  /* Semantic status */
  --operational: #16a34a;
  --degraded: #d97706;
  --down: #dc2626;
  --unknown: #9aa1ab;

  --operational-bg: #eafaf0;
  --degraded-bg: #fdf3e7;
  --down-bg: #fdecec;
  --unknown-bg: #f1f3f5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; }

/* Header */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
h1 { margin: 0; font-size: 23px; font-weight: 650; letter-spacing: -0.01em; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.head-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.updated { color: var(--muted); font-size: 13px; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font-size: 14px; cursor: pointer; box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.spinning .btn-ico { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hero — overall status */
.hero:empty { display: none; }
.hero {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px; margin-bottom: 26px; box-shadow: var(--shadow);
  background: var(--card);
}
.hero.operational { background: var(--operational-bg); border-color: #cdeede; }
.hero.degraded { background: var(--degraded-bg); border-color: #f2ddc0; }
.hero.down { background: var(--down-bg); border-color: #f3cfcf; }
.hero-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.hero-body { flex: 1; min-width: 0; }
.hero-title { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Products */
.products { display: flex; flex-direction: column; gap: 18px; }
.product-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 0 2px 9px;
}
.product-name { font-size: 16px; font-weight: 650; }
.product-name-link { color: inherit; text-decoration: none; }
.product-name-link:hover { color: var(--accent); }
.product-name-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.product-name-link .ext { font-size: 12px; color: var(--muted); margin-left: 4px; }
.product-name-link:hover .ext { color: var(--accent); }
.product-desc { color: var(--muted); font-size: 13px; }
.status-pill {
  margin-left: auto; flex-shrink: 0;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  padding: 3px 10px; border-radius: 999px;
  align-self: center;
}
.status-pill.operational { color: var(--operational); background: var(--operational-bg); }
.status-pill.degraded { color: var(--degraded); background: var(--degraded-bg); }
.status-pill.down { color: var(--down); background: var(--down-bg); }
.status-pill.unknown { color: var(--muted); background: var(--unknown-bg); }

.product-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.product-empty { color: var(--muted); font-size: 13px; padding: 16px; }

/* Component rows (not clickable) */
.svc {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.svc:first-child { border-top: none; }
.svc-main { flex: 1; min-width: 0; }
.svc-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.svc-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.svc-status-text { font-size: 13px; color: var(--muted); }

/* Status dot */
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.operational, .dot.ok, .dot.none { background: var(--operational); }
.dot.degraded, .dot.minor { background: var(--degraded); }
.dot.down, .dot.major, .dot.critical { background: var(--down); }
.dot.unknown { background: var(--unknown); }
.dot.pulse { box-shadow: 0 0 0 0 currentColor; animation: pulse 1.9s infinite; }
.dot.down.pulse, .dot.major.pulse, .dot.critical.pulse { color: var(--down); }
.dot.degraded.pulse, .dot.minor.pulse { color: var(--degraded); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Infrastructure providers (secondary) */
.infra:empty { display: none; }
.infra { margin-top: 34px; }
.infra-heading {
  font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 0 2px 10px;
}
.providers-card {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--card); box-shadow: var(--shadow);
}
.provider {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.provider:first-child { border-top: none; }
.provider .dot { margin-top: 5px; }
.provider-main { flex: 1; min-width: 0; }
.provider-row { display: flex; align-items: center; gap: 10px; }
.provider-name { font-weight: 600; font-size: 14px; }
.provider-desc { color: var(--muted); font-size: 13px; }
.provider-link { margin-left: auto; color: var(--muted); text-decoration: none; font-size: 13px; flex-shrink: 0; }
.provider-link:hover { color: var(--accent); }

.incident { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--border); }
.incident-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.incident-name { font-weight: 600; font-size: 14px; }
.incident-body { color: var(--muted); font-size: 13px; margin-top: 4px; }
.incident-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.incident-meta a, .provider-link { color: var(--muted); }
.tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border);
}
.tag.critical, .tag.major { color: #fff; background: var(--down); border-color: transparent; }
.tag.minor { color: #fff; background: var(--degraded); border-color: transparent; }
.tag.maintenance { color: var(--muted); }

/* States */
.loading, .empty, .error { text-align: center; color: var(--muted); padding: 40px 20px; }
.error {
  background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--down); border-radius: 12px;
  text-align: left; color: var(--text); padding: 16px;
}
.error b { color: var(--down); }
.note { color: var(--muted); font-size: 12px; margin: 0 2px 12px; }

.page-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 36px; color: var(--muted); font-size: 12px;
}
.page-foot a { color: var(--muted); }
.page-foot code { font-size: 11px; background: var(--unknown-bg); padding: 1px 5px; border-radius: 4px; }
.foot-links { display: flex; gap: 14px; }

@media (prefers-reduced-motion: reduce) { .dot.pulse, .btn-ico { animation: none !important; } }
@media (max-width: 560px) {
  .wrap { padding: 20px 14px 48px; }
  .svc-status-text { display: none; }
  .status-pill { margin-left: 0; }
}
