:root {
  color-scheme: dark;
  --bg: #131417;
  --surface: #181a1e;
  --surface-elevated: #1e2127;
  --surface-hover: #23262e;
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f3f5;
  --text-secondary: #a8afbc;
  --text-muted: #8c93a1;

  --ok: #10b981;
  --ok-bar: #10b77f;
  --ok-head: #0d4d3a;
  --ok-border: rgba(16, 185, 129, 0.42);

  --maint: #60a5fa;
  --maint-bar: #3b82f6;
  --maint-head: #15355a;
  --maint-border: rgba(96, 165, 250, 0.45);

  --warn: #f59e0b;
  --warn-bar: #e69d14;
  --warn-head: #55390b;
  --warn-border: rgba(245, 158, 11, 0.48);

  --partial: #f97316;
  --partial-bar: #ea580c;
  --partial-head: #5c270d;
  --partial-border: rgba(249, 115, 22, 0.5);

  --down: #ef4444;
  --down-bar: #dc2626;
  --down-head: #5c191e;
  --down-border: rgba(239, 68, 68, 0.52);

  --nodata: #2a2d34;
  --radius-card: 10px;
  --radius-sm: 6px;
  --focus-ring: #60a5fa;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: clip;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.page-shell {
  width: min(100% - 32px, 688px);
  margin: 0 auto;
  padding: 36px 0 44px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.brand-name {
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-tag {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 10px;
  border-left: 1px solid var(--border-strong);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.refresh-btn:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.24);
}

/* Overall Banner Card (status.arena.ai two-band signature) */
.banner-card {
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--ok-border);
  background: var(--surface);
}

.banner-card[data-status="operational"] {
  border-color: var(--ok-border);
}
.banner-card[data-status="maintenance"] {
  border-color: var(--maint-border);
}
.banner-card[data-status="degraded"] {
  border-color: var(--warn-border);
}
.banner-card[data-status="partial_outage"] {
  border-color: var(--partial-border);
}
.banner-card[data-status="full_outage"] {
  border-color: var(--down-border);
}

.banner-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  background: var(--ok-head);
}

.banner-card[data-status="maintenance"] .banner-head {
  background: var(--maint-head);
}
.banner-card[data-status="degraded"] .banner-head {
  background: var(--warn-head);
}
.banner-card[data-status="partial_outage"] .banner-head {
  background: var(--partial-head);
}
.banner-card[data-status="full_outage"] .banner-head {
  background: var(--down-head);
}

.status-icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.banner-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  color: #ffffff;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.banner-body {
  padding: 15px 18px;
}

.banner-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  text-wrap: pretty;
}

.active-incidents {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.active-incident-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.active-incident-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.active-incident-main {
  min-width: 0;
  flex: 1;
}

.active-incident-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

.active-incident-msg {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  text-wrap: pretty;
}

.active-incident-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Shared Panel Cards */
#home-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}

.period-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.icon-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background-color 120ms ease, color 120ms ease;
}

.icon-nav-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.period-label {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}

