:root{
  --paper:#F6F3EC;
  --paper-raised:#FFFFFF;
  --ink:#211F1C;
  --ink-soft:#5B564C;
  --ink-faint:#8B8579;
  --line:#E2DCCD;
  --line-strong:#CFC7B3;
  --thread:#B8402C;
  --thread-soft:#F1DAD3;
  --mustard:#C4922B;
  --mustard-soft:#F2E3C4;
  --sage:#5E7F5E;
  --sage-soft:#DCE6D8;
  --radius:3px;
}
*{box-sizing:border-box; margin:0; padding:0;}
body{ background:var(--paper); color:var(--ink); font-family:'Inter', sans-serif; font-size:14px; -webkit-font-smoothing:antialiased; }
a{ color:inherit; }

/* ---------- App shell ---------- */
.app{ display:flex; min-height:100vh; }
.sidebar{ width:220px; flex-shrink:0; border-right:1px solid var(--line); padding:28px 20px; display:flex; flex-direction:column; }
.brand{ font-family:'Fraunces', serif; font-weight:600; font-size:22px; letter-spacing:-0.01em; display:flex; align-items:baseline; gap:6px; }
.brand .tag-dot{ width:7px; height:7px; border-radius:50%; background:var(--thread); display:inline-block; transform:translateY(-6px); }
.brand-sub{ font-size:11px; color:var(--ink-faint); text-transform:uppercase; letter-spacing:.08em; margin-bottom:34px; }
nav{ display:flex; flex-direction:column; gap:2px; }
.nav-item{ display:flex; align-items:center; gap:10px; padding:10px 10px; border-radius:var(--radius); color:var(--ink-soft); font-weight:500; font-size:13.5px; text-decoration:none; border-left:2px solid transparent; }
.nav-item:hover{ background:rgba(0,0,0,0.03); color:var(--ink); }
.nav-item.active{ background:var(--paper-raised); color:var(--ink); border-left:2px solid var(--thread); box-shadow:0 1px 2px rgba(0,0,0,0.04); }
.nav-icon{ width:15px; height:15px; flex-shrink:0; opacity:.8; }
.sidebar-foot{ margin-top:auto; padding-top:20px; border-top:1px solid var(--line); font-size:11.5px; color:var(--ink-faint); line-height:1.6; }
.sidebar-foot a{ color:var(--thread); text-decoration:none; }
.sidebar-foot a:hover{ text-decoration:underline; }
.main{ flex:1; padding:34px 42px; max-width:1180px; }

.view-head{ display:flex; justify-content:space-between; align-items:flex-end; margin-bottom:26px; flex-wrap:wrap; gap:14px; }
.view-title{ font-family:'Fraunces', serif; font-size:28px; font-weight:600; letter-spacing:-0.01em; }
.view-desc{ color:var(--ink-faint); font-size:13px; margin-top:4px; }

