/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #22263a;
  --border:     #2d3150;
  --accent:     #4f6ef7;
  --accent-dim: #3a52c4;
  --green:      #22c55e;
  --green-dim:  #16a34a;
  --red:        #ef4444;
  --red-dim:    #b91c1c;
  --text:       #e2e8f0;
  --text-dim:   #94a3b8;
  --text-muted: #475569;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --topbar-h:   56px;
  --tabnav-h:   48px;
}

html { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100%;
}

.hidden { display: none !important; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #1e2747 0%, var(--bg) 70%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 14px; margin-bottom: 12px; font-size: 24px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p  { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 15px; outline: none;
  transition: border-color .2s; font-family: inherit;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-muted); }

.btn-primary {
  width: 100%; padding: 11px;
  background: var(--accent); border: none; border-radius: var(--radius);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .2s; font-family: inherit;
}
.btn-primary:hover { background: var(--accent-dim); }

.error-msg {
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5; padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 18px;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(26,29,39,.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 9px; font-size: 16px; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 700; }

.status-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  padding: 5px 10px;
  background: var(--surface2);
  border-radius: 20px; border: 1px solid var(--border);
}
.status-text-label { display: none; }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted); transition: background .3s; flex-shrink: 0;
}
.status-dot.live    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.loading { background: #f59e0b; }
.status-dot.error   { background: var(--red); }

.logout-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-dim);
  font-size: 13px; font-weight: 500; text-decoration: none;
  transition: all .2s; white-space: nowrap;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Tab navigation ────────────────────────────────────────────────────────── */
.tab-nav {
  position: sticky; top: var(--topbar-h); z-index: 90;
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 0 18px; height: var(--tabnav-h);
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .2s; white-space: nowrap;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-btn svg { flex-shrink: 0; }

/* ── Page content ──────────────────────────────────────────────────────────── */
.page-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ── Stats row ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-label    { font-size: 11px; color: var(--text-dim); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value    { font-size: 24px; font-weight: 700; }
.stat-value-sm { font-size: 18px; font-weight: 700; color: var(--text-dim); }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }
.stat-value.blue  { color: var(--accent); }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.table-header h3 { font-size: 14px; font-weight: 600; }

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 400px; }
thead th {
  padding: 9px 14px;
  background: var(--surface2);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 11px 14px; vertical-align: middle; }

