:root {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #dbe3ee;
  --blue: #2563eb;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 44px rgba(31, 41, 55, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.12), transparent 36%),
              linear-gradient(28deg, rgba(5, 150, 105, 0.12), transparent 34%),
              var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

/* ── Login page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
}

.login-panel {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin: 0 0 8px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: left;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin: 12px 0 0;
}

/* ── Main layout ── */
.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.user-workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.workspace-sidebar {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  position: sticky;
  top: 24px;
}

.sidebar-brand { margin-bottom: 20px; }

.brand-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  color: #fff;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
}

.brand-heading .eyebrow { margin: 0; }
.brand-heading h1 { margin: 0; font-size: 16px; }

.channel-badge {
  display: inline-block;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 8px;
}

.channel-form { margin-bottom: 16px; }
.channel-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

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

.input-row input, .input-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input-row input:focus { border-color: var(--blue); }

.primary-button {
  padding: 8px 18px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.primary-button:hover { background: #1d4ed8; }

.ghost-button {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}

.ghost-button:hover { background: var(--panel-strong); }

.text-button {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.logout-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.logout-link:hover { color: var(--red); }

/* ── Status strip ── */
.status-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel-strong);
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
}

.status-dot.ok { background: var(--green); }
.status-dot.loading { background: var(--amber); animation: pulse 1s infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse { 50% { opacity: 0.4; } }

/* ── Section nav ── */
.section-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.section-nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
}

.section-nav-link:hover { background: var(--panel-strong); color: var(--text); }
.section-nav-link.is-active { background: rgba(37, 99, 235, 0.1); color: var(--blue); font-weight: 600; }

/* ── Workspace main ── */
.workspace-main {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px 32px;
  min-height: 600px;
}

.workspace-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.workspace-topbar h2 { margin: 0; font-size: 20px; }
.workspace-subtitle { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.workspace-channel {
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}

.workspace-channel strong {
  display: block;
  font-size: 16px;
  color: var(--text);
}

/* ── Metric grid ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.metric-label { font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.metric-value { font-size: 28px; font-weight: 700; display: block; }
.metric-note { font-size: 11px; color: var(--muted); margin: 4px 0 0; }

.install-card .metric-value { color: var(--blue); }
.today-install-card .metric-value { color: #7c3aed; }
.trx-card .metric-value { color: var(--amber); }
.usdt-card .metric-value { color: var(--green); }

/* ── Content sections ── */
.content-section { margin-bottom: 24px; }
.section-heading { margin-bottom: 16px; }

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

.panel-heading h2 { margin: 0; font-size: 17px; }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.channel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.channel-table th {
  background: var(--panel-strong);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.channel-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.channel-table tr:last-child td { border-bottom: none; }
.channel-table code {
  font-size: 12px;
  background: var(--panel-strong);
  padding: 2px 6px;
  border-radius: 4px;
}

.table-empty { color: var(--muted); text-align: center; padding: 32px !important; }

/* ── App tags ── */
.device-app-list { max-width: 300px; }

.app-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin: 2px 3px 2px 0;
}

.app-tag.wallet { background: rgba(37, 99, 235, 0.1); color: var(--blue); }
.app-tag.exchange { background: rgba(217, 119, 6, 0.1); color: var(--amber); }
.app-tag.other { background: var(--panel-strong); color: var(--muted); border: 1px solid var(--line); }

.app-toggle-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.app-toggle-btn:hover { background: rgba(37, 99, 235, 0.08); }

/* ── Pagination ── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 0 0;
  font-size: 13px;
}

.page-size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.page-size-control select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.pagination-info { color: var(--muted); }

/* ── Progress bars ── */
.bar-wrap { margin: 8px 0; }
.bar-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.bar-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s; }
.bar-fill.trx { background: linear-gradient(90deg, #f59e0b, var(--amber)); }
.bar-fill.usdt { background: linear-gradient(90deg, #34d399, var(--green)); }

/* ── Ranking toggle ── */
.ranking-toggle { display: flex; gap: 4px; }
.ranking-toggle-button {
  padding: 4px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.ranking-toggle-button.is-active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Wallet address cell ── */
.wallet-address-cell code { font-size: 11px; word-break: break-all; }

/* ── IP location cell ── */
.ip-location-cell { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Summary panel spacing ── */
.summary-panel { margin-top: 24px; }

/* ── Search form in tables ── */
.table-search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.table-search-form input {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  flex: 1;
  max-width: 280px;
}

.table-search-form input:focus { border-color: var(--blue); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .user-workspace { grid-template-columns: 1fr; }
  .workspace-sidebar { position: static; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .metric-grid { grid-template-columns: 1fr; }
}