.btn{ font-family:'Inter', sans-serif; font-size:13px; font-weight:600; padding:9px 16px; border-radius:var(--radius); border:1px solid transparent; cursor:pointer; display:inline-flex; align-items:center; gap:6px; text-decoration:none; background:none; }
.btn-primary{ background:var(--ink); color:var(--paper); }
.btn-primary:hover{ background:#000; }
.btn-ghost{ background:transparent; border:1px solid var(--line-strong); color:var(--ink-soft); }
.btn-ghost:hover{ border-color:var(--ink-soft); color:var(--ink); }
.btn-danger{ background:transparent; border:1px solid var(--thread-soft); color:var(--thread); }
.btn-danger:hover{ background:var(--thread-soft); }

.flash{ padding:11px 16px; border-radius:var(--radius); font-size:13px; margin-bottom:20px; }
.flash.ok{ background:var(--sage-soft); color:#3E5A3E; }
.flash.err{ background:var(--thread-soft); color:var(--thread); }

/* ---------- Stat strip ---------- */
.stats{ display:grid; grid-template-columns:repeat(4,1fr); gap:1px; background:var(--line); border:1px solid var(--line); margin-bottom:22px; border-radius:var(--radius); overflow:hidden; }
.stat{ background:var(--paper-raised); padding:16px 18px; }
.stat-label{ font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); margin-bottom:6px; }
.stat-value{ font-family:'Fraunces', serif; font-size:24px; font-weight:600; }
.stat-value.thread{ color:var(--thread); }

/* ---------- Cards / tables ---------- */
.card{ background:var(--paper-raised); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
table{ width:100%; border-collapse:collapse; }
thead th{ text-align:left; font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); font-weight:600; padding:11px 16px; border-bottom:1px solid var(--line); background:#FAF8F3; }
tbody td{ padding:11px 16px; border-bottom:1px solid var(--line); vertical-align:middle; font-size:13px; }
tbody tr:last-child td{ border-bottom:none; }
.price{ font-family:'IBM Plex Mono', monospace; font-weight:500; }

/* ---------- Inventory cards ---------- */
.product-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(240px,1fr)); gap:16px; }
.product-card{ background:var(--paper-raised); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; display:flex; flex-direction:column; }
.product-photo{ width:100%; aspect-ratio:4/5; background:var(--paper); background-size:cover; background-position:center; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:center; position:relative; }
.product-photo .no-photo{ display:flex; flex-direction:column; align-items:center; gap:6px; font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-faint); }
.product-body{ padding:14px 16px 16px; display:flex; flex-direction:column; gap:10px; flex:1; }
.product-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.prod-name{ font-weight:600; line-height:1.25; }
.prod-sku{ font-family:'IBM Plex Mono', monospace; font-size:10.5px; color:var(--ink-faint); margin-top:2px; }
.swatch{ display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--ink-soft); }
.swatch-dot{ width:9px; height:9px; border-radius:50%; border:1px solid rgba(0,0,0,0.15); flex-shrink:0; }
.sizes-label{ font-size:10px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); margin-top:2px; }
.size-row{ display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.size-pill{ font-family:'IBM Plex Mono', monospace; font-size:11px; padding:4px 8px 4px 9px; border:1px solid var(--line-strong); border-radius:20px; color:var(--ink-soft); background:var(--paper); display:inline-flex; align-items:center; gap:6px; line-height:1; }
.size-pill .sz{ font-weight:600; color:var(--ink); }
.size-pill .qty{ color:var(--ink-faint); }
.size-pill.out{ border-color:var(--thread-soft); background:var(--thread-soft); }
.size-pill.out .sz{ color:var(--thread); }
.size-pill.low .qty{ color:var(--mustard); font-weight:600; }
.size-pill .held{ font-size:9.5px; color:var(--mustard); font-weight:600; background:var(--mustard-soft); padding:1px 5px; border-radius:10px; }
.size-pill form{ display:inline; margin:0; }
.size-pill .rm{ cursor:pointer; color:var(--ink-faint); font-size:12px; background:none; border:none; padding:0; font-family:inherit; }
.size-pill .rm:hover{ color:var(--thread); }
.product-foot{ display:flex; justify-content:space-between; align-items:center; margin-top:auto; padding-top:8px; }
.icon-btn{ width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center; border-radius:var(--radius); color:var(--ink-faint); cursor:pointer; border:1px solid transparent; background:none; }
.icon-btn:hover{ background:var(--line); color:var(--ink); }

.mini-form{ display:flex; gap:6px; align-items:center; }
.mini-form input{ border:1px solid var(--line-strong); background:var(--paper); border-radius:20px; font-family:'IBM Plex Mono', monospace; font-size:11px; padding:4px 8px; }
.mini-form .sz-input{ width:48px; }
.mini-form .qty-input{ width:44px; }
.mini-form button{ border:none; background:var(--ink); color:var(--paper); width:22px; height:22px; border-radius:50%; font-size:13px; cursor:pointer; }
.add-size-toggle{ font-family:'Inter', sans-serif; font-size:11px; font-weight:600; padding:4px 10px; border:1px dashed var(--line-strong); border-radius:20px; color:var(--ink-faint); cursor:pointer; background:transparent; }
.add-size-toggle:hover{ border-color:var(--thread); color:var(--thread); }
details.size-add > summary{ list-style:none; cursor:pointer; }
details.size-add > summary::-webkit-details-marker{ display:none; }
details.size-add[open] summary .add-size-toggle{ display:none; }
details.size-add .mini-form{ margin-top:6px; }

/* ---------- Orders (ticket stub) ---------- */
.order-list{ display:flex; flex-direction:column; gap:12px; }
.ticket{ background:var(--paper-raised); border:1px solid var(--line); border-radius:var(--radius); display:flex; }
.ticket-main{ flex:1; padding:18px 20px; }
.ticket-top{ display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:10px; }
.ticket-id{ font-family:'IBM Plex Mono', monospace; font-size:11px; color:var(--ink-faint); }
.ticket-client{ font-weight:600; font-size:15px; margin-top:2px; }
.ticket-items{ color:var(--ink-soft); font-size:12.5px; margin-top:3px; }
.ticket-total{ font-family:'IBM Plex Mono', monospace; font-weight:600; font-size:15px; text-align:right; }
.ticket-date{ font-size:11px; color:var(--ink-faint); text-align:right; margin-top:2px; }

.stepper{ display:flex; align-items:center; margin-top:14px; }
.step{ display:flex; flex-direction:column; align-items:center; flex:1; position:relative; }
.step form{ margin:0; display:flex; flex-direction:column; align-items:center; }
.step button{ background:none; border:none; cursor:pointer; padding:0; display:flex; flex-direction:column; align-items:center; font-family:inherit; }
.step-dot{ width:11px; height:11px; border-radius:50%; background:var(--paper); border:2px solid var(--line-strong); z-index:2; }
.step-label{ font-size:10px; text-transform:uppercase; letter-spacing:.04em; color:var(--ink-faint); margin-top:6px; text-align:center; }
.step-line{ position:absolute; top:5px; left:50%; width:100%; height:2px; background:var(--line-strong); z-index:1; }
.step:last-child .step-line{ display:none; }
.step.done .step-dot{ background:var(--thread); border-color:var(--thread); }
.step.done .step-line{ background:var(--thread); }
.step.done .step-label{ color:var(--ink); }
.step.current .step-dot{ background:var(--paper-raised); border-color:var(--mustard); box-shadow:0 0 0 3px var(--mustard-soft); }
.step.current .step-label{ color:var(--mustard); font-weight:600; }
.step.confirmed .step-dot{ background:var(--sage); border-color:var(--sage); }
.step.confirmed .step-line{ background:var(--sage); }
.step.confirmed .step-label{ color:var(--sage); font-weight:600; }

.ticket-stub{ width:130px; flex-shrink:0; border-left:1px dashed var(--line-strong); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:12px; }
.status-badge{ font-size:10.5px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; padding:5px 10px; border-radius:20px; }
.status-badge.ordered{ background:var(--thread-soft); color:var(--thread); }
.status-badge.shipped{ background:var(--mustard-soft); color:var(--mustard); }
.status-badge.confirmed{ background:var(--sage-soft); color:var(--sage); }
.status-badge.returned{ background:var(--thread-soft); color:var(--thread); }
.status-badge.no_pickup{ background:var(--mustard-soft); color:var(--mustard); }
.advance-btn{ font-size:10.5px; color:var(--ink-faint); cursor:pointer; text-decoration:underline; text-underline-offset:2px; background:none; border:none; font-family:inherit; padding:0; }
.advance-btn:hover{ color:var(--ink); }
.ticket-stub form{ margin:0; }

/* ---------- Clients ---------- */
.client-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(300px,1fr)); gap:14px; }
.client-card{ background:var(--paper-raised); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; }
.client-top{ display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:12px; }
.client-name{ font-weight:700; font-size:15px; }
.client-contact{ font-size:12px; color:var(--ink-faint); margin-top:2px; }
.client-avatar{ width:34px; height:34px; border-radius:50%; background:var(--paper); border:1px solid var(--line-strong); display:flex; align-items:center; justify-content:center; font-family:'Fraunces', serif; font-weight:600; font-size:13px; color:var(--ink-soft); }
.client-stats{ display:flex; gap:22px; padding-top:12px; border-top:1px solid var(--line); }
.client-stat-label{ font-size:10px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-faint); }
.client-stat-value{ font-family:'IBM Plex Mono', monospace; font-weight:600; font-size:14.5px; margin-top:3px; }
.client-stat-value.thread{ color:var(--thread); }

