:root {
  --bg: #0b0f14;
  --sidebar: #111820;
  --card: #151c27;
  --card-hover: #1a2332;
  --border: #243044;
  --text: #eef2f7;
  --muted: #8b98ab;
  --primary: #3b82f6;
  --primary-dim: rgba(59, 130, 246, 0.15);
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-dim: rgba(239, 68, 68, 0.12);
  --warn: #f59e0b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem;
}
.brand-title { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.75rem; color: var(--muted); }
.nav { flex: 1; padding: 0.75rem 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block;
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.sidebar-foot { padding: 1rem; border-top: 1px solid var(--border); }
.sys-status { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.5rem; line-height: 1.4; }
.sys-status.ok { color: var(--success); }
.sys-status.warn { color: var(--warn); }
.logout { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.logout:hover { color: var(--text); }
.user-badge {
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.table-actions { white-space: nowrap; }
.table-actions .btn { margin-right: 0.25rem; }
.modal-card-wide { max-width: 480px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.modal-head h3 { margin: 0; }
.qr-modal-card { max-width: 420px; text-align: center; }
.qr-modal-card .modal-head h3 { color: #1677ff; }
.qr-modal-body img {
  width: 100%;
  max-height: min(72vh, 620px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}
.qr-modal-meta {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.qr-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.85rem;
}
.order-link-modal-card { text-align: left; }
.order-link-url {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  word-break: break-all;
}
.pull-tg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: 0.5rem;
}
.pull-tg-row .game-select { min-width: 10rem; }
.order-tg-push-select { max-width: 11rem; font-size: 0.85rem; }
.tg-chats-list { display: flex; flex-direction: column; gap: 0.5rem; }
.tg-chat-row { align-items: flex-end; gap: 0.5rem; }
.tg-chat-row label { flex: 1; min-width: 8rem; }
.tg-test-row { align-items: flex-end; grid-template-columns: 1fr auto; }
.tg-test-row label { margin: 0; }
.badge.muted { opacity: 0.75; }
.icon-btn {
  min-width: 2rem;
  padding: 0.15rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
}
.badge.tiny { font-size: 0.68rem; padding: 0.1rem 0.35rem; }

/* Users page */
.users-stats { margin-bottom: 1rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem !important;
}
.toolbar-search {
  flex: 1;
  min-width: 160px;
}
.toolbar-meta { margin-left: auto; font-size: 0.85rem; }
.user-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-dim), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.user-avatar.lg { width: 44px; height: 44px; font-size: 1.1rem; }
.user-name { font-weight: 600; line-height: 1.3; }
.sidebar-foot .sidebar-game-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.sidebar-game-select {
  width: 100%;
  margin-bottom: 0.65rem;
  font-size: 0.82rem;
}
.account-game-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: hsl(211 35% 18%);
  color: hsl(211 80% 88%);
  border: 1px solid hsl(211 30% 28%);
  white-space: nowrap;
}
.account-game-badge.universal {
  background: hsl(220 8% 20%);
  color: var(--muted);
  border-color: hsl(220 8% 28%);
}
.user-date { font-size: 0.82rem; white-space: nowrap; }
.user-row.is-self { background: rgba(59, 130, 246, 0.06); }
.user-row.is-disabled { opacity: 0.72; }
.account-row.is-disabled { opacity: 0.72; }
.user-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.user-preview-inner { display: flex; align-items: center; gap: 0.75rem; }
.checkbox-row.align-end { align-self: end; padding-bottom: 0.35rem; }
.btn.warn { border-color: rgba(245, 158, 11, 0.4); color: var(--warn); }
.btn.success { border-color: rgba(34, 197, 94, 0.35); color: var(--success); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.owner-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}
.record-id,
.id-col {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.id-col { width: 3rem; }
.acc-meta .record-id { margin-right: 0.25rem; }
.toolbar-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 140px;
}
.toolbar-label select { color: var(--text); }

/* Main */
.main { flex: 1; width: 100%; min-width: 0; padding: 1.5rem 2rem; overflow-x: hidden; }
.panel { animation: fadeIn 0.2s ease; width: 100%; min-width: 0; }
.steps a { color: var(--primary); text-decoration: none; }
.steps a:hover { text-decoration: underline; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; }
.subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.stat-card.accent { border-color: rgba(59,130,246,0.3); background: linear-gradient(135deg, var(--card), var(--primary-dim)); }
.stat-card.success { border-color: rgba(34,197,94,0.25); }
.stat-card .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .value { font-size: 2rem; font-weight: 800; margin-top: 0.15rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 0.75rem; font-size: 0.95rem; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.card-head h3 { margin: 0; }

.steps ol { margin: 0; padding-left: 1.25rem; color: var(--muted); }
.steps li { margin-bottom: 0.35rem; }
.steps strong { color: var(--text); }

.recent-list { display: flex; flex-direction: column; gap: 0.5rem; }
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.recent-item .amount { font-weight: 700; color: var(--success); }
.recent-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; }

.dash-todo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.dash-todo-card {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.dash-todo-card:hover { border-color: rgba(59,130,246,0.35); background: var(--primary-dim); }
.dash-todo-card.has-alert { border-color: rgba(245,158,11,0.45); background: rgba(245,158,11,0.08); }
.dash-todo-label { color: var(--muted); font-size: 0.82rem; }
.dash-todo-value { font-size: 1.5rem; font-weight: 800; margin: 0.2rem 0; }

.dash-quick { margin-bottom: 1rem; }
.dash-quick-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .dash-grid-2 { grid-template-columns: 1fr; }
}

.dash-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 160px;
  padding: 0.5rem 0 0;
}
.dash-trend-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
  gap: 0.2rem;
}
.dash-trend-bar {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}
.dash-trend-label { font-size: 0.72rem; color: var(--muted); }
.dash-trend-amt { font-size: 0.68rem; color: var(--text); font-weight: 600; }

.dash-recent-item { text-decoration: none; color: inherit; }
.dash-recent-item:hover { background: var(--primary-dim); }
.recent-main { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; }

.empty-hint { color: var(--muted); font-size: 0.88rem; padding: 1.5rem; text-align: center; }

/* Pull center */
.pull-panel .page-header { align-items: center; }
.pull-context {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.25);
  white-space: nowrap;
}
.pull-toolbar { margin-bottom: 1rem; }
.pull-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.pull-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.pull-field-wide { grid-column: 1 / -1; }
.pull-field-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.amount-row.compact { margin-bottom: 0; gap: 0.65rem; }
.game-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.game-select {
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.amount-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.field-label { color: var(--muted); font-size: 0.85rem; min-width: 4rem; }
.preset-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.preset {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s;
}
.preset:hover { border-color: var(--primary); }
.preset.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.amount-custom { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; }
.amount-custom input { width: 80px; }
.pull-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.pull-auto-qr-row {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}
.pull-auto-qr-row input[type="checkbox"] { margin: 0; }

.pull-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  align-items: start;
}
.account-picker {
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 640px);
  min-height: 320px;
}
.pull-acc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.65rem;
}
.pull-acc-head h3 { margin: 0 0 0.2rem; }
.pull-acc-summary { line-height: 1.4; }
.selected-count-badge {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  white-space: nowrap;
}
.selected-count-badge.has-selection {
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.35);
  background: var(--primary-dim);
}
.pull-acc-toolbar {
  display: flex;
  gap: 0.4rem;
  padding: 0 0.85rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.pull-acc-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.18rem 0.65rem;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { color: var(--text); border-color: rgba(59, 130, 246, 0.25); }
.chip.active {
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.35);
  background: var(--primary-dim);
}
.pull-acc-search {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  font-size: 0.85rem;
}
.account-picker .card-head { padding-bottom: 0; }
.account-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 0.35rem 0;
}
.account-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  margin: 0.15rem 0.35rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  border: 1px solid transparent;
}
.account-item:hover { background: var(--card-hover); }
.account-item.selected {
  background: var(--primary-dim);
  border-color: rgba(59, 130, 246, 0.25);
}
.account-item input { flex-shrink: 0; margin: 0; }
@media (max-width: 900px) {
  .pull-layout { grid-template-columns: 1fr; }
  .account-picker { max-height: none; min-height: 0; }
  .pull-config-grid { grid-template-columns: 1fr; }
  .pull-panel .page-header { flex-direction: column; align-items: stretch; }
  .pull-context { align-self: flex-start; white-space: normal; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; }
  .pull-acc-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pull-acc-filters::-webkit-scrollbar { display: none; }
  .pull-acc-filters .chip { flex: 0 0 auto; }
  .settings-row { grid-template-columns: 1fr; }
  .settings-card-wide { max-width: none; }
  .settings-card .form-row { grid-template-columns: 1fr; }
  .settings-panel-inner { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .settings-panel-wrap .page-header h1 { font-size: 1.25rem; }
  .settings-panel-wrap .page-header .subtitle { font-size: 0.82rem; }

  .settings-tabs {
    display: flex;
    overflow-x: auto;
    gap: 0.45rem;
    padding: 0.45rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .settings-tabs::-webkit-scrollbar { display: none; }

  .settings-tab {
    flex: 1 0 auto;
    min-width: 6.8rem;
    max-width: none;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 0.6rem 0.75rem;
    gap: 0.1rem;
  }
  .settings-tab .tab-label { font-size: 0.85rem; }
  .settings-tab .tab-desc {
    font-size: 0.68rem;
    text-align: left;
    opacity: 0.85;
    white-space: normal;
    word-break: break-word;
  }

  .settings-panel.card {
    padding: 0.85rem;
    border-radius: 12px;
  }
  .settings-panel-inner { gap: 0.85rem; }
  .settings-panel-head {
    margin-bottom: 0.85rem;
    padding-bottom: 0.65rem;
  }
  .settings-panel-head h3 { display: none; }
  .settings-panel-head .tiny { font-size: 0.78rem; line-height: 1.45; margin: 0; }

  .settings-form { gap: 0.65rem; }
  .settings-form .checkbox-row {
    font-size: 0.85rem;
    padding: 0.35rem 0;
  }
  .settings-form .form-row { grid-template-columns: 1fr; gap: 0.65rem; }
  .settings-form input,
  .settings-form select { font-size: 16px; padding: 0.55rem 0.7rem; }
  .settings-form .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
  }
  .settings-form .form-actions .btn {
    flex: 1 1 calc(33.333% - 0.3rem);
    min-width: 5rem;
    padding: 0.45rem 0.35rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .settings-aside {
    position: static;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
  }
  .settings-aside h4 { font-size: 0.85rem; margin-bottom: 0.5rem; }
  .settings-tips {
    font-size: 0.78rem;
    gap: 0.3rem;
    margin-bottom: 0.65rem;
    padding-left: 1rem;
  }
  .settings-tips li { margin-bottom: 0.35rem; }
  .settings-aside-box { padding: 0.6rem 0.7rem; }
  .settings-code { font-size: 0.72rem; }

  .settings-section h4 { font-size: 0.88rem; }
  #totp-panel .btn { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
}

@media (max-width: 640px) {
  .main { padding: 1rem; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn, .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .pull-acc-head { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .selected-count-badge { align-self: flex-start; }
  .pull-toolbar .amount-row { flex-direction: column; align-items: stretch; }
  .pull-actions { width: 100%; }
  .pull-actions .btn { flex: 1; }
  .settings-tab { flex-direction: column; align-items: flex-start; }
  .settings-tab .tab-desc { text-align: left; }
  .orders-toolbar { flex-direction: column; align-items: stretch; }
  .orders-toolbar input[type="text"],
  .orders-toolbar input[type="number"],
  .orders-toolbar select,
  .orders-toolbar .btn { width: 100%; min-width: 0; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form .btn { width: 100%; min-width: 0; }
  .captcha-body { flex-direction: column; }
  .captcha-form .btn-row .btn { flex: 1; }
  .table th, .table td { padding: 0.5rem 0.6rem; font-size: 0.8rem; white-space: nowrap; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; min-width: calc(50% - 0.25rem); }
  .toast { left: 1rem; right: 1rem; max-width: none; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .settings-row { grid-template-columns: 1fr; }
  .settings-card-wide { max-width: none; }
}


.pull-acc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.account-item.selected .pull-acc-avatar {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.3);
}
.pull-acc-body { flex: 1; min-width: 0; }
.account-item .acc-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-item .acc-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.account-item .acc-note {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.captcha-grid { display: flex; flex-direction: column; gap: 1rem; max-height: 600px; overflow-y: auto; }

.captcha-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color 0.2s;
}
.captcha-card.success { border-color: rgba(34,197,94,0.4); background: var(--success-dim); }
.captcha-card.error { border-color: rgba(239,68,68,0.35); }
.captcha-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.captcha-card-head .account { font-weight: 700; font-size: 0.95rem; }
.captcha-card-head .amount-tag {
  background: var(--primary-dim);
  color: var(--primary);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.captcha-body { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.captcha-img-wrap {
  flex-shrink: 0;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border);
}
.captcha-img-wrap img { display: block; height: 48px; width: auto; image-rendering: pixelated; }
.captcha-form { flex: 1; min-width: 180px; }
.captcha-warn {
  color: var(--error);
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 0.45rem;
}
.captcha-form input {
  width: 100%;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.5rem;
}
.captcha-form .btn-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.pay-result { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--border); }
.pay-qr-poster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.pay-qr-poster img {
  width: min(100%, 280px);
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.pay-link {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  word-break: break-all;
  color: #60a5fa;
  margin: 0.5rem 0;
  max-height: 60px;
  overflow-y: auto;
}
.pay-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.pay-hint { font-size: 0.75rem; color: var(--warn); margin-top: 0.35rem; }

/* Forms */
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-form input { flex: 1; min-width: 120px; }
.form-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 0.5rem !important; color: var(--text) !important; }
.link-pay-field { margin: 0.15rem 0 0.25rem; }
.link-pay-field-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.link-pay-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.form-stack .link-pay-option {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  color: var(--text) !important;
  font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s;
}
.form-stack .link-pay-option:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.5);
  background: var(--primary-dim);
}
.link-pay-option input[type="checkbox"] {
  flex-shrink: 0;
  margin: 0;
  width: 1rem;
  height: 1rem;
}
.link-pay-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.link-pay-icon.alipay { background: #1677ff; }
.link-pay-icon.wechat { background: #07c160; }
.link-pay-name { flex: 1; min-width: 0; }
.link-pay-field .muted.tiny { margin-top: 0.35rem; }
@media (max-width: 520px) {
  .link-pay-options { grid-template-columns: 1fr; }
}
.form-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.status-line { font-size: 0.82rem; color: var(--muted); min-height: 1.2em; }
.status-line.ok { color: var(--success); }
.status-line.fail { color: var(--error); }

input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { width: 100%; resize: vertical; font-family: inherit; }

.btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--primary); background: var(--card-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { border-color: rgba(239, 68, 68, 0.45); color: var(--error); }
.btn.danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.12); }
.btn.lg { padding: 0.65rem 1.5rem; font-size: 0.95rem; font-weight: 600; }
.btn.small { padding: 0.3rem 0.55rem; font-size: 0.8rem; }
.btn-loading.hidden, .btn-text.hidden { display: none; }

.settings-layout { display: flex; flex-direction: column; gap: 1.25rem; }
.settings-panel-wrap { width: 100%; }
.settings-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
}
.settings-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-family: inherit;
}
.settings-tab:hover {
  background: var(--card-hover);
  color: var(--text);
}
.settings-tab.active {
  background: var(--primary-dim);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--primary);
}
.settings-tab .tab-label {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
}
.settings-tab .tab-desc {
  font-size: 0.72rem;
  opacity: 0.85;
  line-height: 1.2;
}
.settings-panels { position: relative; }
.settings-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}
.settings-panel.active { display: block; }
.settings-panel-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 1.5rem;
  align-items: start;
}
.settings-main { min-width: 0; }
.settings-aside {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  position: sticky;
  top: 1rem;
}
.settings-aside h4 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
}
.settings-tips {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
}
.settings-tips li { margin-bottom: 0.45rem; }
.settings-tips a { color: var(--primary); }
.settings-aside-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}
.settings-aside-box .aside-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.settings-steps {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}
.settings-code {
  display: block;
  font-size: 0.78rem;
  color: var(--primary);
  word-break: break-all;
}
.settings-panel-head {
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.settings-panel-head h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.settings-section h4 { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--text); }
.settings-form { max-width: none; }
.settings-form .checkbox-row {
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: nowrap;
  white-space: normal;
  word-break: keep-all;
  line-height: 1.45;
  min-width: 0;
}
.settings-form .checkbox-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
}
.settings-form label:not(.checkbox-row) {
  min-width: 0;
}
.input-with-toggle {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.input-with-toggle input {
  width: 100%;
  padding-right: 2.6rem !important;
}
.btn-pwd-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-pwd-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.btn-pwd-toggle .pwd-eye-closed { display: none; }
.btn-pwd-toggle.revealed .pwd-eye-open { display: none; }
.btn-pwd-toggle.revealed .pwd-eye-closed { display: block; }
.settings-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}
.settings-card { margin-bottom: 0; }
.settings-card-wide { max-width: 640px; }
.settings-card .form-stack label { font-size: 0.85rem; }
.settings-card input,
.settings-card select,
.settings-card textarea { width: 100%; }
.settings-card .form-row { grid-template-columns: 1fr 1fr; gap: 1rem; }
.settings-card-wide .form-stack { max-width: 420px; }
.orders-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.orders-toolbar input[type="text"] { flex: 1; min-width: 180px; }
.orders-toolbar input.order-id-input { flex: 0 0 5.5rem; min-width: 5.5rem; max-width: 6rem; }
.orders-toolbar select { min-width: 120px; }

