:root {
  --bg: #f7f7f5; --surface: #fff; --ink: #1c1d1f; --muted: #666a70; --line: #e3e3df;
  --accent: #0f766e; --accent-ink: #fff; --accent-soft: #e3f2f0; --danger: #b42318; --ok: #1a7f4b; --warn-bg: #fff4d6; --warn-ink: #6b4a00;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315; --surface: #1b1c1f; --ink: #ecedee; --muted: #9a9ea5; --line: #2c2e33;
    --accent: #2dd4bf; --accent-ink: #06201d; --accent-soft: #13302d; --danger: #ff8a7a; --ok: #5fd39a; --warn-bg: #3a2f10; --warn-ink: #ffd98a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; text-decoration: none; color: inherit; }
.logo { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: var(--accent-soft); flex: none; }
.logo-mark { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none; }
.brand b { display: block; font-size: 17px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons & fields */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 8px; font-size: 12px; font-weight: 700; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=tel], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.f { display: block; font-size: 13px; font-weight: 600; margin: 0 0 12px; }
label.f > span { display: block; margin-bottom: 4px; }
label.f small { font-weight: 400; color: var(--muted); display: block; margin-top: 4px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* toolbar */
.tools { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 0 8px; }
.tools .grow { flex: 1 1 220px; }
.tools select { width: auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: thin; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 14px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* product grid */
h2.cat { font-size: 18px; margin: 22px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card .ph { aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.card .ph img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.card .ph .none { color: #bbb; font-size: 13px; }
.card .bd { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card h3 { font-size: 15px; margin: 0; line-height: 1.3; }
.card .meta { color: var(--muted); font-size: 13px; }
.price { font-size: 18px; font-weight: 700; margin-top: 4px; }
.price s { color: var(--muted); font-weight: 400; font-size: 14px; margin-right: 6px; }
.price .off { color: var(--ok); font-size: 12px; font-weight: 600; margin-left: 6px; }
.buy { display: flex; gap: 8px; margin-top: auto; padding-top: 10px; }
.buy input { width: 72px; text-align: center; }
.buy .btn { flex: 1; justify-content: center; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* enquiry list drawer */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form, dialog .dlg { padding: 18px; max-height: calc(100vh - 40px); overflow: auto; }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.lines { list-style: none; padding: 0; margin: 0 0 12px; }
.lines li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lines .q { display: flex; gap: 6px; align-items: center; }
.lines .q input { width: 64px; text-align: center; padding: 4px 6px; }
.sum { width: 100%; border-collapse: collapse; margin: 6px 0; }
.sum td { padding: 4px 0; }
.sum td:last-child { text-align: right; }
.sum tr.tot td { font-weight: 700; font-size: 17px; border-top: 1px solid var(--line); padding-top: 8px; }
.sum .g { color: var(--ok); }
.foot { color: var(--muted); font-size: 13px; padding: 28px 0 40px; }

/* admin */
.login { max-width: 380px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
.login h1 { font-size: 20px; margin: 0 0 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab[aria-selected=true] { color: var(--accent); border-color: var(--accent); }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; margin: 14px 0 0; font-size: 14px; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 8px 0 0; }
.msg { color: var(--ok); font-size: 14px; }
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th, .t td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.t tr:last-child td { border-bottom: 0; }
.t td.n { text-align: right; white-space: nowrap; }
.t .th img, .t .th .none { width: 44px; height: 36px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--line); }
.t .off td { opacity: .55; }
.t code { background: var(--accent-soft); padding: 1px 6px; border-radius: 5px; font-size: 13px; word-break: break-word; }
.t .acts { white-space: nowrap; text-align: right; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; max-width: 640px; }
.panel h2 { margin: 0 0 12px; font-size: 17px; }
.upl { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.upl img, .upl .logo-mark { width: 96px; height: 80px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.upl .logo-mark { background: var(--accent); }
.hint { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.hint code { background: var(--surface); padding: 0 5px; border-radius: 4px; }
.try { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; margin: -4px 0 12px; }
.try input { width: 90px; padding: 4px 8px; }
.try output { font-weight: 700; color: var(--ok); }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .bd { padding: 10px; }
  .price { font-size: 16px; }
  .buy { flex-direction: column; }
  .buy input { width: 100%; }
}
@media print { .top .btn, .tools, .chips, .buy { display: none; } }
