/* SAKOOL_CHK หน้าเว็บขาย — สไตล์ทั้งหมดของหน้าอยู่ไฟล์นี้ไฟล์เดียว
   สีทุกสีอ้างจากตัวแปรใน :root เท่านั้น */

:root {
  /* พื้นและตัวอักษร */
  --ink: #18181a;
  --ink-hover: #000000;
  --paper: #f7f6f2;
  --white: #ffffff;
  --cream: #fff4cc;
  --text-2: #33332f;
  --text-3: #5a5a52;

  /* แบรนด์ */
  --yellow: #ffc81e;
  --yellow-soft: #ffd95a;

  /* บนพื้นเข้ม */
  --on-dark-1: #dedcd3;
  --on-dark-2: #cfcdc4;
  --on-dark-3: #b5b3aa;
  --dark-line: #33332f;
  --dark-line-2: #3a3a3c;
  --dark-pill-line: #6b6b63;
  --phone-body: #2a2a2c;

  /* เส้นและกรอบ */
  --border: #d9d6cc;
  --border-strong: #cfccc0;
  --line: #e5e2d8;
  --control-line: #8a887e;
  --chip: #ecebe5;

  /* สถานะ */
  --ok-bg: #dcefe4;
  --ok-fg: #0d4a33;
  --warn-bg: #fde8c8;
  --warn-fg: #6b4300;
  --bad-bg: #fbdcd3;
  --bad-fg: #8a2a10;
  --danger: #a3300f;
  --stamp: #c8401f;
  --line-green: #06c755;

  --font-head: 'Anuphan', sans-serif;
  --font-body: 'IBM Plex Sans Thai Looped', sans-serif;
  --wrap: 1160px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; }
