
:root {
  --bg: #070b14;
  --surface: #0f172a;
  --surface-2: #16213a;
  --gold: #d4af37;
  --gold-hover: #e5c158;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.2);
  --green: #10b981;
  --danger: #ef4444;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

.app-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px 16px 72px;
}

/* Header */
.topbar {
  background: linear-gradient(135deg, #0c1428 0%, #172546 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--gold);
  color: #070b14;
  font-weight: 900;
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-wrap h1 {
  font-size: clamp(1.05rem, 2.5vw, 1.35rem);
  color: var(--gold);
}

.brand-wrap p {
  font-size: 0.85rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-gold {
  background: var(--gold);
  color: #070b14;
}

.btn-gold:hover {
  background: var(--gold-hover);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-green {
  background: var(--green);
  color: #042f1e;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.pill-count {
  background: var(--gold);
  color: #070b14;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Referral Banner */
.ref-banner {
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.ref-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
}

.status-badge {
  background: var(--gold);
  color: #070b14;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
}

.ref-meta {
  font-size: 0.84rem;
  color: #fde68a;
  font-weight: 700;
}

/* Admin Navigation */
.admin-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 18px;
}

.nav-tab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 15px;
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
}

.nav-tab.active {
  background: var(--gold);
  color: #070b14;
  border-color: var(--gold);
}

/* Filter Bar */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 240px);
  gap: 12px;
  margin-bottom: 18px;
}

input, select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.94rem;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--gold);
}

/* Products Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.product-card:hover {
  border-color: rgba(212, 175, 55, 0.55);
  transform: translateY(-2px);
}

.prod-cat {
  font-size: 0.76rem;
  color: var(--gold);
  margin-bottom: 6px;
  font-weight: 700;
}

.product-card h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.product-card p {
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.price-row {
  margin-bottom: 12px;
}

.price-now {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
}

.price-was {
  text-decoration: line-through;
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 8px;
}

.save-pill {
  display: block;
  font-size: 0.78rem;
  color: var(--green);
  margin-top: 2px;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 1.18rem;
  color: var(--gold);
}

.sub {
  font-size: 0.86rem;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.db-indicator {
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #fde68a;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.generated-box {
  background: var(--bg);
  border: 1px dashed var(--gold);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 18px;
  word-break: break-all;
  font-size: 0.88rem;
  color: #fde68a;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 11px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-2);
  color: var(--gold);
  white-space: nowrap;
}

/* KPIs */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.kpi-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.kpi-box .kpi-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold);
  margin-top: 4px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 18px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-sm {
  max-width: 380px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h3 {
  color: var(--gold);
}

.icon-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.qty-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-ctrl button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.cart-summary {
  margin: 14px 0;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 12px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 1.05rem;
  color: var(--gold);
}

.discount-note {
  display: block;
  color: var(--green);
  margin-top: 4px;
}

.checkout-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #070b14;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 200;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 14px;
  }
}
