/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3246;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --accent:    #6c63ff;
  --accent-h:  #7c74ff;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --money:     #06b6d4;
  --radius:    10px;
  --sidebar-w: 220px;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand svg {
  width: 22px; height: 22px;
  stroke: var(--accent);
  flex-shrink: 0;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }

.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,.15); color: var(--accent); }

.sidebar-footer {
  padding: 14px 18px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

.section { display: none; }
.section.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.header-actions { display: flex; gap: 8px; }

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  border-left: 3px solid var(--accent);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.money   { border-left-color: var(--money); }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mt-4 { margin-top: 20px; }
.mb-4 { margin-bottom: 20px; }

/* ── Tables ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,.025); }

.table-sm th, .table-sm td { padding: 8px 12px; font-size: 12px; }

.empty { color: var(--muted); font-style: italic; text-align: center; padding: 24px !important; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success   { background: rgba(34,197,94,.15);  color: var(--success); }
.badge-warning   { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-danger    { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-muted     { background: rgba(136,146,164,.1); color: var(--muted); }
.badge-accent    { background: rgba(108,99,255,.15); color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: .88; }

.btn-primary      { background: var(--accent); color: #fff; }
.btn-ghost        { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm           { padding: 5px 10px; font-size: 11px; }
.btn-lg           { padding: 12px 24px; font-size: 15px; }
.btn-edit         { background: rgba(108,99,255,.15); color: var(--accent); }
.btn-del          { background: rgba(239,68,68,.12); color: var(--danger); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

input[type="text"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

select option { background: var(--surface2); }

textarea { resize: vertical; }

.required { color: var(--danger); }
.hint { font-size: 11px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ── Test section ── */
.test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.test-grid .card { padding: 20px; }
.test-grid p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.mb-3 { margin-bottom: 14px; }

.batch-status {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
}

.batch-status.hidden { display: none; }

.test-log {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 14px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
  background: #0d0f18;
}

.log-entry { display: flex; gap: 10px; align-items: flex-start; padding: 2px 0; }
.log-time  { color: var(--muted); flex-shrink: 0; }
.log-msg   { color: var(--text); }
.log-msg.success { color: var(--success); }
.log-msg.warning { color: var(--warning); }
.log-msg.danger  { color: var(--danger); }
.log-msg.info    { color: var(--accent); }

/* ── Webhook log ── */
.endpoint-display {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0d0f18;
}

.endpoint-display code {
  font-family: 'Cascadia Code', monospace;
  font-size: 13px;
  color: var(--money);
}

.webhook-entry {
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.webhook-entry:last-child { border-bottom: none; }

.webhook-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.webhook-payload {
  background: #0d0f18;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: 'Cascadia Code', monospace;
  font-size: 11.5px;
  color: #a8d8b0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slide-in .2s ease;
  max-width: 360px;
}

.toast.hidden { display: none; }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--accent); }

@keyframes slide-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Misc ── */
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-money   { color: var(--money); font-weight: 700; }
.mono { font-family: 'Cascadia Code', monospace; font-size: 12px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