a { color: var(--ink); }
a:hover { color: var(--ink-hover); }
summary { cursor: pointer; }
img { max-width: 100%; }
[id] { scroll-margin-top: 80px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.muted { color: var(--text-2); }
.h2 { font-weight: 700; font-size: clamp(28px, 4vw, 44px); line-height: 1.3; }
.lead { margin: 8px 0 0; color: var(--text-2); }
.icon-check { flex: none; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-block; text-decoration: none; border-radius: 6px;
  font-weight: 600; font-size: 19px; padding: 16px 34px;
}
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-yellow:hover { color: var(--ink); }
.btn-ghost { border: 1.5px solid var(--control-line); color: var(--white); padding: 14px 30px; font-weight: 500; }
.btn-ghost:hover { color: var(--white); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-dark:hover { color: var(--white); }

/* ---------- หัวเว็บ ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); border-bottom: 1px solid var(--dark-line);
}
.site-header .wrap {
  padding-top: 10px; padding-bottom: 10px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: 0.02em;
  color: var(--white); text-decoration: none;
}
.brand:hover { color: var(--white); }
.brand img { width: 44px; height: 44px; border-radius: 10px; display: block; }
.brand .accent { color: var(--yellow); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; font-size: 16px; }
.site-nav a { text-decoration: none; padding: 10px 0; color: var(--on-dark-1); }
.site-nav a:hover { color: var(--white); }
.site-nav .nav-cta {
  background: var(--yellow); color: var(--ink); padding: 10px 22px; border-radius: 4px; font-weight: 600;
}
.site-nav .nav-cta:hover { color: var(--ink); }

/* ---------- ฮีโร่ ---------- */
.hero { background: var(--ink); color: var(--white); overflow: hidden; }
.hero .wrap {
  padding-top: 64px;
  display: flex; flex-wrap: wrap; gap: 40px 56px; align-items: flex-end;
}
.hero-copy {
  flex: 1 1 460px; min-width: 0;
  display: flex; flex-direction: column; gap: 24px; padding-bottom: 72px;
}
.hero-pill {
  align-self: flex-start; font-size: 15px; font-weight: 500; color: var(--yellow-soft);
  border: 1px solid var(--dark-pill-line); border-radius: 999px; padding: 4px 16px;
}
.hero h1 { font-weight: 700; font-size: clamp(36px, 5.6vw, 64px); line-height: 1.2; }
.hero h1 .accent { color: var(--yellow); }
.hero-sub { margin: 0; font-size: clamp(18px, 2vw, 21px); max-width: 520px; color: var(--on-dark-1); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-note { font-size: 15px; color: var(--on-dark-3); }

.hero-visual {
  flex: 1 1 420px; min-width: 0;
  display: flex; justify-content: center; align-items: flex-end;
  position: relative; min-height: 440px;
}
.hero-visual-inner { display: flex; align-items: flex-end; }
.paper-report {
  width: 250px; flex: none; background: var(--white); color: var(--ink);
  border: 1px solid var(--border-strong); padding: 22px 20px 64px;
  font-size: 13px; line-height: 1.9;
  transform: translate(var(--px, 0px), var(--py, 0px)) rotate(-5deg) translate(26px, 10px); position: relative;
  transition: transform 0.35s ease-out;
}
.paper-report .title { font-family: var(--font-head); font-weight: 700; font-size: 17px; text-align: center; margin-bottom: 8px; }
.paper-report .row { display: flex; justify-content: space-between; }
.paper-report .row.head { border-bottom: 1px solid var(--ink); padding-bottom: 4px; margin-bottom: 6px; }
.paper-report .row.risk { font-weight: 600; color: var(--danger); }
.stamp {
  position: absolute; right: 14px; bottom: 22px; transform: rotate(-8deg);
  border: 2px solid var(--stamp); color: var(--danger);
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
  padding: 1px 12px; border-radius: 3px; background: var(--white);
}
.phone {
  width: 268px; flex: none; background: var(--phone-body);
  border: 6px solid var(--dark-line-2); border-bottom: 0; border-radius: 30px 30px 0 0;
  padding: 18px 12px 0; position: relative; z-index: 2; margin-left: -30px;
  transform: translate(var(--fx, 0px), var(--fy, 0px)); transition: transform 0.35s ease-out;
}
.phone-screen {
  background: var(--paper); border-radius: 16px 16px 0 0; padding: 14px 12px 20px;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13.5px; line-height: 1.55; color: var(--ink); min-height: 384px;
}
.phone-tabs { display: flex; gap: 4px; font-size: 12px; font-weight: 500; }
.phone-tabs div { flex: 1; text-align: center; padding: 5px 0; border-radius: 6px; background: var(--chip); }
.phone-tabs .on { background: var(--yellow); }
.phone-title { font-family: var(--font-head); font-weight: 600; font-size: 15px; margin-top: 4px; }
.phone-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--white); border-radius: 8px; padding: 8px 10px;
}
.phone-save {
  margin-top: 4px; text-align: center; background: var(--ink); color: var(--white);
  border-radius: 8px; padding: 9px; font-weight: 600;
}

/* ป้ายสถานะ */
.tag { border-radius: 999px; padding: 1px 12px; font-weight: 500; white-space: nowrap; }
.tag-ok { background: var(--ok-bg); color: var(--ok-fg); }
.tag-warn { background: var(--warn-bg); color: var(--warn-fg); }
.tag-bad { background: var(--bad-bg); color: var(--bad-fg); }
.tag-neutral { background: var(--chip); color: var(--text-2); }

/* ---------- แถบเหลือง ---------- */
.strip { background: var(--yellow); }
.strip .wrap {
  padding-top: 20px; padding-bottom: 20px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 32px; font-size: 16px; font-weight: 600;
}
.strip-item { display: flex; align-items: center; gap: 10px; }

/* ---------- ปัญหา ---------- */
.problems { padding-top: 80px; padding-bottom: 24px; display: flex; flex-direction: column; gap: 36px; }
.problems .h2 { max-width: 760px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 24px; }
.card h3 { font-weight: 600; font-size: 20px; margin-bottom: 6px; }

/* ---------- สามขั้น ---------- */
.how { padding-top: 72px; padding-bottom: 24px; display: flex; flex-direction: column; gap: 32px; }
.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--white);
}
.step { padding: 32px 28px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.step:last-child { border-right: 0; }
.step-num {
  font-family: var(--font-head); font-weight: 700; font-size: 44px; line-height: 1;
  color: var(--ink); background: var(--yellow); display: inline-block; padding: 8px 20px; border-radius: 8px;
}
.step h3 { font-weight: 600; font-size: 22px; margin: 14px 0 6px; }

/* ---------- โมดูล ---------- */
.modules { padding-top: 88px; padding-bottom: 24px; display: flex; flex-direction: column; gap: 56px; }
.modules .lead { max-width: 640px; }
.feature { display: flex; flex-wrap: wrap; gap: 32px 56px; align-items: center; }
.feature.reverse { flex-wrap: wrap-reverse; }
.feature-copy { flex: 1 1 400px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.feature-copy h3 { font-weight: 700; font-size: clamp(24px, 3vw, 32px); line-height: 1.35; }
.feature-copy p { margin: 0; color: var(--text-2); }
.feature-copy ul { margin: 0; padding-left: 22px; color: var(--text-2); }
.badge {
  font-family: var(--font-head); font-weight: 600; align-self: flex-start;
  padding: 0 12px; border-radius: 4px;
}
.badge-yellow { background: var(--yellow); color: var(--ink); }
.badge-dark { background: var(--ink); color: var(--white); }
.mock {
  flex: 1 1 380px; min-width: 0; background: var(--white); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 22px; box-shadow: 8px 8px 0 var(--yellow); font-size: 15px;
}
.mock-title { font-family: var(--font-head); font-weight: 600; font-size: 18px; margin-bottom: 4px; }
.mock-sub { color: var(--text-3); font-size: 14px; margin-bottom: 12px; }
.mock-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.mock-row .tag { padding: 2px 12px; }
.mock-row .right { display: flex; align-items: center; gap: 12px; }
.mock-row .who { color: var(--text-3); }
.mock-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mock-actions div { border: 1.5px solid var(--ink); border-radius: 6px; padding: 6px 14px; font-weight: 500; }

.dark-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.dark-card { background: var(--ink); color: var(--white); border-radius: 10px; padding: 28px; }
.dark-card .kicker { font-family: var(--font-head); font-weight: 600; color: var(--yellow-soft); }
.dark-card h3 { font-weight: 600; font-size: 22px; margin: 6px 0 8px; }
.dark-card .body { color: var(--on-dark-1); }
.mock-disclaimer { margin: -24px 0 0; font-size: 14px; color: var(--text-3); }

/* ---------- โมดูลเสริมพร้อมราคา ---------- */
.addons { padding-top: 72px; display: flex; flex-direction: column; gap: 24px; }
.addons .lead { max-width: 680px; }
.price-box { background: var(--white); border: 1px solid var(--border-strong); border-radius: 10px; padding: 24px 28px; }
.price-box.dark { background: var(--ink); color: var(--white); border: 0; }
.price-box-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.price-box.dark .price-box-head { margin-bottom: 4px; }
.price-box-head h3 { font-weight: 600; font-size: 22px; }
.status-pill { border-radius: 999px; padding: 1px 14px; font-size: 14px; font-weight: 600; }
.status-ready { background: var(--ok-bg); color: var(--ok-fg); }
.status-queue { background: var(--warn-bg); color: var(--warn-fg); }
.status-device { background: var(--yellow); color: var(--ink); }
.price-box-note { margin: 0 0 12px; font-size: 15px; color: var(--on-dark-2); }
.addon-row {
  display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: baseline;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.price-box.dark .addon-row { border-top-color: var(--dark-line-2); }
.addon-name { flex: 1 1 300px; min-width: 0; }
.addon-desc { font-size: 15px; color: var(--text-3); }
.price-box.dark .addon-desc { color: var(--on-dark-2); }
.addon-price { font-family: var(--font-head); font-weight: 700; font-size: 20px; white-space: nowrap; }
.addon-price .unit { font-size: 14px; font-weight: 500; color: var(--text-3); }
.price-box.dark .addon-price .unit { color: var(--on-dark-2); }

/* ---------- แถบนัดเดโม ---------- */
.cta-band-wrap { padding-top: 72px; padding-bottom: 72px; }
.cta-band {
  background: var(--yellow); color: var(--ink); border-radius: 12px; padding: 40px 36px;
  display: flex; flex-wrap: wrap; gap: 20px 40px; align-items: center; justify-content: space-between;
}
.cta-band h2 { font-weight: 700; font-size: clamp(24px, 3.2vw, 34px); line-height: 1.35; flex: 1 1 400px; min-width: 0; }

/* ---------- ราคา ---------- */
.pricing { background: var(--cream); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.pricing .wrap { padding-top: 80px; padding-bottom: 80px; display: flex; flex-direction: column; gap: 28px; }
/* โรงเรียนที่ใช้งานจริง (อนุญาตแล้ว) เหนือหัวข้อราคา */
.customer {
  display: flex; align-items: center; gap: 14px; align-self: flex-start; max-width: 100%;
  background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px 12px 12px;
}
.customer img { width: 64px; height: 64px; object-fit: contain; flex: none; }
.customer-label { font-size: 14px; color: var(--text-3); }
.customer-name { font-weight: 700; font-size: 17px; line-height: 1.4; }
.term-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.term-label { font-weight: 600; }
.term-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.term-btn {
  font: inherit; font-weight: 600; min-height: 44px; padding: 8px 22px; border-radius: 6px;
  cursor: pointer; border: 1.5px solid var(--ink); background: var(--white); color: var(--ink);
}
.term-btn[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.term-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.discount-note { font-weight: 600; color: var(--ok-fg); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; align-items: stretch; }
.plan {
  background: var(--white); border: 1px solid var(--border-strong); border-radius: 10px; padding: 28px;
  display: flex; flex-direction: column; gap: 6px;
}
.plan-name { font-weight: 500; color: var(--text-3); }
.plan-size, .plan-total { font-size: 15px; color: var(--text-3); }
.plan-unit { color: var(--text-3); }
.plan-price { font-family: var(--font-head); font-weight: 700; font-size: 48px; line-height: 1.2; margin-top: 8px; }
.plan.featured { background: var(--ink); color: var(--white); border: 0; }
.plan.featured .plan-name { color: var(--yellow-soft); }
.plan.featured .plan-size, .plan.featured .plan-unit, .plan.featured .plan-total { color: var(--on-dark-2); }
.plan-info {
  background: var(--white); border: 1px solid var(--border-strong); border-radius: 10px; padding: 24px 28px;
  display: flex; flex-wrap: wrap; gap: 16px 48px;
}
.plan-info > div { flex: 1 1 320px; min-width: 0; }
.plan-info-title { font-family: var(--font-head); font-weight: 600; font-size: 19px; margin-bottom: 6px; }
.plan-info ul { margin: 0; padding-left: 22px; color: var(--text-2); }
.plan-info a { display: inline-block; margin-top: 10px; font-weight: 600; }
.fine-print { margin: 0; font-size: 15px; color: var(--text-3); }

/* ---------- คำถาม ---------- */
.faq-wrap { padding-top: 80px; padding-bottom: 80px; display: flex; flex-wrap: wrap; gap: 40px 64px; }
.faq { flex: 1 1 420px; min-width: 0; }
.faq h2 { font-weight: 700; font-size: clamp(26px, 3.4vw, 36px); line-height: 1.3; margin-bottom: 16px; }
.faq details { border-top: 1px solid var(--border-strong); padding: 14px 0; }
.faq details:last-of-type { border-bottom: 1px solid var(--border-strong); }
.faq summary { font-weight: 600; font-size: 18px; min-height: 30px; }
.faq p { margin: 8px 0 0; color: var(--text-2); }
.provider {
  flex: 1 1 360px; min-width: 0; background: var(--white); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px; align-self: flex-start;
}
.provider h3 { font-weight: 600; font-size: 22px; line-height: 1.4; margin-bottom: 10px; }
.provider p { margin: 0 0 10px; color: var(--text-2); }
.provider ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }

/* ---------- ท้ายเว็บ + แชท ---------- */
.site-footer { background: var(--ink); color: var(--paper); }
.site-footer a { color: var(--on-dark-1); }
.site-footer a:hover { color: var(--white); }
.contact {
  padding-top: 72px; padding-bottom: 72px;
  display: flex; flex-wrap: wrap; gap: 32px 64px; align-items: flex-start; justify-content: space-between;
}
.contact-copy { flex: 1 1 380px; min-width: 0; }
.contact-copy h2 { font-weight: 700; font-size: clamp(30px, 4.4vw, 50px); line-height: 1.25; margin-bottom: 14px; }
.contact-copy h2 .accent { color: var(--yellow); }
.contact-copy p { margin: 0 0 12px; color: var(--on-dark-2); max-width: 480px; }
.contact-copy p.small { margin: 0; color: var(--on-dark-3); font-size: 15px; }

.btn-line {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 20px;
  background: var(--line-green); color: var(--ink); text-decoration: none;
  font-weight: 600; font-size: 17px; padding: 12px 22px; border-radius: 6px; min-height: 48px;
}
.site-footer .btn-line, .site-footer .btn-line:hover { color: var(--ink); }
.btn-line:hover { filter: brightness(1.05); }
.btn-line .line-id { font-weight: 500; font-size: 15px; }
.chat-box {
  flex: 1 1 340px; max-width: 420px; min-width: 0; background: var(--white); color: var(--ink);
  border-radius: 10px; overflow: hidden; font-size: 16px;
}
.chat-head { background: var(--yellow); color: var(--ink); padding: 14px 20px; display: flex; flex-direction: column; gap: 2px; }
.chat-head .name { font-family: var(--font-head); font-weight: 600; font-size: 18px; }
.chat-head .sub { font-size: 14px; color: var(--text-2); }
.chat-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 15px; font-weight: 500; }
.field input, .chat-input input {
  font: inherit; padding: 11px 12px; border: 1px solid var(--control-line); border-radius: 6px;
  min-height: 44px; width: 100%; background: var(--white); color: var(--ink);
}
.field input:focus, .chat-input input:focus { outline: 3px solid var(--yellow); outline-offset: 0; }
.form-error { font-size: 15px; color: var(--danger); }
.chat-btn {
  font: inherit; font-weight: 600; background: var(--ink); color: var(--white);
  border: 0; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.chat-btn:disabled { opacity: 0.7; cursor: progress; }
.chat-btn.start { font-size: 17px; padding: 12px 20px; min-height: 48px; }
.chat-btn.send { padding: 10px 18px; min-height: 44px; white-space: nowrap; }
.spinner {
  width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chat-panel { display: flex; flex-direction: column; }
.chat-log {
  padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px;
  min-height: 220px; max-height: 320px; overflow-y: auto; background: var(--paper);
}
.bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 12px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble.them { align-self: flex-start; background: var(--white); border: 1px solid var(--border); color: var(--ink); }
.bubble.mine { align-self: flex-end; background: var(--ink); color: var(--white); }
/* "กำลังพิมพ์ • • •" ก่อนคำตอบอัตโนมัติ */
.bubble.typing { display: inline-flex; align-items: center; gap: 5px; padding: 13px 14px; }
.bubble.typing .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); animation: typing-bounce 1.2s infinite ease-in-out; }
.bubble.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-5px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bubble.typing .dot { animation: none; opacity: 0.7; } }
.chat-panel .chat-form { border-top: 1px solid var(--border); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; min-width: 0; padding: 10px 12px; }
.chat-error { padding: 0 12px 10px; font-size: 14px; color: var(--danger); }

.footer-bar {
  padding-top: 16px; padding-bottom: 28px; border-top: 1px solid var(--dark-line-2);
  font-size: 14px; color: var(--on-dark-3);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.footer-bar img { width: 36px; height: 36px; border-radius: 8px; display: block; }
.footer-bar .spacer { flex: 1; }

/* ---------- หน้านโยบาย ---------- */
.doc { padding-top: 48px; padding-bottom: 72px; max-width: 760px; }
.doc h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.3; margin-bottom: 16px; }
.doc h2 { font-size: 22px; margin: 28px 0 8px; }
.doc p, .doc li { color: var(--text-2); }

/* ---------- จอแคบ ---------- */
@media (max-width: 560px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .hero-visual { min-height: 0; }
  /* ม็อกอัปกว้าง 488px ย่อลงให้พอดีจอ ไม่ล้นแนวนอน */
  .hero-visual-inner { transform: scale(0.66); transform-origin: bottom center; margin: -150px -90px 0; }
  .cta-band { padding: 32px 20px; }
  .price-box { padding: 20px 18px; }
  .plan-info { padding: 20px 18px; }
  .step { border-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation-duration: 2s; }
}

/* ---------- หน้าผู้ดูแล (ใช้ตัวแปรสีชุดเดียวกัน) ---------- */
body.admin { background: var(--paper); }
.admin-bar { background: var(--ink); }
.admin-bar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.admin-bar .brand img { width: 36px; height: 36px; }
.admin-bar .logout { margin: 0; }
.admin-main { padding-top: 24px; padding-bottom: 48px; }
.admin-h1 { font-size: 26px; line-height: 1.3; margin-bottom: 12px; overflow-wrap: anywhere; }
.admin-h1 .count { font-size: 16px; color: var(--text-3); font-weight: 500; }
.admin-btn {
  font: inherit; font-weight: 600; background: var(--ink); color: var(--white); border: 1.5px solid var(--ink);
  border-radius: 6px; padding: 10px 18px; min-height: 44px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.admin-btn:disabled { opacity: 0.7; cursor: progress; }
.admin-btn.ghost { background: transparent; color: var(--on-dark-1); border-color: var(--control-line); }
.admin-btn.danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.admin-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--white); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card img { border-radius: 14px; align-self: center; }
.login-card h1 { font-size: 22px; text-align: center; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.chat-item {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink);
  background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; position: relative;
}
.chat-item:hover { border-color: var(--ink); }
.chat-item.unread { border-left: 0; box-shadow: inset 4px 0 0 var(--yellow); }
.ci-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ci-name { overflow-wrap: anywhere; }
.ci-time, .ci-contact { font-size: 14px; color: var(--text-3); overflow-wrap: anywhere; }
.ci-last { color: var(--text-2); overflow-wrap: anywhere; }
.ci-badge { align-self: flex-start; background: var(--yellow); color: var(--ink); border-radius: 999px; padding: 0 10px; font-size: 13px; font-weight: 600; }
.admin-chat { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.contact-card { flex: 1 1 260px; min-width: 0; background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.contact-card dl { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.contact-card dt { color: var(--text-3); }
.contact-card dd { margin: 0; overflow-wrap: anywhere; }
.admin-thread { flex: 2 1 420px; min-width: 0; background: var(--white); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.admin-log { max-height: 60vh; min-height: 300px; }
.b-time { display: block; font-size: 12px; opacity: 0.7; margin-top: 2px; }
.admin-reply { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.admin-reply textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 6px; resize: vertical;
}
.admin-reply .admin-btn { align-self: flex-end; }
.admin-bar .admin-btn { white-space: nowrap; }
@media (max-width: 420px) {
  .admin-bar .brand span { display: none; }
  .admin-bar .admin-btn { padding: 8px 14px; }
}

/* ---------- ผู้ดูแล: เมนู + คำตอบอัตโนมัติ ---------- */
.admin-nav { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; }
.admin-nav a { color: var(--on-dark-1); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.admin-nav a:hover, .admin-nav a:focus-visible { background: var(--dark-line); color: var(--white); }
.admin-log .bubble.auto { background: var(--chip); color: var(--ink); border: 1px dashed var(--control-line); }
.admin-log .bubble.auto .b-time { color: var(--text-3); }
.reply-test { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.reply-test-label { font-weight: 600; }
.reply-test-row { display: flex; gap: 8px; }
.reply-test-row input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 6px; min-height: 44px; }
.reply-test-out { white-space: pre-wrap; background: var(--paper); border-radius: 8px; padding: 10px 12px; }
.reply-card { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.reply-card.off { opacity: 0.6; }
.reply-card.hit { box-shadow: 0 0 0 3px var(--yellow); }
.reply-new-title { margin: 0; font-size: 18px; }
.reply-card textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 6px; width: 100%; resize: vertical; }
.reply-card .hint { font-weight: 400; font-size: 13px; color: var(--text-3); }
.reply-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.reply-row .spacer { flex: 1; }
.reply-order { width: 110px; }
.reply-active { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.reply-active input { width: 20px; height: 20px; }
@media (max-width: 560px) {
  /* จอแคบ: เมนูลงไปเป็นแถวที่สองเต็มความกว้าง */
  .admin-bar-in { flex-wrap: wrap; row-gap: 6px; }
  .admin-nav { order: 3; width: 100%; margin: 0; }
  .admin-nav a { padding: 8px 10px; font-size: 15px; }
  .reply-test-row { flex-wrap: wrap; }
  .reply-test-row input { flex-basis: 100%; }
  .reply-test-row .admin-btn { flex: 1 0 auto; }
}

/* ---------- ผู้ดูแล: คำตอบสำเร็จในหน้าแชท ---------- */
.quick-replies { border: 1px solid var(--border); border-radius: 10px; background: var(--white); }
.quick-replies summary {
  list-style: none; cursor: pointer; padding: 8px 12px; min-height: 44px; display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 15px; color: var(--ink); border-radius: 10px; user-select: none;
}
.quick-replies summary::-webkit-details-marker { display: none; }
.quick-replies summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px); transition: transform 0.15s;
}
.quick-replies[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.quick-replies summary:hover { background: var(--paper); }
.qr-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px;
  background: var(--yellow); color: var(--ink); font-size: 13px; font-weight: 700; flex: none;
}
.qr-icon.alt { background: var(--chip); }
.qr-hint { font-weight: 400; font-size: 13px; color: var(--text-3); }
.qr-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 12px 12px; max-height: 220px; overflow-y: auto; align-items: center; }
.qr-chip {
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1.3; color: var(--ink); text-align: left;
  background: var(--paper); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; min-height: 36px; cursor: pointer; max-width: 100%; overflow-wrap: anywhere;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.qr-chip::before { content: "+"; font-weight: 700; color: var(--text-3); }
.qr-chip:hover, .qr-chip:focus-visible { background: #fff6d6; border-color: var(--yellow); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.qr-chip:hover::before { color: var(--ink); }
.qr-chip:active { transform: translateY(1px); }
.qr-chip:disabled { opacity: 0.7; cursor: progress; }
.qr-chip:disabled::before { content: none; }
#starter-questions .qr-chip { background: var(--white); border-color: var(--control-line); }
#starter-questions .qr-chip:hover, #starter-questions .qr-chip:focus-visible { background: #fff6d6; border-color: var(--yellow); }
#starter-questions .qr-chip.all { background: var(--ink); color: var(--white); border-color: var(--ink); }
#starter-questions .qr-chip.all::before { color: var(--yellow); }
#starter-questions .qr-chip.all:hover { background: #2c2c30; }
.qr-manage { font-size: 13px; margin-left: 4px; color: var(--text-3); }
.qr-manage:hover { color: var(--ink); }
.qr-empty { margin: 0; font-size: 14px; }
@media (max-width: 560px) { #starter-questions .qr-hint { display: none; } }

/* ---------- ตอบกลับข้อความ (ทั้งสองฝั่ง) ---------- */
.msg-row { display: flex; align-items: center; gap: 6px; align-self: stretch; min-width: 0; }
.msg-row > .bubble { align-self: auto; }
.reply-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: 50%; cursor: pointer;
  background: var(--white); color: var(--text-3); border: 1px solid var(--border);
  opacity: 0.75; transition: opacity 0.12s, background 0.12s, color 0.12s, border-color 0.12s, transform 0.06s;
}
.reply-btn svg { display: block; }
.reply-btn:hover, .reply-btn:focus-visible { opacity: 1; background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.reply-btn:active { transform: scale(0.94); }
/* เมาส์: ไอคอนจางไว้ เด่นขึ้นเมื่อชี้ที่ข้อความ · จอสัมผัสเห็นชัดตลอด */
@media (hover: hover) and (pointer: fine) {
  .reply-btn { opacity: 0.35; }
  .msg-row:hover .reply-btn { opacity: 1; }
}
.bubble .quote {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; line-height: 1.45; cursor: pointer;
  margin: 0 0 6px; padding: 5px 8px; border: 0; border-left: 3px solid var(--yellow); border-radius: 4px;
  background: rgba(0, 0, 0, 0.06); color: inherit; opacity: 0.85;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.bubble.mine .quote { background: rgba(255, 255, 255, 0.14); }
.bubble .q-who { display: block; font-weight: 600; }
.bubble.flash { animation: bubble-flash 1.2s ease-out; }
@keyframes bubble-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--yellow); } 100% { box-shadow: 0 0 0 3px transparent; } }
@media (prefers-reduced-motion: reduce) { .bubble.flash { animation: none; box-shadow: 0 0 0 3px var(--yellow); } }
.replying {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; font-size: 14px;
  background: var(--chip); border-left: 3px solid var(--yellow); border-radius: 4px;
}
.chat-panel > .replying { margin: 8px 12px 0; }
.replying-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replying-x { font: inherit; font-size: 20px; line-height: 1; background: none; border: 0; cursor: pointer; min-width: 36px; min-height: 36px; color: var(--text-3); }
.replying-x:hover { color: var(--ink); }

/* ---------- ผู้ดูแล: สถานะเคส ---------- */
.case-pill { display: inline-block; border-radius: 999px; padding: 0 10px; font-size: 13px; font-weight: 600; }
.case-pill.open { background: var(--ok-bg); color: var(--ok-fg); }
.case-pill.closed { background: var(--chip); color: var(--text-3); }
.case-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-btn.ghost-dark { background: var(--white); color: var(--ink); border-color: var(--ink); }
.case-note { font-size: 13px; margin: 8px 0 16px; }
.case-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.case-tabs a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--control-line); color: var(--ink); text-decoration: none; font-weight: 500; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.case-tabs a[aria-current="page"] { background: var(--ink); color: var(--white); border-color: var(--ink); }
.case-tabs .count { font-size: 13px; opacity: 0.75; }
.ci-case { font-size: 13px; color: var(--text-3); }
.ci-case.wait { align-self: flex-start; background: var(--chip); color: var(--ink); border-radius: 999px; padding: 0 10px; font-weight: 600; }

/* ---------- ผู้ดูแล: ปุ่มเสียงแจ้งเตือน ---------- */
.sound-btn {
  font: inherit; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--on-dark-1); border: 1px solid var(--control-line); border-radius: 999px;
  padding: 6px 12px; min-height: 40px; cursor: pointer; white-space: nowrap;
}
.sound-btn:hover, .sound-btn:focus-visible { background: var(--dark-line); color: var(--white); }
.sound-btn .sound-ico { color: var(--yellow); }
.sound-btn .sound-slash { display: none; }
.sound-btn.off { opacity: 0.75; }
.sound-btn.off .sound-ico { color: var(--on-dark-1); }
.sound-btn.off .sound-slash { display: inline; }
@media (max-width: 560px) { .sound-btn { margin-left: auto; } }
@media (max-width: 420px) { .sound-btn .sound-label { display: none; } .sound-btn { padding: 6px 10px; } }
.sound-btn.ask { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.sound-btn.ask .sound-ico { color: var(--ink); }
.sound-btn.ask:hover, .sound-btn.ask:focus-visible { background: #ffd54d; color: var(--ink); }

/* อีโมจิในแชท: Windows 10 ไม่มีรูปอีโมจิรุ่นใหม่ (ขึ้นเป็นกล่อง) จึงใช้ฟอนต์อีโมจิจาก Google Fonts
   โหลดเฉพาะช่วงตัวอักษรที่ใช้จริง (unicode-range) ตัวหนังสือไทย/อังกฤษยังใช้ฟอนต์เดิม */
.bubble, .chat-input input, .admin-reply textarea, .replying-text, .ci-last, .reply-test-out {
  font-family: 'IBM Plex Sans Thai Looped', 'Noto Color Emoji', sans-serif;
}

/* ---------- ผู้ดูแล: ลูกค้า / สัญญา ---------- */
.admin-h2 { font-size: 20px; margin: 28px 0 10px; }
.admin-h2 .count { font-size: 15px; color: var(--text-3); font-weight: 500; }
.back { margin: 0 0 8px; }
.cust-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 20px; }
.cust-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; text-decoration: none; color: var(--ink);
  background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px;
}
.cust-item:hover { border-color: var(--ink); color: var(--ink); }
.cust-abbr {
  font-family: ui-monospace, 'Consolas', monospace; font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
  background: var(--ink); color: var(--yellow); border-radius: 6px; padding: 2px 8px; vertical-align: middle;
}
.cust-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; }
.cust-name { font-weight: 600; overflow-wrap: anywhere; }
.cust-sub { font-size: 14px; color: var(--text-3); }
.cust-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill-active { background: var(--ok-bg); color: var(--ok-fg); }
.pill-unpaid { background: var(--warn-bg); color: var(--warn-fg); }
.pill-draft, .pill-cancelled { background: var(--chip); color: var(--text-3); }
.pill-expired { background: var(--bad-bg); color: var(--bad-fg); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.sales-form .field input[type="date"] { min-height: 44px; }
.contract-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.contract.st-cancelled { opacity: 0.65; }
.contract.st-active { border-left: 4px solid var(--ok-fg); }
.contract.st-unpaid { border-left: 4px solid var(--yellow); }
.contract.st-expired { border-left: 4px solid var(--danger); }
.mod-pick { border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px 12px; margin: 0; }
.mod-pick legend { font-weight: 600; padding: 0 6px; }
.mod-line { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.mod-check { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 40px; min-width: 0; }
.mod-check input { width: 20px; height: 20px; flex: none; }
.mod-price { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mod-price input, .module-row input:not([type="checkbox"]) {
  font: inherit; padding: 8px 10px; border: 1px solid var(--control-line); border-radius: 6px; min-height: 40px; background: var(--white);
}
.mod-price input { width: 120px; text-align: right; }
.mod-discount span:first-child, .mod-total span:first-child { flex: 1; }
.mod-total { border-bottom: 0; font-size: 18px; }
.mod-total b { font-family: var(--font-head); }
.ent-box { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 4px 16px 12px; }
.ent-box .admin-h2 { margin-top: 12px; }
.ent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ent-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.module-list { display: flex; flex-direction: column; gap: 8px; }
.module-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px;
}
.module-row.off { opacity: 0.6; }
.module-code { font-family: ui-monospace, 'Consolas', monospace; font-size: 13px; color: var(--text-3); width: 90px; }
.module-name { flex: 1 1 220px; min-width: 0; }
.module-row .mod-price input, .module-row label input[name="price"] { width: 120px; text-align: right; }
.admin-btn.small { min-height: 40px; padding: 6px 14px; }
.field select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 6px;
  min-height: 44px; width: 100%; background: var(--white); color: var(--ink);
}
.field select:focus { outline: 3px solid var(--yellow); outline-offset: 0; }
.mod-grp { font-weight: 600; font-size: 14px; color: var(--text-3); padding: 12px 0 2px; }
.mod-pick legend .hint, .mod-line .hint { font-weight: 400; font-size: 13px; color: var(--text-3); }
.mod-sum { border-top: 2px solid var(--line); }
.mod-sum b { font-family: var(--font-head); }
.mod-sum span:first-child { flex: 1; }
.module-grp { font-size: 16px; margin: 14px 0 0; color: var(--text-2); }
.module-price { font-weight: 600; white-space: nowrap; }
.fine { font-size: 14px; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span2 { grid-column: auto; }
  .admin-nav { overflow-x: auto; }
}
@media (max-width: 560px) {
  .mod-line { flex-wrap: wrap; gap: 4px 10px; }
  .mod-check { flex: 1 1 170px; }
  .mod-price { margin-left: auto; }
  .mod-price input { width: 110px; }
  .module-code { width: auto; }
}

/* ---------- ลิงก์เคส / ใบเสนอราคา ---------- */
.case-link-box { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 4px; }
.case-link-box .admin-h2 { margin-top: 8px; font-size: 17px; }
.quote-row { margin: 4px 0; }
.quote-dl { margin: -2px 0 6px; }
.warn-box { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 10px 14px; }
.case-main { max-width: 760px; }
a.admin-btn { text-decoration: none; }
a.admin-btn:hover { color: var(--white); }
a.admin-btn.ghost-dark:hover { color: var(--ink); }

/* ดู PDF ในหน้าต่างซ้อน (admin.js data-pdf-preview) */
.pdf-modal { width: min(960px, calc(100vw - 24px)); height: calc(100vh - 24px); max-height: none; padding: 0; border: 0; border-radius: 10px; overflow: hidden; display: none; flex-direction: column; background: var(--white, #fff); }
.pdf-modal[open] { display: flex; }
.pdf-modal::backdrop { background: rgba(0, 0, 0, .55); }
.pdf-modal-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #ddd; }
.pdf-modal-title { margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pdf-modal-wait { margin: 0; padding: 8px 14px; color: var(--text-2, #555); }
.pdf-modal-frame { flex: 1; width: 100%; border: 0; background: #525659; }
