*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0f;
  --bg2: #161619;
  --bg3: #1e1e22;
  --bg4: #27272c;
  --text: #eaeaed;
  --text2: #a0a0a8;
  --text3: #66666e;
  --gold: #d4a843;
  --gold-dim: rgba(212, 168, 67, 0.12);
  --gold-glow: rgba(212, 168, 67, 0.25);
  --green: #3ab060;
  --red: #d94545;
  --border: #2a2a30;
  --r: 8px;
  --r-sm: 5px;
}

html, body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* ===== LAYOUT ===== */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo { height: 48px; background: #fff; border-radius: 6px; padding: 4px 8px; }
.top-right { display: flex; gap: 8px; align-items: center; }

.top-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--r-sm);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}
.top-btn:hover { background: var(--bg4); color: var(--text); }

.cart-btn {
  position: relative;
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: var(--r-sm);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cart-btn:hover { background: var(--gold-glow); }

.badge {
  background: var(--gold);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.main-area { display: flex; flex: 1; overflow: hidden; }

/* ===== NAV ===== */
.cat-nav {
  width: 180px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px 6px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: 0.15s;
}
.nav-btn:hover { background: var(--bg3); color: var(--text2); }
.nav-btn.active { background: var(--gold-dim); color: var(--gold); font-weight: 600; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }

/* ===== CONTENT ===== */
.content-area { flex: 1; overflow-y: auto; padding: 24px 28px; }

.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.cat-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.cat-icon { font-size: 22px; }

/* ===== CUSTOMER FORM ===== */
.cust-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
  width: 100%;
  max-width: 560px;
}
.form-card h2 { font-size: 20px; margin-bottom: 4px; }
.form-card .sub { color: var(--text3); font-size: 13px; margin-bottom: 20px; }

.fg { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fg .fw { grid-column: 1 / -1; }
.fg label { display: block; font-size: 12px; font-weight: 600; color: var(--text3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; }
.fg input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
}
.fg input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-dim); }
.fg input::placeholder { color: var(--text3); }

.btn-go {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
}
.btn-go:hover { filter: brightness(1.1); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: var(--r);
  padding: 3px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 8px 14px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.15s;
}
.tab:hover { color: var(--text2); background: var(--bg3); }
.tab.on { background: var(--gold); color: #000; font-weight: 700; }

/* ===== ITEM ROW (tools, bags) ===== */
.item-list { display: flex; flex-direction: column; gap: 6px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: 0.15s;
}
.item-row:hover { background: var(--bg3); }
.item-row.added { border-color: var(--gold); background: var(--gold-dim); }
.item-row.starred { border-left: 3px solid var(--gold); }

.product-img {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--bg3);
  flex-shrink: 0;
}

.item-text { flex: 1; min-width: 0; }
.item-name { display: block; font-size: 13px; font-weight: 500; line-height: 1.3; }
.item-sku { display: block; font-size: 10px; color: var(--text3); font-family: 'Consolas', 'Courier New', monospace; margin-top: 1px; }

