:root {
  color-scheme: dark;
  --bg: #14151a;
  --surface: #1a1c22;
  --surface-raised: #20232b;
  --surface-soft: #181a20;
  --border: #2d303a;
  --border-subtle: #24262e;
  --text: #ede9e0;
  --text-muted: #a6a39a;
  --text-dim: #858994;
  --blue: #2f9bd6;
  --blue-hover: #55afe0;
  --blue-soft: rgba(47, 155, 214, 0.1);
  --green: #5fae6e;
  --amber: #d9a93f;
  --red: #d9685b;
  --mauve: #9c7a8c;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --font-sans: Geist, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

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

a,
button {
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    opacity 150ms ease;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

::selection {
  background: rgba(47, 155, 214, 0.26);
  color: var(--text);
}

.masthead {
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid rgba(45, 48, 58, 0.88);
  background: rgba(20, 21, 26, 0.88);
  backdrop-filter: blur(14px);
}

.masthead__inner,
.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.masthead__inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand__mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #080a10;
}

.brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand__copy {
  min-width: 0;
}

.brand__name {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 720;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand__eyebrow {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.2;
}

.masthead__nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.nav-link,
.nav-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 620;
  white-space: nowrap;
}

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

.nav-link:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.nav-link--accent {
  color: var(--blue);
}

.nav-link svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.nav-badge {
  border-color: rgba(95, 174, 110, 0.34);
  background: rgba(95, 174, 110, 0.08);
  color: var(--green);
}

.page-shell {
  padding-block: 44px 72px;
}

.overview {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.overview::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--status, var(--blue));
  content: "";
}

.overview__main {
  min-width: 0;
  padding: 30px;
}

.overview__label,
.section-label {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 680;
}

.overview__state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: var(--status, var(--text-dim));
}

.status-dot--large {
  width: 12px;
  height: 12px;
  flex-basis: 12px;
}

.overview__title {
  margin: 0;
  color: var(--status, var(--text));
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.03;
}

.overview__description {
  max-width: 650px;
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.overview__subline {
  margin-top: 21px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--text-dim);
  font-size: 12px;
}

.overview__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: stretch;
  border-left: 1px solid var(--border-subtle);
}

.overview-stat {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.overview-stat:nth-child(odd) {
  border-right: 1px solid var(--border-subtle);
}

.overview-stat:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.overview-stat__label {
  color: var(--text-dim);
  font-size: 12px;
}

.overview-stat__value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--status) 36%, transparent);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  background: color-mix(in srgb, var(--status) 9%, transparent);
  color: var(--status);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.service-area {
  margin-top: 38px;
}

.section-heading {
  margin-bottom: 16px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2,
.panel__title,
.legal-title {
  margin: 0;
  color: var(--text);
  font-weight: 720;
  letter-spacing: -0.025em;
}

.section-heading h2 {
  margin-top: 5px;
  font-size: 19px;
}

.section-heading__meta {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.group-block {
  margin-bottom: 26px;
  transition: opacity 150ms ease;
}

.group-heading {
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 660;
}

.drag-handle {
  display: inline-flex;
  min-width: 22px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: grab;
  user-select: none;
}

.drag-handle:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.drag-handle:active {
  cursor: grabbing;
}

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

.service-card {
  --status: var(--text-dim);
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--status);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    opacity 150ms ease;
}

.service-card:hover {
  border-color: #3a3e49;
  border-left-color: var(--status);
  background: #1c1e24;
}

.service-card.dragging,
.group-block.dragging {
  opacity: 0.35;
}

.service-card__header,
.service-card__identity,
.service-card__status,
.service-card__metrics,
.timeline-labels,
.admin-actions {
  display: flex;
  align-items: center;
}

.service-card__header {
  justify-content: space-between;
  gap: 14px;
}

.service-card__identity {
  min-width: 0;
  gap: 9px;
}

.service-card__name {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 690;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-card__status {
  flex: none;
  gap: 9px;
}

.metric-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.timeline {
  height: 19px;
  display: flex;
  gap: 1px;
  overflow: hidden;
  margin-top: 18px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.timeline__segment {
  min-width: 0;
  flex: 1;
  opacity: 0.92;
  transition: opacity 150ms ease;
}

.timeline__segment:hover {
  opacity: 0.58;
}

.timeline-labels {
  justify-content: space-between;
  margin-top: 6px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 9px;
}

.service-card__metrics {
  min-height: 22px;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.service-card__metrics strong {
  font-weight: 650;
}

.sparkline {
  height: 37px;
  margin-top: 7px;
}

.sparkline svg {
  width: 100%;
  height: 37px;
  display: block;
}

.ssl-note {
  margin-top: 8px;
  font-size: 11px;
}

.threshold-note {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.55;
}

.threshold-note strong {
  font-family: var(--font-mono);
  font-weight: 600;
}

.panel {
  margin-top: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.panel--incidents {
  margin-top: 34px;
}

.panel__header {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.panel__heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel__icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--blue);
}

.panel__title {
  font-size: 15px;
}

.panel__hint {
  color: var(--text-dim);
  font-size: 11px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 650;
}

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

.data-table td.mono {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.data-table td.text-danger {
  color: var(--red);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.012);
}

.empty-state {
  padding: 31px 20px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

.incident-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--red);
  vertical-align: 1px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}

.field-grid + .field-grid {
  margin-top: 10px;
}

.field {
  min-width: 0;
}

.field label,
.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg);
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
}

.field input::placeholder {
  color: #5d5f68;
}

.field input:hover,
.field select:hover {
  border-color: #3a3e49;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(47, 155, 214, 0.13);
}

.checkbox-field {
  margin-top: 12px;
}

.checkbox-field label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

.checkbox-field input {
  accent-color: var(--blue);
}

.button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-muted);
  padding: 6px 11px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.button:hover {
  border-color: #414550;
  background: #252833;
  color: var(--text);
}

