:root {
  --ink: #12141c;
  --ink-soft: #1b1e29;
  --ink-softer: #242835;
  --ink-line: #2e3340;
  --cream: #f4f1e9;
  --muted: #8b93a3;
  --gold: #c9a15a;
  --gold-light: #e4c892;
  --gold-dark: #8f6e33;
  --platinum: #d8dee6;
  --silver: #a7aeb8;
  --success: #4caf77;
  --danger: #e0575b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: 'Manrope', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

h1, h2, .font-display { font-family: 'Fraunces', serif; }

a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(18,20,28,0.95);
  border-bottom: 1px solid var(--ink-line);
  backdrop-filter: blur(6px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-family: 'Fraunces', serif; font-size: 1.25rem; letter-spacing: 0.02em; }
.gold { color: var(--gold); }
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; color: rgba(244,241,233,0.8); position: relative; }
.nav a:hover { background: var(--ink-soft); color: var(--cream); }
.nav a.active { background: var(--gold); color: var(--ink); }
.nav .btn-outline { border: 1px solid var(--ink-line); }
.nav .btn-outline:hover { border-color: var(--gold); }
.nav .btn-gold-outline { border: 1px solid rgba(201,161,90,0.4); color: var(--gold); }
.nav-cart .badge {
  position: absolute; top: -6px; right: -2px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; height: 18px; width: 18px; display: grid; place-items: center;
}

.main-content { flex: 1; width: 100%; padding: 24px 20px 60px; }

.site-footer { border-top: 1px solid var(--ink-line); padding: 20px 0; text-align: center; font-size: 0.75rem; color: var(--muted); }

/* ---------- Flash messages ---------- */
.flash { border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; font-size: 0.9rem; border: 1px solid; }
.flash-error { background: rgba(224,87,91,0.1); border-color: rgba(224,87,91,0.4); color: var(--danger); }
.flash-success { background: rgba(76,175,119,0.1); border-color: rgba(76,175,119,0.4); color: var(--success); }
.flash-info { background: var(--ink-softer); border-color: var(--ink-line); color: var(--cream); }

/* ---------- Generic components ---------- */
.card { border: 1px solid var(--ink-line); background: var(--ink-soft); border-radius: 20px; padding: 20px; }
.btn {
  display: inline-block; border: none; border-radius: 12px; padding: 12px 20px;
  font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.95rem;
}
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: var(--gold-light); }
.btn-gold:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--ink-line); color: var(--cream); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger-ghost { background: transparent; border: 1px solid rgba(224,87,91,0.4); color: var(--danger); }

