:root {
  --g: #2d6a4f; --g-light: #d8f3dc; --g-hover: #1b4332;
  --bg: #f4f6f4; --card: #ffffff; --text: #212529; --hint: #6c757d;
  --bd: #dee2e6; --danger: #e63946;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
header { background: var(--g); color: #fff; padding: 12px 20px; position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
header b { font-size: 20px; }
nav { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; }
nav button { background: rgba(255,255,255,0.15); color: #fff; border: 0; padding: 8px 14px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
nav button.on { background: #fff; color: var(--g); font-weight: 600; }
nav button.out { background: rgba(230,57,70,0.3); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.card { background: var(--card); border: 1px solid var(--bd); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
h2, h3 { margin: 0 0 12px; color: #1b4332; }
label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 8px; }
label input, label select, label textarea { margin-top: 3px; color: var(--text); font-size: 15px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--bd); border-radius: 8px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g); box-shadow: 0 0 0 3px rgba(45,106,79,0.1); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.row > * { flex: 1 1 150px; }
.row > .btn.fit { flex: 0 0 auto; }
.btn { background: var(--g); color: #fff; border: 0; padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--g-hover); }
.btn.ghost { background: #fff; color: var(--g); border: 1px solid var(--g); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.hint { color: var(--hint); font-size: 13px; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: #2d6a4f; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; } }
.plant { display: flex; flex-direction: column; gap: 4px; padding: 14px; margin: 0; cursor: pointer; }
.plant:hover { border-color: var(--g); }
.ph { display: flex; align-items: center; justify-content: center; font-size: 36px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.st-available { background: #d8f3dc; color: #1b4332; }
.st-reserved { background: #fff3d6; color: #bc6c25; }
.st-pending_ship { background: #e0fbfc; color: #0077b6; }
.st-sold { background: #e9ecef; color: #6c757d; }
.st-sick { background: #f8d7da; color: #721c24; }
.st-mother { background: #e2eafc; color: #3f37c9; }
.st-propagating { background: #e8f4f8; color: #2a9d8f; }
select.st { font-weight: 600; margin-top: 4px; }
select.st.st-available { border-color: var(--g); }
select.st.st-reserved { border-color: #e9c46a; }
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(520px, 94vw); max-height: 92vh; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }
dialog::backdrop { background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #212529; color: #fff; padding: 10px 20px; border-radius: 10px; opacity: 0; transition: all 0.25s; z-index: 99; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2d6a4f, #1b4332); padding: 16px; }
.login .card { width: min(360px, 100%); padding: 24px; margin: 0; }
.preview { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: var(--g-light); margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--bd); font-size: 14px; vertical-align: middle; }
th { color: var(--hint); font-weight: 600; font-size: 13px; }
td.r, th.r { text-align: right; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats .card { margin: 0; text-align: center; }
.stats b { font-size: 22px; color: var(--g); display: block; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.pick { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--bd); cursor: pointer; margin: 0; color: var(--text); font-size: 14px; }
.pick input { width: auto; margin: 0; }
.pick-list { max-height: 360px; overflow: auto; border: 1px solid var(--bd); border-radius: 8px; padding: 0 8px; }
@media print {
  @page { margin: 8mm; }
  body { background: #fff; }
  header, .noprint, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; box-shadow: none; }
  }

/* ---------- รูปการ์ด + แอนิเมชัน ---------- */
:root { --ease: cubic-bezier(.22,.8,.3,1); }
.plant .imgw { overflow: hidden; border-radius: 8px; aspect-ratio: 1; background: var(--g-light); margin-bottom: 4px; }
.plant .img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.04); transition: opacity .5s ease, transform .7s var(--ease); }
.plant .img.ok { opacity: 1; transform: none; }
.plant:hover .img.ok { transform: scale(1.06); }
.plant { transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .2s; }
.plant:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(27,67,50,.12); }
.plant .ph { opacity: 1; transform: none; display: flex; align-items: center; justify-content: center; font-size: 36px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes sway { 0%,100% { rotate: -5deg; } 50% { rotate: 5deg; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
main.swap { animation: fade .35s ease both; }
.grid.enter .plant { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
.skel { border-radius: 12px; aspect-ratio: 3/4; background: linear-gradient(100deg, #e9eee9 30%, #f6f9f6 50%, #e9eee9 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
dialog[open] { animation: pop .3s var(--ease); }
dialog[open]::backdrop { animation: fade .25s ease; }
.btn { transition: background .2s, transform .15s var(--ease), box-shadow .25s; }
.btn:active { transform: scale(.97); }
nav button, nav a { transition: background .2s, color .2s; }
nav .navlink { background: rgba(255,255,255,.15); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; }
nav .navlink:hover { background: rgba(255,255,255,.28); }
.login { position: relative; overflow: hidden; }
.login .card { position: relative; z-index: 1; animation: rise .6s var(--ease) both; }
.lf { position: absolute; bottom: -30px; fill: rgba(255,255,255,.09); transform-origin: 50% 100%; pointer-events: none; }
.lf1 { left: -20px; width: 240px; height: 280px; animation: sway 8s ease-in-out infinite; }
.lf2 { right: -20px; width: 200px; height: 240px; animation: sway 9s -4s ease-in-out infinite reverse; }

/* ---------- สแกน / ตัดสต๊อก ---------- */
.reader-wrap { margin: 4px 0 12px; padding: 12px; border: 1px solid var(--bd); border-radius: 12px; background: #fafcfa; animation: rise .35s var(--ease) both; }
#reader { width: 100%; max-width: 480px; margin: 0 auto; border-radius: 10px; overflow: hidden; }
#reader video { border-radius: 10px; }
.found { animation: rise .35s var(--ease) both; }
.done { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 14px 16px; background: var(--g-light); border-radius: 12px; animation: rise .4s var(--ease) both; }
.done svg path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw .5s .15s ease forwards; }
.done svg circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s ease forwards; }

/* ---------- ป้าย QR-only แนวนอน: QR + รหัส + ชื่อ + แบรนด์ ---------- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .plant .img { opacity: 1; transform: none; } }

.plant { height: 100%; }
.plant select.st { margin-top: auto; }
.plant .hint { margin-bottom: 4px; }

/* ---------- ป้ายแนวนอน 15mm: QR ซ้าย, รหัสบน, ชื่อกลาง, แบรนด์ขวาล่าง ---------- */
.labels { --lw: 75mm; --lh: 15mm; --s: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.label { position:relative; width:var(--lw); height:var(--lh); border:1px dashed #999; border-radius:4px; padding:1mm; background:#fff; overflow:hidden; break-inside:avoid;
  display:grid; grid-template-columns:var(--qr) minmax(0,1fr); grid-template-rows:minmax(0,1fr); gap:0 2mm; }
.label .qr { grid-column:1; grid-row:1; align-self:center; width:var(--qr); height:var(--qr); object-fit:contain; }
.label .tx { grid-column:2; grid-row:1; display:flex; flex-direction:column; justify-content:space-between; min-width:0; padding:0 0 2.8mm; }
.label .lc { font-family:ui-monospace,Consolas,monospace; font-weight:800; font-size:8pt; line-height:1.05; white-space:nowrap; }
.label .ln { font-size:8.5pt; line-height:1.1; max-height:2.2em; overflow:hidden; }
.label .label-brand { grid-column:2; grid-row:1; align-self:end; justify-self:end; max-width:100%; overflow:hidden; font-size:6.2pt; font-weight:600; line-height:1; white-space:nowrap; }
.label .lp { font-size:8pt; font-weight:700; }
.label .bc { grid-column:1 / -1; width:100%; height:100%; min-height:0; }
.inl { display: flex; gap: 6px; align-items: center; } .inl input { width: 90px; }

/* ---------- ชิปสรุปสถานะ ---------- */
.sumchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.sc { border: 1px solid var(--bd); background: #fff; color: var(--text); padding: 5px 14px; border-radius: 99px; font: inherit; font-size: 14px; cursor: pointer; transition: all .2s var(--ease); }
.sc:hover { border-color: var(--g); }
.sc b { margin-left: 4px; }
.sc.on { background: var(--g); border-color: var(--g); color: #fff; box-shadow: 0 3px 10px rgba(45,106,79,.25); }
.sc.st-available:not(.on) { background: #d8f3dc; border-color: #b7e4c7; } .sc.st-reserved:not(.on) { background: #fff3d6; border-color: #f1dfa8; }
.sc.st-pending_ship:not(.on) { background: #e0fbfc; border-color: #bde5ea; } .sc.st-sold:not(.on) { background: #e9ecef; }
.sc.st-sick:not(.on) { background: #f8d7da; border-color: #efb9bf; } .sc.st-mother:not(.on) { background: #e2eafc; border-color: #c5d3f5; } .sc.st-propagating:not(.on) { background: #e8f4f8; }

/* ---------- ข้อความแจ้งเตือน/สำเร็จ ---------- */
.okbar { background: var(--g-light); color: var(--g-hover); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; animation: rise .35s var(--ease) both; }
.okbar a { color: var(--g); font-weight: 600; }
.warnbox { background: #fff3d6; color: #8a4b0f; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; margin-top: 8px; }
.hint.bad { color: var(--danger); font-weight: 600; } .hint.good { color: var(--g); }
button:disabled { opacity: .5; cursor: not-allowed; }
.hist { max-height: 220px; overflow: auto; margin-top: 8px; font-size: 13.5px; display: grid; gap: 8px; }
.hist > div { padding: 6px 0; border-bottom: 1px solid var(--bd); }
#toast.act { pointer-events: auto; }
#toast button { margin-left: 12px; background: transparent; border: 1px solid rgba(255,255,255,.7); color: #fff; border-radius: 6px; padding: 2px 12px; font: inherit; cursor: pointer; }
#toast button:hover { background: rgba(255,255,255,.15); }
dialog #toast { position: fixed; }

/* ---------- ยอดขายรายเดือน ---------- */
.mrow { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 8px 10px; border-radius: 10px; font: inherit; color: inherit; cursor: pointer; transition: background .2s, border-color .2s; }
.mrow:hover { background: #f4f8f5; } .mrow.on { background: var(--g-light); border-color: var(--g); }
.mbar { height: 10px; background: #edf1ed; border-radius: 99px; overflow: hidden; } .mbar i { display: block; height: 100%; background: linear-gradient(90deg, #52b788, var(--g)); border-radius: 99px; animation: grow .7s var(--ease) both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } to { transform: none; } }
.mval { text-align: right; white-space: nowrap; }
@media (max-width: 600px) { .mrow { grid-template-columns: 1fr auto; } .mbar { grid-column: 1 / -1; order: 3; } header b { font-size: 18px; } nav button, nav .navlink { padding: 7px 10px; font-size: 13px; } main { padding: 14px 10px; } }
@media print { .sumchips, .okbar { display: none !important; } }

@media print { .noprint, nav, header { display: none !important; } }

/* ---------- เมนูใหม่ + รายการพันธุ์/หมวดหมู่ ---------- */
header { gap: 12px; flex-wrap: nowrap; }
header b { margin-right: auto; white-space: nowrap; }
.ic, .ts { display: none; }
.hright { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.hright .navlink, .hright .out { background: rgba(255,255,255,.15); color: #fff; border: 0; padding: 8px 14px; border-radius: 8px; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .2s; }
.hright .out { background: rgba(230,57,70,.3); }
.hright .navlink:hover { background: rgba(255,255,255,.28); }
.stack { display: grid; gap: 16px; }
.stack > .card { margin: 0; }
.field { display: block; margin-bottom: 12px; }
.codein { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; font-size: 20px; max-width: 160px; }
.addbox { background: #f8faf8; border: 1px solid var(--bd); border-radius: 12px; padding: 14px; }
.lrow { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--bd); }
.lrow.cat { grid-template-columns: 1fr auto; }
.lrow .scode { font-family: ui-monospace, Consolas, monospace; font-weight: 800; font-size: 18px; letter-spacing: 1px; background: var(--g-light); color: var(--g-hover); padding: 6px 12px; border-radius: 8px; }
.lrow .acts { display: flex; gap: 6px; justify-content: flex-end; }
.btnbar { margin: 12px 0 0; position: sticky; bottom: -1px; background: #fff; padding: 10px 0 2px; z-index: 2; }
.btn.danger:disabled { border-color: var(--bd); color: var(--hint); background: #f4f4f4; }

/* ---------- มือถือ: แท็บล่าง, ป๊อปอัพแบบแผ่นล่าง, ปุ่ม/ช่องกรอกนิ้วกดง่าย ---------- */
@keyframes sheet { from { transform: translateY(50px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 700px) {
  header { padding: 10px 14px; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-width: none; background: #fff; border-top: 1px solid var(--bd); box-shadow: 0 -4px 16px rgba(0,0,0,.07);
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); overflow: visible; }
  nav button { background: transparent; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; font-size: 11.5px; }
  nav button.on { background: var(--g-light); color: var(--g-hover); font-weight: 700; }
  .ic { display: block; font-size: 21px; line-height: 1.1; } .ts { display: block; } .tl { display: none; }
  .hright .navlink, .hright .out { padding: 6px 10px; font-size: 13px; }
  main { padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(86px + env(safe-area-inset-bottom)); max-width: 92vw; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0 0; border-radius: 22px 22px 0 0; max-height: 94vh; padding: 16px 16px calc(14px + env(safe-area-inset-bottom)); }
  dialog[open] { animation: sheet .32s var(--ease); }
  input:not([type=checkbox]):not([type=file]), select, textarea { font-size: 16px; min-height: 46px; }
  .btn { min-height: 46px; } .btn.sm { min-height: 38px; padding: 6px 14px; }
  .row > * { flex: 1 1 100%; } .row > .btn.fit { flex: 1 1 100%; }
  .lrow { grid-template-columns: auto 1fr; } .lrow.cat { grid-template-columns: 1fr; }
  .lrow .acts { grid-column: 1 / -1; } .lrow .acts .btn { flex: 1; }
  .grid { gap: 10px; } .plant { padding: 10px; }
  .stats { grid-template-columns: 1fr; } .stats .card { padding: 12px; }
  .mrow { grid-template-columns: 1fr auto; } .mbar { grid-column: 1 / -1; order: 3; }
  th, td { padding: 8px 4px; font-size: 13px; }
  .reader-wrap { padding: 8px; }
  .labels { justify-content: center; }
}
@media print { .hright { display: none !important; } }

/* ป้ายชื่อช่องอยู่บน ช่องกรอกอยู่ล่าง เต็มความกว้าง + สีข้อความตรวจรหัส */
.field > input, .field > select, .field > textarea { display: block; margin-top: 5px; }
.field > .codein { width: 100%; max-width: 100%; }
.good { color: var(--g); font-size: 13.5px; font-weight: 600; }
.bad { color: var(--danger); font-size: 13.5px; font-weight: 600; }

@media (max-width: 700px) { .filters > * { flex: 1 1 calc(50% - 6px); min-width: 0; } .filters #fst { display: none; } }
@media (max-width: 700px) { .btnbar > * { flex: 1 1 calc(50% - 6px); } .btnbar > [data-more] { flex-basis: 100%; } }


/* ---------- Catalog: แผงพันธุ์/หมวดหมู่/ตั้งค่าที่เลื่อนแยกกัน ---------- */
.catalog-scene {
  --catalog-ink: #244c39;
  position: relative;
  isolation: isolate;
  padding: clamp(10px, 2vw, 22px);
  border: 1px solid rgba(45, 106, 79, .12);
  border-radius: 24px;
  overflow: hidden;
  background: #e9f1e8;
}
.catalog-scene::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -3%;
  background-image: linear-gradient(120deg, rgba(247, 251, 245, .50), rgba(241, 247, 239, .70)), url('../catalog-botanical-bg.webp');
  background-size: cover;
  background-position: center;
  animation: catalog-drift 28s ease-in-out infinite alternate;
}
.catalog-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.catalog-layout > .catalog-panel { margin: 0; }
.catalog-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 360px;
  max-height: 70vh;
  overflow: hidden;
  padding: clamp(14px, 1.8vw, 20px);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 20px;
  background: rgba(255, 255, 255, .90);
  box-shadow: 0 12px 36px rgba(32, 76, 51, .10), inset 0 1px 0 rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  animation: catalog-arrive .55s var(--ease) both;
}
.catalog-categories { animation-delay: 80ms; }
.catalog-settings { animation-delay: 150ms; }
.catalog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.catalog-heading > div { display: flex; align-items: center; gap: 11px; min-width: 0; }
.catalog-heading h3 { margin: 0 0 2px; color: var(--catalog-ink); font-size: 18px; }
.catalog-heading .hint { line-height: 1.35; }
.catalog-icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, #eff8ed, #d9edde);
  box-shadow: inset 0 0 0 1px rgba(45, 106, 79, .08);
  font-size: 21px;
  animation: catalog-bob 5s ease-in-out infinite;
}
.catalog-categories .catalog-icon { animation-delay: -1.7s; }
.catalog-settings .catalog-icon { animation-delay: -3.2s; }
.catalog-count { flex: 0 0 auto; padding: 5px 10px; border: 1px solid #d7e8d8; border-radius: 99px; background: #f3f8f1; color: #37664a; font-size: 12px; font-weight: 700; }
.catalog-preview { flex: 0 0 auto; color: var(--g); font-size: 13px; text-decoration: none; white-space: nowrap; }
.catalog-preview:hover { text-decoration: underline; }
.catalog-panel .addbox { flex: 0 0 auto; background: rgba(247, 250, 247, .92); border-color: #e1eae1; }
.catalog-panel .field { color: #53665a; }
.catalog-note { flex: 0 0 auto; margin: 12px 2px 8px; color: #607365; font-size: 12.5px; line-height: 1.55; }
.catalog-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #91b89a rgba(225, 237, 225, .58);
  scrollbar-gutter: stable;
  border: 1px solid rgba(209, 225, 210, .7);
  border-radius: 13px;
  background: rgba(255,255,255,.42);
  padding: 0 10px;
  -webkit-overflow-scrolling: touch;
}
.catalog-scroll:focus-visible { outline: 3px solid rgba(45, 106, 79, .28); outline-offset: 2px; }
.catalog-scroll::-webkit-scrollbar { width: 9px; }
.catalog-scroll::-webkit-scrollbar-track { border-radius: 99px; background: rgba(225, 237, 225, .62); }
.catalog-scroll::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 99px; background: #91b89a; background-clip: padding-box; }
.catalog-scroll .lrow { animation: catalog-row-in .38s var(--ease) both; }
.catalog-scroll .lrow:nth-child(2) { animation-delay: 25ms; }
.catalog-scroll .lrow:nth-child(3) { animation-delay: 50ms; }
.catalog-scroll .lrow:nth-child(4) { animation-delay: 75ms; }
.catalog-scroll .lrow:nth-child(5) { animation-delay: 100ms; }
.catalog-scroll .lrow:last-child { border-bottom: 0; }
.catalog-scroll .lrow:hover { background: rgba(235, 245, 235, .68); }
.catalog-scroll .lrow .acts .btn { white-space: nowrap; }
.catalog-empty { padding: 18px 8px; color: #718477; }
.settings-scroll { padding: 14px; }
.settings-scroll form { display: grid; gap: 3px; }
.settings-scroll .btn { margin-top: 4px; }

@keyframes catalog-arrive { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes catalog-row-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes catalog-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
@keyframes catalog-drift { from { transform: scale(1) translate3d(-.4%, 0, 0); } to { transform: scale(1.045) translate3d(.4%, -.3%, 0); } }

@media (min-width: 820px) {
  .catalog-layout {
    height: min(80svh, 920px);
    min-height: 640px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
  }
  .catalog-species { grid-row: 1 / span 2; }
  .catalog-panel { height: 100%; min-height: 0; max-height: none; }
  .species-scroll, .category-scroll, .settings-scroll { max-height: none; }
}
@media (max-width: 819px) {
  .catalog-panel { min-height: 0; max-height: 68svh; }
  .species-scroll { min-height: 120px; }
  .category-scroll { min-height: 110px; }
  .settings-scroll { min-height: 150px; }
}
@media (max-width: 700px) {
  .catalog-scene { padding: 8px; border-radius: 19px; }
  .catalog-layout { gap: 12px; }
  .catalog-panel { padding: 13px; border-radius: 17px; }
  .catalog-species { max-height: 74svh; }
  .catalog-categories { max-height: 62svh; }
  .catalog-settings { max-height: 66svh; }
  .catalog-heading { margin-bottom: 10px; }
  .catalog-heading h3 { font-size: 17px; }
  .catalog-icon { flex-basis: 38px; width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }
  .catalog-count { font-size: 11px; padding: 4px 8px; }
  .catalog-note { margin: 9px 2px 7px; font-size: 12px; }
  .catalog-scroll { padding-right: 6px; padding-left: 7px; scrollbar-gutter: auto; }
  .catalog-scroll .lrow { gap: 9px; padding: 10px 3px; }
  .catalog-scroll .lrow.cat { grid-template-columns: minmax(0,1fr) auto; }
  .catalog-scroll .lrow.cat .acts { grid-column: auto; }
  .catalog-scroll .lrow .acts { gap: 5px; }
  .catalog-scroll .lrow .acts .btn { flex: 0 1 auto; padding: 5px 8px; font-size: 12px; }
  .settings-scroll { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .catalog-panel, .catalog-icon, .catalog-scene::before, .catalog-scroll .lrow { animation: none !important; }
}


/* ---------- Plo.Ant.Plant brand + reference sticker composition ---------- */
.admin-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-brand img { width: 62px; height: 42px; object-fit: contain; border-radius: 7px; background: #fff; }
.admin-brand span { display: flex; flex-direction: column; line-height: 1.2; }
header .admin-brand b { font-size: 18px; letter-spacing: .01em; }
.admin-brand small { margin-top: 3px; color: rgba(255,255,255,.82); font-size: 11px; }
.login-logo { display: block; width: min(220px, 72%); height: 110px; object-fit: contain; margin: -4px auto 10px; }
.brand-setting { display: grid; gap: 2px; margin-bottom: 12px; padding: 12px; border: 1px solid #dce8dc; border-radius: 10px; background: #f7faf6; }
.brand-setting strong { color: var(--g-hover); font-size: 16px; }
.labels { --lw: 75mm; --lh: 15mm; display: flex; flex-wrap: wrap; gap: 8px; }
.label { position:relative; width:var(--lw); height:var(--lh); padding:1mm; display:grid; grid-template-columns:var(--qr,13mm) minmax(0,1fr); grid-template-rows:minmax(0,1fr); align-items:stretch; gap:0 2mm; overflow:hidden; border:1px dashed #999; border-radius:2px; background:#fff; break-inside:avoid; }
.label .qr { grid-column:1; grid-row:1; align-self:center; display:block; width:var(--qr,13mm); height:var(--qr,13mm); object-fit:contain; }
.label .tx { grid-column:2; grid-row:1; display:flex; min-width:0; flex-direction:column; justify-content:space-between; padding:0 0 2.8mm; overflow:hidden; }
.label .lc { overflow:hidden; color:#234a37; font-family:ui-monospace,Consolas,monospace; font-size:2.8mm; font-weight:800; line-height:1.05; letter-spacing:.02em; text-overflow:ellipsis; white-space:nowrap; }
.label .ln { overflow:hidden; color:#26352c; font-size:3mm; line-height:1.08; text-overflow:ellipsis; white-space:nowrap; }
.label-brand { grid-column:2; grid-row:1; align-self:end; justify-self:end; max-width:100%; overflow:hidden; color:#37654a; font-size:2.2mm; font-weight:700; line-height:1; text-align:right; white-space:nowrap; }
@media (max-width: 700px) {
  .admin-brand { gap: 7px; }
  .admin-brand img { width: 48px; height: 34px; }
  header .admin-brand b { font-size: 15px; }
  .admin-brand small { font-size: 10px; }
  .labels { max-width:100%; overflow-x:auto; flex-wrap:nowrap; justify-content:flex-start; padding:3px 1px 8px; }
  .label { flex:0 0 var(--lw); }
}
@media print {
  .labels { max-width:none; overflow:visible; }
  .label { flex:0 0 auto; border:0 !important; border-radius:0 !important; }
}


/* ---------- บิล / CRM / ภาพขยาย ---------- */
.photo-viewer { width:min(96vw,1200px); max-width:96vw; height:min(94vh,900px); max-height:94vh; padding:42px 18px 18px; border:0; border-radius:16px; background:#102017; color:#fff; overflow:hidden; }
.photo-viewer::backdrop { background:rgba(5,18,11,.88); backdrop-filter:blur(5px); }
.photo-viewer img { display:block; width:100%; height:100%; object-fit:contain; }
.photo-close { position:absolute; top:8px; right:9px; width:34px; height:34px; border:0; border-radius:50%; background:rgba(255,255,255,.92); color:#183425; font-size:24px; line-height:1; cursor:pointer; }
.zoomable { cursor:zoom-in; }
.lineage-box { margin:8px 0 12px; padding:12px; border:1px solid #dce9df; border-radius:10px; background:#f7fbf7; }
.lineage-box > strong { display:block; color:var(--g); margin-bottom:9px; }
.bill-editor { display:grid; gap:16px; }
.bill-plant { display:flex; align-items:center; gap:16px; padding-bottom:14px; border-bottom:1px solid var(--bd); }
.bill-plant-photo { flex:0 0 138px; width:138px; height:138px; border-radius:12px; object-fit:cover; background:#edf6ef; }
.photo-placeholder { display:grid; place-items:center; font-size:38px; color:var(--g); }
.bill-fields h3 { margin-bottom:12px; }
.bill-calc { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin:12px 0; }
.bill-calc > div { display:flex; flex-direction:column; gap:2px; padding:10px 12px; border:1px solid var(--bd); border-radius:10px; background:#fafcfb; }
.bill-calc span { color:var(--hint); font-size:12px; }
.bill-calc strong { color:var(--text); font-size:17px; }
.bill-calc .garden-total { border-color:#a9cfb4; background:#eff8f0; }
.bill-calc .garden-total strong { color:var(--g); font-size:20px; }
.photo-picker { margin:12px 0; padding:12px; border:1px solid var(--bd); border-radius:12px; background:#fbfdfb; }
.picker-grid { max-height:430px; overflow:auto; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); }
.picker-plant { min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:3px; padding:8px; border:1px solid var(--bd); border-radius:10px; background:#fff; color:var(--text); font:inherit; text-align:left; cursor:pointer; }
.picker-plant:hover { border-color:var(--g); box-shadow:0 4px 14px rgba(45,106,79,.12); }
.picker-photo { display:grid; width:100%; aspect-ratio:1; place-items:center; overflow:hidden; border-radius:7px; background:#edf6ef; color:var(--g); font-size:28px; }
.picker-photo img { width:100%; height:100%; object-fit:cover; }
.picker-plant > span:not(.picker-photo) { overflow:hidden; max-width:100%; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.picker-plant small { margin-top:2px; }
.customer-head, .report-head { align-items:center; justify-content:space-between; }
.customer-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:12px; }
.customer-card { display:flex; align-items:flex-start; gap:12px; margin:0; }
.customer-avatar { flex:0 0 42px; display:grid; width:42px; height:42px; place-items:center; border-radius:50%; background:#e5f1e8; color:var(--g); font-weight:700; font-size:19px; }
.customer-main { flex:1; min-width:0; }
.customer-main h3 { margin:0 0 4px; font-size:17px; overflow-wrap:anywhere; }
.tag-list { display:flex; flex-wrap:wrap; gap:5px; margin-top:8px; }
.customer-tag { padding:3px 9px; border-radius:999px; background:#e7f2e9; color:#285c3f; font-size:12px; }
.tag-options { display:flex; flex-wrap:wrap; gap:8px 14px; margin:10px 0 16px; padding:12px; border:1px solid var(--bd); border-radius:9px; }
.tag-options legend { padding:0 5px; color:var(--hint); font-size:13px; }
.tag-options label { display:flex; align-items:center; gap:6px; margin:0; color:var(--text); }
.tag-options input { width:auto; margin:0; accent-color:var(--g); }
.sumchips { display:flex; flex-wrap:wrap; gap:7px; margin-top:12px; }
.sc { padding:6px 10px; border:1px solid var(--bd); border-radius:999px; background:#fff; color:var(--text); font:inherit; font-size:13px; cursor:pointer; }
.sc.on { border-color:var(--g); background:#edf6ef; color:var(--g); }
.sc b { margin-left:4px; }
.report-stats { grid-template-columns:repeat(4,minmax(0,1fr)); }
.report-caption { padding-top:8px; border-top:1px solid var(--bd); }
.month-list { display:grid; gap:6px; }
.mrow { display:grid; grid-template-columns:minmax(120px,1fr) minmax(80px,2fr) minmax(125px,1fr); align-items:center; gap:12px; padding:8px 10px; border:1px solid transparent; border-radius:8px; background:#fff; color:var(--text); font:inherit; text-align:left; cursor:pointer; }
.mrow:hover, .mrow.on { border-color:#b9d6c1; background:#f2f8f3; }
.mbar { height:9px; overflow:hidden; border-radius:99px; background:#edf1ed; }
.mbar i { display:block; height:100%; min-width:2px; border-radius:99px; background:linear-gradient(90deg,#74a58a,var(--g)); }
.mval { text-align:right; }
.pending-bills { display:grid; gap:8px; }
.pending-bill { display:grid; grid-template-columns:86px minmax(0,1fr) auto; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--bd); }
.bill-thumb { display:block; width:62px; height:62px; border-radius:9px; object-fit:cover; background:#edf6ef; }
.pending-bill .bill-thumb { width:86px; height:86px; }
.no-photo { display:grid; place-items:center; color:var(--g); font-size:25px; }
.pending-main { min-width:0; }
.pending-main strong { display:block; }
.table-scroll { width:100%; overflow:auto; }
.bill-history table { min-width:900px; }
.bill-history td .bill-thumb { width:54px; height:54px; }
.cancelled-list { display:grid; gap:7px; padding-top:10px; }
@media(max-width:700px) {
  main { padding:14px 10px; }
  header { padding:10px; }
  nav { width:100%; }
  nav button { padding:7px 10px; font-size:13px; }
  .bill-plant { align-items:flex-start; }
  .bill-plant-photo { flex-basis:96px; width:96px; height:96px; }
  .bill-calc { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .picker-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
  .picker-plant { padding:6px; font-size:12px; }
  .customer-grid { grid-template-columns:1fr; }
  .report-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .mrow { grid-template-columns:1fr auto; gap:5px 9px; }
  .mbar { grid-column:1 / -1; grid-row:2; }
  .mval { grid-column:2; grid-row:1; }
  .pending-bill { grid-template-columns:62px minmax(0,1fr); }
  .pending-bill .bill-thumb { width:62px; height:62px; }
  .pending-bill .btn { grid-column:1 / -1; width:100%; }
  .customer-head > * { flex-basis:100% !important; }
  .photo-viewer { padding:42px 8px 8px; }
}
@media(prefers-reduced-motion:reduce) { .picker-plant, .customer-card { transition:none; } }
.pending-actions { display:flex; flex-direction:column; gap:6px; }
@media(max-width:700px) { .pending-actions { grid-column:1 / -1; display:grid; grid-template-columns:1fr 1fr; } }
.bill-timeline { margin-top:5px; color:var(--hint); font-size:12px; }
.bill-timeline summary { color:var(--g); cursor:pointer; font-weight:600; }
.bill-timeline > div { padding:2px 0 0 8px; }
.ezpx-note { margin:-2px 0 12px; padding:10px 12px; border-left:3px solid #d38c34; border-radius:6px; background:#fff8ed; color:#765225; font-size:13px; }
@media(max-width:700px) { #lezpx { width:100%; } }


/* Searchable taxonomy, optional fee, and six-tab mobile navigation */
.catalog-search { display: grid; gap: 5px; margin: 4px 0 10px; color: var(--hint); font-size: 13px; }
.catalog-search input { width: 100%; }
#species-selection-note { min-height: 1.25em; }
.commission-toggle { display: inline-flex; align-items: center; gap: 9px; margin: 2px 0 12px; padding: 10px 12px; border: 1px solid var(--bd); border-radius: 11px; background: #f8faf8; color: var(--g-hover); font-weight: 600; cursor: pointer; }
.commission-toggle input { width: 19px; height: 19px; margin: 0; accent-color: var(--g); }
@media (max-width: 700px) {
  nav { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
  nav button { min-width: 0; padding: 5px 0; font-size: 10px; }
  nav .ts { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
}

/* Multi-image plant form */
.image-manager { margin: 4px 0 13px; padding: 11px; border: 1px solid #dce9df; border-radius: 12px; background: #f8fbf8; }
.image-thumbs { display: flex; flex-wrap: nowrap; gap: 8px; min-height: 82px; margin-bottom: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 1px 7px; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.admin-photo-item { position: relative; flex: 0 0 76px; width: 76px; height: 76px; }
.admin-photo-view { display: block; width: 100%; height: 100%; padding: 0; overflow: hidden; border: 1px solid #d6e4d8; border-radius: 10px; background: #edf6ef; cursor: zoom-in; }
.admin-photo-view img { display: block; width: 100%; height: 100%; object-fit: cover; }
.admin-photo-view:focus-visible { outline: 3px solid rgba(45,106,79,.45); outline-offset: 2px; }
.admin-photo-remove { position: absolute; top: 3px; right: 3px; display: grid; width: 23px; height: 23px; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.8); border-radius: 50%; background: rgba(25,48,34,.82); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.image-manager label { margin: 7px 0 4px; }
.image-manager input[type=file] { padding: 8px; background: #fff; }
@media(max-width:700px) { .image-thumbs { gap: 6px; min-height: 70px; } .admin-photo-item { flex-basis: 64px; width: 64px; height: 64px; } }
