:root {
  color-scheme: dark;
  --bg: #121417;
  --panel: #1d2127;
  --panel-strong: #242a32;
  --border: #353d49;
  --text: #f4f6f8;
  --muted: #a9b2bf;
  --accent: #d73f3f;
  --accent-hover: #ef5555;
  --good: #35c789;
  --warn: #dca943;
  --bad: #ef6461;
  --input: #15191f;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  background: var(--accent-hover);
}

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

button.secondary:hover {
  background: #2f3743;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
}

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

.login-panel {
  width: min(420px, 100%);
  margin: 10vh auto 0;
  display: grid;
  gap: 24px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

.topbar,
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

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

.current-user {
  color: var(--muted);
  font-size: 0.92rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-hover);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

h2 {
  font-size: 1.1rem;
}

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

.stats-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.stat-tile,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-tile {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.stat-tile span,
.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-tile strong {
  font-size: 2rem;
}

.panel {
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 130px;
  gap: 10px;
}

.dashboard-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  min-height: 38px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 0;
  color: var(--muted);
}

.tab-button:hover {
  background: var(--panel-strong);
  color: var(--text);
}

.tab-button.active {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
}

.tab-panel {
  min-width: 0;
}

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

.chart-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(180px, 1fr) minmax(74px, auto);
  align-items: center;
  gap: 12px;
}

.chart-label {
  min-width: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-bar {
  height: 12px;
  width: 100%;
  min-width: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: #11151a;
  border: 1px solid var(--border);
}

.chart-bar.stacked {
  display: flex;
  width: auto;
  max-width: 100%;
}

.chart-fill {
  display: block;
  height: 100%;
}

.chart-fill.total {
  background: var(--accent);
}

.chart-fill.online {
  background: var(--good);
}

.chart-fill.idle {
  background: var(--warn);
}

.chart-value {
  justify-self: end;
  font-size: 0.9rem;
  white-space: nowrap;
}

.chart-empty {
  margin: 18px 0 0;
}

.table-wrap {
  overflow-x: auto;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 68px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.online {
  background: rgba(53, 199, 137, 0.14);
  color: var(--good);
}

.status-pill.idle {
  background: rgba(220, 169, 67, 0.13);
  color: var(--warn);
}

.status-pill.offline {
  background: rgba(239, 100, 97, 0.13);
  color: var(--bad);
}

.country-flag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--good);
  font-size: 0.9rem;
}

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

.is-hidden {
  display: none !important;
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0;
  }

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

  .stats-grid,
  .stats-grid.compact,
  .admin-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .chart-value {
    justify-self: start;
  }

  .filters {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .session-actions {
    width: 100%;
  }

  .session-actions button {
    flex: 1;
  }
}
