@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --page-background: #070c17;
  --page-glow-1: rgba(96, 165, 250, 0.18);
  --page-glow-2: rgba(52, 211, 153, 0.12);
  --page-fade-top: rgba(7, 12, 23, 0.96);
  --page-fade-bottom: rgba(11, 18, 32, 0.98);
  --grid-line: rgba(148, 163, 184, 0.06);
  --card-background: linear-gradient(180deg, rgba(17, 24, 39, 0.94), rgba(15, 23, 42, 0.82));
  --panel-background: rgba(15, 23, 42, 0.52);
  --panel-background-hover: rgba(15, 23, 42, 0.68);
  --foreground: #f8fafc;
  --card: rgba(17, 24, 39, 0.88);
  --card-strong: rgba(15, 23, 42, 0.94);
  --muted-foreground: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --accent: #34d399;
  --accent-foreground: #04140d;
  --info: #60a5fa;
  --warning: #fbbf24;
  --critical: #f87171;
  --focus-ring: #93c5fd;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
  --radius: 22px;
  --font-sans: "Fira Sans", "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Fira Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

body[data-theme="light"] {
  color-scheme: light;
  --page-background: #f8fafc;
  --page-glow-1: rgba(96, 165, 250, 0.16);
  --page-glow-2: rgba(52, 211, 153, 0.1);
  --page-fade-top: rgba(248, 250, 252, 0.98);
  --page-fade-bottom: rgba(241, 245, 249, 0.99);
  --grid-line: rgba(15, 23, 42, 0.06);
  --card-background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9));
  --panel-background: rgba(255, 255, 255, 0.8);
  --panel-background-hover: rgba(241, 245, 249, 0.92);
  --foreground: #0f172a;
  --muted-foreground: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.18);
  --accent: #047857;
  --accent-foreground: #f8fafc;
  --info: #2563eb;
  --warning: #b45309;
  --critical: #b91c1c;
  --focus-ring: #2563eb;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  background: var(--page-background);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 0%, var(--page-glow-1), transparent 32%),
    radial-gradient(circle at 92% 4%, var(--page-glow-2), transparent 30%),
    linear-gradient(180deg, var(--page-fade-top), var(--page-fade-bottom));
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(180deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 50% 0%, rgba(0, 0, 0, 0.9), transparent 74%);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--accent-foreground);
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 20px 20px;
}

.app-header,
.status-strip,
.panel,
.app-footer {
  border: 1px solid var(--border);
  background: var(--card-background);
  backdrop-filter: blur(18px);
}

.app-header {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(96, 165, 250, 0.32);
  border-radius: 14px;
  color: #bfdbfe;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.28), rgba(52, 211, 153, 0.16));
  box-shadow: inset 0 0 18px rgba(96, 165, 250, 0.18);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand p {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 1 auto;
  gap: 10px;
}

.button {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

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

.button:active,
.chip:active {
  transform: translateY(0);
}

.button.primary {
  color: var(--accent-foreground);
  background: linear-gradient(135deg, #34d399, #60a5fa);
  box-shadow: 0 10px 28px rgba(52, 211, 153, 0.18);
}

.button.secondary {
  color: var(--foreground);
  border-color: var(--border-strong);
  background: rgba(51, 65, 85, 0.58);
}

.status-strip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  padding: 14px 18px;
  border-radius: 16px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.status-strip::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.12);
  animation: pulse 2.4s ease-in-out infinite;
}

.status-strip p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 0;
}

.status-strip strong {
  color: var(--accent);
}

.status-strip span {
  color: var(--muted-foreground);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-card {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-background);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.36);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.9), rgba(52, 211, 153, 0.7), transparent);
  opacity: 0.85;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.48);
}

.kpi-card > span {
  color: var(--muted-foreground);
  font-size: 14px;
}

.kpi-value {
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.kpi-hint {
  color: var(--muted-foreground);
  font-size: 14px;
}

.panel {
  margin-top: 18px;
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.chart-figure {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(7, 12, 23, 0.55));
}

#metric-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.metric-path {
  fill: none;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 6px 14px rgba(56, 189, 248, 0.18));
}

.grid-line {
  stroke: rgba(148, 163, 184, 0.14);
  stroke-width: 1;
  stroke-dasharray: 4 8;
}

.chart-figure figcaption {
  margin-top: 12px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.metric-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}

.metric-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-background);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.metric-summary-item:hover {
  border-color: var(--border-strong);
  background: var(--panel-background-hover);
}

.metric-summary-item dt,
.metric-summary-item dd {
  margin: 0;
}

.metric-summary-item dt {
  color: var(--muted-foreground);
}

.metric-summary-item dd {
  font-family: var(--font-mono);
  font-weight: 700;
}

.metric-summary-item dd span {
  color: var(--muted-foreground);
  font-weight: 400;
}

.layout-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.layout-two-column > * {
  margin-top: 0;
}

.filters {
  display: grid;
  gap: 14px;
}

.search-field {
  display: grid;
  gap: 7px;
}

