:root {
  --bg: #111315;
  --surface: #181b1f;
  --surface-strong: #20252b;
  --surface-soft: #262c33;
  --ink: #f2f7f5;
  --muted: #9aa8a1;
  --line: #303941;
  --grid: rgba(255, 255, 255, 0.045);
  --teal: #31d0aa;
  --teal-dark: #1da184;
  --lime: #b9f25d;
  --amber: #f2b84b;
  --red: #ff6b6b;
  --magenta: #d87cff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.26);
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px;
  background: #0b0d0f;
  border-right: 1px solid var(--line);
  color: var(--ink);
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(49, 208, 170, 0.55);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #10251f;
  color: var(--teal);
  font-weight: 900;
  box-shadow: inset 0 0 18px rgba(49, 208, 170, 0.16);
}

.brand h1,
.brand p,
.panel-label,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 1.15rem;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-list,
.env-switcher {
  display: grid;
  gap: 8px;
}

.nav-item,
.env-btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #cad6d1;
  padding: 12px;
  text-align: left;
  font-weight: 800;
}

.nav-item:hover,
.nav-item.active,
.env-btn:hover,
.env-btn.active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--teal);
}

.environment-panel {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow,
.panel-label {
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(1.75rem, 4vw, 2.45rem);
}

.topbar-actions,
.filters,
.panel-header.split,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border-radius: var(--radius);
  font-weight: 850;
}

.primary-btn,
.ghost-btn {
  border: 1px solid transparent;
  padding: 10px 14px;
}

.primary-btn {
  background: var(--teal);
  color: #07100d;
}

.primary-btn:hover {
  background: var(--lime);
}

.ghost-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.ghost-btn:hover,
.action-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
}

.ops-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.ops-strip div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  background: rgba(24, 27, 31, 0.78);
  padding: 10px 12px;
}

.ops-strip strong {
  white-space: nowrap;
  font-size: 0.8rem;
}

.ops-strip span:last-child {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--lime);
  box-shadow: 0 0 14px var(--lime);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.metric,
.panel,
.service-card,
.incident-card,
.deployment-item,
.alert-item {
  background: rgba(24, 27, 31, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
}

.panel {
  padding: 20px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h3 {
  margin: 4px 0 0;
  font-size: 1.05rem;
}

.live-pill,
.status-pill,
.severity-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.live-pill {
  background: rgba(49, 208, 170, 0.12);
  color: var(--teal);
}

.service-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  box-shadow: none;
}

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

.service-card h4,
.incident-card h4,
.deployment-item h4,
.alert-item h4 {
  margin: 0 0 6px;
}

.service-card p,
.incident-card p,
.deployment-item p,
.alert-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.service-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
}

.mini-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 0.94rem;
}

.status-healthy {
  background: rgba(185, 242, 93, 0.12);
  color: var(--lime);
}

.status-degraded,
.sev-2,
.sev-3 {
  background: rgba(242, 184, 75, 0.12);
  color: var(--amber);
}

.status-outage,
.sev-1 {
  background: rgba(255, 107, 107, 0.12);
  color: var(--red);
}

.status-resolved {
  background: rgba(185, 242, 93, 0.12);
  color: var(--lime);
}

.status-monitoring {
  background: rgba(216, 124, 255, 0.12);
  color: var(--magenta);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: end;
  gap: 6px;
  min-height: 230px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    #0f1215;
  background-size: 100% 25%;
}

.bar {
  min-height: 22px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--lime), var(--teal-dark));
}

.alert-list,
.incident-list,
.deployment-list {
  display: grid;
  gap: 12px;
}

.alert-item,
.incident-card,
.deployment-item {
  padding: 14px;
  box-shadow: none;
}

.incident-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.incident-meta,
.deployment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: #cbd7d2;
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 850;
}

.incident-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 850;
}

.action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1215;
  color: var(--ink);
  padding: 10px 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

textarea {
  resize: vertical;
}

.api-output {
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #07090a;
  color: #d8ffe9;
  padding: 18px;
  line-height: 1.55;
  font-size: 0.88rem;
}

.dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

.dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.dialog-header h3 {
  margin: 4px 0 0;
}

.dialog-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #07090a;
  color: var(--teal);
  padding: 12px 16px;
  font-weight: 850;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .env-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item,
  .env-btn {
    text-align: center;
    padding: 10px 8px;
  }

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

@media (max-width: 720px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header.split,
  .filters,
  .incident-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .incident-card {
    display: flex;
  }

  .topbar-actions,
  .incident-actions,
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .nav-list,
  .ops-strip {
    grid-template-columns: 1fr;
  }

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

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