:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #7c3aed;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  background: #0f172a;
  color: #fff;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  min-height: 100vh;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #8b5cf6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}
.brand-title { font-size: 20px; font-weight: 700; }
.brand-sub { font-size: 13px; color: #94a3b8; }

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
}
.nav-item.active,
.nav-item:hover {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.35);
}

.token-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px;
}

.auth-box { margin-top: auto; }
.box-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: #f8fafc; }

.field-label { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 8px; }
.text-input, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.token-actions { display: flex; gap: 8px; margin-top: 10px; }

.primary-btn,
.ghost-btn,
.danger-btn,
.success-btn,
.warn-btn {
  border-radius: 12px;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.primary-btn { background: var(--primary); color: #fff; }
.ghost-btn { background: #eef2ff; color: #4338ca; }
.danger-btn { background: #fee2e2; color: var(--danger); }
.success-btn { background: #dcfce7; color: var(--success); }
.warn-btn { background: #fef3c7; color: var(--warning); }

.hint-text, .muted { font-size: 13px; color: var(--muted); }
.content { padding: 28px; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 6px; font-size: 28px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.flash {
  margin-bottom: 16px;
  border-radius: 14px;
  padding: 12px 14px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.flash.error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.hidden { display: none !important; }

.grid { display: grid; gap: 16px; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide-gap { margin-top: 16px; }

.stat-card, .panel {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { margin-top: 10px; font-size: 30px; font-weight: 700; }
.panel h3, .panel h4 { margin: 0 0 12px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.sub-head { padding-top: 6px; border-top: 1px dashed var(--line); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toolbar-row,
.toolbar-group,
.toolbar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar-row { justify-content: space-between; }
.toolbar-wrap { flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.small-input { width: 110px; }
.section-top-gap { margin-top: 16px; }

.meta-grid {
  display: grid;
  gap: 10px;
}
.meta-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.meta-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.meta-item {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
}
.meta-label { font-size: 12px; color: var(--muted); }
.meta-value { margin-top: 6px; font-size: 14px; word-break: break-all; }

.list-wrap { display: flex; flex-direction: column; gap: 12px; }
.compact-list { max-height: 420px; overflow: auto; }
.list-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.compact-list .list-card { padding: 12px 14px; }
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.list-title { font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.meta-line { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #e5e7eb;
  color: #374151;
}
.badge.pending_review { background: #fef3c7; color: #92400e; }
.badge.approved, .badge.processing, .badge.clicked { background: #dbeafe; color: #1d4ed8; }
.badge.paid, .badge.refunded, .badge.applied { background: #dcfce7; color: #166534; }
.badge.rejected, .badge.failed, .badge.dismissed { background: #fee2e2; color: #b91c1c; }
.badge.exposed { background: #ede9fe; color: #6d28d9; }

.json-box {
  min-height: 180px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  overflow: auto;
}
.json-box.large { min-height: 480px; }
.json-box.small { min-height: 220px; }

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 16px;
}
.split-left, .split-right { min-height: 640px; }
.empty-state {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: #fafafa;
}
.subpanel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.user-secondary-grid { align-items: start; }

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}


.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.op-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fafafa;
}
.op-card h4 { margin-bottom: 10px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-card {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-message { margin-top: 12px; color: var(--text); white-space: pre-wrap; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-danger #confirmModalConfirmBtn { background: var(--danger); color: #fff; }

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

code {
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 1440px) {
  .cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subpanel-grid { grid-template-columns: 1fr; }
  .ops-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .split-layout { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; }
  .content { padding: 18px; }
  .cards-4, .cards-3, .cards-2, .form-grid-3, .form-grid-2, .meta-grid-2, .meta-grid-3, .ops-grid { grid-template-columns: 1fr; }
  .toolbar-row, .topbar, .topbar-right { flex-direction: column; align-items: stretch; }
}
