:root {
  color-scheme: dark;
  --bg: #050807;
  --panel: #0c1110;
  --panel-soft: #111816;
  --line: #22302d;
  --text: #f4fffb;
  --muted: #8b9d98;
  --accent: #41e6ad;
  --danger: #ff6f6f;
  --warn: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.auth {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
}

.auth-box {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 22px 0;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-form label {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-form input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #060908;
  color: var(--text);
}

.auth-form .button {
  width: 100%;
  margin-top: 14px;
}

.notice {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.message {
  min-height: 1.3em;
  margin: 12px 0 0;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--accent);
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 8px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.1rem;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--accent);
  color: #03110d;
  font-weight: 850;
  text-decoration: none;
}

.button.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.button.compact {
  padding: 8px 10px;
  font-size: 0.9rem;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.status {
  min-width: 116px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

.status.error {
  color: var(--danger);
}

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

.speed-card,
.mini-grid article,
.details,
.selector-panel,
.admin-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.selector-panel {
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.selector-panel label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.selector-panel select,
.search-form input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #060908;
  color: var(--text);
}

.speed-card {
  overflow: hidden;
  padding: 20px;
}

.speed-card.active {
  border-color: rgba(65, 230, 173, 0.72);
}

.card-head,
.details,
.topbar {
  min-width: 0;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.speed-card strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  margin: 18px 0;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1;
}

.speed-card strong span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(2.6rem, 6.2vw, 4.9rem);
}

.speed-card small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #050807;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms linear;
}

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

.mini-grid article {
  padding: 16px;
}

.mini-grid span,
.details span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-grid strong,
.details strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.08rem;
}

.admin-panel {
  padding: 16px;
}

.admin-page .topbar {
  margin-bottom: 10px;
}

.admin-layout {
  display: grid;
  gap: 14px;
}

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

.users-list {
  display: grid;
  gap: 8px;
}

.user-row,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.user-row span,
.history-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.user-row.pending {
  border-color: rgba(255, 209, 102, 0.42);
}

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

.search-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-row {
  align-items: center;
}

.history-row a {
  color: var(--accent);
  font-weight: 850;
  text-decoration: none;
}

.history-stats {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.details {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
}

.result-link {
  color: var(--accent);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 980px);
    padding: 16px 0;
  }

  .topbar,
  .actions,
  .panel-head,
  .user-row,
  .history-row {
    align-items: stretch;
    flex-direction: column;
  }

  .live-grid,
  .mini-grid,
  .details,
  .selector-panel,
  .search-form {
    grid-template-columns: 1fr;
  }

  .status,
  .button,
  .row-actions {
    width: 100%;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .speed-card strong span {
    font-size: clamp(2.5rem, 15vw, 4rem);
  }
}
