/* KueMue B2B design system — minimal black/white + warm cream, lowercase wordmark brand.
   Every page uses these tokens/components; page CSS only adds layout. Mobile-first. */

:root {
  --ink: #141414;
  --ink-2: #3d3a35;
  --paper: #faf7f2;
  --card: #ffffff;
  --line: #e8e2d9;
  --line-2: #d9d2c6;
  --accent: #b07d3f;
  --accent-ink: #8a5f28;
  --accent-soft: #f3e9db;
  --muted: #7a7368;
  --ok: #2e7d4f;    --ok-soft: #e3f1e9;
  --warn: #b26a00;  --warn-soft: #fdf0dd;
  --bad: #b3261e;   --bad-soft: #f9e5e4;
  --info: #2f5f8f;  --info-soft: #e6eef6;
  --violet: #6b4fa3; --violet-soft: #ece6f6;
  --teal: #1f7a72;  --teal-soft: #e0f0ee;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(20,20,20,.05), 0 4px 16px rgba(20,20,20,.06);
  --shadow-lg: 0 4px 12px rgba(20,20,20,.08), 0 16px 48px rgba(20,20,20,.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
}
h1,h2,h3,h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
p { margin: 0 0 1em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
::placeholder { color: #b3aca1; }

/* ── Brand ── */
.wordmark { font-weight: 700; font-size: 22px; letter-spacing: -.5px; color: var(--ink); }
.wordmark b { font-weight: 700; }
.wordmark .tag {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin-left: 6px; vertical-align: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); font: 600 14px/1.2 var(--font);
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, opacity .12s;
  min-height: 42px;
}
.btn:hover { background: #f4f0e9; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2b2b2b; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); }
.btn-danger { background: var(--card); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(20,20,20,.06); }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ── Forms ── */
.label { display: block; font: 600 13px/1.3 var(--font); color: var(--ink-2); margin: 14px 0 6px; }
.label .req { color: var(--bad); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--card); color: var(--ink); font: 400 15px/1.4 var(--font);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 90px; resize: vertical; }
.field-err { color: var(--bad); font-size: 13px; margin-top: 4px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

/* ── Cards / layout ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card h3 { margin-bottom: 12px; }
.stack > * + * { margin-top: 14px; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font: 600 12px/1.3 var(--font); text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: default; }
.table .rowlink { cursor: pointer; }
.table .rowlink:hover { background: #faf7f0; }

/* ── Badges & status pills ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font: 600 12px/1.4 var(--font); background: #f0ece4; color: var(--ink-2); white-space: nowrap;
}
.pill-draft, .pill-expired, .pill-cancelled { background: #efece6; color: var(--muted); }
.pill-submitted, .pill-under_review { background: var(--info-soft); color: var(--info); }
.pill-quoted { background: var(--violet-soft); color: var(--violet); }
.pill-awaiting_deposit, .pill-awaiting_balance { background: var(--warn-soft); color: var(--warn); }
.pill-preparing, .pill-ready_to_ship { background: var(--teal-soft); color: var(--teal); }
.pill-shipped { background: var(--info-soft); color: var(--info); }
.pill-delivered, .pill-completed, .pill-confirmed, .pill-approved { background: var(--ok-soft); color: var(--ok); }
.pill-declined, .pill-rejected, .pill-suspended { background: var(--bad-soft); color: var(--bad); }
.pill-pending { background: var(--warn-soft); color: var(--warn); }

/* ── Nav (top bar) ── */
.nav {
  position: sticky; top: 0; z-index: 40; background: rgba(250,247,242,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-in { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.nav .spacer { flex: 1; }
.nav a.navlink { color: var(--ink-2); font-weight: 600; font-size: 14px; padding: 8px 10px; border-radius: 8px; }
.nav a.navlink:hover { background: rgba(20,20,20,.05); text-decoration: none; }
.nav a.navlink.on { color: var(--ink); background: rgba(20,20,20,.07); }

/* ── Bottom tab bar (portal, mobile) ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: none;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-bottom));
}
.tabbar .tb {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font: 600 11px/1.2 var(--font); padding: 6px 0; border-radius: 8px;
  text-decoration: none; position: relative;
}
.tabbar .tb.on { color: var(--ink); }
.tabbar .tb svg { width: 22px; height: 22px; }
.tabbar .tb .dot {
  position: absolute; top: 2px; right: calc(50% - 16px); min-width: 16px; height: 16px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10px; line-height: 16px; text-align: center; padding: 0 4px;
}
@media (max-width: 720px) { .tabbar { display: flex; } .has-tabbar { padding-bottom: 76px; } }

/* ── Sidebar (admin, desktop) ── */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 220px; flex: none; border-right: 1px solid var(--line); background: var(--card);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .navlink {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); font: 600 14px/1.2 var(--font); text-decoration: none; margin-bottom: 2px;
}
.side .navlink:hover { background: #f4f0e9; }
.side .navlink.on { background: var(--ink); color: #fff; }
.side .navlink .cnt { margin-left: auto; }
.main { flex: 1; min-width: 0; padding: 22px 24px 60px; }
@media (max-width: 999px) {
  .shell { display: block; }
  .side { position: static; width: auto; height: auto; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .side .navlink { white-space: nowrap; }
  .main { padding: 16px 14px 60px; }
}

/* ── Modal ── */
.modal-back {
  position: fixed; inset: 0; z-index: 90; background: rgba(20,20,20,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; padding: 22px;
}
.modal.modal-lg { max-width: 760px; }
@media (max-width: 560px) { .modal-back { align-items: flex-end; padding: 0; } .modal { border-radius: 16px 16px 0 0; max-height: 92vh; } }

/* ── Toast ── */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast {
  background: var(--ink); color: #fff; border-radius: 10px; padding: 12px 16px; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: toastin .18s ease-out;
}
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes toastin { from { opacity: 0; transform: translateY(-6px); } }

/* ── Product grid ── */
.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
@media (max-width: 560px) { .grid-products { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; transition: box-shadow .12s, transform .12s; display: flex; flex-direction: column; }
.pcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.pcard .pimg { aspect-ratio: 1; background: var(--accent-soft) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 34px; }
.pcard .pbody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard .pname { font-weight: 600; font-size: 14px; }
.pcard .pprice { font-weight: 700; font-size: 15px; }
.pcard .pfrom { color: var(--muted); font-size: 12px; }

/* ── Stats / empty / skeleton ── */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat.hot { border-color: var(--accent); background: linear-gradient(0deg, var(--accent-soft), var(--card)); }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.skel { background: linear-gradient(90deg, #eee9e0 25%, #f6f2ea 50%, #eee9e0 75%); background-size: 200% 100%; animation: skel 1.1s infinite linear; border-radius: 8px; min-height: 16px; }
@keyframes skel { to { background-position: -200% 0; } }

/* ── Timeline ── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 6px; width: 8px; height: 8px; border-radius: 999px; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 10.5px; top: 18px; bottom: -2px; width: 1.5px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }
.timeline .t-title { font-weight: 600; font-size: 14px; }
.timeline .t-sub { color: var(--muted); font-size: 12.5px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs .tab {
  padding: 10px 14px; font: 600 14px/1.2 var(--font); color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0;
}
.tabs .tab.on { color: var(--ink); border-bottom-color: var(--ink); }

/* ── Misc ── */
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { margin-top: 8px; } }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.qty-stepper button { width: 40px; height: 40px; border: 0; background: var(--card); font-size: 18px; cursor: pointer; color: var(--ink); }
.qty-stepper button:hover { background: #f4f0e9; }
.qty-stepper input { width: 64px; height: 40px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font: 600 15px var(--font); outline: none; }
.notif-dot { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; padding: 0 4px; font-weight: 700; }