/* ---------- Forms / panels ---------- */
.panel{ background:var(--paper-raised); border:1px solid var(--line); border-radius:var(--radius); padding:22px 24px; margin-bottom:24px; max-width:480px; }
.panel-wide{ max-width:620px; }
.panel h3{ font-family:'Fraunces', serif; font-size:19px; margin-bottom:4px; }
.panel .sub{ color:var(--ink-faint); font-size:12.5px; margin-bottom:18px; }
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-soft); margin-bottom:6px; }
.field input, .field select{ width:100%; padding:9px 11px; border:1px solid var(--line-strong); border-radius:var(--radius); font-family:'Inter', sans-serif; font-size:13.5px; background:var(--paper); }
.field input:focus, .field select:focus{ outline:2px solid var(--thread); outline-offset:0; border-color:var(--thread); }
.field-row{ display:flex; gap:10px; }
.field-row .field{ flex:1; }
.form-actions{ display:flex; gap:10px; margin-top:20px; }
.helper-text{ font-size:11.5px; color:var(--ink-faint); margin-top:-6px; margin-bottom:12px; line-height:1.5; }

.order-item-row{ display:flex; gap:8px; align-items:flex-end; margin-bottom:10px; }
.order-item-row .field{ margin-bottom:0; flex:1; }
.order-item-row .qty-field{ max-width:70px; }
.draft-items{ border:1px solid var(--line); border-radius:var(--radius); margin-bottom:16px; }
.draft-item{ display:flex; justify-content:space-between; align-items:center; padding:9px 12px; font-size:12.5px; border-bottom:1px solid var(--line); }
.draft-item:last-child{ border-bottom:none; }
.draft-item .di-name{ font-weight:600; }
.draft-item .di-meta{ color:var(--ink-faint); font-size:11px; }
.draft-total-row{ display:flex; justify-content:space-between; padding:10px 12px; background:#FAF8F3; font-weight:700; font-size:13px; border-top:1px solid var(--line); }

/* ---------- Users page ---------- */
.role-badge{ font-size:10.5px; font-weight:600; text-transform:uppercase; padding:3px 9px; border-radius:20px; }
.role-badge.admin{ background:var(--thread-soft); color:var(--thread); }
.role-badge.staff{ background:var(--line); color:var(--ink-soft); }

/* ---------- Login page ---------- */
.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card{ width:100%; max-width:360px; background:var(--paper-raised); border:1px solid var(--line); border-radius:var(--radius); padding:36px 32px; }
.login-brand{ font-family:'Fraunces', serif; font-weight:600; font-size:26px; display:flex; align-items:baseline; gap:6px; margin-bottom:4px; }
.login-brand .tag-dot{ width:8px; height:8px; border-radius:50%; background:var(--thread); display:inline-block; transform:translateY(-6px); }
.login-sub{ color:var(--ink-faint); font-size:12.5px; margin-bottom:26px; }

@media (max-width:820px){
  .app{ flex-direction:column; }
  .sidebar{ width:100%; flex-direction:row; align-items:center; padding:16px 20px; overflow-x:auto; }
  .brand-sub{ display:none; }
  nav{ flex-direction:row; margin-left:20px; }
  .sidebar-foot{ display:none; }
  .main{ padding:24px 18px; }
  .stats{ grid-template-columns:repeat(2,1fr); }
  .ticket{ flex-direction:column; }
  .ticket-stub{ border-left:none; border-top:1px dashed var(--line-strong); flex-direction:row; flex-wrap:wrap; }
}

 
/* ---------- Inventory edit panel ---------- */
.edit-panel{
  border:1px solid var(--line-strong);
  border-radius:var(--radius);
  padding:14px;
  background:#FAF8F3;
}
.edit-panel .field{ margin-bottom:10px; }
.edit-panel .form-actions{ margin-top:14px; }
/* ---------- Product picker (New order) ---------- */
.product-picker{
  border:1px solid var(--line-strong);
  border-radius:var(--radius);
  max-height:220px;
  overflow-y:auto;
  background:var(--paper);
  margin-top:8px;
}
.product-picker-item{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px;
  cursor:pointer;
  border-bottom:1px solid var(--line);
}
.product-picker-item:last-child{ border-bottom:none; }
.product-picker-item:hover{ background:#F1EEE6; }
.product-picker-item.selected{ background:var(--thread-soft); }
.product-picker-thumb{
  width:34px; height:34px; border-radius:3px; object-fit:cover;
  background:var(--paper-raised); border:1px solid var(--line); flex-shrink:0;
}
.product-picker-thumb.empty{
  display:flex; align-items:center; justify-content:center;
  color:var(--ink-faint); font-size:8px; text-align:center; text-transform:uppercase; letter-spacing:.03em;
}
.product-picker-name{ font-weight:600; font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.product-picker-meta{ font-size:11px; color:var(--ink-faint); }
.product-picker-price{ margin-left:auto; font-family:'IBM Plex Mono', monospace; font-size:12px; font-weight:600; flex-shrink:0; }