.search-field label {
  color: var(--muted-foreground);
  font-size: 14px;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--foreground);
  background: var(--panel-background);
  font: inherit;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.search-field input:focus {
  border-color: rgba(96, 165, 250, 0.72);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12);
  outline: none;
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.chip {
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--foreground);
  background: var(--panel-background);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.chip[aria-pressed="true"] {
  border-color: rgba(52, 211, 153, 0.62);
  background: rgba(52, 211, 153, 0.14);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.08);
}

.table-scroll {
  overflow-x: auto;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.table-scroll::-webkit-scrollbar {
  height: 8px;
}

.table-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--panel-background-hover);
  backdrop-filter: blur(12px);
}

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

tbody tr:hover td {
  background: rgba(96, 165, 250, 0.07);
}

.server-name {
  display: grid;
  gap: 3px;
}

.server-name strong {
  font-family: var(--font-mono);
  font-size: 15px;
}

.server-name span {
  color: var(--muted-foreground);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-healthy {
  border-color: color-mix(in srgb, var(--accent) 36%, transparent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
}

.status-healthy .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

.status-warning {
  border-color: color-mix(in srgb, var(--warning) 38%, transparent);
  background: color-mix(in srgb, var(--warning) 13%, transparent);
  color: var(--warning);
}

.status-warning .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 12%, transparent);
}

.status-critical {
  border-color: color-mix(in srgb, var(--critical) 40%, transparent);
  background: color-mix(in srgb, var(--critical) 13%, transparent);
  color: var(--critical);
}

.status-critical .status-dot {
  background: var(--critical);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--critical) 12%, transparent);
}

.resource {
  display: grid;
  min-width: 104px;
  gap: 6px;
}

.resource-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 12px;
}

.resource-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}

.resource-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #60a5fa);
}

.resource-warning .resource-fill {
  background: linear-gradient(90deg, #fbbf24, #f97316);
}

.resource-critical .resource-fill {
  background: linear-gradient(90deg, #f87171, #ef4444);
}

.table-button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: 10px;
  color: #bfdbfe;
  background: rgba(96, 165, 250, 0.12);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.table-button:hover {
  transform: translateY(-1px);
  background: rgba(96, 165, 250, 0.18);
  box-shadow: 0 8px 22px rgba(96, 165, 250, 0.16);
}

.empty-row {
  color: var(--muted-foreground);
  text-align: center;
}

.server-details {
  display: grid;
  gap: 16px;
}

.details-empty {
  margin: 0;
  padding: 30px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  color: var(--muted-foreground);
  text-align: center;
}

.details-title {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(96, 165, 250, 0.16);
  border-radius: 16px;
  background: rgba(96, 165, 250, 0.08);
}

.details-title strong {
  font-family: var(--font-mono);
  font-size: 17px;
}

.details-title span {
  color: var(--muted-foreground);
}

.details-grid {
  display: grid;
  gap: 10px;
}

.details-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel-background);
}

.details-item span {
  color: var(--muted-foreground);
}

.details-item strong {
  font-family: var(--font-mono);
}

.event-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-background);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.event-item:hover {
  border-color: var(--border-strong);
  background: var(--panel-background-hover);
}

.event-level {
  align-self: start;
  justify-self: start;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.event-content {
  display: grid;
  gap: 6px;
}

.event-content strong {
  line-height: 1.35;
}

.event-content span,
.event-time {
  color: var(--muted-foreground);
  font-size: 13px;
}

.level-info {
  color: #bfdbfe;
  background: rgba(96, 165, 250, 0.14);
}

.level-warning {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.14);
}

.level-critical {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.14);
}

.app-footer {
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: 16px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.app-footer p {
  margin: 0;
}

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

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.16);
  }
}

@media (min-width: 720px) {
  .app-header {
    flex-direction: row;
  }

  .brand {
    flex: 1 1 auto;
  }

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

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

@media (min-width: 1024px) {
  .layout-two-column {
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
  }

  .panel {
    padding: 22px;
  }
}

@media (max-width: 719px) {
  .app-shell {
    padding: 14px 12px 12px;
  }

  .app-header {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }

  .brand {
    flex: 1 1 auto;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions .button {
    flex: 1 1 100%;
  }

  .status-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .kpi-grid,
  .metric-summary {
    grid-template-columns: minmax(0, 1fr);
  align-items: start;
  }

  .panel {
    padding: 18px;
  }

  .panel-header {
    flex-direction: column;
  }

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

  .table-scroll {
    overflow: visible;
    border: 0;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-background);
  }

  tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 14px;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .server-name {
    min-width: 0;
    flex: 1;
  }

  .server-name strong {
    overflow-wrap: anywhere;
  }

  .resource {
    width: 100%;
    min-width: 0;
  }

  .resource-label {
    width: 100%;
  }

  .table-button {
    flex: 0 0 auto;
  }

  .empty-row td::before {
    content: "";
  }

  .status-filter {
    justify-content: stretch;
  }

  .chip {
    flex: 1 1 40%;
  }
}

@media (max-width: 480px) {
  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand p {
    font-size: 18px;
  }

  .kpi-value {
    font-size: 30px;
  }

  .header-actions .button {
    flex: 1 1 100%;
  }

  .chip {
    flex: 1 1 100%;
  }
}

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

  .button:hover,
  .chip:hover,
  .table-button:hover {
    transform: none;
  }
}
