:root {
  --bg: #0b0f17;
  --bg-elev: #131a26;
  --bg-card: #1a2333;
  --border: #26324a;
  --text: #e6edf7;
  --text-dim: #8a97ad;
  --primary: #2f80ed;
  --primary-hover: #3d8bf0;
  --online: #2ecc71;
  --offline: #4a5568;
  --danger: #e74c3c;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.brand { text-align: center; margin-bottom: 28px; }
.logo { font-size: 48px; margin-bottom: 8px; }
.brand h1 { font-size: 24px; letter-spacing: -0.5px; }
.tagline { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.login-card label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  margin-bottom: 16px;
}
input:focus { outline: none; border-color: var(--primary); }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; }
.footer-note { color: var(--text-dim); font-size: 12px; }

/* Tabs (auth + config modal) */
.tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 8px; padding: 4px; margin-bottom: 20px; }
.tab, .ctab {
  flex: 1; background: transparent; border: none; color: var(--text-dim);
  padding: 9px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px;
}
.tab.active, .ctab.active { background: var(--primary); color: #fff; }
.auth-form label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.bonus-note {
  background: rgba(46,204,113,0.1); border: 1px solid rgba(46,204,113,0.3);
  color: var(--online); font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 16px;
}
select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; color: var(--text); font: inherit; margin-bottom: 16px;
}
select:focus { outline: none; border-color: var(--primary); }

/* Coin badge + welcome */
.coin-badge {
  display: flex; align-items: center; gap: 6px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 14px;
}
.welcome { color: var(--text-dim); font-size: 15px; margin-bottom: 20px; }
.welcome span { color: var(--text); font-weight: 600; }

/* Config modal extras */
.modal-wide { max-width: 480px; }
.ctab-panel { margin-bottom: 12px; }
.code-block {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-family: 'Consolas', 'Monaco', monospace; font-size: 12px;
  color: #a5d6ff; white-space: pre-wrap; word-break: break-all;
  max-height: 260px; overflow-y: auto; margin-bottom: 12px;
}
.dev-icon { font-size: 20px; flex-shrink: 0; }