.button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.button--primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #0e151b;
}

.button--primary:hover {
  border-color: var(--blue-hover);
  background: var(--blue-hover);
  color: #0e151b;
}

.button--success {
  border-color: rgba(95, 174, 110, 0.42);
  background: rgba(95, 174, 110, 0.09);
  color: var(--green);
}

.button--danger {
  border-color: rgba(217, 104, 91, 0.4);
  background: rgba(217, 104, 91, 0.08);
  color: var(--red);
}

.button--maintenance {
  border-color: rgba(156, 122, 140, 0.42);
  background: rgba(156, 122, 140, 0.09);
  color: #bd96aa;
}

.panel__action {
  margin-top: 12px;
}

.edit-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.admin-actions {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border-subtle);
}

.admin-actions__label {
  margin-right: 3px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 650;
}

.site-footer {
  margin-top: 34px;
  padding-top: 19px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px 24px;
  color: var(--text-dim);
  font-size: 11px;
}

.site-footer__meta,
.site-footer__links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 14px;
}

.site-footer__links {
  justify-content: flex-end;
}

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

.site-footer a:hover {
  color: var(--blue);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.text-success {
  color: var(--green);
}

.text-warning {
  color: var(--amber);
}

.text-danger {
  color: var(--red);
}

.text-maintenance {
  color: var(--mauve);
}

.legal-shell {
  width: min(900px, calc(100% - 32px));
  margin-inline: auto;
  padding-block: 44px 72px;
}

.legal-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 620;
}

.legal-back:hover {
  color: var(--blue);
}

.legal-header {
  max-width: 670px;
  margin-top: 52px;
}

.legal-kicker {
  color: var(--blue);
  font-size: 11px;
  font-weight: 680;
}

.legal-title {
  margin-top: 11px;
  font-size: clamp(36px, 7vw, 64px);
  line-height: 0.98;
}

.legal-date {
  margin-top: 17px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}

.legal-content {
  margin-top: 42px;
  border-top: 1px solid var(--border);
}

.legal-section {
  display: grid;
  grid-template-columns: minmax(150px, 0.34fr) minmax(0, 1fr);
  gap: 28px;
  padding-block: 25px;
  border-bottom: 1px solid var(--border-subtle);
}

.legal-section h2 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 680;
}

.legal-section p {
  margin: 0 0 11px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
}

.legal-section p:last-child {
  margin-bottom: 0;
}

.legal-links {
  margin-top: 25px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legal-links a {
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 620;
}

.legal-links a:hover {
  border-color: #414550;
  background: var(--surface);
  color: var(--text);
}

.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.error-panel {
  width: min(500px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.error-code {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 650;
}

.error-panel h1 {
  margin: 12px 0 0;
  color: var(--text);
  font-size: clamp(30px, 8vw, 48px);
  font-weight: 740;
  letter-spacing: -0.04em;
  line-height: 1;
}

.error-panel p {
  margin: 14px 0 22px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

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

  .overview__stats {
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--border-subtle);
    border-left: 0;
  }

  .overview-stat {
    min-height: 72px;
    display: block;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 0;
  }

  .overview-stat:last-child {
    border-right: 0;
  }

  .overview-stat__value {
    display: block;
    margin-top: 7px;
  }

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

  .site-footer {
    grid-template-columns: 1fr;
  }

  .site-footer__links {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .masthead__inner,
  .page-shell,
  .legal-shell {
    width: min(100% - 24px, 1180px);
  }

  .masthead__inner {
    min-height: 60px;
  }

  .brand__eyebrow,
  .nav-link__label,
  .nav-badge {
    display: none;
  }

  .masthead__nav {
    gap: 2px;
  }

  .nav-link {
    min-height: 40px;
    min-width: 34px;
    justify-content: center;
    padding-inline: 7px;
  }

  .page-shell {
    padding-block: 26px 52px;
  }

  .overview__main {
    padding: 23px 20px;
  }

  .overview__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-stat {
    min-height: auto;
    display: block;
  }

  .overview-stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border-subtle);
  }

  .overview-stat:nth-child(even) {
    border-right: 0;
  }

  .service-area {
    margin-top: 30px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  .service-card {
    padding: 15px;
  }

  .service-card__header {
    align-items: flex-start;
  }

  .service-card__status {
    align-items: flex-end;
    flex-direction: column-reverse;
    gap: 5px;
  }

  .panel {
    padding: 16px;
  }

  .panel__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

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

  .legal-header {
    margin-top: 38px;
  }

  .legal-content {
    margin-top: 34px;
  }

  .legal-section {
    grid-template-columns: 1fr;
    gap: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
