:root{--bg:#f3f4f6;--surface:#fff;--ink:#111827;--muted:#6b7280;--line:#e5e7eb;--accent:#111827;font-family:Inter,"Noto Sans TC","Microsoft JhengHei",system-ui,sans-serif}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);min-height:100vh}button,input,select,textarea{font:inherit}.app-header{display:flex;gap:12px;align-items:flex-start;padding:calc(20px + env(safe-area-inset-top)) 16px 22px;background:#111827;color:#fff}.app-header>div{width:min(920px,100%);margin:0 auto}.header-back{border:1px solid rgba(255,255,255,.35);background:transparent;color:#fff;border-radius:9px;padding:8px 10px}.eyebrow{margin:0 0 5px;font-size:11px;letter-spacing:.15em;opacity:.7}.eyebrow.dark{color:var(--muted)}h1,h2,h3,p{margin-top:0}.sync-status{margin:6px 0 0;font-size:12px;opacity:.8}.app-shell{width:min(920px,100%);margin:0 auto;padding:14px 12px calc(28px + env(safe-area-inset-bottom))}.home-menu{display:grid;gap:12px}.home-action{display:flex;justify-content:space-between;align-items:center;width:100%;padding:22px 18px;border:1px solid var(--line);border-radius:14px;background:#fff;text-align:left;font-weight:800}.count-badge{display:inline-flex;min-width:28px;height:28px;align-items:center;justify-content:center;border-radius:999px;background:#e5e7eb;font-size:13px}.search-panel,.update-panel,.session-panel,.simple-panel{padding:16px;border:1px solid var(--line);border-radius:14px;background:#fff}.search-panel label{display:block;margin-bottom:7px;font-weight:700}.search-row{display:grid;grid-template-columns:1fr auto;gap:8px}.search-row input,.form-field input,.form-field select,.form-field textarea{width:100%;padding:12px;border:1px solid var(--line);border-radius:10px;background:#f9fafb}.search-row button,.form-actions button[type=submit],.primary-wide{border:0;border-radius:10px;background:var(--accent);color:#fff;font-weight:800;padding:0 16px}.suggestions{margin-top:8px;border:1px solid var(--line);border-radius:10px;overflow:hidden}.suggestion{display:flex;justify-content:space-between;width:100%;padding:12px;border:0;border-bottom:1px solid var(--line);background:#fff;text-align:left}.suggestion:last-child{border-bottom:0}.empty-state{margin-top:14px;padding:34px 16px;border:1px dashed #cbd5e1;border-radius:14px;text-align:center;color:var(--muted)}.empty-state.compact{padding:25px 14px}.results{margin-top:14px}.card{overflow:hidden;border:1px solid var(--line);border-radius:14px;background:#fff}.card-head{padding:16px;background:#1f2937;color:#fff}.card-head h2{margin-bottom:5px}.meta{font-size:13px;opacity:.8}.section{padding:15px;border-top:1px solid var(--line)}.section h3{font-size:15px}.info-grid,.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.info .label,.form-field label{display:block;margin-bottom:4px;color:var(--muted);font-size:12px}.info .value{font-weight:650;overflow-wrap:anywhere}.full{grid-column:1/-1}.pills{display:flex;flex-wrap:wrap;gap:6px}.pill{padding:5px 8px;border-radius:999px;background:#e5e7eb;font-size:12px}.history-item{padding:10px 0;border-top:1px dashed var(--line)}.history-item:first-child{border-top:0}.history-date{font-weight:800}.history-detail{margin-top:4px;font-size:13px;line-height:1.5}.update-launch{width:100%;padding:13px;border:0;border-radius:10px;background:#374151;color:#fff;font-weight:800}.not-found,.match-button{padding:14px;border:1px solid var(--line);border-radius:12px;background:#fff}.match-list{display:grid;gap:8px}.match-button{text-align:left}.match-button strong,.match-button span{display:block}.match-button span{margin-top:4px;color:var(--muted);font-size:12px}.update-head,.session-head{display:flex;justify-content:space-between;align-items:flex-start}.form-section{padding-top:16px;margin-top:16px;border-top:1px solid var(--line)}.form-section:first-child{padding-top:0;margin-top:0;border-top:0}.form-field textarea{min-height:88px;resize:vertical}.form-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:18px}.form-actions button{padding:12px 16px;border-radius:10px;font-weight:800}.secondary-button{border:1px solid var(--line);background:#fff}.product-status{border:1px solid var(--line);border-radius:10px;overflow:hidden}.product-row{display:grid;grid-template-columns:minmax(128px,1.45fr) minmax(78px,.85fr) 46px 46px 46px;align-items:center;border-top:1px solid var(--line);min-height:44px}.product-row:first-child{border-top:0}.product-row>div,.status-cell{padding:8px;text-align:center}.product-name{text-align:left!important;font-size:13px}.product-header{background:#f3f4f6;font-size:12px;font-weight:800}.series-title{padding:9px 10px;background:#e5e7eb;font-weight:800;font-size:13px}.status-cell input{width:20px;height:20px;margin:0}.status-cell span{display:none}.form-help{margin:8px 0 0;color:var(--muted);font-size:12px}.session-list{display:grid;gap:10px}.session-item{display:flex;justify-content:space-between;gap:10px;padding:13px;border:1px solid var(--line);border-radius:10px}.session-item h3{margin-bottom:4px;font-size:16px}.session-item p{margin:0;color:var(--muted);font-size:12px}.session-actions{display:flex;gap:6px;align-items:center}.session-actions button{padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:#fff}.primary-wide{width:100%;margin-top:14px;padding:14px}.primary-wide:disabled{opacity:.4}.simple-panel p{line-height:1.5}@media(max-width:560px){.info-grid,.form-grid{grid-template-columns:1fr}.full{grid-column:auto}.product-row{grid-template-columns:minmax(108px,1.45fr) minmax(72px,.85fr) 42px 42px 42px}.session-item{align-items:flex-start;flex-direction:column}.form-actions{flex-direction:column-reverse}.form-actions button{width:100%}}

.not-found p{margin:8px 0 14px;color:var(--muted);font-size:13px;line-height:1.5}
.add-cvs-button{width:100%;padding:12px 14px;border:0;border-radius:10px;background:#374151;color:#fff;font-weight:800}

/* SVMS｜現場品項狀況：提示＋底部即時統計 */
.product-status-help{
  margin:0 0 10px;
  color:var(--muted);
  font-size:12px;
  line-height:1.5;
}

.product-status-summary{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:nowrap;
  gap:10px;
  margin-top:10px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#f9fafb;
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

.product-status-summary .summary-title{
  color:var(--ink);
  font-weight:800;
}

.product-status-summary .summary-separator{
  color:#9ca3af;
  font-weight:400;
}

.product-status-summary .summary-display{
  color:#059669;
}

.product-status-summary .summary-distribution{
  color:#2563eb;
}

.product-status-summary .summary-out{
  color:#ea580c;
}

.product-status-summary strong{
  font-size:15px;
}

@media(max-width:560px){
  .product-status-summary{
    justify-content:flex-start;
    gap:7px;
    padding:9px 10px;
    font-size:12px;
  }
  .product-status-summary strong{
    font-size:14px;
  }
}


/* SVMS GT 品項參考欄位：總表目前狀態 + 最新巡店紀錄 */
.product-reference-note{display:flex;flex-wrap:wrap;gap:6px 12px;margin:0 0 10px;padding:8px 10px;border:1px solid var(--line);border-radius:10px;background:#f9fafb;color:var(--muted);font-size:11px;line-height:1.45}
.reference-cell{display:flex;justify-content:center;align-items:center;padding:6px 3px!important;min-width:0}
.reference-badge{display:inline-flex;align-items:center;justify-content:center;gap:3px;max-width:100%;padding:4px 6px;border-radius:7px;font-size:11px;font-weight:800;white-space:nowrap}
.reference-mark{display:inline-flex;width:17px;height:17px;align-items:center;justify-content:center;border:1px solid currentColor;border-radius:999px;font-size:10px;line-height:1}
.reference-display{background:#ecfdf5;color:#16a34a}.reference-distribution{background:#eff6ff;color:#2563eb}.reference-none{background:#f3f4f6;color:#6b7280}
.product-header>div{line-height:1.25}
@media(max-width:560px){
  .product-status{
    overflow:visible;
  }
  .product-row{
    min-width:0;
    grid-template-columns:minmax(104px,1.5fr) minmax(68px,.82fr) 40px 40px 40px;
    min-height:40px;
  }
  .product-row>div,
  .status-cell{
    padding:5px 2px;
  }
  .product-name{
    position:static;
    background:#fff;
    font-size:12px;
    line-height:1.25;
    overflow-wrap:anywhere;
  }
  .product-header>div:first-child{
    background:#f3f4f6;
  }
  .product-header{
    font-size:10px;
  }
  .reference-badge{
    padding:3px 4px;
    gap:2px;
    font-size:9px;
    border-radius:6px;
  }
  .reference-mark{
    width:14px;
    height:14px;
    font-size:8px;
  }
  .status-cell input{
    width:18px;
    height:18px;
  }
  .series-title{
    padding:7px 8px;
    font-size:12px;
  }
}


/* SVMS Mobile：缺貨原屬對齊 + 品項欄位標題置頂 */
.osd-origin{
  font-size:12px;
  line-height:1.4;
}

.osd-origin > span{
  font-size:12px;
  font-weight:700!important;
}

.osd-origin label{
  display:inline-flex;
  align-items:center;
  gap:4px;
  font-size:12px;
  line-height:1.4;
}

.osd-origin input[type="radio"]{
  width:18px;
  height:18px;
  margin:0;
  vertical-align:middle;
}

.product-header{
  position:sticky;
  top:0;
  z-index:8;
  box-shadow:0 1px 0 var(--line);
}

.product-header > div{
  background:#f3f4f6;
}

@media(max-width:560px){
  .osd-origin{
    padding:7px 8px!important;
    font-size:12px;
  }

  .osd-origin > span,
  .osd-origin label{
    font-size:12px;
  }

  .osd-origin input[type="radio"]{
    width:18px;
    height:18px;
  }

  .product-header{
    position:sticky;
    top:0;
    z-index:8;
  }
}


/* SVMS Mobile Sticky Header Fix */
.product-status{
  overflow:visible!important;
}

.product-header{
  position:sticky!important;
  top:0!important;
  z-index:30!important;
  background:#f3f4f6!important;
  box-shadow:0 2px 4px rgba(17,24,39,.10);
}

.product-header > div{
  background:#f3f4f6!important;
}

@media(max-width:560px){
  .product-status{
    overflow:visible!important;
  }

  .product-header{
    position:sticky!important;
    top:0!important;
    z-index:30!important;
  }
}
/* Distributor edition */
.distributor-products .product-row{grid-template-columns:minmax(0,1fr) 74px 74px}
.distributor-products .product-header{grid-template-columns:minmax(0,1fr) 74px 74px}