.input, select.input, textarea.input {
  width: 100%; background: var(--ink-softer); border: 1px solid var(--ink-line); border-radius: 12px;
  padding: 10px 14px; color: var(--cream); font-family: inherit; font-size: 0.95rem;
}
.input::placeholder { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.field label { color: var(--muted); }

.pill {
  display: inline-block; border-radius: 999px; padding: 6px 16px; font-size: 0.85rem; font-weight: 600;
  border: 1px solid var(--ink-line); color: rgba(244,241,233,0.8);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.pill.active { background: var(--gold); color: var(--ink); border-color: var(--gold); }

.badge-status { border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; border: 1px solid; }
.badge-PAID { color: var(--success); background: rgba(76,175,119,0.1); border-color: rgba(76,175,119,0.3); }
.badge-PENDING { color: var(--gold); background: rgba(201,161,90,0.1); border-color: rgba(201,161,90,0.3); }
.badge-FAILED { color: var(--danger); background: rgba(224,87,91,0.1); border-color: rgba(224,87,91,0.3); }

.tier-badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 700; color: var(--ink); }
.tier-1 { background: linear-gradient(135deg, var(--platinum), #fff); }
.tier-2 { background: linear-gradient(135deg, var(--gold-light), var(--gold-dark)); }
.tier-3 { background: linear-gradient(135deg, var(--silver), var(--ink-line)); }

/* ---------- Grid utilities ---------- */
.grid { display: grid; gap: 16px; }
.grid-products { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 32px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 720px) {
  .two-col, .detail-grid { grid-template-columns: 1fr; }
}
.center { text-align: center; }
.muted { color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.max-sm { max-width: 400px; margin: 0 auto; }
.max-md { max-width: 560px; margin: 0 auto; }

/* ---------- Product card ---------- */
.product-card { display: flex; flex-direction: column; border: 1px solid var(--ink-line); background: var(--ink-soft); border-radius: 20px; overflow: hidden; transition: border-color .15s; }
.product-card:hover { border-color: rgba(201,161,90,0.6); }
.product-thumb { aspect-ratio: 1; display: grid; place-items: center; background: var(--ink-softer); font-size: 2.5rem; }
.product-body { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.product-body h3 { margin: 0; font-size: 1rem; }

/* ---------- Cart / list rows ---------- */
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--ink-line); background: var(--ink-soft); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.qty-control { display: flex; align-items: center; border: 1px solid var(--ink-line); border-radius: 12px; overflow: hidden; }
.qty-control button { background: none; border: none; color: var(--cream); padding: 6px 12px; cursor: pointer; font-size: 1rem; }
.qty-control button:hover { background: var(--ink-softer); }
.qty-control span { padding: 6px 12px; min-width: 2.5rem; text-align: center; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data-table th { text-align: left; background: var(--ink-softer); color: var(--muted); padding: 10px 14px; font-weight: 600; }
table.data-table td { padding: 10px 14px; border-top: 1px solid var(--ink-line); background: var(--ink-soft); }

/* ---------- Admin ---------- */
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 24px; }
@media (max-width: 720px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-nav { display: flex; flex-direction: column; gap: 8px; }
.admin-nav a { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--ink-line); font-weight: 600; }
.admin-nav a.active { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.stat-card p.label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 6px; }
.stat-card p.value { font-family: 'Fraunces', serif; font-size: 1.6rem; color: var(--gold); margin: 0; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal-box { width: 100%; max-width: 460px; background: var(--ink-soft); border: 1px solid var(--ink-line); border-radius: 20px; padding: 24px; }

/* ---------- Hero Slider ---------- */
/* ---------- Hero Slider (geser mulus ala Tokopedia) ---------- */
.hero-slider {
  position: relative;
  overflow: hidden;
  height: 320px;
  padding: 0 !important;
  background: var(--ink-soft) !important;
}
@media (max-width: 640px) {
  .hero-slider { height: 180px; }
}

.hero-slides-track {
  display: flex;
  height: 100%;
  transition: transform .6s cubic-bezier(.65, 0, .35, 1);
}
.hero-slide {
  flex: 0 0 100%;
  min-width: 100%;
  height: 100%;
}
.hero-slide-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.hero-dots {
  position: absolute; bottom: 16px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 8px;
  z-index: 2;
}
.hero-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,0.5); border: none; cursor: pointer; padding: 0;
  transition: all .25s;
}
.hero-dot.active { background: var(--gold); width: 22px; }

/* ---------- Dashboard Admin (kartu berwarna + grafik) ---------- */
.kpi-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .kpi-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-cards { grid-template-columns: 1fr; } }
.kpi-card {
  border-radius: 16px; padding: 20px; position: relative; overflow: hidden;
  color: #fff; display: flex; flex-direction: column; gap: 6px;
}
.kpi-card .kpi-icon {
  position: absolute; right: 16px; top: 16px; font-size: 1.8rem; opacity: 0.3;
}
.kpi-card .kpi-value { font-family: 'Fraunces', serif; font-size: 1.6rem; font-weight: 700; word-break: break-word; padding-right: 30px; }
.kpi-card .kpi-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.9; }
.kpi-card .kpi-trend { font-size: 0.8rem; opacity: 0.9; margin-top: 4px; }
.kpi-green  { background: linear-gradient(135deg, #2f9e6b, #1f7a52); }
.kpi-purple { background: linear-gradient(135deg, #9b7fd4, #7259ad); }
.kpi-blue   { background: linear-gradient(135deg, #4f8fe0, #3568b0); }
.kpi-gold   { background: linear-gradient(135deg, var(--gold-light), var(--gold-dark)); color: var(--ink); }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 20px; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.chart-box { position: relative; height: 280px; width: 100%; }
.chart-box-sm { position: relative; height: 220px; width: 100%; }
.chart-box canvas, .chart-box-sm canvas { max-width: 100%; }

.activity-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--ink-line); }
.activity-row:last-child { border-bottom: none; }
.activity-icon { width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; font-size: 1rem; flex-shrink: 0; }
.activity-icon.order { background: rgba(79,143,224,0.15); color: #4f8fe0; }
.activity-icon.user { background: rgba(47,158,107,0.15); color: #2f9e6b; }
.activity-icon.commission { background: rgba(201,161,90,0.15); color: var(--gold); }
.activity-time { font-size: 0.75rem; color: var(--muted); }

.legend-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }

.top-product-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--ink-line); }
.top-product-row:last-child { border-bottom: none; }
.top-product-thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--ink-softer); display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }

.scroll-panel { display: flex; flex-direction: column; height: 420px; }
.scroll-panel .scroll-body { flex: 1; overflow-y: auto; padding-right: 4px; }
.scroll-panel .scroll-body::-webkit-scrollbar { width: 6px; }
.scroll-panel .scroll-body::-webkit-scrollbar-thumb { background: var(--ink-line); border-radius: 999px; }
.scroll-panel .scroll-body::-webkit-scrollbar-track { background: transparent; }

/* ---------- Admin sidebar (selalu menumpuk di atas konten, nempel di tepi kiri layar) ---------- */
.sidebar-toggle-btn {
  background: var(--ink-soft); border: 1px solid var(--ink-line); color: var(--cream);
  width: 38px; height: 38px; border-radius: 10px; font-size: 1.1rem; cursor: pointer;
}
.sidebar-toggle-btn:hover { border-color: var(--gold); }

.admin-nav {
  position: fixed; top: 64px; left: 0; bottom: 0; z-index: 80;
  width: 220px; background: var(--ink-soft); border-right: 1px solid var(--ink-line);
  padding: 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  transform: translateX(-100%);
  transition: transform .25s ease;
}
.admin-nav.open { transform: translateX(0); }
.admin-nav a { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--ink-line); font-weight: 600; }
.admin-nav a.active { background: var(--gold); color: var(--ink); border-color: var(--gold); }

.admin-overlay {
  display: none;
  position: fixed; top: 64px; left: 0; right: 0; bottom: 0; z-index: 70;
  background: rgba(0,0,0,0.5);
}
.admin-overlay.open { display: block; }

.admin-content { min-width: 0; }

/* ============================================================
   RESPONSIVE - MOBILE
   ============================================================ */
@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 0;
    gap: 8px;
    justify-content: center;
  }
  .brand { font-size: 1.05rem; }
  .nav {
    width: 100%;
    justify-content: center;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav a {
    padding: 7px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .nav .btn-outline, .nav .btn-gold-outline {
    padding: 7px 10px;
  }

  .container { padding: 0 14px; }
  .main-content { padding: 16px 14px 40px; }
  h1.font-display, .font-display { font-size: 1.4rem; }
  .card { padding: 16px; border-radius: 16px; }
}

@media (max-width: 480px) {
  .list-row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .list-row > div:first-child { width: 100%; }
  .qty-control { order: 2; }
  .list-row > span:last-child { order: 3; margin-left: auto; }

  h1.font-display { font-size: 1.6rem; }
}

@media (max-width: 380px) {
  .field .grid[style*="repeat(3"] { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ---------- Voucher Card ---------- */
.voucher-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #f3d38a 0%, var(--gold) 45%, var(--gold-dark) 100%);
  color: var(--ink);
  border-radius: 18px;
  padding: 22px 53px;
  max-width: 420px;
}
.voucher-card::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: -10px;
  width: 20px; background: radial-gradient(circle, transparent 9px, transparent 9px);
}
.voucher-icon-corner {
  position: absolute; bottom: 16px; right: 16px;
  width: 34px; height: 34px; border-radius: 999px;
  background: var(--ink); color: var(--gold-light);
  display: grid; place-items: center; font-size: 0.95rem;
}
.voucher-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.voucher-gift-icon { font-size: 1.6rem; }
.voucher-badge { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(18,20,28,0.7); }
.voucher-sublabel { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(18,20,28,0.6); margin: 0 0 4px; }
.voucher-amount { font-family: 'Fraunces', serif; font-size: 2.1rem; font-weight: 800; margin: 0 0 14px; }
.voucher-divider { border-top: 2px dashed rgba(18,20,28,0.3); margin-bottom: 12px; }
.voucher-footer { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; color: rgba(18,20,28,0.75); }

.voucher-card.used { filter: grayscale(0.8); opacity: 0.6; }
.voucher-status-tag {
  position: absolute; top: 14px; right: 14px; background: var(--ink); color: #fff;
  font-size: 0.7rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}

.pill.active { background: var(--gold); color: var(--ink); border-color: var(--gold); }