:root {
  --bg: #050507;
  --panel: #111218;
  --panel-2: #171820;
  --line: rgba(245, 196, 91, 0.2);
  --gold: #f5c45b;
  --ink: #fff7e7;
  --muted: #a8a090;
  --green: #32d19c;
  --red: #ff6961;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-size: 14px;
  background:
    radial-gradient(circle at 80% 4%, rgba(245, 196, 91, 0.14), transparent 24rem),
    linear-gradient(135deg, #050507, #0b0c11);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.login-page {
  display: grid;
  place-items: center;
  padding: 18px;
}
.login-card, .panel-card, .stats-grid article {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}
.login-card {
  width: min(420px, 100%);
  padding: 22px;
}
.login-mark, .panel-brand span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #211404;
  font-weight: 950;
  background: linear-gradient(135deg, #fff0a6, #f3bd43 56%, #a65f0c);
  clip-path: polygon(50% 0, 92% 26%, 78% 86%, 50% 100%, 22% 86%, 8% 26%);
}
.login-logo {
  display: block;
  width: min(210px, 82%);
  max-height: 70px;
  margin-bottom: 10px;
  object-fit: contain;
  object-position: left center;
}
.panel-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
h1, h2, p { margin-top: 0; }
h1 { font-size: 1.7rem; line-height: 1.12; }
h2 { font-size: 1.08rem; line-height: 1.2; }
p, small, label, .lead-meta span, .lead-meta small { color: var(--muted); }
form { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .8rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.055);
  padding: 9px 10px;
  outline: none;
  font-size: .84rem;
}
textarea { resize: vertical; }
option { background: #111218; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.055);
  cursor: pointer;
  font-weight: 700;
  font-size: .82rem;
}
.primary {
  color: #211404;
  background: linear-gradient(135deg, #fff0a6, #f3bd43 56%, #a65f0c);
}
.danger {
  color: #ffd8d6;
  border-color: rgba(255,105,97,.32);
  background: rgba(255,105,97,.12);
}
.ai-btn {
  color: #dffcf1;
  border-color: rgba(50,209,156,.32);
  background: rgba(50,209,156,.11);
}
.wa-btn {
  color: #dffcf1;
  border-color: rgba(37, 211, 102, .35);
  background: rgba(37, 211, 102, .14);
}
.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(50,209,156,.32);
  background: rgba(50,209,156,.1);
}
.alert.error {
  border-color: rgba(255,105,97,.35);
  background: rgba(255,105,97,.12);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  padding: 14px;
  border-right: 1px solid rgba(255,255,255,.08);
  background: rgba(7,8,11,.92);
}
.panel-brand {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}
.panel-brand strong { letter-spacing: .06em; }
.panel-brand small { text-transform: uppercase; }
.sidebar nav {
  display: grid;
  gap: 6px;
}
.sidebar nav a {
  padding: 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: .84rem;
}
.sidebar nav a.active, .sidebar nav a:hover {
  color: var(--ink);
  background: rgba(245,196,91,.1);
}

.panel-main {
  margin-left: 220px;
  padding: 16px;
}
.panel-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}
.eyebrow {
  color: var(--gold);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.panel-top h1 { margin-bottom: 0; }
.user-chip {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  background: rgba(245,196,91,.08);
  font-weight: 600;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stats-grid article {
  padding: 14px;
}
.stats-grid span, .stats-grid strong { display: block; }
.stats-grid span { color: var(--muted); }
.stats-grid strong { margin-top: 6px; color: var(--gold); font-size: 1.55rem; }
.panel-card {
  padding: 13px;
  margin-bottom: 12px;
}
.referral-card {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(260px, 1.1fr);
  gap: 12px;
  align-items: center;
}
.referral-card p {
  margin-bottom: 0;
  font-size: .82rem;
}
.referral-card input {
  color: var(--gold);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.card-head h2, .panel-card h2 { margin-bottom: 12px; }
.card-head a { color: var(--gold); font-weight: 900; }

.lead-list {
  display: grid;
  gap: 8px;
}
.lead-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .78fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
}
.lead-meta strong { display: block; font-size: .92rem; }
.lead-meta p { margin: 8px 0; }
.lead-meta span,
.lead-meta p,
.lead-meta small { font-size: .78rem; }
.lead-action {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.lead-action textarea, .lead-action button { grid-column: 1 / -1; }
.empty { margin-bottom: 0; }

.editor-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.form-card { position: sticky; top: 16px; }
.inline-edit {
  display: grid;
  grid-template-columns: repeat(7, minmax(74px, 1fr)) auto auto;
  gap: 7px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}
.package-edit { grid-template-columns: repeat(5, minmax(90px, 1fr)) auto auto auto auto; }
.users-edit { grid-template-columns: repeat(9, minmax(82px, 1fr)) auto auto auto; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}
.check input { width: auto; }
.file-mini {
  display: grid;
  gap: 6px;
}
.file-mini img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}
.file-mini input {
  padding: 7px;
}
.setting-preview {
  width: 74px;
  height: 74px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  object-fit: contain;
  padding: 6px;
}
.favicon-preview {
  width: 42px;
  height: 42px;
}
.ai-box {
  grid-column: 1 / -1;
  padding: 9px 10px;
  border: 1px solid rgba(50,209,156,.28);
  border-radius: 8px;
  color: #dffcf1;
  background: rgba(50,209,156,.09);
  font-size: .78rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.ai-box strong {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
}
.settings-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.settings-form h2, .settings-form label:has(textarea), .settings-form button, .settings-divider {
  grid-column: 1 / -1;
}
.settings-divider {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.settings-divider h2 { margin-bottom: 4px; }
.settings-divider p {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}
.settings-divider code {
  color: var(--gold);
  font-weight: 800;
}

@media (max-width: 920px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: auto;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    backdrop-filter: blur(14px);
  }
  .panel-brand {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
  }
  .panel-brand small { margin-left: auto; }
  .sidebar nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a {
    flex: 0 0 auto;
    padding: 9px 10px;
    white-space: nowrap;
  }
  .panel-main { margin-left: 0; padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .referral-card { grid-template-columns: 1fr; }
  .editor-grid, .settings-form { grid-template-columns: 1fr; }
  .form-card { position: static; }
  .lead-item { grid-template-columns: 1fr; }
  .inline-edit, .package-edit, .users-edit { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .login-card { padding: 18px; }
  .login-logo {
    width: min(180px, 84%);
    max-height: 58px;
  }
  .sidebar { padding: 9px; }
  .panel-brand strong { font-size: .88rem; }
  .panel-brand span {
    width: 34px;
    height: 34px;
  }
  .panel-brand img {
    width: 34px;
    height: 34px;
  }
  .panel-brand small { font-size: .68rem; }
  .sidebar nav a {
    padding: 8px 9px;
    font-size: .76rem;
  }
  .panel-main { padding: 10px; }
  .panel-top {
    align-items: start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
  }
  .panel-top h1 { font-size: 1.35rem; }
  .user-chip { font-size: .78rem; }
  .stats-grid { gap: 8px; }
  .stats-grid article { padding: 11px; }
  .stats-grid span { font-size: .72rem; }
  .stats-grid strong { font-size: 1.25rem; }
  .panel-card { padding: 10px; }
  .card-head {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }
  .lead-item { padding: 9px; }
  .lead-action { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  input, select, textarea {
    min-height: 36px;
    font-size: .8rem;
  }
}
