:root {
  color-scheme: dark;
  font-family: Inter, Arial, sans-serif;
  background: #0c111b;
  color: #e7edf8;
}

* { box-sizing: border-box; }
html { width: 100%; overflow-x: hidden; }
body { margin: 0; min-width: 0; background: #0c111b; overflow-x: hidden; }
button, input, select { font: inherit; }
button {
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  background: #1f6feb;
  color: white;
  font-weight: 700;
  touch-action: manipulation;
}
button:disabled { cursor: not-allowed; opacity: 0.65; }
button.ghost { background: #202a3b; color: #c8d4e7; }
button.danger { background: #c93c48; }
button.small { padding: 7px 10px; font-size: 13px; }
.hidden { display: none !important; }
.muted { color: #91a0b8; }
.error { color: #ff808d; min-height: 20px; }
.eyebrow {
  margin: 0 0 6px;
  color: #65a4ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(24px, 5vw, 34px); line-height: 1.08; }
h2 { font-size: clamp(20px, 4vw, 26px); line-height: 1.15; }
h3 { font-size: 17px; line-height: 1.25; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 30px;
  background: #141c29;
  border: 1px solid #263247;
  border-radius: 16px;
  box-shadow: 0 18px 50px #00000055;
}
label {
  display: grid;
  gap: 6px;
  margin: 15px 0;
  color: #b5c1d4;
  font-size: 13px;
  font-weight: 700;
}
input, select {
  width: 100%;
  min-width: 0;
  border: 1px solid #344158;
  border-radius: 8px;
  padding: 10px;
  background: #0e1623;
  color: #e7edf8;
}

#app-view {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px 22px 48px;
}
.topbar, .toolbar, .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}
.tabs button { background: transparent; color: #91a0b8; }
.tabs button.active { background: #283750; color: white; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat, .card {
  min-width: 0;
  background: #141c29;
  border: 1px solid #263247;
  border-radius: 12px;
  padding: 16px;
}
.stat strong { display: block; margin-top: 8px; font-size: 26px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 14px;
}
.provider { margin-bottom: 12px; }
.provider-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.meter {
  height: 8px;
  margin: 12px 0 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #273247;
}
.meter span { display: block; height: 100%; border-radius: inherit; background: #1f6feb; }
.badge {
  display: inline-block;
  border-radius: 99px;
  padding: 4px 8px;
  color: #b9c5d8;
  background: #283449;
  font-size: 12px;
  font-weight: 800;
}
.badge.online, .badge.ok { color: #7be3aa; background: #173d2d; }
.badge.error { color: #ff9ba5; background: #48222b; }
.badge.cache { color: #9bc4ff; background: #203a60; }
.badge.fake { color: #ffd59b; background: #4a3218; }
.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin-top: 14px;
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  padding: 11px 8px;
  border-bottom: 1px solid #263247;
  text-align: left;
  white-space: nowrap;
}
th { color: #91a0b8; font-size: 12px; text-transform: uppercase; }
tr.clickable:hover { background: #1b2638; cursor: pointer; }
.toolbar input { max-width: 360px; }
dialog {
  width: min(620px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid #344158;
  border-radius: 14px;
  padding: 22px;
  background: #141c29;
  color: #e7edf8;
  box-shadow: 0 20px 70px #00000088;
}
dialog::backdrop { background: #05080dcc; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.details div {
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 10px;
  border-radius: 8px;
  background: #0f1724;
}
.details span { display: block; margin-bottom: 4px; color: #91a0b8; font-size: 12px; }
.settings-card { max-width: 760px; }
hr { margin: 22px 0; border: 0; border-top: 1px solid #263247; }

.fake-users-panel {
  margin: 16px 0 10px;
  padding: 14px;
  border: 1px solid #2f405b;
  border-radius: 12px;
  background: #101827;
}
.fake-users-panel h3 { margin-bottom: 6px; }
.fake-users-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto auto;
  align-items: end;
  gap: 10px;
  margin-top: 10px;
}
.fake-users-form label { margin: 0; }

.bot-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0 18px;
  padding: 14px;
  border: 1px solid #344158;
  border-radius: 12px;
  background: #0f1724;
}
.bot-control h3 { margin-bottom: 6px; }
.control-actions { flex-wrap: wrap; margin-top: 0; }

.custom-match-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.custom-match-form .dialog-actions {
  grid-column: 1 / -1;
  margin-top: 4px;
}
.custom-match-list { margin-top: 12px; }

@media (max-width: 900px) {
  #app-view { padding: 20px 14px 36px; }
  .fake-users-form { grid-template-columns: 1fr; }
  .settings-card { max-width: none; }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .topbar #logout { align-self: stretch; }
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 8px;
    margin-left: -2px;
    margin-right: -2px;
    -webkit-overflow-scrolling: touch;
  }
  .tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .toolbar, .card-head {
    align-items: stretch;
    flex-direction: column;
  }
  .toolbar input { max-width: none; }
  .details { grid-template-columns: 1fr; }
  .bot-control { align-items: stretch; flex-direction: column; }
  .control-actions { justify-content: flex-start; }
  .custom-match-form { grid-template-columns: 1fr; }
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .dialog-actions button { width: 100%; }
}

@media (max-width: 520px) {
  body { font-size: 14px; }
  .login-shell { padding: 12px; place-items: start center; }
  .login-card { padding: 20px; border-radius: 14px; }
  #app-view { padding: 14px 8px 28px; }
  .card, .stat, .fake-users-panel, .bot-control {
    padding: 12px;
    border-radius: 11px;
  }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat strong { font-size: 22px; }
  button, input, select {
    min-height: 42px;
    font-size: 14px;
  }
  button.small { min-height: 36px; }
  table { font-size: 13px; min-width: 620px; }
  th, td { padding: 9px 7px; }
  dialog {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    padding: 14px;
    border-radius: 12px;
  }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
  #app-view { padding-left: 6px; padding-right: 6px; }
}