/* ===== Dashboard ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.topbar-actions { display: flex; gap: 10px; }
.content { max-width: 1000px; margin: 0 auto; padding: 28px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-label { color: var(--text-dim); font-size: 13px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.small { font-size: 16px; word-break: break-all; }
.stat-value.online { color: var(--online); }

.devices-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.devices-header h2 { font-size: 18px; }

.device-list { display: flex; flex-direction: column; gap: 12px; }
.device {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--offline); flex-shrink: 0; }
.dot.online { background: var(--online); box-shadow: 0 0 8px var(--online); }
.device-info { flex: 1; min-width: 0; }
.device-name { font-weight: 600; font-size: 15px; }
.device-meta { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.device-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 400px;
}
.modal h3 { margin-bottom: 18px; }
.modal label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.modal-hint { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.qr-box { background: #fff; border-radius: 10px; padding: 12px; display: flex; justify-content: center; margin-bottom: 20px; }
.qr-box img { width: 260px; height: 260px; }

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .device { flex-wrap: wrap; }
}

/* ============ LANDING PAGE ============ */
.landing { background: radial-gradient(ellipse at top, #0f1626 0%, var(--bg) 60%); }
.btn-lg { padding: 14px 26px; font-size: 15px; }

.nav { position: sticky; top: 0; z-index: 20; background: rgba(11,15,23,0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav-inner { max-width: 1200px; margin: 0 auto; padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; }
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 18px; }
.nav-link { color: var(--text-dim); text-decoration: none; font-weight: 600; }
.nav-link:hover { color: var(--text); }

.hero { padding: 90px 28px 70px; }
.hero-inner { max-width: 1200px; margin: 0 auto; }
.badge { display: inline-block; background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 600; margin-bottom: 26px; }
.hero-title { font-size: 56px; line-height: 1.08; letter-spacing: -1.5px; max-width: 800px; font-weight: 800; }
.accent { color: var(--primary); background: linear-gradient(90deg, #2f80ed, #3fc8f5); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { color: var(--text-dim); font-size: 18px; line-height: 1.6; max-width: 620px; margin-top: 22px; }
.hero-bonus { display: inline-block; background: rgba(46,204,113,0.08); border: 1px solid rgba(46,204,113,0.3); color: var(--online); padding: 12px 18px; border-radius: 10px; margin-top: 28px; font-weight: 600; font-size: 14px; }
.hero-cta { display: flex; gap: 14px; margin-top: 28px; flex-wrap: wrap; }
.hero-checks { display: flex; gap: 28px; list-style: none; margin-top: 30px; flex-wrap: wrap; color: var(--text-dim); font-size: 14px; font-weight: 500; }

.section { max-width: 1200px; margin: 0 auto; padding: 80px 28px; text-align: center; }
.section-alt { background: var(--bg-elev); max-width: none; }
.section-alt > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.section-title { font-size: 38px; font-weight: 800; letter-spacing: -0.5px; }
.section-sub { color: var(--text-dim); font-size: 17px; margin-top: 14px; max-width: 640px; margin-left: auto; margin-right: auto; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 50px; text-align: left; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.feature-card .fi { font-size: 32px; margin-bottom: 16px; }
.feature-card h3 { font-size: 18px; margin-bottom: 10px; }
.feature-card p { color: var(--text-dim); font-size: 14.5px; line-height: 1.6; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; margin-top: 50px; }
.step-num { font-size: 44px; font-weight: 800; color: var(--primary); opacity: 0.35; margin-bottom: 8px; }
.step h3 { font-size: 19px; margin-bottom: 10px; }
.step p { color: var(--text-dim); font-size: 14.5px; line-height: 1.6; }

.pricing-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-top: 50px; }
.price-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.price-card.popular { border-color: var(--primary); border-width: 2px; }
.popular-tag { position: absolute; top: -12px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 12px; }
.price-coins { font-size: 40px; font-weight: 800; }
.price-unit { color: var(--text-dim); font-size: 13px; }
.price-amt { font-size: 24px; font-weight: 700; margin-top: 12px; }
.price-desc { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }
.price-card .btn { margin-top: auto; }
.pricing-note { color: var(--text-dim); font-size: 14px; margin-top: 30px; }

.section-cta { text-align: center; }
.footer { border-top: 1px solid var(--border); padding: 30px 28px; text-align: center; color: var(--text-dim); font-size: 13px; }

@media (max-width: 900px) {
  .hero-title { font-size: 40px; }
  .feature-grid, .steps { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ BILLING + ADMIN ============ */
.dim-link { color: var(--text-dim); text-decoration: none; }
.dim-link:hover { color: var(--text); }
.icon-btn.primary { color: var(--primary); border-color: rgba(47,128,237,0.5); }
.icon-btn.primary:hover { background: rgba(47,128,237,0.12); }

/* Subscription badges */
.sub { font-size: 12px; font-weight: 600; margin-left: 6px; }
.sub.active { color: var(--online); }
.sub.expired { color: var(--danger); }
.sub.free { color: var(--text-dim); }

/* Activate modal */
.cost-line { font-size: 15px; margin: 6px 0 16px; color: var(--text-dim); }
.cost-line strong { color: var(--text); font-size: 18px; }

/* Buy coins packages */
.pkg-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 14px 0 20px; }
.pkg {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px 8px;
  cursor: pointer; text-align: center; position: relative; color: var(--text); font: inherit;
}
.pkg:hover { border-color: var(--text-dim); }
.pkg.selected { border-color: var(--primary); border-width: 2px; background: rgba(47,128,237,0.08); }
.pkg.popular { border-color: rgba(47,128,237,0.5); }
.pkg-tag { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.pkg-coins { font-size: 24px; font-weight: 800; }
.pkg-unit { font-size: 11px; color: var(--text-dim); }
.pkg-amt { font-size: 16px; font-weight: 700; margin-top: 8px; }
.pkg-desc { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

.method-row { display: flex; gap: 10px; margin-bottom: 18px; }
.method-btn { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text-dim); padding: 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700; }
.method-btn.active { border-color: var(--primary); color: var(--text); background: rgba(47,128,237,0.08); }

.pay-instructions { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.pay-title { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.pay-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.pay-row span { color: var(--text-dim); }
.pay-hint { font-size: 12.5px; color: var(--text-dim); margin-top: 12px; line-height: 1.5; }

/* History */
.history-list { max-height: 400px; overflow-y: auto; margin-bottom: 16px; }
.hist-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.hist-note { font-size: 14px; font-weight: 600; }
.hist-meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.hist-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.hist-coins.pos { color: var(--online); font-weight: 700; }
.hist-coins.neg { color: var(--danger); font-weight: 700; }
.hist-status { font-size: 11px; text-transform: uppercase; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.hist-status.ok { background: rgba(46,204,113,0.15); color: var(--online); }
.hist-status.pending { background: rgba(241,196,15,0.15); color: #f1c40f; }
.hist-status.bad { background: rgba(231,76,60,0.15); color: var(--danger); }

/* Admin */
.admin-h { font-size: 16px; margin: 28px 0 14px; color: var(--text); }
.settings-form { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-width: 480px; }
.settings-form label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.saved-note { color: var(--online); font-size: 13px; margin-left: 10px; }
.lbl-hint { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.mode-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 12px; margin-left: 8px; vertical-align: middle; }
.mode-pill.live { background: rgba(46,204,113,0.15); color: var(--online); }
.mode-pill.mock { background: rgba(241,196,15,0.15); color: #f1c40f; }
.webhook-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-top: 8px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.webhook-box code { display: block; margin-top: 6px; color: #a5d6ff; font-size: 12.5px; word-break: break-all; background: #0b0f17; padding: 8px 10px; border-radius: 6px; }
.settings-save-bar { margin-top: 22px; display: flex; align-items: center; }

.xendit-note { text-align: center; color: var(--text-dim); font-size: 12.5px; margin: 4px 0 16px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 14px 24px; border-radius: 10px; font-weight: 600; font-size: 14px; z-index: 200;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.toast.ok { background: var(--online); color: #04240f; }
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .pkg-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
