:root {
  --ink: #0f0e0d;
  --muted: #5f5951;
  --faint: #8b847b;
  --line: #ece6de;
  --paper: #ffffff;
  --parch: #f6f3ef;
  --gold: #9a6c33;
  --gold-deep: #7e5626;
  --gold-soft: rgba(154, 108, 51, 0.12);
  --champagne: #ddb97c;
  --sale: #d23b4a;
  --sale-soft: rgba(210, 59, 74, 0.1);
  --ok: #2e8b57;
  --ok-soft: rgba(46, 139, 87, 0.1);
  --info: #3b6ea8;
  --info-soft: rgba(59, 110, 168, 0.1);
  --violet: #7b57c2;
  --violet-soft: rgba(123, 87, 194, 0.1);
  --noir: linear-gradient(160deg, #3a2c19 0%, #17130e 45%, #0b0a09 100%);
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 14, 13, 0.04), 0 8px 24px rgba(15, 14, 13, 0.06);
  font-family: 'Montserrat', system-ui, sans-serif;
  color: var(--ink);
  background: var(--parch);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--parch); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-deep); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--noir); color: #f5f2ec; padding: 26px 16px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { padding: 0 10px 22px; }
.brand .w1 { font-weight: 300; letter-spacing: 0.08em; font-size: 22px; line-height: 1; }
.brand .w2 { font-weight: 800; font-size: 22px; line-height: 1.1; }
.brand .w2 small { font-weight: 600; font-size: 11px; margin-right: 3px; text-decoration: underline; }
.brand .tag { font-family: 'Cormorant Garamond', serif; font-style: italic; color: var(--champagne); font-size: 15px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #c9c1b6;
  text-decoration: none; font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav a.on { background: rgba(221, 185, 124, 0.14); color: #fff; }
.nav a.on svg { color: var(--champagne); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav a.parent, .nav .group.parent { color: #fff; }
.nav .group {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #c9c1b6; width: 100%;
  background: none; border: 0; cursor: pointer; font-weight: 500; font-size: 13.5px; text-align: left;
}
.nav .group:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav .group svg { width: 18px; height: 18px; flex: none; }
.nav .group.parent svg { color: var(--champagne); }
.nav .chev { margin-left: auto; transition: transform 0.15s; font-size: 16px; line-height: 1; transform: rotate(90deg); opacity: 0.6; }
.nav .chev.up { transform: rotate(-90deg); }
.nav .group .count + .chev { margin-left: 8px; }
.nav a.parent svg { color: var(--champagne); }
.subnav { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 8px 21px; padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, 0.1); }
.subnav a { padding: 7px 10px; font-size: 13px; font-weight: 500; border-radius: 10px; }
.subnav a.on { background: rgba(221, 185, 124, 0.14); color: #fff; }
.nav .count.warn { background: var(--sale); color: #fff; }
.tabs.mobile-only { display: none; }
.nav .count {
  margin-left: auto; background: var(--champagne); color: #1a1408; border-radius: 99px; font-size: 11px;
  font-weight: 700; padding: 1px 8px; font-variant-numeric: tabular-nums;
}
.side .me { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 12px; color: #a9a299; }
.side .me button { background: none; border: 0; color: var(--champagne); padding: 4px 0; cursor: pointer; font-weight: 600; }
.emu { margin: 8px 10px; font-size: 11px; color: #1a1408; background: var(--champagne); border-radius: 8px; padding: 6px 10px; font-weight: 600; }

.main { min-width: 0; padding: 28px 32px 60px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head .eyebrow { font-family: 'Cormorant Garamond', serif; font-style: italic; color: var(--gold); font-size: 17px; }
.head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.head .tools { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- building blocks ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 300; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.dark { background: var(--noir); border: 0; color: #fff; }
.stat.dark .label, .stat.dark .sub { color: #a9a299; }
.stat.dark .value { color: #fff; }
.stat.alert .value { color: var(--sale); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  border-radius: 12px; padding: 9px 16px; font-weight: 600; font-size: 13px; cursor: pointer; background: var(--ink); color: #fff;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn.gold { background: linear-gradient(120deg, #f1dcae, #ddb97c 45%, #c2955a); color: #1a1408; }
.btn.ghost { background: var(--paper); border-color: var(--line); color: var(--ink); }
.btn.danger { background: var(--paper); border-color: rgba(210, 59, 74, 0.35); color: var(--sale); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 10px; }
.btn svg { width: 16px; height: 16px; }

.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 9px 12px; outline: none;
}
.input:focus { border-color: var(--ink); }
textarea.input { resize: vertical; min-height: 84px; }
.search { position: relative; }
.search input { padding-left: 36px; width: 260px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; color: var(--faint); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--ink); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  border: 0; background: var(--paper); border: 1px solid var(--line); padding: 7px 14px; border-radius: 99px;
  cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--muted);
}
.tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab .n { margin-left: 6px; opacity: 0.6; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; border-radius: 99px; padding: 3px 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill.PENDING, .pill.REVIEW { background: var(--violet-soft); color: var(--violet); }
.pill.PREPARING { background: var(--gold-soft); color: var(--gold-deep); }
.pill.SHIPPED { background: var(--info-soft); color: var(--info); }
.pill.DELIVERED, .pill.CONFIRMED, .pill.APPROVED { background: var(--ok-soft); color: var(--ok); }
.pill.CANCELLED, .pill.REJECTED, .pill.late { background: var(--sale-soft); color: var(--sale); }
.pill.muted { background: var(--parch); color: var(--muted); }
.pill.gold { background: var(--gold-soft); color: var(--gold-deep); }

table.list { width: 100%; border-collapse: collapse; background: var(--paper); }
.tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--paper); }
table.list th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fcfbf9;
}
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #fbf8f4; }
td.r, th.r { text-align: right; }
td.num, td .num { white-space: nowrap; }
.who b { display: block; font-weight: 600; }
.who span { color: var(--muted); font-size: 12px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.sep { height: 1px; background: var(--line); margin: 16px 0; }
.note { border-radius: 12px; padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.note.warn { background: var(--sale-soft); color: var(--sale); }
.note.info { background: var(--info-soft); color: var(--info); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.gold { background: var(--gold-soft); color: var(--gold-deep); }

.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: var(--parch); flex: none; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.doc { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--parch); cursor: zoom-in; display: block; text-decoration: none; color: var(--ink); }
.doc img { width: 100%; height: 120px; object-fit: cover; display: block; }
.doc .cap { padding: 7px 10px; font-size: 12px; font-weight: 600; background: var(--paper); }
.doc .missing { height: 120px; display: grid; place-items: center; color: var(--faint); font-size: 12px; }

/* wide side panel (zone editor), sticky right column, region checklist */
.drawer.wide { width: min(980px, 100vw); }
.sticky { position: sticky; top: 16px; }
.regions { columns: 3 220px; column-gap: 22px; margin-top: 12px; max-height: 420px; overflow-y: auto; }
.region { break-inside: avoid; margin-bottom: 14px; }
.region .check { display: flex; font-size: 13px; font-weight: 400; padding: 3px 0; }
.region .rhead { font-size: 13.5px; padding-bottom: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.region .rhead b { color: var(--info); }

/* small suggestion buttons (notes) */
.chip { border: 1px dashed var(--line); background: var(--paper); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.chip:hover { border-color: var(--gold); color: var(--gold-deep); }

/* phone field with customer suggestions */
.phonefield { position: relative; margin-bottom: 12px; }
.phonefield > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% - 2px); z-index: 5; background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; margin-top: 6px;
}
.suggest .opt { display: flex; width: 100%; gap: 12px; align-items: center; padding: 10px 14px; border: 0; background: none; cursor: pointer; text-align: left; border-bottom: 1px solid var(--line); }
.suggest .opt:last-child { border-bottom: 0; }
.suggest .opt.on { background: var(--gold-soft); }
.suggest .av { width: 34px; height: 34px; border-radius: 50%; background: var(--noir); color: var(--champagne); display: grid; place-items: center; font-weight: 700; flex: none; }
.suggest .who { flex: 1; min-width: 0; }
.suggest .who b { display: block; font-weight: 600; }
.suggest .who span { color: var(--muted); font-size: 12.5px; }
.suggest mark { background: none; color: var(--ink); font-weight: 700; }
.suggest .meta { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.suggest .meta em { font-style: normal; color: var(--gold-deep); }
.suggest .meta em.late { color: var(--sale); }
.phonehint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.phonehint.ok { color: var(--ok); font-weight: 600; }

/* side panel and dialogs */
.overlay { position: fixed; inset: 0; background: rgba(15, 14, 13, 0.32); z-index: 20; animation: fade 0.15s ease-out; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(620px, 100vw); background: var(--parch); z-index: 21;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12); display: flex; flex-direction: column; animation: slide 0.2s ease-out;
}
.drawer .dhead { display: flex; align-items: center; gap: 12px; padding: 18px 22px; background: var(--paper); border-bottom: 1px solid var(--line); }
.drawer .dhead h2 { margin: 0; font-size: 18px; }
.drawer .dbody { flex: 1; overflow-y: auto; padding: 18px 22px 28px; display: grid; gap: 14px; align-content: start; }
.drawer .dfoot { padding: 14px 22px; background: var(--paper); border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.x { border: 0; background: var(--parch); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; margin-left: auto; }
.x svg { width: 18px; }
.dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, calc(100vw - 32px)); z-index: 31;
  background: var(--paper); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); animation: fade 0.15s ease-out;
}
.dialog h3 { margin: 0 0 8px; }
.dialog p { margin: 0 0 14px; color: var(--muted); }
.overlay.top { z-index: 30; }
.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(11, 10, 9, 0.9); display: grid; place-items: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; z-index: 50;
  padding: 11px 18px; border-radius: 12px; font-weight: 500; box-shadow: var(--shadow); animation: fade 0.2s ease-out;
}
.toast.err { background: var(--sale); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .stack { display: flex; flex-direction: column-reverse; border-radius: 6px 6px 2px 2px; overflow: hidden; }
.bars .cash { background: var(--ink); }
.bars .inst { background: var(--champagne); }
.bars .lbl { font-size: 10.5px; color: var(--faint); text-align: center; margin-top: 6px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--noir); padding: 20px; }
.login .box { width: min(400px, 100%); background: var(--paper); border-radius: 24px; padding: 30px; }
.login .brand { padding: 0 0 18px; color: var(--ink); }
.login .brand .tag { color: var(--gold); }
.login h1 { font-size: 18px; margin: 0 0 16px; }
.err { color: var(--sale); font-size: 13px; margin: 0 0 12px; }

.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.pcard { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.pcard:hover { border-color: #d9cfc2; }
.pcard .img { aspect-ratio: 1; background: #fff; display: grid; place-items: center; position: relative; }
.pcard .img img { width: 78%; height: 78%; object-fit: contain; }
.pcard .img .pill { position: absolute; left: 10px; top: 10px; }
.pcard .body { padding: 12px 14px 14px; display: grid; gap: 2px; }
.pcard .brandname { font-size: 11px; color: var(--gold); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.pcard .name { font-weight: 600; }
.pcard .prices { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; }
.pcard .prices span { color: var(--muted); font-size: 11px; display: block; }
.pcard.off { opacity: 0.55; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px 12px; }
  .brand { padding-bottom: 10px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav a { white-space: nowrap; }
  .subnav { display: none; }
  .nav .chev { display: none; }
  .nav .group { white-space: nowrap; width: auto; }
  .tabs.mobile-only { display: flex; }
  .side .me { display: none; }
  .main { padding: 18px 16px 50px; }
  .g2 { grid-template-columns: 1fr; }
  .grid[style*='grid-template-columns'] { grid-template-columns: 1fr !important; }
  .sticky { position: static; }
  .search input { width: 100%; }
  .head .tools { width: 100%; margin-left: 0; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  /* page-specific two-column layouts stack on phones */
  .grid[style*='grid-template-columns'] { grid-template-columns: 1fr !important; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .stat .value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
