:root {
  color-scheme: light;
  --site-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #111827;
  --text-soft: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --control-active: #eef2f7;
  --row-hover: #fbfdff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #171a21;
  --surface-soft: #1d212a;
  --text: #f5f7fb;
  --text-soft: #d8dee9;
  --muted: #9aa3b2;
  --border: #2a303a;
  --border-strong: #3a4350;
  --control-active: #2b3340;
  --row-hover: #1b2028;
  --green: #4ade80;
  --green-soft: #12351f;
  --amber: #fbbf24;
  --amber-soft: #3a2a0b;
  --red: #fb7185;
  --red-soft: #3b1620;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--site-font);
  font-size: 14px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
}

.status-page {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  text-decoration: none;
}

.brand span span {
  color: #8b95a1;
  font-weight: 600;
}

.header-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.language-switch,
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.control-option {
  min-width: 40px;
  min-height: 32px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: 700 13px/1.2 var(--site-font);
  letter-spacing: 0;
  cursor: pointer;
}

.icon-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.control-option:hover {
  color: var(--text);
}

.control-option.active {
  background: var(--control-active);
  color: var(--text);
}

.flag-icon,
.theme-icon {
  display: inline-block;
  flex: none;
}

.flag-icon {
  width: 22px;
  height: 16px;
  overflow: hidden;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.flag-ru {
  background: linear-gradient(to bottom, #fff 0 33.333%, #1d4ed8 33.333% 66.666%, #dc2626 66.666% 100%);
}

.flag-en {
  position: relative;
  background: #1d4ed8;
}

.flag-en::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, transparent 0 42%, #fff 42% 58%, transparent 58% 100%),
    linear-gradient(to bottom, transparent 0 38%, #fff 38% 62%, transparent 62% 100%),
    linear-gradient(to right, transparent 0 46%, #dc2626 46% 54%, transparent 54% 100%),
    linear-gradient(to bottom, transparent 0 43%, #dc2626 43% 57%, transparent 57% 100%);
}

.theme-icon {
  position: relative;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.sun-icon {
  border: 2px solid currentColor;
  border-radius: 999px;
  transform: scale(0.62);
  box-shadow:
    0 -14px 0 -6px currentColor,
    0 14px 0 -6px currentColor,
    14px 0 0 -6px currentColor,
    -14px 0 0 -6px currentColor,
    10px 10px 0 -6px currentColor,
    -10px -10px 0 -6px currentColor,
    10px -10px 0 -6px currentColor,
    -10px 10px 0 -6px currentColor;
}

.moon-icon {
  border-radius: 999px;
  background: currentColor;
}

.moon-icon::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -2px;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--surface);
}

.status-section {
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 1400px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

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

tbody tr:hover td {
  background: var(--row-hover);
}

td {
  color: var(--text-soft);
  font-size: 14px;
}

td:first-child {
  color: var(--text);
  font-weight: 650;
}

th.num,
.num {
  text-align: right;
}

th.sorted-asc::after {
  content: " ↑";
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

th.sorted-desc::after {
  content: " ↓";
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.ok,
.full,
.bad {
  font-weight: 700;
}

.ok {
  color: var(--green);
}

.full {
  color: var(--amber);
}

.bad {
  color: var(--red);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 84px;
  font-weight: 700;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

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

.health-card {
  min-height: 132px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.health-card.loading {
  grid-column: 1 / -1;
  min-height: 86px;
  color: var(--muted);
  font-weight: 600;
}

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

.health-card-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.health-card-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.health-card-latency {
  color: var(--text);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  line-height: 1;
}

.health-card-latency span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin-left: 8px;
}

@media (max-width: 768px) {
  .status-page {
    width: min(100% - 20px, 1680px);
    padding: 16px 0 32px;
  }

  .status-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
  }

  .header-controls {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

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

  th,
  td {
    padding: 11px 13px;
  }

  table {
    min-width: 1400px;
  }

  .health-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }
}

@media (max-width: 480px) {
  html,
  body {
    font-size: 13px;
  }

  .status-page {
    width: min(100% - 16px, 1680px);
  }

  .status-section {
    border-radius: 10px;
  }

  h2 {
    font-size: 16px;
  }

  th,
  td {
    padding: 10px 12px;
  }
}