/* ===== QTY CONTROL ===== */
.qty-ctl {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.qb {
  width: 32px;
  height: 32px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qb:hover { background: var(--bg4); color: var(--text); }
.qb.minus { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.qb.plus { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.qi {
  width: 42px;
  height: 32px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  -moz-appearance: textfield;
}
.qi::-webkit-inner-spin-button, .qi::-webkit-outer-spin-button { -webkit-appearance: none; }
.qi:focus { outline: none; background: var(--bg2); }

/* ===== SWATCH CARDS (colors) ===== */
.fill-all-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.fill-all-bar label { font-size: 13px; font-weight: 600; color: var(--text2); white-space: nowrap; }
.fill-all-input { width: 70px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); font-size: 14px; text-align: center; }
.btn-fill-all { padding: 6px 14px; background: var(--gold-dim); color: var(--gold); border: 1px solid var(--gold); border-radius: var(--r-sm); font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-fill-all:hover { background: var(--gold-glow); }

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.swatch-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: 0.15s;
}
.swatch-card:hover { background: var(--bg3); }
.swatch-card.added { border-color: var(--gold); background: var(--gold-dim); }

.sw {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.1);
}
.sw.sm { width: 24px; height: 24px; }
.dual-sw { display: flex; gap: 3px; flex-shrink: 0; }

.hint-banner {
  font-size: 12px;
  color: var(--text2);
  padding: 8px 12px;
  background: var(--bg2);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-bottom: 12px;
}

/* ===== SECTION GROUPS (apparel) ===== */
.section-group { margin-bottom: 24px; }
.sec-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== MATRIX (slugs, finger grips) ===== */
.matrix-wrap { display: flex; flex-direction: column; gap: 14px; }

.bulk-fill {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.bulk-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-right: 4px;
  white-space: nowrap;
}
.fill-pill {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.fill-input {
  width: 48px;
  height: 26px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 12px;
  -moz-appearance: textfield;
}
.fill-input::-webkit-inner-spin-button, .fill-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.fill-input:focus { outline: none; border-color: var(--gold); }

.matrix-scroll { overflow-x: auto; }

.matrix-table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
  min-width: max-content;
}
.matrix-table th {
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-align: center;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.matrix-table th .dot { margin: 0 auto 2px; display: block; }
.col-label { display: block; font-size: 10px; }
.row-head {
  font-weight: 600;
  color: var(--text2);
  padding: 6px 10px 6px 0;
  white-space: nowrap;
  text-align: right;
  border-right: 2px solid var(--border);
  min-width: 70px;
}
.row-fill-head {
  font-size: 10px;
  color: var(--text3);
  padding-left: 8px;
}

.matrix-table td {
  padding: 2px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.matrix-table td.has-qty { background: var(--gold-dim); }
.row-fill-cell { padding-left: 6px; }
.row-fill-inp { width: 52px; }

.cell-input {
  width: 44px;
  height: 28px;
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  -moz-appearance: textfield;
}
.cell-input::-webkit-inner-spin-button, .cell-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.cell-input:focus { outline: none; border-color: var(--gold); background: var(--bg); }

/* ===== ORDER SUMMARY ===== */
.summary-sec { margin-bottom: 20px; }
.summary-sec h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }

.sum-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sum-table th { text-align: left; padding: 6px 8px; font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; border-bottom: 1px solid var(--border); }
.sum-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.mono { font-family: 'Consolas', monospace; font-size: 11px; color: var(--text3); white-space: nowrap; }
.ctr { text-align: center; font-weight: 600; }
.rm { background: none; border: none; color: var(--red); font-size: 14px; cursor: pointer; padding: 2px 6px; border-radius: 3px; }
.rm:hover { background: rgba(217,69,69,0.15); }

.totals-bar {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--gold);
  border-radius: var(--r);
  display: flex;
  gap: 24px;
  font-size: 14px;
}

.empty-msg { text-align: center; color: var(--text3); padding: 40px; font-size: 14px; }

/* ===== BOTTOM BARS ===== */
.bot-bar {
  padding: 10px 20px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.btn-submit {
  padding: 10px 28px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-submit:hover { filter: brightness(1.1); }

.btn-sec {
  padding: 10px 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  font-size: 14px;
  cursor: pointer;
}
.btn-sec:hover { background: var(--bg4); }

.btn-sm {
  padding: 5px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
}
.btn-sm:hover { background: var(--bg4); }

/* ===== PRINT SUMMARY ===== */
.order-summary-print {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
}
.summary-header { text-align: center; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid var(--border); }
.summary-header h2 { font-size: 20px; }
.summary-meta { margin-top: 6px; display: flex; gap: 20px; justify-content: center; color: var(--text2); font-size: 13px; }
.summary-customer { margin-bottom: 20px; }
.customer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.summary-category { margin-bottom: 16px; }
.summary-category h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.summary-table th { text-align: left; padding: 5px 8px; font-size: 10px; font-weight: 600; color: var(--text3); border-bottom: 1px solid var(--border); }
.summary-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.sku-cell { font-family: monospace; font-size: 10px; color: var(--text3); }
.qty-cell { text-align: center; font-weight: 600; }
.summary-footer { margin-top: 20px; padding-top: 14px; border-top: 2px solid var(--border); text-align: center; }
.summary-footer p { margin-bottom: 6px; font-size: 14px; }
.summary-sig { margin-top: 20px; color: var(--text3); font-size: 13px; }

/* ===== SYNC STATUS ===== */
.sync-msg { margin-top: 16px; padding: 12px 16px; border-radius: var(--r); font-size: 13px; font-weight: 600; text-align: center; }
.sync-ok { background: rgba(76, 175, 80, 0.15); color: #81c784; border: 1px solid rgba(76, 175, 80, 0.3); }
.sync-pending { background: rgba(212, 168, 67, 0.15); color: var(--gold); border: 1px solid rgba(212, 168, 67, 0.3); }
.sync-fail { background: rgba(244, 67, 54, 0.15); color: #e57373; border: 1px solid rgba(244, 67, 54, 0.3); }
#new-order-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .cat-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    overflow-x: auto;
    padding: 4px;
    gap: 2px;
  }
  .nav-btn {
    flex-direction: column;
    padding: 6px 10px;
    font-size: 10px;
    min-width: max-content;
    gap: 3px;
  }
  .nav-icon { font-size: 18px; }
  .main-area { flex-direction: column; }
  .content-area { padding: 14px; }
  .swatch-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .fg { grid-template-columns: 1fr; }
  .customer-grid { grid-template-columns: 1fr; }
}

@media print {
  .top-bar, .cat-nav, .bot-bar { display: none; }
  .content-area { padding: 0; overflow: visible; }
  .order-summary-print { border: none; padding: 12px; }
  body { background: #fff; color: #000; }
  .summary-table td, .summary-table th { border-color: #ccc; }
}
