:root {
  color-scheme: dark;
  --bg: #0b1011;
  --surface: #12191b;
  --surface-soft: #182124;
  --surface-raised: #1d282b;
  --line: #2c3b3f;
  --text: #e7eff0;
  --muted: #93a4a8;
  --accent: #5ad2b8;
  --accent-strong: #8de8d8;
  --warn: #f0b95a;
  --danger: #ff7b65;
  --ok: #82dd84;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(90, 210, 184, 0.08), transparent 360px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.topbar,
.section__header,
.panel__header,
.detail-head,
.status-strip,
.tabs,
.inline-controls,
.search-row {
  display: flex;
  align-items: center;
}

.topbar__side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.header-links {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.header-links a,
.header-links span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.header-links a:hover,
.header-links a:focus-visible {
  border-color: rgba(90, 210, 184, 0.6);
  color: var(--text);
  outline: none;
}

.topbar {
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.4rem);
}

h2 {
  font-size: clamp(1.7rem, 3vw, 3rem);
}

h3 {
  font-size: 1.05rem;
}

.status-strip {
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.status-dot::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot--ok::before {
  background: var(--ok);
  box-shadow: 0 0 16px rgba(130, 221, 132, 0.45);
}

.status-dot--error::before {
  background: var(--danger);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  gap: 4px;
  padding: 8px;
  margin: 10px 0 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 25, 27, 0.92);
  backdrop-filter: blur(14px);
  overflow-x: auto;
}

.tabs a {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.tabs a:hover,
.tabs a:focus-visible {
  color: var(--text);
  background: var(--surface-raised);
  outline: none;
}

.section {
  scroll-margin-top: 78px;
  padding: 26px 0 12px;
}

.section__header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

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

.kpi {
  min-height: 138px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  box-shadow: var(--shadow);
}

.kpi span,
.kpi small,
.panel__header span,
.inline-controls label,
.empty-state,
.empty-cell,
.result-item small,
.bar-item small,
.rank-item small {
  color: var(--muted);
}

.kpi span {
  display: block;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.kpi strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-size: clamp(1.8rem, 3vw, 3.1rem);
  line-height: 1;
}

.kpi small {
  display: block;
  margin-top: 12px;
  font-size: 0.82rem;
}

.platform-breakdown {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.platform-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.82rem;
}

.platform-row strong {
  color: var(--accent-strong);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  text-align: right;
}

.platform-row--empty {
  justify-content: center;
  border-style: dashed;
  color: var(--muted);
  text-align: center;
}

.kpi-grid--compact .kpi,
.kpi-grid--api .kpi {
  min-height: 118px;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.split--wide {
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  margin-bottom: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel__header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel__header--inside {
  margin-top: 18px;
}

.button,
.segmented button,
.link-button,
.rank-item,
.bar-item,
.result-item {
  cursor: pointer;
}

.button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
}

.button--primary {
  color: #061312;
  background: var(--accent);
}

.button--primary:hover,
.button--primary:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-width: 54px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.is-active {
  color: #061312;
  background: var(--accent);
}

.inline-controls label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
}

select,
input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1416;
  color: var(--text);
}

select {
  padding: 0 36px 0 12px;
}

input {
  width: 100%;
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(90, 210, 184, 0.16);
}

.search-row {
  gap: 8px;
  margin-bottom: 12px;
}

.search-row input {
  min-width: 0;
}

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

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

.api-table {
  min-width: 980px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

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

.empty-state,
.empty-cell {
  padding: 22px 0;
  text-align: center;
}

.rank-list,
.bar-list,
.country-list,
.result-list {
  display: grid;
  gap: 9px;
}

.rank-item,
.bar-item,
.result-item {
  position: relative;
  display: grid;
  align-items: center;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: left;
  overflow: hidden;
}

.rank-item:hover,
.bar-item:hover,
.result-item:hover,
.link-button:hover {
  border-color: rgba(90, 210, 184, 0.6);
}

.rank-item {
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  min-height: 70px;
  padding: 12px;
}

.rank-item__main,
.bar-item__label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.rank-item__main strong,
.rank-item__main small,
.bar-item__label strong,
.bar-item__label small,
.result-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-item__meta,
.bar-item__value {
  color: var(--accent-strong);
  font-weight: 900;
}

.rank-item__fresh {
  color: var(--muted);
  font-size: 0.8rem;
}

.rank-item__bar,
.bar-item__bar {
  position: absolute;
  inset: auto auto 0 0;
  width: var(--bar-width);
  height: 3px;
  background: var(--accent);
}

.bar-item {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 74px;
  padding: 13px 14px;
}

.bar-item__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: #0d1416;
  color: var(--muted);
  font-weight: 900;
}

.country-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.country-item__flag {
  font-size: 1.35rem;
}

.country-item span:last-child {
  color: var(--accent-strong);
  font-weight: 900;
}

.result-item {
  grid-template-columns: 100px minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 58px;
  padding: 12px;
}

.detail-panel {
  margin-top: 14px;
}

.detail-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.detail-head h3 {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.detail-head > span {
  color: var(--accent-strong);
  font-weight: 900;
}

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

.mini-grid div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mini-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.mini-grid strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 900;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(130, 221, 132, 0.12);
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.method-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(90, 210, 184, 0.1);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.route-cell {
  position: relative;
  min-width: 240px;
  overflow: hidden;
}

.route-cell span:first-child {
  position: relative;
  z-index: 1;
}

.route-cell__bar {
  position: absolute;
  inset: auto auto 7px 10px;
  width: var(--bar-width);
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.75;
}

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

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

  .split,
  .split--wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 12px;
  }

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

  .topbar__side,
  .status-strip {
    justify-items: start;
    justify-content: flex-start;
  }

  .kpi-grid,
  .kpi-grid--overview,
  .kpi-grid--api,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .kpi {
    padding: 14px;
  }

  .rank-item,
  .bar-item,
  .result-item {
    grid-template-columns: 1fr;
  }

  .rank-item__main strong,
  .rank-item__main small,
  .bar-item__label strong,
  .bar-item__label small,
  .result-item span {
    white-space: normal;
  }

  .search-row {
    align-items: stretch;
    flex-direction: column;
  }
}