.orders-filter-card {
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}
.orders-filter-primary {
  display: grid;
  grid-template-columns: minmax(240px, 1.8fr) repeat(3, minmax(120px, 1fr)) auto;
  gap: 0.85rem 1rem;
  align-items: end;
}
.orders-filter-public {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(132px, 1fr)) auto;
  gap: 0.85rem 1rem;
  align-items: end;
}
@media (max-width: 1100px) {
  .orders-filter-public {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .orders-filter-public .orders-field-search {
    grid-column: 1 / -1;
  }
  .orders-filter-public .orders-filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
.orders-field-search {
  min-width: 0;
}
.orders-filter-advanced {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
}
.orders-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 0.85rem 1rem;
  align-items: end;
}
.orders-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.orders-field-wide {
  grid-column: span 2;
}
.orders-field-narrow {
  max-width: 7rem;
}
.orders-field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.orders-field input,
.orders-field select {
  width: 100%;
}
.orders-field input[type="date"] {
  min-height: 2.35rem;
  padding: 0.42rem 0.55rem;
  color-scheme: dark;
}
.orders-field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
}
.orders-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 1px;
}
.orders-filter-card .status-line {
  margin: 0.65rem 0 0;
  min-height: 1.2em;
}
.orders-filter-actions .btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.orders-summary-stats {
  margin-bottom: 0.85rem;
}
.orders-summary-stats .stat-card {
  padding: 0.75rem 0.9rem;
}
.orders-summary-stats .value {
  font-size: 1.35rem;
}
.orders-summary-stats .value .unit {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}
.orders-summary-empty {
  grid-column: 1 / -1;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
}
.orders-list-summary {
  margin: 0 0 0.75rem;
  font-size: 0.84rem;
}
.orders-table-wrap {
  padding: 0 !important;
  overflow: auto;
}
.orders-table {
  min-width: 1180px;
}
.orders-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(6px);
}
.orders-table tbody tr {
  transition: background 0.15s ease;
}
.orders-table tbody tr:hover td {
  background: rgba(59, 130, 246, 0.06);
}
.orders-table tbody tr.order-row-ok {
  border-left: 3px solid transparent;
}
.orders-table tbody tr.order-row-fail {
  border-left: 3px solid rgba(239, 68, 68, 0.45);
}
.orders-table .check-col { width: 2.5rem; }
.orders-table .col-serial { width: 5.5rem; }
.orders-table .col-owner { width: 4.5rem; }
.orders-table .col-order-main { min-width: 9rem; }
.orders-table .col-source { min-width: 8rem; max-width: 11rem; }
.orders-table .col-time { white-space: nowrap; width: 7.5rem; }
.orders-table .col-detail { min-width: 10rem; max-width: 16rem; }
.orders-table .col-payer { min-width: 8rem; max-width: 11rem; }
.orders-table .col-status { min-width: 9rem; max-width: 13rem; }
.orders-table .col-actions { width: 9.5rem; }
.orders-table .order-stack-cell { vertical-align: top; }
.orders-table td.order-serial-col,
.orders-table th.order-serial-col {
  min-width: 15.5rem;
  width: 15.5rem;
  vertical-align: top;
}
.order-serial-cell {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 14rem;
}
.order-serial-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.3;
  min-width: 0;
}
.order-serial-tag {
  flex: 0 0 2rem;
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  padding: 0.08rem 0.25rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  letter-spacing: 0.04em;
}
.order-serial-val {
  flex: 1 1 auto;
  font-size: 0.74rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-serial-line.is-primary .order-serial-val {
  color: var(--text);
  font-weight: 600;
}
.order-serial-line.is-trade .order-serial-tag {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
}
.order-serial-line.is-trade .order-serial-val {
  color: #bfdbfe;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}
.order-merchant-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  line-height: 1.35;
  min-width: 4.5rem;
  max-width: 10rem;
}
.order-merchant-name {
  font-size: 0.86rem;
  font-weight: 500;
  word-break: break-word;
}
.order-merchant-slug {
  font-size: 0.68rem;
  color: var(--muted);
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.orders-table .order-merchant-col {
  min-width: 5.5rem;
  max-width: 9rem;
}
.orders-table .order-payer-col {
  min-width: 9.5rem;
  max-width: 12rem;
}
.order-payer-cell {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  line-height: 1.35;
  min-width: 0;
}
.order-payer-ip {
  font-size: 0.8rem;
  word-break: break-all;
  white-space: normal;
}
.order-payer-region {
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: normal;
  word-break: keep-all;
}
.order-serial-no {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.order-serial-game {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.3;
}
.order-serial-gt {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0 0.3rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.7rem;
}
.order-main-cell .order-main-account {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
}
.order-main-cell .order-main-amount {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.88rem;
  color: #fbbf24;
  font-weight: 700;
}
.order-source-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.order-source-merchant .order-main-line {
  font-size: 0.84rem;
}
.order-source-merchant .order-sub-line {
  font-size: 0.74rem;
}
.order-detail-chips {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.order-chip {
  display: inline-block;
  max-width: 100%;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.74rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-chip-link {
  color: #60a5fa !important;
  text-decoration: none;
  border-color: rgba(96, 165, 250, 0.25);
  background: rgba(59, 130, 246, 0.1);
}
.order-chip-link:hover {
  text-decoration: underline;
}
.order-status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  align-items: center;
}
.order-status-stack .badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}
.order-mini-badge {
  opacity: 0.92;
}
.order-status-note {
  flex: 1 1 100%;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}
.order-status-note.fail-text {
  color: #f87171;
}
.order-actions-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  max-width: 9rem;
}
.order-actions-compact .btn.xs {
  padding: 0.18rem 0.42rem;
  font-size: 0.72rem;
  line-height: 1.2;
}
.badge.source-public {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.badge.source-admin {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.orders-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin-right: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.orders-collapse-btn:hover {
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.35);
}
.orders-collapse-icon {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.85rem;
}
.dj-pay-stats-panel:not(.is-collapsed) .orders-collapse-icon,
.dj-pay-stats-panel.is-expanded .orders-collapse-icon {
  transform: rotate(90deg);
}
.dj-pay-stats-head-main {
  display: flex;
  align-items: flex-start;
}
.dj-pay-stats-panel.is-collapsed .dj-pay-stats-body {
  display: none;
}
.dj-pay-stats-panel.is-collapsed .dj-pay-stats-filters {
  opacity: 0.65;
}
.orders-table .col-time { white-space: nowrap; }
.orders-table .col-amount { white-space: nowrap; }
.orders-table .order-stack-cell { min-width: 8.5rem; max-width: 14rem; }
.order-main-line {
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
}
.order-sub-line {
  margin-top: 0.22rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  word-break: break-all;
}
.order-sub-line a {
  color: #60a5fa;
  text-decoration: none;
}
.order-sub-line a:hover {
  text-decoration: underline;
}
.order-time {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  line-height: 1.35;
}
.order-time-date {
  font-weight: 600;
  font-size: 0.84rem;
}
.order-time-clock {
  color: var(--muted);
  font-size: 0.76rem;
}

@media (max-width: 1100px) {
  .orders-filter-primary {
    grid-template-columns: 1fr 1fr;
  }
  .orders-filter-actions {
    grid-column: 1 / -1;
  }
  .orders-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .orders-field-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .orders-filter-primary,
  .orders-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .orders-summary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.order-date-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 130px;
}
.order-date-label { font-size: 0.72rem; color: var(--muted); }
.order-date-field input[type="date"] {
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
.page-header-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.check-col { width: 2rem; text-align: center; }
.check-col input[type="checkbox"] { cursor: pointer; }
.order-card-select {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Orders & users: mobile cards */
.orders-cards,
.users-cards {
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}
.order-card,
.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
}
.order-card-ok { border-left: 3px solid var(--success); }
.order-card-fail { border-left: 3px solid var(--error); }
.order-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.order-card-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.order-game { font-weight: 700; font-size: 0.95rem; }
.order-amount { font-size: 0.88rem; color: var(--success); font-weight: 600; }
.order-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
  flex-shrink: 0;
}
.order-card-meta {
  margin: 0 0 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.order-meta-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.5rem;
  align-items: start;
  font-size: 0.82rem;
  line-height: 1.45;
}
.order-meta-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}
.order-meta-row dd {
  margin: 0;
  word-break: break-all;
  color: var(--text);
}
.order-meta-link dd { font-size: 0.75rem; color: var(--muted); }
.order-link-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.order-error { color: var(--error); }
.order-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.btn.xs {
  padding: 0.22rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.3;
  border-radius: 6px;
}

/* User cards */
.user-card-self { border-left: 3px solid var(--primary); }
.user-card-disabled { opacity: 0.78; }
.user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.user-card-title { min-width: 0; }
.user-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
  flex-shrink: 0;
}
.user-card-meta {
  margin: 0 0 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.backup-preview-dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  margin: 0;
}
.backup-preview-dl div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.backup-preview-dl dt {
  color: var(--muted);
  margin: 0;
}
.backup-preview-dl dd {
  margin: 0;
  font-weight: 600;
}

  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0.5rem;
  align-items: start;
  font-size: 0.82rem;
  line-height: 1.45;
}
.user-meta-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}
.user-meta-row dd {
  margin: 0;
  word-break: break-word;
  color: var(--text);
}
.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.user-card-actions .btn.xs { flex: 1 1 auto; min-width: 4.5rem; text-align: center; }

