:root {
  --bg:        #0d1117;
  --bg-card:   #161b22;
  --bg-input:  #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --text-muted:#8b949e;
  --purple:    #6C63FF;
  --purple-dim:#5a52e0;
  --green:     #3fb950;
  --red:       #f85149;
  --yellow:    #d29922;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth Pages ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.auth-logo .dot { color: var(--purple); }

h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.auth-sub { color: var(--text-muted); margin-bottom: 1.8rem; font-size: 0.9rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.875rem; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dim); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--purple); color: var(--purple); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-danger { background: var(--red); color: #fff; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: rgba(248,81,73,.15); border: 1px solid rgba(248,81,73,.4); color: var(--red); }
.alert-success { background: rgba(63,185,80,.15); border: 1px solid rgba(63,185,80,.4); color: var(--green); }

.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.2rem; }
.plan-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.plan-card:hover { border-color: var(--purple); }
.plan-card.selected { border-color: var(--purple); background: rgba(108,99,255,.08); }
.plan-card input[type="radio"] { display: none; }
.plan-name { font-weight: 700; margin-bottom: 2px; }
.plan-price { font-size: 0.82rem; color: var(--text-muted); }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.auth-footer { text-align: center; margin-top: 1.4rem; font-size: 0.875rem; color: var(--text-muted); }

/* ── Dashboard Layout ── */
.dash-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.4rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 1.4rem 1.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-logo .dot { color: var(--purple); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 1.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, background .15s;
  border-radius: 0;
  text-decoration: none;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); text-decoration: none; }
.nav-item.active { color: var(--purple); background: rgba(108,99,255,.1); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.main-area { display: flex; flex-direction: column; overflow: auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title { font-size: 1.05rem; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.plan-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.plan-badge.free     { background: rgba(139,148,158,.2); color: var(--text-muted); }
.plan-badge.starter  { background: rgba(108,99,255,.2); color: var(--purple); }
.plan-badge.growth   { background: rgba(63,185,80,.2);  color: var(--green); }
.plan-badge.enterprise { background: rgba(210,153,34,.2); color: var(--yellow); }

.page { padding: 2rem; }
.page-header { margin-bottom: 1.8rem; }
.page-header h2 { font-size: 1.3rem; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; }

/* ── Stats Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-sub   { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Table ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.4rem;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
}
.card-body { padding: 1.4rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid rgba(48,54,61,.6); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }

/* ── Code block ── */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #a5d6ff;
  overflow-x: auto;
  white-space: pre;
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* ── Widget preview ── */
.widget-preview {
  position: relative;
  height: 340px;
  background: repeating-linear-gradient(45deg, #1a1f27, #1a1f27 10px, #1d2230 10px, #1d2230 20px);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.widget-bubble {
  position: absolute;
  bottom: 20px; right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  transition: transform .2s;
}
.widget-bubble:hover { transform: scale(1.1); }
.widget-bubble svg { width: 26px; height: 26px; fill: #fff; }

.widget-panel {
  position: absolute;
  bottom: 82px; right: 20px;
  width: 280px;
  background: #1a1e2a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: none;
}
.widget-panel.open { display: block; }
.widget-panel-header {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.88rem;
  color: #fff;
}
.widget-panel-body { padding: 10px 14px; min-height: 120px; }
.widget-panel-input {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.widget-panel-input input {
  flex: 1; padding: 7px 10px;
  background: rgba(255,255,255,.08);
  border: none; border-radius: 6px;
  color: #fff; font-size: 0.82rem;
}
.widget-panel-input button {
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}

/* ── Embed generator ── */
.embed-layout { display: grid; grid-template-columns: 340px 1fr; gap: 2rem; }
@media (max-width: 860px) { .embed-layout { grid-template-columns: 1fr; } }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Utility ── */
.text-muted  { color: var(--text-muted); }
.text-purple { color: var(--purple); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.hidden { display: none !important; }
