:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e4e4df;
  --brand: #1f4fd8;
  --brand-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.logo { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav { display: flex; gap: 18px; align-items: center; font-size: .95rem; }
.nav a { color: var(--text); }
.cart-link { display: inline-flex; align-items: center; gap: 6px; }
.badge { background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: .75rem; padding: 1px 8px; font-weight: 600; }

main.wrap { padding-top: 28px; padding-bottom: 60px; }
h1 { font-size: 1.6rem; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 22px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 10px 18px; border-radius: 8px; font-size: .95rem; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field { margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* catalog */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: .9rem; color: var(--text); }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card img { aspect-ratio: 4/3; object-fit: cover; width: 100%; background: #eee; }
.card .body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .cat { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card h3 { margin: 0; font-size: 1.02rem; }
.card p { margin: 0; color: var(--muted); font-size: .88rem; flex: 1; }
.card .buy { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.price { font-weight: 700; font-size: 1.05rem; }
.oos { color: var(--err); font-size: .85rem; font-weight: 600; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.layout-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
.lines { width: 100%; border-collapse: collapse; }
.lines td, .lines th { padding: 10px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.lines th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lines .num { text-align: right; white-space: nowrap; }
.thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; }
.qty button { border: 0; background: none; width: 30px; height: 30px; cursor: pointer; font-size: 1rem; color: var(--text); }
.qty span { min-width: 24px; text-align: center; }
.totals { display: grid; gap: 6px; margin: 12px 0 18px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--border); padding-top: 8px; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.notice { padding: 12px 14px; border-radius: 8px; font-size: .9rem; margin-bottom: 16px; }
.notice.info { background: #eef3ff; color: #1e3a8a; }
.notice.err { background: #fdecec; color: var(--err); }
.notice.ok { background: #e8f6ee; color: var(--ok); }

/* tracking timeline */
.timeline { list-style: none; padding: 0; margin: 16px 0 0; }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); }
.timeline li.done .dot { background: var(--ok); border-color: var(--ok); }
.timeline li.current .dot { background: var(--brand); border-color: var(--brand); }
.timeline .t { font-weight: 600; }
.timeline .when { font-size: .82rem; color: var(--muted); }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef3ff; color: #1e3a8a; }
.status-pill.delivered { background: #e8f6ee; color: var(--ok); }
.status-pill.cancelled, .status-pill.payment_failed { background: #fdecec; color: var(--err); }
.status-pill.pending_payment { background: #fff4e0; color: var(--warn); }

/* demo payment modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 24px; max-width: 380px; width: 100%; }
.modal h3 { margin-top: 0; }
.modal .actions { display: grid; gap: 10px; margin-top: 18px; }

/* admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.admin-table select, .admin-table input { padding: 6px 8px; font-size: .85rem; }
.table-scroll { overflow-x: auto; }

footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: .85rem; }

@media (max-width: 760px) {
  .layout-2 { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .nav { gap: 12px; font-size: .88rem; }
  .hide-sm { display: none; }
}
