:root {
  --bg0: #0a0e14;
  --bg1: #121a24;
  --bg2: #1a2434;
  --line: rgba(212, 175, 55, 0.22);
  --gold: #d4af37;
  --gold2: #f4d03f;
  --cyan: #5ce1e6;
  --text: #e8eef7;
  --muted: #9aa7b8;
  --danger: #ff6b6b;
  --ok: #69f0ae;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --wrap: 1200px;
  font-family: "Sarabun", system-ui, sans-serif;
}

* { box-sizing: border-box; min-width: 0; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(92, 225, 230, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(212, 175, 55, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg0), #070a0f 70%);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; word-break: break-word; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}
@media (max-width: 640px) { .wrap { padding: 0 14px; } }

/* ========== Topbar / Nav ========== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: clamp(68px, 14vw, 92px); flex-wrap: nowrap;
}
.brand {
  display: flex; align-items: center;
  color: var(--text); text-decoration: none !important;
  flex-shrink: 1;
  min-width: 0;
}
.brand:hover { filter: brightness(1.06); text-decoration: none !important; }
.brand__logo {
  display: block;
  height: clamp(52px, 14vw, 88px);
  width: auto;
  max-width: min(460px, 88vw);
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 1px 8px rgba(0, 0, 0, 0.35));
}

.nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
  color: var(--text); font-weight: 600; padding: 6px 4px;
  white-space: nowrap;
}
.nav a:hover { color: var(--gold2); text-decoration: none; }

.nav-toggle { display: none; }
.nav-burger {
  display: none;
  width: 40px; height: 40px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 10px;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
}
.nav-burger span {
  display: block; width: 20px; height: 2px;
  background: var(--gold2); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

@media (max-width: 820px) {
  .nav-burger { display: inline-flex; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    background: rgba(10, 14, 20, 0.98);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 10px 20px 16px;
    gap: 4px;
    display: none;
  }
  .nav a { padding: 12px 10px; border-radius: 10px; }
  .nav a:hover { background: rgba(212, 175, 55, 0.10); }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav-toggle:checked ~ .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
}

.main { padding: 28px 0 64px; }
@media (max-width: 640px) { .main { padding: 18px 0 48px; } }

/* ========== Hero ========== */
.hero {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(135deg, rgba(26, 36, 52, 0.9), rgba(18, 26, 36, 0.92));
  box-shadow: var(--shadow);
  padding: clamp(18px, 3.5vw, 32px);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: -40% -20% auto auto;
  width: min(520px, 90vw); height: min(520px, 90vw);
  background: radial-gradient(circle at 30% 30%, rgba(212, 175, 55, 0.18), transparent 60%);
  pointer-events: none;
}
.hero h1 {
  font-family: "Cinzel", serif;
  margin: 0 0 10px;
  font-size: clamp(22px, 3.6vw, 38px);
  color: var(--gold2);
  letter-spacing: 0.04em;
}
.hero h2 {
  font-family: "Cinzel", serif;
  margin: 0 0 10px;
  color: var(--gold2);
  font-size: clamp(18px, 2.8vw, 26px);
}
.hero p { margin: 0 0 10px; color: var(--muted); max-width: 72ch; }

.alert {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  color: #ffd6d6;
  line-height: 1.55;
  font-size: clamp(13px, 1.6vw, 15px);
}

/* ========== Stats ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}
@media (max-width: 780px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.18);
  min-width: 0;
}
.stat b { display: block; font-size: clamp(18px, 2.4vw, 22px); color: var(--gold2); }
.stat span { color: var(--muted); font-size: 13px; }

/* ========== Section title ========== */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 34px 0 16px;
  flex-wrap: wrap;
}
.section-title h2 {
  margin: 0;
  font-family: "Cinzel", serif;
  color: var(--text);
  letter-spacing: 0.03em;
  font-size: clamp(20px, 2.6vw, 26px);
}
.muted { color: var(--muted); }

/* ========== Grid of cards ========== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 26, 36, 0.72);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: transform 0.15s ease, border-color 0.15s ease;
  color: inherit;
}
a.card { text-decoration: none !important; color: inherit; }
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(212, 175, 55, 0.45);
}
.card__media {
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 30% 30%, rgba(92, 225, 230, 0.18), transparent 55%),
    linear-gradient(135deg, rgba(26, 36, 52, 1), rgba(10, 14, 20, 1));
  border-bottom: 1px solid var(--line);
}
.card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card__title { margin: 0; font-size: 16px; line-height: 1.35; }
.price { color: var(--gold2); font-weight: 700; font-size: 18px; }
.stock { color: var(--muted); font-size: 13px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.45);
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.22), rgba(212, 175, 55, 0.08));
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none !important;
  font-family: inherit;
  font-size: 15px;
}
.btn:hover { filter: brightness(1.06); }
.btn--sm { padding: 8px 12px; font-size: 14px; }
.btn--ghost { background: transparent; border-color: rgba(154, 167, 184, 0.35); }
.btn--danger { border-color: rgba(255, 107, 107, 0.45); background: rgba(255, 107, 107, 0.12); }

/* ========== Forms ========== */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(154, 167, 184, 0.28);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
label { display: block; font-weight: 600; margin: 10px 0 6px; }
.form { max-width: 560px; }
.help { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ========== Table ========== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.table th { background: rgba(0, 0, 0, 0.22); color: var(--gold2); }

/* keep legacy .table without wrapper working */
.table:not(.table-wrap *) { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.pill--ok { border-color: rgba(105, 240, 174, 0.35); color: var(--ok); }
.pill--warn { border-color: rgba(244, 208, 63, 0.35); color: var(--gold2); }

/* ========== Footer ========== */
.footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  color: var(--muted);
  font-size: 14px;
}
.footer p { margin: 8px 0; }

.delivery-box {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(105, 240, 174, 0.25);
  background: rgba(105, 240, 174, 0.06);
  overflow-x: auto;
}

/* ========== Admin ========== */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-nav {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
  height: fit-content;
  position: sticky;
  top: 96px;
}
@media (max-width: 900px) { .admin-nav { position: static; } }
.admin-nav a { display: block; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.admin-nav a:hover { background: rgba(212, 175, 55, 0.10); text-decoration: none; }
