:root {
  --ink: #12212e;
  --sub: #5c6b78;
  --line: #dce4ea;
  --bg: #eaeef1;
  --card: #ffffff;
  --brand: #0e7f63;      /* teal-green: ยอดขาย / net */
  --brand-dk: #0a5d48;
  --brand-tint: #e6f3ef;
  --amber: #b9761a;      /* ส่งคืน */
  --amber-tint: #fbf1e2;
  --red: #a93a33;        /* จัดส่งไม่สำเร็จ */
  --indigo: #23324a;     /* structural header */
  --shadow: 0 1px 2px rgba(18,33,46,.06), 0 8px 24px rgba(18,33,46,.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans Thai","IBM Plex Sans Thai","Sarabun",system-ui,-apple-system,"Segoe UI",sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 100% -10%, #f3f7f5 0, transparent 60%),
    var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--indigo);
  color: #eaf1ef;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 6px 18px rgba(18,33,46,.18);
}
.brandmark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--brand) 0, var(--brand-dk) 100%);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.brandmark svg { width: 20px; height: 20px; }
.topbar h1 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.topbar .tag { font-size: 12px; color: #a9bcc0; font-weight: 500; }
.topbar .spacer { flex: 1; }
.badge-offline {
  font-size: 11.5px; color: #bfe6d8; border: 1px solid rgba(120,200,175,.35);
  padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
}
.badge-offline i { width: 6px; height: 6px; border-radius: 50%; background: #35d0a0; display: inline-block; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* ---------- dropzone ---------- */
.slip {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.drop {
  padding: 40px 28px; text-align: center; cursor: pointer;
  border: 2px dashed #c4d2cd; border-radius: var(--radius); margin: 14px;
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(14,127,99,.04) 22px 23px);
  transition: border-color .15s, background .15s;
}
.drop:hover { border-color: var(--brand); }
.drop.drag { border-color: var(--brand); background: var(--brand-tint); }
.drop .big { font-size: 17px; font-weight: 700; margin: 10px 0 4px; }
.drop .small { font-size: 13px; color: var(--sub); }
.drop .icon {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 14px;
  background: var(--brand-tint); color: var(--brand);
  display: grid; place-items: center;
}
.drop .icon svg { width: 28px; height: 28px; }
.pickbtn {
  margin-top: 16px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 2px 0 var(--brand-dk);
}
.pickbtn:hover { background: var(--brand-dk); }
.filemeta { padding: 0 26px 16px; font-size: 13px; color: var(--sub); display: none; }
.filemeta.show { display: block; }
.filemeta b { color: var(--ink); }

.hint { font-size: 12.5px; color: var(--sub); padding: 0 26px 18px; }
.hint code {
  background: #f1f4f3; padding: 1px 6px; border-radius: 5px; font-size: 12px;
  color: var(--brand-dk);
}

/* ---------- error ---------- */
.err {
  display: none; margin: 14px 26px 22px; padding: 12px 14px;
  background: #fdeeec; border: 1px solid #f2c7c1; color: #8f2f28;
  border-radius: 10px; font-size: 13.5px;
}
.err.show { display: block; }

/* ---------- results ---------- */
#results { display: none; margin-top: 22px; }
#results.show { display: block; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.kpi.amber::before { background: var(--amber); }
.kpi.ink::before { background: var(--indigo); }
.kpi .label { font-size: 12.5px; color: var(--sub); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.kpi .value .baht { font-size: 14px; font-weight: 600; color: var(--sub); margin-left: 3px; }
.kpi .foot { font-size: 12px; color: var(--sub); margin-top: 3px; }
.kpi .foot.pos { color: var(--brand); } .kpi .foot.neg { color: var(--amber); }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px;
}
.panel > h2 {
  margin: 0; font-size: 14px; font-weight: 700; padding: 14px 18px;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
}
.panel > h2 .muted { font-weight: 500; color: var(--sub); font-size: 12.5px; }

/* status summary */
.statusgrid { display: grid; grid-template-columns: repeat(3,1fr); gap: 0; }
.statuscell { padding: 16px 18px; border-right: 1px solid var(--line); }
.statuscell:last-child { border-right: 0; }
.statuscell .st { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--brand); } .dot.ret { background: var(--amber); } .dot.fail { background: var(--red); }
.statuscell .big { font-size: 20px; font-weight: 800; margin-top: 6px; }
.statuscell .sub { font-size: 12.5px; color: var(--sub); margin-top: 2px; }

/* toolbar over table */
.tablebar { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: inline-flex; background: #eef2f1; border-radius: 9px; padding: 3px; }
.tab { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 13px;
  color: var(--sub); padding: 7px 14px; border-radius: 7px; cursor: pointer; }
.tab.active { background: #fff; color: var(--brand-dk); box-shadow: var(--shadow); }
.search { flex: 1; min-width: 180px; }
.search input {
  width: 100%; font: inherit; font-size: 13.5px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfdfc;
}
.search input:focus { outline: 2px solid var(--brand-tint); border-color: var(--brand); }
.dl {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 700; font-size: 13px;
  background: var(--indigo); color: #fff; border: 0; cursor: pointer; padding: 9px 15px; border-radius: 9px;
}
.dl:hover { background: #16283d; }
.dl.ghost { background: #fff; color: var(--brand-dk); border: 1px solid var(--brand); }
.dl.ghost:hover { background: var(--brand-tint); }
.dl.ghost svg { color: var(--brand-dk); }
.barhint { font-size: 12px; color: var(--sub); margin-left: auto; }
.dl svg { width: 15px; height: 15px; }

/* table */
.tablescroll { overflow: auto; max-height: 62vh; }
table.recon { border-collapse: collapse; width: 100%; font-size: 13px; }
table.recon thead th {
  position: sticky; top: 0; z-index: 2; background: #f3f6f5; color: var(--indigo);
  font-weight: 700; text-align: right; padding: 10px 12px; border-bottom: 2px solid var(--line);
  white-space: nowrap; cursor: pointer; user-select: none;
}
table.recon thead th.l { text-align: left; }
table.recon thead th .ar { color: var(--brand); font-size: 10px; margin-left: 3px; }
table.recon tbody td { padding: 9px 12px; border-bottom: 1px solid #eef2f1; text-align: right; white-space: nowrap; }
table.recon tbody td.l { text-align: left; }
table.recon tbody tr:nth-child(even) { background: #fafcfb; }
table.recon tbody tr:hover { background: var(--brand-tint); }
.rank { color: var(--sub); font-variant-numeric: tabular-nums; width: 34px; }
.who .nick { font-weight: 700; }
.who .email { color: var(--sub); font-size: 11.5px; }
.total-col { font-weight: 800; color: var(--brand-dk); }
.muted-num { color: var(--sub); }
.retpct { font-weight: 700; }
.retpct.hi { color: var(--red); } .retpct.mid { color: var(--amber); } .retpct.lo { color: var(--brand); }
.ratepill { display: inline-block; min-width: 34px; padding: 1px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.ratepill.r2 { background: #eef2f1; color: #5c6b78; }
.ratepill.r4 { background: #e6f3ef; color: var(--brand-dk); }
.ratepill.r5 { background: #dcefe7; color: var(--brand-dk); }
.ratepill.r6 { background: var(--brand); color: #fff; }
tfoot td { padding: 11px 12px; font-weight: 800; background: var(--indigo); color: #fff; text-align: right; position: sticky; bottom: 0; }
tfoot td.l { text-align: left; }

.footnote { font-size: 12px; color: var(--sub); padding: 12px 18px; border-top: 1px solid var(--line); background: #fbfdfc; }
.footnote b { color: var(--ink); }

.credit { text-align: center; color: #93a3ab; font-size: 12px; padding: 8px 0 28px; }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2,1fr); }
  .statusgrid { grid-template-columns: 1fr; }
  .statuscell { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* Import diagnostics stay visible alongside all-status totals. */
.importwarning { margin: 14px 0; padding: 14px 18px; border: 1px solid #e4b351; border-radius: 10px; background: #fff7df; color: #6b4600; line-height: 1.7; overflow-wrap: anywhere; }
.importwarning[hidden] { display: none; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Website workspace */
.brandtitle { font-size: 17px; font-weight: 750; }
.topbar { padding-left: max(24px, calc((100vw - 1132px) / 2)); padding-right: max(24px, calc((100vw - 1132px) / 2)); }
body { background: #f1f5f3; }
.workspace-intro { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; padding: 24px 2px 32px; }
.eyebrow { font-size: 12px; font-weight: 650; color: var(--brand); letter-spacing: .7px; margin-bottom: 12px; }
.workspace-intro h1 { font-size: clamp(28px, 3.5vw, 42px); line-height: 1.35; letter-spacing: -.7px; margin: 0; }
.workspace-intro h1 span { color: var(--brand); }
.workspace-intro p { font-size: 14px; color: var(--sub); line-height: 1.8; margin-bottom: 0; }
.workflow-steps { list-style: none; padding: 24px; margin: 0; border: 1px solid #dce7e1; border-radius: 16px; background: #e8f0ec; display: grid; gap: 20px; }
.workflow-steps li { display: flex; align-items: center; gap: 14px; }
.workflow-steps li > span { font-size: 12px; font-weight: 750; background: white; color: var(--brand); border: 1px solid #d4e5db; border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0; }
.workflow-steps b { font-size: 14px; font-weight: 650; display: block; }
.workflow-steps small { font-size: 12px; color: var(--sub); }
.drop { background: #fbfdfc; padding: 30px 24px; }
.samplebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 20px; padding: 0 20px 20px; }
.samplebar > span { font-size: 12px; color: var(--sub); }
.textbtn { font: inherit; font-size: 12px; font-weight: 650; border: 0; background: transparent; color: var(--brand); cursor: pointer; padding: 5px 0; }
.textbtn.secondary { color: var(--sub); text-decoration: underline; text-underline-offset: 4px; }
.textbtn:hover { color: var(--brand-dk); }
button:focus-visible, .drop:focus-visible { outline: 3px solid #80c9b3; outline-offset: 3px; }
.demo-notice { padding: 12px 16px; color: #1c5d4d; border: 1px solid #b7dacc; background: #e3f3eb; font-size: 13px; border-radius: 10px; margin-bottom: 18px; }
.demo-notice[hidden] { display: none; }
.credit { font-size: 11px; letter-spacing: .1px; margin-top: 28px; }
.credit span { padding: 0 7px; }
@media (max-width: 700px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .badge-offline { display: none; }
  .wrap { padding: 16px; }
  .workspace-intro { grid-template-columns: 1fr; gap: 22px; padding-top: 12px; padding-bottom: 24px; }
  .workflow-steps { padding: 18px; gap: 14px; }
  .desktop-break { display: none; }
  .panel > h2 { flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 12px; }
  .kpi .value { font-size: 21px; }
  .statusgrid { grid-template-columns: 1fr; }
  .statuscell { border-right: 0; border-bottom: 1px solid var(--line); }
  .statuscell:last-child { border-bottom: 0; }
  .samplebar > span { width: 100%; text-align: center; }
  .tablebar { gap: 10px; padding: 12px; }
  .tablebar .search { flex-basis: 100%; }
  .dl { flex-grow: 1; justify-content: center; }
  .credit { line-height: 1.8; }
}
