@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap");

:root {
  --bg: #0b1117;
  --bg-soft: #0f1724;
  --panel: #111827;
  --panel-soft: #172033;
  --panel-highlight: #1d2940;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #ff8f3f;
  --accent-soft: rgba(255, 143, 63, 0.14);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --unknown: #64748b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  --sidebar-width: 280px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 143, 63, 0.12), transparent 25%),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.08), transparent 20%),
    linear-gradient(180deg, #0b1117 0%, #0d1520 45%, #0a1017 100%);
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 20px;
  background: rgba(9, 14, 21, 0.94);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  display: grid;
  gap: 18px;
  align-content: start;
  z-index: 5;
}

.sidebar-top,
.card-heading,
.topbar,
.topbar-left,
.topbar-right,
.toolbar-grid,
.form-actions,
.section-header,
.section-actions,
.tabs,
.settings-actions {
  display: flex;
  align-items: center;
}

.sidebar-top {
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #2c1a0d;
  background: linear-gradient(135deg, #ffc18f 0%, #ff8f3f 55%, #ff7332 100%);
  box-shadow: 0 12px 28px rgba(255, 143, 63, 0.28);
}

.brand-copy {
  min-width: 0;
}

.brand-eyebrow,
.section-label,
.mini-label,
.status-pill-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-copy strong,
.section-header h2,
.card-heading h2,
.card-heading h3,
.topbar h1 {
  margin: 0;
  font-family: "Space Grotesk", Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

.brand-copy strong {
  font-size: 1.05rem;
}

.sidebar-toggle {
  display: none;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  transform: translateX(2px);
}

.sidebar-card,
.panel,
.status-pill,
.kpi-card {
  background: linear-gradient(180deg, rgba(23, 32, 51, 0.92), rgba(17, 24, 39, 0.96));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.sidebar-card {
  padding: 18px;
}

.sidebar-note,
.muted-copy,
.form-status,
.summary-copy,
.data-table td,
.data-table th,
.detail-list dt,
.detail-list dd,
.notes-list,
.empty-panel {
  color: var(--muted);
}

.sidebar-overlay {
  display: none;
}

.app-main {
  min-width: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.topbar {
  position: relative;
  top: auto;
  z-index: 1;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 0;
  background: rgba(11, 17, 23, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(18px);
}

.topbar-left {
  gap: 18px;
  min-width: 0;
}

.topbar h1 {
  font-size: clamp(1.6rem, 2vw, 2.35rem);
  line-height: 1.05;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.meta-chip,
.soft-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.86rem;
  white-space: nowrap;
}

.meta-chip,
.soft-badge {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.status-badge {
  font-weight: 700;
}

.status-healthy {
  color: #defbe6;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.32);
}

.status-warning {
  color: #ffecbf;
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.34);
}

.status-critical {
  color: #ffe1dd;
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.34);
}

.status-unknown {
  color: #d0dae8;
  background: rgba(100, 116, 139, 0.18);
  border-color: rgba(100, 116, 139, 0.34);
}

.status-strip {
  position: relative;
  top: auto;
  z-index: auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.status-pill {
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  min-height: 84px;
}

.status-pill-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: "Space Grotesk", Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.status-pill-subtext {
  font-size: 0.85rem;
  color: var(--muted);
}

.dashboard-content {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.dashboard-section {
  display: grid;
  gap: 20px;
}

.section-header {
  justify-content: space-between;
  gap: 16px;
}

.section-header h2 {
  font-size: 1.35rem;
}

.panel {
  padding: 22px;
}

.control-layout,
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.control-form,
.diagnostic-grid,
.summary-grid,
.debug-grid {
  display: grid;
  gap: 18px;
}

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

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-span-2 {
  grid-column: span 2;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 12, 18, 0.76);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(255, 143, 63, 0.42);
  box-shadow: 0 0 0 4px rgba(255, 143, 63, 0.12);
}

.toolbar-grid {
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-card,
.summary-card,
.diagnostic-meta-card {
  min-width: 0;
  flex: 1 1 180px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.035);
}

.toolbar-card strong,
.diagnostic-meta-card strong {
  display: block;
  margin-top: 8px;
  line-height: 1.35;
}

.toolbar-label {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 0.84rem;
}

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

.toggle input {
  display: none;
}

.toggle-track {
  width: 54px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.24);
  border: 1px solid var(--border);
  transition: background 0.2s ease;
}

.toggle-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f8fafc;
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-track {
  background: rgba(34, 197, 94, 0.28);
}

.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(23px);
}

.form-actions,
.section-actions,
.settings-actions {
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: #2b190d;
  background: linear-gradient(135deg, #ffbf8f 0%, #ff8f3f 56%, #ff6d2f 100%);
  box-shadow: 0 14px 24px rgba(255, 143, 63, 0.22);
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled,
.tab-button:disabled {
  opacity: 0.64;
  cursor: progress;
  transform: none;
}

.secondary-button,
.icon-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

.icon-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 12px;
}

.incident-panel h4 {
  margin: 4px 0 0;
  font-size: 1.3rem;
}

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

.diagnostic-banner {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 143, 63, 0.18);
  background: rgba(255, 143, 63, 0.08);
}

.diagnostic-banner p {
  margin: 0;
  color: #f7d7bb;
  line-height: 1.55;
}

.empty-panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.kpi-card {
  padding: 18px;
  display: grid;
  gap: 14px;
  min-height: 174px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.kpi-card:hover,
.panel:hover,
.sidebar-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.kpi-card-top,
.metric-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.kpi-title {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value {
  font-size: clamp(1.7rem, 2.6vw, 2.6rem);
  font-weight: 800;
  font-family: "Space Grotesk", Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.kpi-description {
  color: var(--muted);
  line-height: 1.5;
}

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

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.sparkline {
  min-height: 48px;
  display: grid;
  align-items: end;
}

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

.chart-panel {
  display: grid;
  gap: 16px;
}

.chart-surface {
  min-height: 220px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)),
    rgba(4, 10, 16, 0.32);
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.chart-caption strong {
  color: var(--text);
}

.chart-center {
  display: grid;
  place-items: center;
}

.svg-chart,
.ring-chart,
.bar-chart {
  width: 100%;
  height: 100%;
}

.chart-placeholder {
  min-height: inherit;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.detail-layout {
  gap: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

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

.data-table td:last-child {
  max-width: 320px;
}

.data-table th {
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-list {
  display: grid;
  gap: 14px;
}

.detail-list-wide div {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.detail-list dd,
.detail-list dt,
.kpi-value,
.status-pill-value,
.summary-card strong,
.topbar,
.sidebar-card,
.kpi-card,
.notes-list,
.code-block {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-list dt {
  margin-bottom: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.detail-list dd {
  margin: 0;
  color: var(--text);
}

.tabs {
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-button {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.tab-button.is-active {
  color: var(--text);
  background: rgba(255, 143, 63, 0.12);
  border-color: rgba(255, 143, 63, 0.24);
}

.tab-button:hover {
  border-color: var(--border-strong);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

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

.summary-card {
  line-height: 1.55;
}

.notes-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.code-block {
  margin: 0;
  padding: 18px;
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(4, 10, 16, 0.62);
  color: #d6e3f1;
  font-size: 0.92rem;
}

.service-ring-wrap {
  display: grid;
  place-items: center;
  min-height: inherit;
  padding: 12px;
}

.ring-chart-grid {
  display: grid;
  place-items: center;
  gap: 14px;
}

.ring-summary {
  text-align: center;
}

.ring-summary strong {
  display: block;
  font-size: 1.5rem;
  font-family: "Space Grotesk", Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

.ring-legend {
  width: 100%;
  display: grid;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.bar-chart-wrap {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.form-status.is-error {
  color: #ffd8d3;
}

.form-status.is-success {
  color: #d4f8dd;
}

.form-status.is-loading {
  color: #ffe7c6;
}

.metric-detail {
  line-height: 1.45;
}

.metric-detail strong {
  color: var(--text);
}

.hidden {
  display: none !important;
}

@media (max-width: 1400px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 18;
  }

  .sidebar-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle {
    display: inline-grid;
  }

  .app-main {
    padding: 18px;
  }

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

@media (max-width: 900px) {
  .control-layout,
  .detail-layout,
  .chart-grid {
    grid-template-columns: 1fr;
  }

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

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

  .section-header,
  .toolbar-grid,
  .summary-grid,
  .debug-grid {
    display: grid;
  }

  .section-header {
    gap: 14px;
  }

  .form-grid,
  .diagnostic-meta-grid,
  .summary-grid,
  .debug-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-main {
    padding: 14px;
  }

  .panel,
  .sidebar-card,
  .status-pill,
  .kpi-card,
  .topbar {
    padding: 18px;
  }

  .topbar,
  .topbar-left,
  .topbar-right {
    display: grid;
  }

  .topbar,
  .topbar-left {
    gap: 14px;
  }

  .topbar-right {
    justify-items: start;
  }

  .kpi-grid,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .meta-chip,
  .soft-badge,
  .status-badge {
    white-space: normal;
  }

  .section-actions,
  .form-actions,
  .settings-actions {
    align-items: stretch;
  }

  button,
  .secondary-button {
    width: 100%;
  }
}