.col-num   { width: 42px; color: var(--text-muted); font-size: 12px; }
.col-name  { font-weight: 600; font-size: 14px; }
.col-desc  { color: var(--text-dim); font-size: 13px; }
.col-badge { width: 90px; }
.col-toggle{ width: 60px; text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-on  { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.badge-off { background: rgba(148,163,184,.08); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Toggle switch ─────────────────────────────────────────────────────────── */
.toggle-switch {
  position: relative; display: inline-block;
  width: 44px; height: 24px; cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; transition: all .25s;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text-muted); border-radius: 50%;
  transition: all .25s; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.toggle-switch input:checked + .toggle-track { background: var(--green); border-color: var(--green-dim); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { left: 23px; background: #fff; }
.toggle-switch input:disabled + .toggle-track { opacity: .45; cursor: not-allowed; }

.row-loading td { opacity: .5; pointer-events: none; }

/* ── Skeleton ──────────────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 800px 100%; animation: shimmer 1.4s infinite;
  border-radius: 4px; height: 13px; display: inline-block;
}

/* ── Tool pages (Retry / Discord) ──────────────────────────────────────────── */
.tool-page { max-width: 600px; margin: 0 auto; }

.tool-page-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
}
.tool-page-icon {
  width: 52px; height: 52px; flex-shrink: 0;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.tool-page-title { font-size: 20px; font-weight: 700; }
.tool-page-desc  { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

/* Steps */
.tool-steps { display: flex; flex-direction: column; gap: 16px; }

.step-card {
  display: flex; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  transition: opacity .25s;
}
.step-card-inactive { opacity: .45; pointer-events: none; }

.step-num {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  margin-top: 1px;
}
.step-card-inactive .step-num { background: var(--surface2); color: var(--text-muted); }

.step-body { flex: 1; min-width: 0; }
.step-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.step-desc  { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }

/* Fields */
.field-group { margin-bottom: 14px; }
.field-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-dim); margin-bottom: 6px;
}
.field-input {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  outline: none; transition: border-color .2s; font-family: 'Consolas', monospace;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--text-muted); font-family: 'Inter', sans-serif; }

/* Step actions */
.step-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.action-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit; white-space: nowrap;
}
.action-btn:disabled { opacity: .55; cursor: not-allowed; }

.action-btn-primary { background: var(--accent); color: #fff; }
.action-btn-primary:hover:not(:disabled) { background: var(--accent-dim); }

.action-btn-success { background: var(--green); color: #fff; }
.action-btn-success:hover:not(:disabled) { background: var(--green-dim); }

.action-btn-ghost {
  background: var(--surface2); color: var(--text-dim);
  border: 1px solid var(--border);
}
.action-btn-ghost:hover:not(:disabled) { border-color: var(--text-dim); color: var(--text); }

/* Payment info block */
.info-block {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  font-family: 'Consolas', 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--text);
  white-space: pre-wrap; word-break: break-all;
  line-height: 1.7; margin: 0;
}

/* ── Spinner ────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: middle;
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px;
  max-width: 400px; width: 100%; box-shadow: var(--shadow);
  animation: modal-in .2s ease;
}
@keyframes modal-in {
  from { opacity:0; transform: translateY(-10px) scale(.97); }
  to   { opacity:1; transform: none; }
}
.modal-icon {
  width: 44px; height: 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 14px;
}
.modal-icon.warn { background: rgba(245,158,11,.15); }
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 7px; }
.modal p  { color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.modal-highlight {
  display: inline-block; margin-top: 10px; padding: 6px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-weight: 600; word-break: break-all;
}
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn-cancel {
  flex: 1; padding: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-dim);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }
.btn-confirm {
  flex: 1; padding: 10px;
  background: var(--accent); border: none; border-radius: var(--radius);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .2s; font-family: inherit;
}
.btn-confirm:hover { background: var(--accent-dim); }
.btn-confirm.danger { background: var(--red); }
.btn-confirm.danger:hover { background: var(--red-dim); }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px);
}
.toast {
  padding: 11px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  animation: toast-in .25s ease; border: 1px solid var(--border);
}
@keyframes toast-in {
  from { opacity:0; transform: translateX(16px); }
  to   { opacity:1; transform: none; }
}
.toast-success { background: #14532d; border-color: var(--green-dim); color: #86efac; }
.toast-error   { background: #450a0a; border-color: var(--red-dim); color: #fca5a5; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .status-text-label { display: inline; }
  .logout-label { display: inline; }
  .stats-row { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 599px) {
  .logout-label { display: none; }
  .topbar { padding: 0 14px; }
  .page-content { padding: 14px 12px 32px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
  .stat-value { font-size: 20px; }
  .tab-btn { padding: 0 12px; font-size: 13px; gap: 5px; }
  .step-card { padding: 16px 14px; gap: 12px; }
  .step-num { width: 24px; height: 24px; font-size: 11px; }
  .tool-page-header { gap: 12px; }
  .tool-page-icon { width: 44px; height: 44px; font-size: 20px; }
  .tool-page-title { font-size: 17px; }
  .action-btn { padding: 10px 16px; font-size: 14px; }
  .col-desc { display: none; }
  .col-badge .badge { font-size: 10px; padding: 2px 7px; }
  .modal { padding: 22px 18px; }
}

@media (max-width: 380px) {
  .tab-btn span { display: none; }
  .tab-btn { padding: 0 16px; }
}