@media (max-width: 768px) {
  .orders-table-wrap,
  .users-table-wrap { display: none !important; }
  .orders-cards,
  .users-cards { display: flex; }
  .orders-toolbar .btn { padding: 0.4rem 0.65rem; font-size: 0.82rem; }
  .orders-toolbar input[type="text"],
  .orders-toolbar input[type="number"],
  .orders-toolbar select { font-size: 0.88rem; padding: 0.45rem 0.65rem; }
  .users-stats { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .users-stats .stat-card { padding: 0.65rem 0.75rem; }
  .users-stats .value { font-size: 1.25rem; }
  .toolbar.card { flex-direction: column; align-items: stretch; }
  .toolbar-search,
  .toolbar select { width: 100%; min-width: 0; }
  .toolbar-meta { margin-left: 0; text-align: right; }
  .user-note { max-width: none; white-space: normal; }
  .empty-hint.card {
    padding: 1.25rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
  }
}

.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }

.table-wrap { overflow-x: auto; padding: 0 !important; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; }
.table th { color: var(--muted); background: rgba(0,0,0,0.2); font-weight: 500; font-size: 0.8rem; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); }

.dj-pay-stats-panel { margin-bottom: 1rem; padding: 1rem 1.1rem; }
.dj-pay-stats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}
.dj-pay-stats-title { margin: 0; font-size: 1.05rem; }
.dj-pay-stats-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
.dj-stats-account-input {
  min-width: 7.5rem;
  max-width: 10rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}
