:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #65706d;
  --line: #d9dfdc;
  --line-strong: #bcc7c2;
  --soft: #f0f3f1;
  --canvas: #f6f8f7;
  --white: #fff;
  --green: #137a58;
  --green-dark: #0c5b41;
  --green-soft: #e7f4ee;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #9a5b0a;
  --amber-soft: #fff6e6;
  --blue: #1769aa;
  --nav: #1d2624;
  --shadow: 0 8px 24px rgb(23 33 31 / 7%);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.55 Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: var(--blue); text-underline-offset: 3px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 24px 0 12px; font-size: 17px; }

.topbar {
  min-height: 64px;
  background: rgb(255 255 255 / 96%);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 2px 12px rgb(23 33 31 / 4%);
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; font-size: 15px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  border-bottom: 3px solid #35a67a;
  font-size: 11px;
}
.top-actions { display: flex; align-items: center; gap: 12px; }

.shell { max-width: 1180px; margin: 0 auto; padding: 32px 24px 48px; }
.shell.narrow { max-width: 920px; }
.page-title { margin: 0 0 4px; font-size: 25px; line-height: 1.25; }
.page-lead { margin: 0 0 20px; }
.subtle { color: var(--muted); }
.section-kicker { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .08em; }

.notice {
  padding: 12px 14px;
  border: 1px solid #ead5ad;
  border-left: 4px solid var(--amber);
  border-radius: 4px;
  background: var(--amber-soft);
  margin: 18px 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.step { min-width: 0; padding: 14px 15px; border-right: 1px solid var(--line); color: var(--muted); }
.step:last-child { border: 0; }
.step.active { color: var(--ink); background: var(--green-soft); box-shadow: inset 0 -3px var(--green); }
.step b { display: block; font-size: 10px; color: var(--muted); }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { font-size: 16px; margin: 0; }
.panel-body { padding: 18px; }

.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field label { font-weight: 680; }
.field small { color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 130px; resize: vertical; font-family: Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(19 122 88 / 14%); }
input[readonly] { background: var(--soft); }

.row { display: flex; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn {
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  padding: 9px 14px;
  font-weight: 680;
  min-height: 39px;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn:hover { background: #2b3835; border-color: #2b3835; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--soft); border-color: #98a7a1; }
.btn.danger { background: #fff; color: var(--red); border-color: #dc8b84; }
.btn.link { border: 0; background: transparent; color: var(--blue); padding: 5px 7px; min-height: auto; }
.btn-block { width: 100%; }

.message { min-height: 22px; color: var(--red); }
.message.ok { color: var(--green); }
.badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; background: #edf0ef; color: #3c4744; font-size: 12px; }
.badge.success, .badge.active, .badge.qr_ready, .badge.ready, .badge.verified { background: var(--green-soft); color: var(--green-dark); }
.badge.failed, .badge.invalid, .badge.not_ready, .badge.payout_failed { background: var(--red-soft); color: var(--red); }
.badge.waiting_proxy, .badge.verifying, .badge.pending, .badge.pending_review { background: var(--amber-soft); color: var(--amber); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table th { background: var(--soft); color: #4f5b57; font-weight: 680; }
.table tbody tr:hover { background: #f9fbfa; }
.table tr:last-child td { border-bottom: 0; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 32px 20px; }
.auth-panel { width: min(560px, 100%); }
.auth-link { display: block; text-align: center; margin-top: 15px; }
.wallet-alert { padding: 11px 12px; border: 1px solid #e4b968; border-radius: 4px; color: #754308; background: var(--amber-soft); font-weight: 650; }

.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { background: var(--nav); padding: 16px 10px; }
.nav-btn { display: block; width: 100%; border: 0; background: transparent; color: #cbd5d2; padding: 10px 12px; text-align: left; border-radius: 4px; margin: 2px 0; }
.nav-btn.active, .nav-btn:hover { background: #34413e; color: #fff; }
.admin-main { padding: 26px; min-width: 0; }
.admin-section { display: none; }
.admin-section.active { display: block; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 5px; background: #fff; padding: 15px; box-shadow: 0 4px 14px rgb(23 33 31 / 4%); }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; font-size: 24px; line-height: 1.25; margin-top: 5px; font-variant-numeric: tabular-nums; }
.task-list { display: grid; gap: 12px; }
.task { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 16px; align-items: center; border: 1px solid var(--line); background: #fff; padding: 14px; border-radius: 6px; box-shadow: var(--shadow); }
.task img { width: 150px; height: 150px; object-fit: contain; border: 1px solid var(--line); }
.task-actions { display: grid; gap: 8px; min-width: 120px; }
.lang { width: auto; min-width: 96px; padding: 7px 28px 7px 9px; }
.hidden { display: none !important; }

@media (max-width: 800px) {
  .shell { padding: 22px 12px 36px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .step:nth-child(2) { border-right: 0; }
  .step:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .grid-2, .stats { grid-template-columns: 1fr; }
  .admin-layout { display: block; }
  .sidebar { display: flex; overflow: auto; padding: 8px; position: sticky; top: 64px; z-index: 4; }
  .nav-btn { width: auto; white-space: nowrap; }
  .admin-main { padding: 16px 12px; }
  .task { grid-template-columns: 90px minmax(0, 1fr); }
  .task img { width: 90px; height: 90px; }
  .task-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; }
  .topbar { padding: 0 12px; }
  .row.mobile-stack { align-items: stretch; flex-direction: column; }
}

@media (max-width: 520px) {
  .topbar { align-items: center; min-height: 60px; gap: 8px; }
  .brand { gap: 8px; font-size: 13px; }
  .brand-mark { width: 32px; height: 32px; }
  .top-actions { gap: 4px; }
  .lang { min-width: 82px; max-width: 105px; }
  .panel-head, .panel-body { padding: 14px; }
  .page-title { font-size: 22px; }
}
