:root {
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --brand-light: #eaf1ff;
  --line: #dbe4f5;
  --bg: #f7f9ff;
  --text: #0f1b3d;
  --muted: #5b6b8c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand-dark);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.topbar h1 { margin: 0; font-size: 1.05rem; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  height: 40px;
  width: auto;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
}

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

.cart-btn {
  background: #fff;
  color: var(--brand-dark);
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
a.cart-btn { text-decoration: none; display: inline-block; }

.hero {
  background-color: var(--brand);
  /* Soft dotted pattern, shown until a banner photo is uploaded */
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  color: #fff;
  text-align: center;
  padding: 28px 16px;
}
.hero p { margin: 0; font-size: 1.1rem; }

/* With a banner photo from Admin > Settings */
.hero.has-photo {
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 230px;
  padding: 50px 16px;
}
.hero.has-photo p {
  font-size: 1.4rem;
  font-weight: 700;
  max-width: 560px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

/* Products */
main { max-width: 960px; margin: 0 auto; padding: 0 16px 40px; }
.narrow { max-width: 640px; padding-top: 16px; }

h2 {
  color: var(--brand-dark);
  border-bottom: 2px solid var(--brand);
  padding-bottom: 6px;
  margin-top: 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.unit { margin: 0 0 10px; color: var(--muted); font-size: 0.85rem; }
.price { margin: 0 0 10px; font-weight: 700; color: var(--brand); font-size: 1.1rem; }
.card button { margin-top: auto; }

.card.clickable {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.card.clickable:hover,
.card.clickable:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.18);
  outline: none;
}
.card.clickable:active { transform: scale(0.98); }
.tap-hint {
  margin: auto 0 0;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.85rem;
}

.photo {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
  display: block;
}
.photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 2.2rem;
  font-weight: 700;
}

.card.soldout { opacity: 0.55; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  background: #e5e7eb;
  border-radius: 999px;
  font-size: 0.85rem;
  margin: 0 0 10px;
}

/* Buttons */
button { font-family: inherit; }

.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.primary:disabled { background: #b6bfd3; cursor: not-allowed; }

.add-btn { padding: 9px; font-size: 0.95rem; }

.close-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
}

/* Search and category buttons */
.toolbar { margin: 18px 0 10px; }
#search {
  width: 100%;
  padding: 12px;
  border: 1px solid #c3cde4;
  border-radius: 999px;
  font-size: 1rem;
  font-family: inherit;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.chip {
  padding: 8px 14px;
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { background: var(--brand); color: #fff; }

/* Cart panel */
.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 380px;
  height: 100%;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.25);
  padding: 16px;
  z-index: 20;
  overflow-y: auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-head h2 { margin: 0; border: none; }

.cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #eef1f8;
}
.cart-row .name { font-weight: 600; }
.cart-row .sub { font-size: 0.85rem; color: var(--muted); }

.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  font-size: 1.1rem;
  cursor: pointer;
}

.total { font-size: 1.1rem; margin: 16px 0; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
}

/* Product popup */
.product-box { position: relative; max-width: 380px; }
.product-box .photo { height: 200px; border-radius: 10px; margin-bottom: 12px; }
.product-box .photo.placeholder { font-size: 3.5rem; }
.product-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font-size: 1.1rem;
  line-height: 1;
}
.product-name { margin: 0 0 4px; font-size: 1.3rem; }
.product-box .price { margin: 0 0 6px; }

.qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 14px 0 4px;
}
.qty-row button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  font-size: 1.4rem;
  cursor: pointer;
}
.qty-row span {
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 80px;
  text-align: center;
}

/* "Added to cart" message */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: 90%;
  padding: 12px 20px;
  border-radius: 999px;
  background: #15803d;
  color: #fff;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

/* Forms */
form label { display: block; margin: 12px 0; font-weight: 600; }
form input[type="text"],
form input[type="email"],
form input[type="tel"],
form input[type="password"],
form input[type="number"],
form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid #c3cde4;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.label-text { margin: 14px 0 4px; font-weight: 600; }
form label.radio { font-weight: 400; margin: 6px 0; }

.summary {
  background: var(--brand-light);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 16px 0;
}
.summary p { margin: 6px 0; display: flex; justify-content: space-between; }
.summary .grand { font-weight: 700; font-size: 1.1rem; }

.error-text { color: #b91c1c; margin: 6px 0; }
.ok-text { color: #15803d; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.9rem; }

/* Order tracking */
.steps { list-style: none; padding: 0; margin: 16px 0; }
.steps li {
  padding: 10px 12px 10px 38px;
  position: relative;
  color: #9aa5bf;
}
.steps li::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 12px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #c3cde4;
  background: #fff;
}
.steps li.done { color: var(--text); }
.steps li.done::before { background: #16a34a; border-color: #16a34a; }
.steps li.current { font-weight: 700; color: var(--brand); }
.steps li.current::before { background: var(--brand); border-color: var(--brand); }

.order-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 14px 0;
}
.order-box p { margin: 4px 0; }
.cancelled { color: #b91c1c; font-weight: 700; }

/* Admin */
.tabs { display: flex; gap: 8px; margin: 16px 0; }
.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.tab.active { background: var(--brand); color: #fff; }

.admin-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.admin-row .row-top { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; }
.admin-row input[type="text"],
.admin-row input[type="number"] {
  padding: 8px;
  border: 1px solid #c3cde4;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  margin: 0;
}
.admin-row .row-top input[type="text"] { flex: 1; font-weight: 600; }
.admin-row input.small { width: 110px; }
.admin-row .cat { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.admin-row label.check { margin: 0; font-weight: 400; display: flex; align-items: center; gap: 6px; }

.photo-box { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

.upload-btn {
  display: inline-block;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.logo-preview {
  display: block;
  max-height: 80px;
  max-width: 220px;
  margin: 10px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #c3cde4;
  font-size: 1rem;
  font-family: inherit;
  margin-top: 6px;
}

.danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #b91c1c;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}
.small-btn { padding: 8px 12px; }

/* Footer */
.shop-footer {
  background: var(--brand-dark);
  color: #fff;
  text-align: center;
  padding: 24px 16px;
  margin-top: 30px;
}
.shop-footer p { margin: 6px 0; }
.foot-name { font-weight: 700; font-size: 1.05rem; }
.wa-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 18px;
  background: #16a34a;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 700;
}

/* Phones */
@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 10px;
  }
  .topbar > h1 { flex: 1 1 100%; }
  .brand { flex: 1 1 100%; }
  .brand h1 { font-size: 1rem; line-height: 1.25; }
  .logo { height: 44px; flex-shrink: 0; }

  .top-actions { flex: 1 1 100%; gap: 6px; }
  .top-actions .cart-btn {
    flex: 1 1 0;
    padding: 9px 6px;
    font-size: 0.85rem;
    text-align: center;
  }

  .hero { padding: 20px 16px; }
  .hero p { font-size: 1rem; }
  .hero.has-photo { min-height: 190px; padding: 36px 16px; }
  .hero.has-photo p { font-size: 1.2rem; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .photo { height: 110px; }
}