:root {
  --bg-0: #0a0e14;
  --bg-1: #11161e;
  --bg-2: #1a212c;
  --bg-3: #232b38;
  --border: #2d3646;
  --text: #e6edf3;
  --text-dim: #94a3b8;
  --text-mute: #64748b;
  --accent: #38bdf8;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,.32);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────── Auth ───────── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: radial-gradient(ellipse at top, #1e293b 0%, #0a0e14 60%);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-emoji { font-size: 44px; line-height: 1; }
.auth-logo h1 { margin: 6px 0 2px; font-size: 22px; }
.auth-subtitle { margin: 0; color: var(--text-dim); font-size: 13px; }
.auth-foot { margin: 16px 0 0; text-align: center; color: var(--text-mute); font-size: 11px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--text-dim); }
.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%; padding: 11px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); font-size: 14px;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); }

.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 42px; }
.eye-btn {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 18px;
  padding: 4px 8px; color: var(--text-dim);
}
.eye-btn:hover { color: var(--text); }

.checkbox-row { display: flex; gap: 8px; align-items: center; margin: 8px 0 18px; font-size: 13px; color: var(--text-dim); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-3); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #0a0e14;
  width: 100%; padding: 12px; font-weight: 600;
}
.btn-primary:hover { background: #67d4fa; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fecaca; }

/* ───────── Topbar ───────── */
.dash-body { padding: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-emoji { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-version { font-size: 11px; color: var(--text-mute); margin-left: 4px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px;
}
.user-emoji { font-size: 14px; }
.role-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--accent); color: #0a0e14;
}

.dash-main { padding: 20px 24px 60px; max-width: 1480px; margin: 0 auto; }

.section { margin-bottom: 32px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.muted { color: var(--text-mute); font-size: 12px; }

/* ───────── Shop cards grid ───────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.shop-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.shop-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.shop-card.healthy::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--green);
}
.shop-card.warn::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--yellow);
}
.shop-card.critical::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--red);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.shop-name { font-weight: 600; font-size: 15px; }
.platform-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 7px; border-radius: 4px;
  background: var(--bg-3); color: var(--text-dim); text-transform: uppercase;
}
.platform-tag.tokopedia { background: #003d2b; color: #4ade80; }
.platform-tag.shopee { background: #4d1a08; color: #fb923c; }
.platform-tag.tiktok { background: #1a1a1a; color: #f0f0f0; }
.platform-tag.lazada { background: #0d2942; color: #60a5fa; }
.platform-tag.goodang { background: #1e293b; color: #93c5fd; }
.platform-tag.odoo { background: #3d1a3d; color: #d8b4fe; }

.gauge-wrap { width: 100%; height: 170px; margin: -10px 0 4px; }

.subscores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 11.5px;
}
.sub-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sub-label { color: var(--text-dim); }
.sub-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.sub-bar {
  width: 36px; height: 4px; border-radius: 2px; background: var(--bg-3);
  overflow: hidden;
}
.sub-bar > span { display: block; height: 100%; }

.metrics-row {
  display: flex; gap: 10px; margin-top: 10px;
  font-size: 11px; color: var(--text-mute);
  border-top: 1px dashed var(--border); padding-top: 8px;
}
.metric-item strong { color: var(--text-dim); font-weight: 600; }

/* sparkline mini */
.spark { width: 100%; height: 38px; margin-top: 4px; }

/* ───────── Leaderboard ───────── */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 8px; padding: 2px; }
.seg-btn {
  background: transparent; border: none; padding: 5px 12px;
  font-size: 12px; color: var(--text-dim); cursor: pointer; border-radius: 6px;
}
.seg-btn.active { background: var(--accent); color: #0a0e14; font-weight: 600; }

.leaderboard {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.leader-row {
  display: grid;
  grid-template-columns: 38px 1fr 80px 80px 80px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.leader-row.head {
  font-size: 11px; color: var(--text-mute); text-transform: uppercase;
  letter-spacing: .5px; padding: 6px 12px;
}
.leader-row:not(.head):hover { background: var(--bg-2); }
.rank-1 { background: linear-gradient(90deg, rgba(245,158,11,.18), transparent); }
.rank-2 { background: linear-gradient(90deg, rgba(148,163,184,.14), transparent); }
.rank-3 { background: linear-gradient(90deg, rgba(217,119,6,.14), transparent); }

.rank-num { font-size: 18px; font-weight: 700; text-align: center; }
.rank-1 .rank-num::before { content: "🥇 "; }
.rank-2 .rank-num::before { content: "🥈 "; }
.rank-3 .rank-num::before { content: "🥉 "; }
.lb-name { font-weight: 600; }
.lb-name small { display: block; color: var(--text-mute); font-size: 11px; font-weight: normal; }
.lb-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.lb-points { color: var(--accent); font-size: 15px; }

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .user-chip { display: none; }
  .dash-main { padding: 14px; }
  .cards-grid { grid-template-columns: 1fr; gap: 12px; }
  .leader-row { grid-template-columns: 32px 1fr 60px 60px; font-size: 12px; }
  .leader-row > :nth-child(5) { display: none; }
  .leader-row.head > :nth-child(5) { display: none; }
}
