:root {
  --red: #4c9c2e;   /* Smart Environmental green (PMS 362) - variable name kept from the Landquip template */
  --red-dark: #3a7a23;
  --ink: #1b1b1f;
  --ink-2: #4a4a52;
  --muted: #6f6f78;
  --line: #e4e4e8;
  --bg: #f4f4f6;
  --card: #ffffff;
  --ok: #1a8f4c;
  --warn: #b7791f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(20,20,30,.06);
  --shadow-lg: 0 20px 60px rgba(20,20,30,.22);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 24px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0 0 12px; }
a { color: inherit; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.fineprint { font-size: 12px; color: #a0a0a8; margin-top: 28px; text-align: center; }
[hidden] { display: none !important; }

/* ---- Inputs & buttons ---- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=search], input:not([type]), textarea, select {
  width: 100%; font: inherit; padding: 11px 13px; border: 1px solid #cfcfd6; border-radius: 9px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(76,156,46,.18); }
textarea { resize: vertical; }
.code-input { font-size: 28px; letter-spacing: 10px; text-align: center; font-weight: 700; }
.btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 9px; padding: 11px 18px; cursor: pointer; background: #fff; color: var(--ink); transition: background .15s, transform .05s, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.btn-ghost { background: transparent; border-color: #cfcfd6; }
.btn-ghost:hover { background: #fff; }
.btn-link { background: none; color: var(--muted); padding: 8px; text-decoration: underline; font-weight: 500; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.icon-btn { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.stack > * + * { margin-top: 14px; }
.msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 14px; background: #fdecec; color: #9b1c1c; }
.msg.ok { background: #e6f6ec; color: #16693a; }
.msg.warn { background: #fff5dd; color: #7a5200; }

/* ---- Login ---- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(76,156,46,.14), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 18px; padding: 36px 34px 26px; box-shadow: var(--shadow-lg); }
.login-logo { width: 220px; display: block; margin: 0 0 22px; }
.login-card h1 { margin-bottom: 6px; }
.login-card .muted { margin-bottom: 22px; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 700; color: var(--ink-2); font-size: 14px; }
.brand img { height: 26px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab { text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.active { color: var(--red); background: rgba(76,156,46,.10); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.cart-btn { display: flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; font-size: 14px; background: var(--ink); color: #fff; border: 0; border-radius: 9px; padding: 9px 14px; cursor: pointer; }
.cart-btn:hover { background: #000; }
.badge { background: var(--red); color: #fff; font-size: 12px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: inline-grid; place-items: center; padding: 0 6px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-email { font-size: 13px; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Page ---- */
.page { max-width: 1280px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .muted { margin: 6px 0 0; max-width: 560px; }
.filters { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.filters .tf-toggle { align-self: flex-end; }
.filters input { width: 280px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid #d5d5dc; background: #fff; color: var(--ink-2); cursor: pointer; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- Time frame toggle ---- */
.tf-toggle { display: inline-flex; border: 1px solid #cfcfd6; border-radius: 9px; overflow: hidden; background: #fff; }
.tf { font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border: 0; background: #fff; color: var(--ink-2); cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.tf small { font-weight: 500; font-size: 11px; color: var(--muted); }
.tf.active { background: var(--ink); color: #fff; }
.tf.active small { color: #ccc; }
.tf[data-tf=rush].active { background: var(--red); }
.cart-tf { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.cart-tf .tf-toggle { transform: scale(.92); transform-origin: right center; }
.price-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price-hint { font-size: 12px; color: var(--muted); }
.price-hint.break { color: #7a5200; }

/* ---- Product grid ---- */
.card-img.no-img { cursor: default; background: linear-gradient(135deg, #ececef, #dcdcdf); }
.img-placeholder { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 4px; color: #8a8a92; font-weight: 700; letter-spacing: .08em; }
.img-placeholder small { font-weight: 500; letter-spacing: 0; font-size: 12px; }
.img-mini { width: 72px; height: 48px; border-radius: 6px; background: #e4e4e8; }
.review-row .img-mini { width: 64px; height: 42px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; border: 1px solid transparent; transition: border-color .15s, box-shadow .15s; }
.card.in-cart { border-color: var(--red); }
.card-img { position: relative; aspect-ratio: 16 / 10; background: #fff; border-bottom: 1px solid var(--line); cursor: zoom-in; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .25s; }
.card:hover .card-img img { transform: scale(1.03); }
.card-img .sku { position: absolute; top: 10px; left: 10px; background: rgba(27,27,31,.85); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 4px 8px; border-radius: 6px; }
.card-img .zoom { position: absolute; right: 10px; bottom: 10px; background: rgba(255,255,255,.9); border-radius: 6px; font-size: 11px; font-weight: 600; padding: 4px 8px; color: var(--ink-2); }
.card-body { padding: 12px 14px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.min-hint { font-size: 12px; color: var(--muted); }
.btn-danger { color: var(--red); border-color: #f0c2c5; }
.btn-danger:hover { background: var(--accent-soft, #fdecec); }
.card-title { font-weight: 700; font-size: 15px; }
.card-desc { font-size: 12.5px; color: var(--muted); flex: 1; }
.card-price { font-weight: 700; font-size: 15px; }
.card-price small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.card-price.poa { color: var(--muted); font-weight: 500; font-size: 13px; }
.card-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.card-foot select { flex: 1; padding: 9px 10px; font-size: 14px; }
.qty { display: inline-flex; align-items: stretch; border: 1px solid #cfcfd6; border-radius: 9px; overflow: hidden; background: #fff; }
.qty button { font: inherit; font-size: 18px; width: 30px; border: 0; background: #fff; cursor: pointer; color: var(--ink-2); }
.qty button:hover { background: var(--bg); }
.qty input { width: 46px; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; padding: 8px 4px; font-weight: 700; }
.qty input:focus { box-shadow: none; }
.btn-add { margin-left: auto; white-space: nowrap; padding: 10px 12px; font-size: 14px; }
.btn-add.added { background: var(--ok); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 0; }

/* ---- Drawer ---- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20,20,30,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: #fff; z-index: 41; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow: auto; padding: 8px 20px; }
.drawer-foot { padding: 16px 20px 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.cart-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; }
.cart-total .muted { font-weight: 500; font-size: 13px; }
.cart-line { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-line img { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.cart-line .name { font-weight: 600; font-size: 14px; }
.cart-line .sub { font-size: 12px; color: var(--muted); }
.cart-line .qty input { width: 44px; }
.cart-line .remove { background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 4px 0; }
.cart-empty { text-align: center; color: var(--muted); padding: 50px 10px; }

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; background: rgba(20,20,30,.5); z-index: 50; display: grid; place-items: center; padding: 20px; overflow: auto; }
.modal-card { background: #fff; border-radius: 16px; width: 100%; max-width: 680px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-card.small { max-width: 460px; padding: 36px 32px; text-align: center; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 22px 22px; overflow: auto; }
.review-items { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.review-row { display: grid; grid-template-columns: 64px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.review-row:last-child { border-bottom: 0; }
.review-row img { width: 64px; height: 42px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.review-row .q { font-weight: 700; }
.review-row .p { color: var(--muted); min-width: 70px; text-align: right; }
.review-total { display: flex; justify-content: flex-end; gap: 12px; padding: 10px 12px; background: var(--bg); font-weight: 700; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field.span-2 { grid-column: span 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-actions.center { justify-content: center; }
.done-icon { width: 64px; height: 64px; border-radius: 50%; background: #e6f6ec; color: var(--ok); font-size: 32px; font-weight: 800; display: grid; place-items: center; margin: 0 auto 16px; }

/* ---- Orders ---- */
.orders { display: flex; flex-direction: column; gap: 14px; }
.order { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.order-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 12px; }
.order-num { font-weight: 800; font-size: 17px; }
.order-meta { color: var(--muted); font-size: 13px; }
.status { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #eef0ff; color: #3a43b8; text-transform: capitalize; }
.status.complete { background: #e6f6ec; color: var(--ok); }
.status.cancelled { background: #f1f1f3; color: var(--muted); }
.status.in_shopvox { background: #fff5dd; color: #7a5200; }
.order-head .btn { margin-left: auto; }
.order-head .btn + .btn { margin-left: 0; }
.order-items { display: flex; flex-wrap: wrap; gap: 10px; }
.order-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 6px 6px; font-size: 13px; }
.order-item img { width: 56px; height: 36px; object-fit: cover; border-radius: 4px; }
.order-item b { font-size: 14px; }
.order-notes { margin-top: 12px; font-size: 13px; color: var(--ink-2); background: #fff8e1; border-left: 3px solid #f5b400; padding: 8px 12px; border-radius: 6px; white-space: pre-wrap; }

/* ---- Lightbox & toast ---- */
.lightbox { position: fixed; inset: 0; background: rgba(10,10,14,.88); z-index: 60; display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }
.lightbox-close { position: absolute; top: 14px; right: 18px; color: #fff; font-size: 36px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; z-index: 70; box-shadow: var(--shadow-lg); }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .topbar-inner { gap: 10px; padding: 0 12px; height: auto; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .brand img { height: 22px; }
  .brand span { display: none; }
  .user-email { display: none; }
  .user-menu .btn { padding: 7px 10px; }
  .cart-btn { margin-left: auto; padding: 8px 12px; }
  .cart-btn span:not(.badge) { display: none; }
  .tabs { order: 10; width: 100%; margin-left: 0; }
  .tab { flex: 1; text-align: center; padding: 8px 6px; white-space: nowrap; }
  .page { padding: 20px 14px 80px; }
  .filters { align-items: stretch; width: 100%; }
  .filters input { width: 100%; }
  .chips { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
  .review-row { grid-template-columns: 56px 1fr auto; }
  .review-row .p { display: none; }
}
