/* Theme */
:root { --bg: #f3f3f3; --fg: #111; --muted:#565959; --line:#e6e6e6; --accent:#ffa41c; --header:#131921; --headerText:#fff; --badge:#232f3e; }
:root[data-theme="dark"] { --bg:#0f1111; --fg:#e3e6e6; --muted:#aab7b8; --line:#232f3e; --accent:#ffa41c; --header:#131921; --headerText:#fff; --badge:#232f3e; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Header - Amazon-like */
.app-header {
  display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 12px;
  align-items: center; padding: 10px 16px;
  background: var(--header); color: var(--headerText); border-bottom: none;
}
.logo img { height: 32px; display: block; filter: brightness(1) invert(0); }
.search {
  width: 100%; max-width: none; padding: 10px 12px; border: none; border-radius: 6px 0 0 6px;
}
#category {
  border: none; border-radius: 6px 0 0 6px; padding: 10px; background: #e6e6e6; color: #111;
}
.app-header .search { border-radius: 6px; }
.app-header .btn {
  background: var(--accent); color: #111; border: 1px solid #e79700; border-radius: 6px; padding: 8px 12px;
}
#theme {
  background:#232f3e; color:#fff; border: 1px solid #2e4053; border-radius:6px; padding: 8px 10px;
}

/* Footer */
.app-footer {
  display: flex; align-items: center; justify-content: center;
  padding: 16px 20px; border-top: 1px solid var(--line); border-bottom: none; background:#fafafa;
}

/* Main layout */
.app-main { max-width: 1200px; margin: 16px auto; padding: 0 16px; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--fg);
  padding: 10px 16px; border-radius: 8px; cursor: pointer; font-weight: 600;
  transition: transform .05s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.btn:hover { background: #f7f7f7; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #111; border-color: #e79700; }
.btn.subtle { background: #fff; color: var(--fg); }
.btn.restock-btn { background:#ffd814; color:#111; border:1px solid #f0c14b; }

/* Badges and feedback */
.feedback { min-height: 28px; text-align: center; color: var(--muted); }
.feedback.positive { color: #0a7f36; }
.feedback.negative { color: #b00020; }
.badge { border: 1px solid var(--line); padding: 4px 8px; border-radius: 999px; font-size: 12px; background:#fff; }

/* Product grid and cards */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.product-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); background:#fff; }
.product-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-1px); }
.product-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 8px; background: #fafafa; padding: 8px; }
.product-title { font-size: 14px; font-weight: 700; margin: 0; line-height: 1.3; min-height: 36px; }
.product-sub { color: var(--muted); font-size: 12px; }
.product-price { font-size: 18px; font-weight: 800; color:#b12704; }
.product-row { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.product-row span { border: 1px solid var(--line); padding: 2px 6px; border-radius: 999px; background:#f8f9fa; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background:#fff; }
dialog::backdrop { background: rgba(0,0,0,.2); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dialog-body { display: grid; gap: 16px; max-width: 720px; }

/* Product detail */
.product-detail { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
.product-detail img { width: 100%; max-width: 240px; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background:#fafafa; margin: 0 auto; padding: 8px; }
.pd-info { display: grid; gap: 8px; }
.section-title { margin: 0 0 6px; font-size: 14px; color: var(--muted); }

/* Forms */
.form-grid { display: grid; gap: 8px; }
.form-grid input[type="text"], .form-grid input:not([type]) , .form-grid input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background:#fff; }
.form-grid label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background:#fff; }
.form-grid .row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Cart and inventory */
.cart-list { display: grid; gap: 8px; }
.cart-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background:#fff; }
.cart-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background:#fafafa; }
.cart-item .ci-title { font-size: 13px; font-weight: 700; }
.cart-item .ci-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }
.cart-item .ci-price { font-weight: 700; }
.cart-item .ci-actions { display: flex; gap: 6px; align-items: center; }
.cart-qty { display: inline-flex; align-items: center; gap: 6px; }
.cart-qty button { padding: 4px 8px; }

/* Summary */
.summary { display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background:#fff; }
.summary-row { display: flex; justify-content: space-between; }
.summary-row.total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.note { color: var(--muted); font-size: 12px; }

/* Reviews */
.reviews { display: grid; gap: 8px; margin-top: 8px; }
.reviews .cart-list .cart-item { grid-template-columns: 1fr auto; }
.reviews .star { color: #d4aa00; font-weight: 700; margin-right: 6px; }

/* Responsive */
@media (max-width: 640px) {
  .app-header { grid-template-columns: 1fr auto auto; gap: 8px; }
  .product-detail { grid-template-columns: 1fr; }
  .form-grid .row { grid-template-columns: 1fr; }
}