.dj-pay-summary { margin-bottom: 1rem; }
.dj-pay-stats-detail { margin-top: 0.25rem; }
.dj-stats-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.dj-stats-tab {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.dj-stats-tab.active {
  background: var(--primary-dim);
  border-color: rgba(59, 130, 246, 0.45);
  color: var(--primary);
  font-weight: 600;
}
.dj-stats-view { display: none; }
.dj-stats-view.active { display: block; }
.dj-stats-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.dj-stats-pager .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.dj-pay-stats-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.dj-pay-stats-block h3 { margin: 0 0 0.5rem; font-size: 0.92rem; color: var(--muted); }
@media (max-width: 900px) {
  .dj-pay-stats-tables { grid-template-columns: 1fr; }
}

.tiny { font-size: 0.78rem; margin: 0.25rem 0 0.75rem; }
.tiny a { color: var(--primary); }
.pwd-text {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pwd-text.masked { filter: blur(4px); user-select: none; }
.table input.cell-input {
  width: 100%;
  min-width: 100px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}
.table .actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(139, 152, 171, 0.12);
  color: var(--muted);
}
.badge.ok,
.badge.success { background: var(--success-dim); color: var(--success); }
.badge.info { background: var(--primary-dim); color: var(--primary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.badge.fail,
.badge.danger { background: var(--error-dim); color: var(--error); }
.badge.warn { background: rgba(245, 158, 11, 0.14); color: var(--warn); }
.badge.off { background: var(--error-dim); color: var(--error); }
.badge.unknown { background: rgba(139,152,171,0.12); color: var(--muted); }
.badge.ok { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }

.warn-hint { color: var(--warn); }

.hidden { display: none !important; }

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  max-width: 360px;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } }
.toast.error { border-color: var(--error); }
.toast.success { border-color: var(--success); }
.toast.info { border-color: var(--accent, #3b82f6); }
.toast.loading { border-color: var(--accent, #3b82f6); opacity: 0.95; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--bg); }
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 0.25rem; }
.login-card .muted { margin-bottom: 1.5rem; }
.login-card label { display: block; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.85rem; }
.login-card input { width: 100%; margin-bottom: 0.5rem; }
.login-card .btn { width: 100%; margin-top: 0.75rem; padding: 0.65rem; }
.alert.error { color: var(--error); margin-bottom: 0.75rem; font-size: 0.9rem; }

/* Merchants */
.merchants-list { display: grid; gap: 1rem; margin-top: 1rem; }
.merchant-card-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; margin-bottom: 0.75rem; }
.merchant-card-head h3 { margin: 0; font-size: 1.05rem; }
.merchant-meta { color: var(--muted); font-size: 0.82rem; margin-top: 0.25rem; }
.merchant-link-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding: 0.65rem 0; border-top: 1px solid var(--border); }
.merchant-link-row:first-child { border-top: none; }
.merchant-link-url { flex: 1 1 12rem; font-size: 0.78rem; color: var(--accent); word-break: break-all; }
.multi-select { min-height: 5.5rem; }
.accounts-admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.75rem;
}
.accounts-admin-bar .toolbar-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.88rem;
}
.accounts-admin-bar select { min-width: 140px; }
.login-msg-cell { max-width: 220px; word-break: break-word; }
.import-modal textarea {
  width: 100%;
  min-height: 10rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  resize: vertical;
}
.import-modal .import-text-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.acc-import-form .import-games-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.acc-import-form .import-games-head .field-label {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.acc-import-form .import-multi-toggle {
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  padding-top: 0.05rem;
}
.import-modal h3 { margin: 0 0 0.25rem; }
.game-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem 0.75rem;
  margin: 0;
}
.game-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.88rem;
  color: var(--text);
}
.game-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
}
.game-check-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
}
.game-check-row input[type="checkbox"] {
  flex-shrink: 0;
  margin: 0;
  width: 1rem;
  height: 1rem;
}
.game-check-row label {
  display: block;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}