.last-checked {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Service List & 90-day Uptime Bars */
.service-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.service-row {
  padding: 16px 18px 18px;
  border-bottom: 1px solid var(--border);
}

.service-row:last-child {
  border-bottom: 0;
}

.service-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.service-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.service-name {
  font-size: 14px;
  font-weight: 560;
  color: var(--text);
  overflow-wrap: break-word;
}

.service-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.service-detail-note {
  font-size: 12px;
  color: var(--text-muted);
}

.service-uptime {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.uptime-bars {
  display: flex;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  height: 26px;
}

.uptime-bar {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  border-radius: 2px;
  background: var(--nodata);
  transition: transform 110ms ease, opacity 110ms ease;
  transform-origin: center;
}

.uptime-bar[data-status="operational"] {
  background: var(--ok-bar);
}
.uptime-bar[data-status="maintenance"] {
  background: var(--maint-bar);
}
.uptime-bar[data-status="degraded"] {
  background: var(--warn-bar);
}
.uptime-bar[data-status="partial_outage"] {
  background: var(--partial-bar);
}
.uptime-bar[data-status="full_outage"] {
  background: var(--down-bar);
}
.uptime-bar[data-status="no_data"] {
  background: var(--nodata);
}

.uptime-bar:hover,
.uptime-bar:focus-visible,
.uptime-bar[aria-expanded="true"] {
  transform: scaleY(1.14);
  opacity: 0.92;
}

.mobile-range-caption {
  display: none;
  margin-top: 6px;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Calendar Grid (status.arena.ai hairline grid aesthetic) */
.calendar-legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot[data-level="degraded"] {
  background: var(--warn);
}
.legend-dot[data-level="partial_outage"] {
  background: var(--partial);
}
.legend-dot[data-level="full_outage"] {
  background: var(--down);
}

.calendar-wrap {
  width: 100%;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  border-bottom: 1px solid var(--border);
}

.calendar-weekdays span {
  text-align: center;
  padding: 11px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.cal-cell {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.cal-cell:nth-child(7n) {
  border-right: 0;
}

.cal-cell.last-row {
  border-bottom: 0;
}

.cal-day-plain {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cal-day-plain.is-today {
  color: var(--text);
  font-weight: 650;
}

.cal-day-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  border: 1.5px solid transparent;
  transition: background-color 120ms ease, transform 120ms ease;
}

.cal-day-btn:hover {
  transform: scale(1.06);
}

.cal-day-btn[data-severity="maintenance"] {
  border-color: var(--maint);
  background: rgba(59, 130, 246, 0.14);
}
.cal-day-btn[data-severity="degraded"] {
  border-color: var(--warn);
  background: rgba(245, 158, 11, 0.15);
}
.cal-day-btn[data-severity="partial_outage"] {
  border-color: var(--partial);
  background: rgba(249, 115, 22, 0.16);
}
.cal-day-btn[data-severity="full_outage"] {
  border-color: var(--down);
  background: rgba(239, 68, 68, 0.18);
}

/* Floating Popover */
.floating-popover {
  position: fixed;
  z-index: 60;
  width: min(296px, calc(100vw - 24px));
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 12px 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.48);
  color: var(--text);
}

.popover-date {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.popover-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 560;
}

.popover-status-left {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.popover-metrics {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.popover-incidents {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popover-incident-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  color: var(--text);
  transition: background-color 120ms ease;
}

.popover-incident-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Incident Detail View */
.back-row {
  margin-bottom: 14px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: color 120ms ease;
}

.back-link:hover {
  color: var(--text);
}

.incident-card-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.incident-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
}

.incident-hero-title {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.015em;
  color: var(--text);
  text-wrap: balance;
}

.incident-badge-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--text-secondary);
}

.pill-badge[data-tone="operational"] {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
}
.pill-badge[data-tone="maintenance"] {
  border-color: rgba(96, 165, 250, 0.42);
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.13);
}
.pill-badge[data-tone="degraded"] {
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.13);
}
.pill-badge[data-tone="partial_outage"] {
  border-color: rgba(249, 115, 22, 0.45);
  color: #fb923c;
  background: rgba(249, 115, 22, 0.14);
}
.pill-badge[data-tone="full_outage"] {
  border-color: rgba(239, 68, 68, 0.48);
  color: #f87171;
  background: rgba(239, 68, 68, 0.14);
}

.incident-time-summary {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.affected-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
}

.affected-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.affected-bar-track {
  width: 140px;
  height: 8px;
  border-radius: 999px;
  background: var(--ok-bar);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

.affected-bar-segment {
  height: 100%;
  margin-left: 24%;
  width: 52%;
}

.affected-bar-segment[data-level="maintenance"] {
  background: var(--maint-bar);
}
.affected-bar-segment[data-level="degraded"] {
  background: var(--warn-bar);
}
.affected-bar-segment[data-level="partial_outage"] {
  background: var(--partial-bar);
}
.affected-bar-segment[data-level="full_outage"] {
  background: var(--down-bar);
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.timeline-item {
  position: relative;
  padding-left: 24px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: -20px;
  width: 1px;
  background: var(--border-strong);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  position: absolute;
  left: 1px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.timeline-dot[data-stage="resolved"],
.timeline-dot[data-stage="completed"] {
  background: var(--ok);
}
.timeline-dot[data-stage="monitoring"] {
  background: var(--maint);
}
.timeline-dot[data-stage="identified"],
.timeline-dot[data-stage="scheduled"],
.timeline-dot[data-stage="in_progress"] {
  background: var(--warn);
}
.timeline-dot[data-stage="investigating"] {
  background: var(--down);
}

.timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.timeline-stage {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.timeline-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.timeline-msg {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  text-wrap: pretty;
}

/* Loading & Error States */
.loading-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.skeleton-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  opacity: 0.7;
}

.skeleton-banner {
  height: 104px;
}

.skeleton-services {
  height: 290px;
}

.skeleton-calendar {
  height: 310px;
}

.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 28px 22px;
  text-align: center;
}

.error-card h1 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 650;
}

.error-card p {
  margin: 0 0 18px;
  color: var(--text-secondary);
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  background: #f1f3f5;
  color: #131417;
  font-size: 13px;
  font-weight: 620;
  transition: opacity 120ms ease;
}

.primary-btn:hover {
  opacity: 0.9;
}

.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  font-size: 12px;
  font-weight: 560;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.22);
}

/* Footer */
.site-footer {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

/* Admin Console Forms */
.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 560;
  color: var(--text-secondary);
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
}

.textarea-input {
  min-height: 88px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-chip input {
  accent-color: var(--ok);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.form-feedback {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-feedback[data-tone="ok"] {
  color: #34d399;
}

.form-feedback[data-tone="error"] {
  color: #f87171;
}

.admin-incident-list {
  display: flex;
  flex-direction: column;
}

.admin-incident-item {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-incident-item:last-child {
  border-bottom: 0;
}

.admin-incident-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-inline-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 560px) {
  .page-shell {
    width: calc(100% - 24px);
    padding: 22px 0 32px;
  }

  .brand-tag {
    display: none;
  }

  .panel-header {
    padding: 13px 14px;
  }

  .service-row {
    padding: 14px;
  }

  .service-detail-note {
    display: none;
  }

  .uptime-bar.hide-on-mobile {
    display: none;
  }

  .uptime-bars {
    gap: 3px;
    height: 24px;
  }

  .mobile-range-caption {
    display: flex;
  }

  .calendar-legend {
    width: 100%;
  }

  .cal-cell {
    height: 42px;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
