:root {
  --green: #03ac0e;
  --green-dark: #008a0e;
  --green-soft: #eaf8ec;
  --orange: #f59e0b;
  --red: #ef4444;
  --ink: #1f2937;
  --muted: #6b7280;
  --soft: #f6f7f9;
  --line: #e5e7eb;
  --surface: #ffffff;
  --dark: #111827;
  --shadow-sm: 0 2px 8px rgba(17, 24, 39, .05);
  --shadow-md: 0 14px 32px rgba(17, 24, 39, .09);
  --radius: 12px;
  --container: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--soft);
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.container { width: min(var(--container), calc(100% - 32px)); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo, .store-avatar {
  flex: none;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  letter-spacing: -.08em;
  box-shadow: 0 8px 20px rgba(3,172,14,.18);
}
.brand-logo { width: 42px; height: 42px; border-radius: 11px; }
.store-avatar { width: 70px; height: 70px; border-radius: 18px; font-size: 24px; }
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav-actions { display: flex; align-items: center; gap: 8px; color: #374151; font-weight: 800; font-size: 14px; }
.nav-actions a:not(.wa-button):not(.outline-top) { padding: 9px 10px; border-radius: 999px; }
.nav-actions a:not(.wa-button):not(.outline-top):hover { background: #f3f4f6; }

.wa-button, .primary-button, .outline-button, .outline-top, .market-button, .outline-dark {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 9px;
  padding: 9px 13px;
  font-weight: 900;
  font-size: 13px;
  border: 1px solid transparent;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
  text-align: center;
}
.wa-button, .primary-button { background: var(--green); color: #fff; border-color: var(--green); }
.wa-button:hover, .primary-button:hover { background: var(--green-dark); border-color: var(--green-dark); box-shadow: 0 8px 18px rgba(3,172,14,.18); transform: translateY(-1px); }
.outline-button, .outline-top { background: #fff; color: var(--green-dark); border-color: #bfe8c5; }
.outline-button:hover, .outline-top:hover { background: var(--green-soft); border-color: var(--green); }
.market-button { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.market-button:hover { background: #ffedd5; border-color: #fb923c; transform: translateY(-1px); }
.market-button.big { min-width: 130px; }
.outline-dark { background: transparent; color: #fff; border-color: rgba(255,255,255,.24); }
.outline-dark:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.45); }

.market-head { padding: 18px 0 10px; }
.market-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}
.market-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.verified-line { display: grid; gap: 3px; }
.verified-line span, .section-label {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.verified-line strong { font-size: clamp(22px, 3vw, 34px); line-height: 1.1; letter-spacing: -.04em; color: #111827; }
.market-left p { margin: 6px 0 0; color: #4b5563; max-width: 680px; font-size: 15px; }
.store-stats { display: grid; grid-template-columns: repeat(5, minmax(74px, 1fr)); gap: 8px; }
.store-stats div {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
  padding: 11px;
  display: grid;
  align-content: center;
}
.store-stats strong { font-size: 23px; line-height: 1; color: var(--green-dark); }
.store-stats span { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }

.catalog-section { padding: 12px 0 24px; }
.catalog-title-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 8px 0 12px; }
.catalog-title-row h1, .order-card h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.1; letter-spacing: -.035em; color: #111827; }
.sync-status { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.sync-status.success { color: var(--green-dark); border-color: #b9e7c0; background: #f3fbf4; }
.sync-status.warning { color: #92400e; border-color: #fed7aa; background: #fff7ed; }

.toolbar {
  position: sticky;
  top: 69px;
  z-index: 60;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 160px 170px;
  gap: 10px;
  padding: 10px;
  background: rgba(246,247,249,.94);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(14px);
}
.search-box { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 13px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.toolbar select { height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #374151; padding: 0 11px; outline: 0; font-weight: 800; }
.search-box:focus-within, .toolbar select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(3,172,14,.08); }
.active-filters { min-height: 38px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 7px 0; }
.filter-pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 900; }

.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.product-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.product-card:hover { transform: translateY(-2px); border-color: #c9d1db; box-shadow: var(--shadow-md); }
.product-image-wrap { position: relative; aspect-ratio: 1 / 1; background: #f3f4f6; display: grid; place-items: center; overflow: hidden; }
.product-image-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-image-wrap.image-missing::after { content: 'Foto produk'; width: 82px; height: 82px; border-radius: 18px; display: grid; place-items: center; background: #fff; color: var(--muted); border: 1px dashed #cbd5e1; font-size: 12px; font-weight: 900; }
.image-placeholder { width: 100%; height: 100%; display: grid; place-items: center; align-content: center; gap: 5px; background: linear-gradient(135deg, #f9fafb, #eef2f7); color: #64748b; }
.image-placeholder strong { font-size: 36px; letter-spacing: -.08em; }
.image-placeholder span { font-size: 12px; font-weight: 900; }
.badge-row { position: absolute; top: 9px; left: 9px; right: 9px; z-index: 2; display: flex; flex-wrap: wrap; gap: 5px; }
.badge { border-radius: 999px; padding: 5px 8px; background: rgba(255,255,255,.97); border: 1px solid rgba(229,231,235,.95); box-shadow: 0 3px 10px rgba(17,24,39,.06); font-size: 10.5px; line-height: 1; font-weight: 900; }
.badge.best { color: #b91c1c; }
.badge.ready { color: var(--green-dark); }
.badge.po { color: #92400e; }
.badge.neutral { color: #475569; }
.product-info { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 7px; }
.product-meta { display: flex; justify-content: space-between; gap: 10px; color: #64748b; font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .045em; }
.product-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-info h3 { margin: 0; color: #111827; font-size: 14px; line-height: 1.35; font-weight: 900; overflow-wrap: anywhere; }
.product-info p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.48; overflow-wrap: anywhere; }
.price-block { display: grid; gap: 1px; margin-top: auto; padding-top: 4px; }
.price-block span, .compare-line span { color: var(--muted); font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .045em; }
.price-block strong { color: #111827; font-size: 20px; line-height: 1.15; letter-spacing: -.03em; }
.compare-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 7px; min-width: 0; }
.compare-line strong { color: #374151; font-size: 12px; white-space: nowrap; }
.saving-line { width: fit-content; max-width: 100%; border-radius: 999px; padding: 5px 8px; background: var(--green-soft); color: var(--green-dark); font-size: 11.5px; font-weight: 900; overflow-wrap: anywhere; }
.saving-line.large { font-size: 13px; padding: 7px 10px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 3px; }
.card-actions.with-market { grid-template-columns: 1fr 1fr; }
.card-actions .group-button { grid-column: 1 / -1; background: #f0fdf4; }
.card-actions.with-market .group-button, .card-actions.with-market .market-button { grid-column: auto; }
.card-actions .primary-button, .card-actions .outline-button, .card-actions .market-button { width: 100%; min-height: 36px; padding: 8px 9px; font-size: 12.5px; }

.empty-state { text-align: center; padding: 48px 20px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.empty-state h3 { margin: 0 0 6px; }
.empty-state p { margin: 0 0 16px; color: var(--muted); }

.order-section { padding: 10px 0 34px; }
.order-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--dark); color: #fff; border-radius: 16px; padding: 22px; }
.order-card p { margin: 8px 0 0; color: #cbd5e1; max-width: 720px; }
.order-card .section-label.dark { background: rgba(255,255,255,.1); color: #bbf7d0; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.footer { border-top: 1px solid var(--line); background: #fff; }
.footer-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 13px; font-weight: 800; }
.footer-links { display: flex; align-items: center; gap: 14px; }
.footer a { color: var(--green-dark); }

.product-dialog { width: min(930px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 18px; overflow: visible; box-shadow: 0 24px 80px rgba(0,0,0,.24); }
.product-dialog::backdrop { background: rgba(15, 23, 42, .56); }
.dialog-close { position: absolute; top: 10px; right: 10px; z-index: 4; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.96); color: #111827; font-size: 24px; line-height: 1; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.dialog-layout { display: grid; grid-template-columns: 385px 1fr; min-height: 450px; background: #fff; border-radius: 18px; overflow: hidden; }
.dialog-image { aspect-ratio: auto; min-height: 450px; background: #f3f4f6; }
.dialog-info { padding: 28px; display: grid; align-content: start; gap: 12px; }
.dialog-info h2 { margin: 0; font-size: 28px; line-height: 1.16; letter-spacing: -.03em; color: #111827; }
.dialog-info p { margin: 0; color: #4b5563; }
.dialog-price-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 3px; }
.dialog-price-grid div { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: #fbfbfc; display: grid; gap: 4px; }
.dialog-price-grid span, .detail-list span { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .045em; }
.dialog-price-grid strong { font-size: 20px; }
.detail-list { display: grid; gap: 8px; margin-top: 3px; }
.detail-list div { display: grid; gap: 2px; border-top: 1px solid #eef0f2; padding-top: 8px; }
.detail-list strong { font-size: 14px; color: #111827; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 110; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; background: #111827; color: #fff; border-radius: 999px; padding: 12px 16px; box-shadow: 0 14px 36px rgba(0,0,0,.18); font-size: 14px; font-weight: 900; transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.admin-page { min-height: 100vh; background: var(--soft); }
.admin-shell { padding: 24px 0 42px; }
.admin-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 18px; }
.admin-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.admin-head h1 { margin: 0 0 6px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.035em; }
.admin-head p { margin: 0; color: var(--muted); }
.login-box { width: min(460px, calc(100% - 32px)); margin: 80px auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); padding: 22px; }
.login-box h1 { margin: 0 0 8px; }
.login-box p { margin: 0 0 16px; color: var(--muted); }
.login-box input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: grid; gap: 5px; }
.form-field label { font-size: 12px; font-weight: 900; color: #374151; text-transform: uppercase; letter-spacing: .045em; }
.form-field input, .form-field select, .form-field textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; outline: 0; background: #fff; }
.form-field textarea { min-height: 92px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(3,172,14,.08); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.admin-tab { border: 1px solid var(--line); background: #fff; color: #374151; border-radius: 999px; padding: 8px 12px; font-weight: 900; }
.admin-tab.active { color: var(--green-dark); border-color: #bfe8c5; background: var(--green-soft); }
.admin-panel[hidden] { display: none; }
.admin-list { display: grid; gap: 9px; margin-top: 14px; }
.admin-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fafafa; }
.admin-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: #eee; }
.admin-item strong { display: block; }
.admin-item span { color: var(--muted); font-size: 12px; font-weight: 800; }
.admin-item-actions { display: flex; gap: 6px; }
.note-box { border: 1px solid #fed7aa; background: #fff7ed; color: #7c2d12; border-radius: 12px; padding: 12px; font-size: 13px; font-weight: 700; margin-bottom: 12px; }

@media (max-width: 1100px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .market-card { grid-template-columns: 1fr; }
  .store-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
  .dialog-layout { grid-template-columns: 330px 1fr; }
}
@media (max-width: 760px) {
  .container { width: min(100% - 22px, var(--container)); }
  .topbar-inner { min-height: 64px; }
  .brand-logo { width: 40px; height: 40px; }
  .brand-text strong { font-size: 14px; }
  .brand-text small { display: none; }
  .nav-actions a:not(.wa-button):not(.outline-top) { display: none; }
  .outline-top { display: none; }
  .wa-button { min-height: 36px; padding: 8px 11px; font-size: 12.5px; }
  .market-head { padding-top: 12px; }
  .market-card { padding: 14px; }
  .market-left { align-items: flex-start; }
  .store-avatar { width: 54px; height: 54px; border-radius: 14px; font-size: 18px; }
  .market-left p { font-size: 13.5px; }
  .store-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .store-stats div { min-height: 58px; padding: 7px 5px; text-align: center; }
  .store-stats strong { font-size: 18px; }
  .store-stats span { font-size: 9px; }
  .catalog-title-row { align-items: start; flex-direction: column; gap: 7px; }
  .sync-status { white-space: normal; }
  .toolbar { grid-template-columns: 1fr; top: 65px; padding: 9px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-info { padding: 10px; gap: 6px; }
  .product-meta { font-size: 9.5px; }
  .product-info h3 { font-size: 13px; line-height: 1.32; }
  .product-info p { font-size: 11.5px; }
  .price-block strong { font-size: 17px; }
  .compare-line { align-items: flex-start; flex-direction: column; gap: 2px; }
  .card-actions, .card-actions.with-market { grid-template-columns: 1fr; }
  .card-actions.with-market .market-button { grid-column: auto; }
  .order-card { align-items: flex-start; flex-direction: column; padding: 18px; }
  .footer-inner { min-height: 70px; align-items: flex-start; flex-direction: column; justify-content: center; }
  .dialog-layout { grid-template-columns: 1fr; }
  .dialog-image { min-height: auto; aspect-ratio: 1 / 1; }
  .dialog-info { padding: 20px; }
  .dialog-info h2 { font-size: 22px; }
  .dialog-price-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-item { grid-template-columns: 44px 1fr; }
  .admin-item img { width: 44px; height: 44px; }
  .admin-item-actions { grid-column: 1 / -1; }
}
@media (max-width: 390px) {
  .product-grid { grid-template-columns: 1fr; }
  .store-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* v4 refinements */
.price-block {
  border-top: 1px solid #eef0f2;
  padding-top: 9px;
}
.price-block strong {
  overflow-wrap: anywhere;
  white-space: normal;
}
.single-price-box {
  border: 1px solid #bfe8c5;
  border-radius: 12px;
  padding: 14px;
  background: var(--green-soft);
  display: grid;
  gap: 4px;
}
.single-price-box span {
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .045em;
}
.single-price-box strong {
  color: #111827;
  font-size: 24px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.storage-status {
  border: 1px solid var(--line);
  background: #fff;
  color: #374151;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 12px;
}
.storage-status.success { color: var(--green-dark); border-color: #bfe8c5; background: var(--green-soft); }
.storage-status.warning { color: #92400e; border-color: #fed7aa; background: #fff7ed; }
.admin-small { display: block; color: var(--green-dark); font-size: 11px; font-weight: 900; margin-top: 3px; }
.admin-small.muted { color: var(--muted); }
.admin-item-actions .market-button { color: #b91c1c; background: #fff5f5; border-color: #fecaca; }
.admin-item-actions .market-button:hover { background: #fee2e2; border-color: #fca5a5; }
.form-field code, .note-box code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 900; }

/* v5 admin upload + anti-duplicate refinements */
.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
}
.image-admin-preview {
  min-height: 170px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.image-admin-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
  background: #fff;
}
.product-info h3,
.product-info p {
  overflow: visible;
  display: block;
}
.product-card {
  min-height: 100%;
}

.compact-note {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}