.form-stack .game-fieldset .game-check-row label {
  flex-direction: row;
}
.modal-card-wide { max-width: 640px; width: min(96vw, 640px); }
.merchant-account-picker {
  max-height: 220px;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.merchant-acc-row { margin: 0; font-size: 0.88rem; }
.merchant-create-form .section-title { margin: 0 0 0.5rem; font-size: 1rem; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 0.18rem 0.45rem;
}
.btn.ghost:hover:not(:disabled) {
  color: var(--primary);
  background: var(--primary-dim);
  border-color: rgba(59, 130, 246, 0.2);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

/* Merchant portal */
.merchant-layout {
  width: 100%;
}
.merchant-layout .main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: none;
  padding: 1.25rem 1.75rem 2rem;
}
.merchant-orders-panel,
.merchant-account-panel,
.merchant-links-panel,
.merchant-layout .panel {
  width: 100%;
  max-width: none;
}
.merchant-sidebar .brand-icon {
  background: linear-gradient(135deg, #1677ff, #3b82f6);
}
.merchant-stats {
  margin-bottom: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.merchant-finance-stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.merchant-stats .value {
  font-size: 1.65rem;
}
.merchant-stat-amount {
  font-size: 1.35rem !important;
}
.merchant-toolbar {
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.merchant-toolbar-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(140px, 1fr)) auto;
  gap: 0.85rem 1rem;
  align-items: end;
}
.merchant-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.merchant-field-wide {
  grid-column: span 1;
}
.merchant-field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.merchant-field input,
.merchant-field select {
  width: 100%;
}
.merchant-toolbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 1px;
}
.merchant-toolbar-actions .btn {
  min-width: 4.5rem;
}
.merchant-table-wrap {
  padding: 0 !important;
  overflow: auto;
  width: 100%;
}
.merchant-orders-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td,
.merchant-orders-table th,
.merchant-orders-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}
.data-table th,
.merchant-orders-table th {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}
.data-table tr:last-child td,
.merchant-orders-table tr:last-child td {
  border-bottom: none;
}
.data-table tr:hover td,
.merchant-orders-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.merchant-orders-table .col-time { width: 7.5rem; white-space: nowrap; }
.merchant-orders-table .col-order { min-width: 12rem; max-width: 18rem; }
.merchant-orders-table .col-amount { width: 5.5rem; white-space: nowrap; }
.merchant-orders-table .col-payer { min-width: 9rem; }
.merchant-orders-table .col-status { min-width: 7rem; max-width: 10rem; }
.merchant-orders-table .col-actions { width: 5.5rem; white-space: nowrap; }
.empty-cell {
  text-align: center;
  padding: 2rem 1rem !important;
}
.order-time {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.35;
}
.order-time-date {
  color: var(--text);
  font-weight: 600;
  font-size: 0.84rem;
}
.order-time-clock {
  color: var(--muted);
  font-size: 0.78rem;
}
.merchant-order-id {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.merchant-id-link {
  color: #60a5fa;
  text-decoration: none;
  word-break: break-all;
}
.merchant-id-link:hover {
  text-decoration: underline;
}
.merchant-order-sub,
.merchant-payer-sub,
.merchant-status-note {
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}
.merchant-payer-main {
  font-weight: 600;
  color: var(--text);
}
.merchant-amount {
  font-size: 1rem;
  font-weight: 800;
  color: #4ade80;
}
.merchant-amount-unit {
  margin-left: 0.15rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.merchant-orders-cards {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

@media (max-width: 960px) {
  .merchant-toolbar-grid {
    grid-template-columns: 1fr 1fr;
  }
  .merchant-field-wide {
    grid-column: 1 / -1;
  }
  .merchant-toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .merchant-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .merchant-stats .value {
    font-size: 1.35rem;
  }
  .merchant-toolbar-grid {
    grid-template-columns: 1fr;
  }
  .merchant-table-wrap {
    display: none !important;
  }
  .merchant-orders-cards {
    display: flex;
  }
}

.merchant-impersonate-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fcd34d;
  font-size: 0.84rem;
}
.merchant-impersonate-banner strong {
  color: #fde68a;
}
.merchant-finance-stats .stat-card {
  min-width: 0;
}
.merchant-finance-modal .modal-card {
  max-width: 960px;
  max-height: 90vh;
  overflow: auto;
}
.merchant-settlement-form {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}
.merchant-finance-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.section-title {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
}
.merchant-settlements-filter {
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(140px, 1fr)) auto;
}
.merchant-settlements-wrap,
.merchant-account-panel .table-wrap + .table-wrap {
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .merchant-finance-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .merchant-settlements-filter {
    grid-template-columns: 1fr 1fr;
  }
}

.data-table td.muted {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 1rem;
}

/* Native dialog modals (used by admin.js / merchant.js) */
dialog {
  border: none;
  padding: 1rem;
  margin: auto;
  background: transparent;
  color: var(--text);
  max-width: calc(100vw - 2rem);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
dialog .modal-card,
dialog form.modal-card {
  margin: 0;
  width: min(480px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
dialog .modal-card h3,
dialog form.modal-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}
dialog .form-stack input,
dialog .form-stack select,
dialog .form-stack textarea {
  width: 100%;
}

/* Merchant link cards */
.item-card .item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.item-card .item-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.item-card .order-card-actions {
  border-top: none;
  padding-top: 0;
}

/* --- Mobile layout: drawer sidebar --- */
html { overflow-x: hidden; }
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 100;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.sidebar-backdrop.visible {
  display: block;
  pointer-events: auto;
}
body.sidebar-open { overflow: hidden; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; }
.login-card label { display: block; margin-bottom: 12px; }
.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.btn.block { width: 100%; margin-top: 8px; }
.card-list { display: grid; gap: 12px; }
.item-card .link-row { display: flex; gap: 8px; margin-top: 8px; }
.link-input { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.merchant-impersonate-banner {
  background: var(--warn);
  color: #111;
  padding: 8px 16px;
  font-size: 13px;
}
@media (max-width: 900px) {
  .mobile-nav-toggle { display: block; }

  .layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 85vw);
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    flex-direction: column;
    border-right: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar .brand {
    width: auto;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar .nav {
    flex: 1;
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: hidden;
    overflow-y: auto;
    width: auto;
    padding: 0.75rem 0.5rem;
    gap: 2px;
    border: none;
  }

  .sidebar .nav-item {
    flex: none;
    min-width: 0;
    text-align: left;
    padding: 0.65rem 0.85rem;
    font-size: 0.92rem;
    white-space: normal;
  }

  .sidebar .sidebar-foot {
    width: auto;
    display: block;
    border-top: 1px solid var(--border);
    padding: 1rem;
  }

  .main {
    flex: 1;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding:
      calc(52px + env(safe-area-inset-top, 0px))
      max(12px, env(safe-area-inset-right, 0px))
      max(20px, env(safe-area-inset-bottom, 0px))
      max(12px, env(safe-area-inset-left, 0px));
  }

  #main-content,
  #merchant-main {
    width: 100%;
    min-width: 0;
  }

  .page-header h1 { font-size: 1.25rem; }
  .page-header .subtitle { font-size: 0.82rem; }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .stat-card { padding: 0.85rem; min-width: 0; }
  .stat-card .value { font-size: 1.45rem; }

  .settings-tabs {
    display: flex;
    overflow-x: auto;
    gap: 0.45rem;
    padding: 0.45rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    grid-template-columns: unset;
  }
  .settings-tabs::-webkit-scrollbar { display: none; }

  .settings-tab {
    flex: 0 0 auto;
    min-width: 7rem;
    max-width: 9.5rem;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 0.6rem 0.75rem;
    gap: 0.15rem;
  }
  .settings-tab .tab-label { font-size: 0.85rem; }
  .settings-tab .tab-desc {
    font-size: 0.68rem;
    white-space: normal;
    line-height: 1.35;
    word-break: break-word;
  }

  .dash-todo-grid { grid-template-columns: 1fr; }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    font-size: 12px;
    min-width: 640px;
  }

  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input,
  .inline-form .btn { width: 100%; min-width: 0; }

  .merchant-toolbar-grid { grid-template-columns: 1fr; }
  .merchant-table-wrap { display: none !important; }
  .merchant-orders-cards { display: flex; }
  .merchant-finance-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .merchant-settlements-filter { grid-template-columns: 1fr; }

  .settings-panel-wrap {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }
  .settings-panel-inner {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .settings-main,
  .settings-aside {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .settings-aside {
    position: static;
    top: auto;
  }
  .settings-panel-head .tiny {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.45;
  }
  .site-config-card {
    padding: 0.85rem;
  }
  .site-config-card h3 {
    font-size: 1rem;
    margin: 0 0 0.5rem;
  }
  .site-config-card .form-actions .btn {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .settings-tab { min-width: 6.2rem; max-width: 8rem; }
  .settings-tab .tab-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .stat-card .value { font-size: 1.25rem; }
}

.game-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  padding: 0.35rem 0;
}
.game-picker-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.45rem 0.65rem;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.game-picker-panel .game-pick-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.game-picker-panel .game-pick-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.game-picker-panel .game-pick-item input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  margin: 0;
  flex-shrink: 0;
}
.game-picker-col {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}
.acc-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
.acc-add-form .acc-add-primary {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) minmax(120px, 1fr) minmax(120px, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
}
.acc-add-form .acc-add-primary input,
.acc-add-form .acc-add-primary .btn {
  width: 100%;
  min-width: 0;
}
.acc-add-form .form-field,
.acc-edit-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.acc-add-form .field-label,
.acc-edit-form .field-label {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.acc-edit-form .acc-edit-games-field .game-picker-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .acc-add-form .acc-add-primary {
    grid-template-columns: 1fr 1fr;
  }
  .acc-add-form .acc-add-primary .btn {
    grid-column: 1 / -1;
  }
  .game-picker-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.game-pick-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  white-space: nowrap;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
