@charset "UTF-8";
/* ============================================================
   ERPThai — Design System
   ทิศทาง: apple.com — พื้นขาว/เทาอ่อน ตัวอักษรคมชัด
   ระยะห่างเยอะ ไม่มีเส้นกรอบหนา เน้นลำดับชั้นด้วยขนาดตัวอักษร
   ============================================================ */

:root {
  /* สี */
  --ink:        #1d1d1f;
  --ink-soft:   #6e6e73;
  --ink-faint:  #86868b;
  --line:       #d2d2d7;
  --line-soft:  #e8e8ed;
  --surface:    #ffffff;
  --canvas:     #f5f5f7;
  --accent:     #0071e3;
  --accent-hi:  #0077ed;
  --green:      #248a3d;
  --green-bg:   #e8f6ec;
  --amber:      #b25000;
  --amber-bg:   #fdf0e4;
  --red:        #d70015;
  --red-bg:     #fdeaec;
  --blue-bg:    #e8f1fd;
  --grey-bg:    #f0f0f3;

  /* ตัวอักษร */
  --sans: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue",
          "IBM Plex Sans Thai", "Noto Sans Thai", sans-serif;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont,
             "IBM Plex Sans Thai", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "IBM Plex Mono", monospace;

  /* ระยะและรัศมี */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 980px;
  --nav-h: 44px;
  --local-h: 52px;
  --gutter: 22px;
  --maxw: 1440px;

  --shadow-card: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --shadow-pop:  0 8px 40px rgba(0,0,0,.12);
}

/* ---------------------------------------------------------- พื้นฐาน */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ------------------------------------------------- แถบนำทางระดับบน (dark) */
.globalnav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  background: rgba(22,22,23,.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: #f5f5f7;
}
.globalnav__in {
  max-width: var(--maxw); margin: 0 auto; height: 100%;
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 4px;
}
.globalnav__brand {
  font-family: var(--display);
  font-size: 17px; font-weight: 600; letter-spacing: -.02em;
  color: #f5f5f7; margin-right: 20px; white-space: nowrap;
}
.globalnav__brand:hover { text-decoration: none; opacity: .85; }
.globalnav__brand span { color: var(--accent); }

.globalnav a.gn {
  color: #f5f5f7; font-size: 12.5px; opacity: .82;
  padding: 6px 11px; border-radius: var(--r-sm);
  white-space: nowrap; transition: opacity .2s, background .2s;
}
.globalnav a.gn:hover { opacity: 1; background: rgba(255,255,255,.09); text-decoration: none; }
.globalnav a.gn[aria-current="true"] { opacity: 1; background: rgba(255,255,255,.14); }

.globalnav__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ตัวสลับบริษัท */
.copicker { position: relative; }
.copicker__btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.11); border: 0; cursor: pointer;
  color: #f5f5f7; font-family: var(--sans); font-size: 12.5px;
  padding: 6px 12px; border-radius: var(--r-pill);
  max-width: 320px;
}
.copicker__btn:hover { background: rgba(255,255,255,.18); }
.copicker__btn b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copicker__code { opacity: .6; font-family: var(--mono); font-size: 11px; }

.copicker__menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 320px; background: var(--surface); color: var(--ink);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  padding: 8px; display: none;
}
.copicker__menu[data-open="true"] { display: block; }
.copicker__menu h6 {
  margin: 6px 10px 8px; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 500;
}
.copicker__item {
  display: block; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--ink); font-size: 14px;
}
.copicker__item:hover { background: var(--canvas); text-decoration: none; }
.copicker__item small { display: block; color: var(--ink-faint); font-size: 12px; }
.copicker__item[aria-current="true"] { background: var(--blue-bg); }

/* -------------------------------------------- แถบนำทางระดับหน้า (light) */
.localnav {
  position: sticky; top: var(--nav-h); z-index: 50;
  background: rgba(250,250,252,.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
}
.localnav__in {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--local-h); padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.localnav__title {
  font-family: var(--display); font-size: 19px; font-weight: 600;
  letter-spacing: -.02em; white-space: nowrap;
}
.localnav__links { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.localnav__links::-webkit-scrollbar { display: none; }
.localnav__links a {
  color: var(--ink-soft); font-size: 13px; padding: 6px 11px;
  border-radius: var(--r-sm); white-space: nowrap;
}
.localnav__links a:hover { color: var(--ink); background: rgba(0,0,0,.045); text-decoration: none; }
.localnav__links a[aria-current="true"] { color: var(--ink); background: rgba(0,0,0,.07); font-weight: 500; }
.localnav__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------- โครงหน้า */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 34px var(--gutter) 96px; }

.pagehead { margin-bottom: 26px; }
.pagehead h1 {
  font-size: clamp(30px, 3.6vw, 44px); line-height: 1.08;
  letter-spacing: -.028em;
}
.pagehead p { color: var(--ink-soft); font-size: 16px; margin: 10px 0 0; max-width: 62ch; }

.section-gap { margin-top: 42px; }

/* -------------------------------------------------------------- ปุ่ม */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--sans); font-size: 14px; font-weight: 400;
  padding: 8px 18px; border-radius: var(--r-pill);
  border: 1px solid transparent; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .12s;
  white-space: nowrap; line-height: 1.3;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.975); }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hi); }

.btn--ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn--ghost:hover { background: rgba(0,113,227,.06); border-color: var(--accent); }

.btn--quiet { background: var(--grey-bg); color: var(--ink); }
.btn--quiet:hover { background: #e6e6ea; }

.btn--danger { background: transparent; color: var(--red); border-color: rgba(215,0,21,.3); }
.btn--danger:hover { background: var(--red-bg); }

.btn--sm { font-size: 13px; padding: 5px 13px; }
.btn--lg { font-size: 16px; padding: 12px 26px; }

.linkarrow { font-size: 14px; }
.linkarrow::after { content: " \203A"; font-weight: 400; }

/* --------------------------------------------------------- การ์ด/แผง */
.card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); padding: 24px;
}
.card__head {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 18px;
}
.card__head h3 { font-size: 17px; font-weight: 600; }
.card__head .spacer { margin-left: auto; }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1080px) { .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px)  { .grid--2, .grid--3 { grid-template-columns: 1fr; } }
@media (max-width: 640px)  { .grid--4 { grid-template-columns: 1fr; } }

/* ตัวเลขชูโรง — แบบหน้าโปรดักต์ Apple */
.stat__label {
  font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 500; margin-bottom: 8px;
}
.stat__value {
  font-family: var(--display); font-size: clamp(30px, 3.2vw, 40px);
  font-weight: 600; letter-spacing: -.03em; line-height: 1;
}
.stat__unit { font-size: .5em; font-weight: 400; color: var(--ink-soft); margin-left: 4px; }
.stat__foot { margin-top: 10px; font-size: 13px; color: var(--ink-soft); }
.stat__foot b { font-weight: 500; }
.up   { color: var(--green); }
.down { color: var(--red); }

/* ---------------------------------------------------------- ตาราง */
.tablecard { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-card); overflow: hidden; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--line-soft);
}
.toolbar .spacer { margin-left: auto; }

.tablewrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-weight: 500; font-size: 12px; letter-spacing: .03em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap; background: var(--surface);
}
table.data td {
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafafc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .docno { font-family: var(--mono); font-size: 13px; }
table.data .sub { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 3px; }
table.data .strong { font-weight: 500; }

.empty { padding: 72px 24px; text-align: center; }
.empty h4 { font-size: 19px; margin-bottom: 8px; }
.empty p { color: var(--ink-soft); margin: 0 0 20px; }

/* ป้ายสถานะ */
.badge {
  display: inline-block; font-size: 12.5px; font-weight: 500;
  padding: 4px 11px; border-radius: var(--r-pill); white-space: nowrap;
}
.badge--grey  { background: var(--grey-bg);  color: var(--ink-soft); }
.badge--blue  { background: var(--blue-bg);  color: var(--accent); }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--amber { background: var(--amber-bg); color: var(--amber); }
.badge--red   { background: var(--red-bg);   color: var(--red); }

/* แบ่งหน้า */
.pager { display: flex; align-items: center; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line-soft); }
.pager .spacer { margin-left: auto; }
.pager a, .pager span {
  min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); font-size: 13px; color: var(--ink-soft); padding: 0 9px;
}
.pager a:hover { background: var(--canvas); text-decoration: none; color: var(--ink); }
.pager .cur { background: var(--accent); color: #fff; font-weight: 500; }

/* ---------------------------------------------------------- ฟอร์ม */
.field { margin-bottom: 18px; }
.field > label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--ink-soft); margin-bottom: 7px;
}
.field .hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], select, textarea {
  width: 100%; font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 13px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,113,227,.14);
}
input::placeholder { color: var(--ink-faint); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236e6e73' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 34px;
}
textarea { resize: vertical; min-height: 84px; }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }

.search {
  position: relative; flex: 1 1 260px; max-width: 380px;
}
.search input {
  padding-left: 36px; background-color: var(--canvas); border-color: transparent;
  border-radius: var(--r-pill); font-size: 14px; padding-top: 8px; padding-bottom: 8px;
}
.search input:focus { background-color: var(--surface); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); opacity: .45; }

.switchrow {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--line-soft);
}
.switchrow:last-child { border-bottom: 0; }
.switchrow__text { flex: 1; }
.switchrow__text strong { display: block; font-weight: 500; font-size: 15px; }
.switchrow__text span { color: var(--ink-soft); font-size: 13.5px; }

.toggle { position: relative; width: 51px; height: 31px; flex: none; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle span {
  position: absolute; inset: 0; background: #e9e9eb; border-radius: var(--r-pill);
  transition: background .25s; pointer-events: none;
}
.toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.18);
  transition: transform .25s;
}
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { box-shadow: 0 0 0 4px rgba(0,113,227,.25); }

/* ตารางรายการสินค้าในเอกสาร */
table.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lines th {
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-faint); font-weight: 500; text-align: left;
  padding: 10px 10px; border-bottom: 1px solid var(--line-soft);
}
table.lines td { padding: 8px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.lines input, table.lines select { padding: 8px 10px; font-size: 14px; }
table.lines .col-qty   { width: 96px; }
table.lines .col-price { width: 130px; }
table.lines .col-disc  { width: 110px; }
table.lines .col-total { width: 130px; text-align: right; }
table.lines .col-del   { width: 44px; }
.rowtotal { font-variant-numeric: tabular-nums; padding-top: 17px; display: block; text-align: right; }
.iconbtn {
  background: none; border: 0; cursor: pointer; color: var(--ink-faint);
  font-size: 17px; line-height: 1; padding: 8px; border-radius: var(--r-sm);
}
.iconbtn:hover { color: var(--red); background: var(--red-bg); }

.totals { margin-left: auto; width: 100%; max-width: 380px; font-size: 15px; }
.totals div { display: flex; justify-content: space-between; padding: 9px 0; }
.totals div span:last-child { font-variant-numeric: tabular-nums; }
.totals .grand {
  border-top: 1px solid var(--line); margin-top: 6px; padding-top: 16px;
  font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -.02em;
}

/* ------------------------------------------------------ แจ้งเตือน/flash */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-radius: var(--r-md); margin-bottom: 22px; font-size: 14.5px;
}
.flash--ok   { background: var(--green-bg); color: var(--green); }
.flash--err  { background: var(--red-bg);   color: var(--red); }
.flash--info { background: var(--blue-bg);  color: var(--accent); }

/* ---------------------------------------------------------- ล็อกอิน */
.auth {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--canvas); padding: 40px 20px;
}
.auth__card {
  width: 100%; max-width: 420px; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 44px 40px 34px;
}
.auth__brand {
  font-family: var(--display); font-size: 30px; font-weight: 600;
  letter-spacing: -.03em; text-align: center;
}
.auth__brand span { color: var(--accent); }
.auth__sub { text-align: center; color: var(--ink-soft); font-size: 14.5px; margin: 8px 0 32px; }
.auth__foot { text-align: center; margin-top: 26px; font-size: 12.5px; color: var(--ink-faint); }
.auth__foot a { color: var(--ink-faint); }

/* --------------------------------------------------------- แผนภูมิ */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; margin-top: 20px; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.bars__bar {
  width: 100%; max-width: 46px; background: var(--accent);
  border-radius: 5px 5px 2px 2px; min-height: 3px;
  transition: opacity .2s;
}
.bars__col:hover .bars__bar { opacity: .78; }
.bars__lab {
  font-size: 11px; color: var(--ink-faint); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

.donut { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut__legend { flex: 1; min-width: 220px; }
.donut__row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.donut__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.donut__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut__val { font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* --------------------------------------------------- หน้าพิมพ์เอกสาร */
/* ==========================================================================
   เอกสาร A4 แนวตั้ง — ใช้ร่วมกันระหว่างหน้าจอ การพิมพ์ และไฟล์ PDF
   ========================================================================== */

.paperwrap {
  display: flex; justify-content: center;
  padding: 4px 0 8px; overflow-x: auto;
}

/* กระดาษ A4 210 x 297 มม. */
.doc {
  --doc-pad: 15mm;
  width: 210mm; min-height: 297mm;
  background: #fff; color: var(--ink);
  padding: 0 var(--doc-pad) 18mm;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .13), 0 2px 6px rgba(0, 0, 0, .06);
  position: relative; flex: none;
  font-size: 12.5px; line-height: 1.55;

  /* จัดเป็นคอลัมน์เพื่อดันช่องลายเซ็นลงไปชิดขอบล่างของกระดาษ */
  display: flex; flex-direction: column;
}

/* แถบสีด้านบนสุดของเอกสาร */
.doc__band {
  height: 6mm; margin: 0 calc(var(--doc-pad) * -1) 9mm;
  background: linear-gradient(90deg, var(--accent) 0%, #34aadc 58%, #5ac8fa 100%);
  border-radius: 4px 4px 0 0;
}

/* ---------------------------------------------------------------- ส่วนหัว */
.doc__head { display: flex; gap: 10mm; align-items: flex-start; justify-content: space-between; }

.doc__brand { display: flex; gap: 5mm; align-items: flex-start; min-width: 0; }
.doc__logo { width: 20mm; height: 20mm; object-fit: contain; flex: none; }

.doc__coname {
  font-family: var(--display); font-size: 17px; font-weight: 600;
  letter-spacing: -.015em; line-height: 1.25; margin-bottom: 1mm;
}
.doc__coen { font-size: 11.5px; color: var(--ink-soft); margin-bottom: 2mm; }
.doc__coinfo { font-size: 11px; color: var(--ink-soft); line-height: 1.65; white-space: pre-line; }

.doc__titleblock { text-align: right; flex: none; min-width: 62mm; }
.doc__type {
  display: inline-block; background: var(--ink); color: #fff;
  font-family: var(--display); font-size: 15px; font-weight: 600;
  letter-spacing: -.01em; padding: 3mm 6mm; border-radius: 999px;
  margin-bottom: 2.5mm; white-space: nowrap;
}
.doc__typeen {
  font-size: 10px; color: var(--ink-faint); letter-spacing: .07em;
  text-transform: uppercase; margin-bottom: 3mm;
}

/* ตารางเลขที่ / วันที่ */
/* ป้ายต้นฉบับ / สำเนา */
.doc__copy {
  display: inline-block; margin-bottom: 3mm;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  padding: 1.4mm 4mm; border-radius: 1.5mm; border: .4mm solid var(--ink);
}
.doc__copy span { font-size: 9px; font-weight: 400; letter-spacing: .1em; opacity: .6; }
.doc__copy--dup { border-color: var(--ink-faint); color: var(--ink-soft); }

.doc__nums { display: grid; grid-template-columns: auto auto; gap: 1.2mm 5mm; font-size: 11.5px; }
.doc__nums dt { color: var(--ink-soft); text-align: right; }
.doc__nums dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.doc__nums dd.mono { letter-spacing: .02em; }

/* ------------------------------------------------------------ คู่สัญญา */
.doc__parties {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 6mm;
  margin: 8mm 0 6mm;
}
.party {
  background: var(--canvas); border-radius: 3mm;
  padding: 4mm 5mm; border-left: 1mm solid var(--accent);
}
.party--plain { background: transparent; border-left: 0; padding: 4mm 0 4mm 5mm;
  border-left: .3mm solid var(--line); border-radius: 0; }
.party__label {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 1.5mm; font-weight: 500;
}
.party__name { font-weight: 600; font-size: 13px; line-height: 1.4; margin-bottom: 1.5mm; }
.party__info { font-size: 11px; color: var(--ink-soft); line-height: 1.6; white-space: pre-line; }
.party__row { display: flex; justify-content: space-between; gap: 4mm; font-size: 11.5px; padding: 1mm 0; }
.party__row + .party__row { border-top: .2mm solid var(--line-soft); }
.party__row span:first-child { color: var(--ink-soft); white-space: nowrap; flex: none; }
.party__row span:last-child { font-weight: 500; text-align: right; }

/* ------------------------------------------------------------- ตารางรายการ */
.doc__table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 5mm; }
.doc__table thead th {
  background: var(--ink); color: #fff; font-weight: 500; font-size: 10.5px;
  letter-spacing: .02em; padding: 3mm 3mm; text-align: left; white-space: nowrap;
}
.doc__table thead th:first-child { border-radius: 2mm 0 0 2mm; }
.doc__table thead th:last-child  { border-radius: 0 2mm 2mm 0; }
.doc__table tbody td { padding: 3mm; border-bottom: .25mm solid var(--line-soft); vertical-align: top; }
.doc__table tbody tr:nth-child(even) td { background: #fafafc; }
.doc__table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc__table .idx { color: var(--ink-faint); width: 8mm; }
.doc__itemname { font-weight: 500; }
.doc__itemdesc { color: var(--ink-soft); font-size: 10.5px; margin-top: .8mm; line-height: 1.5; }

/* ------------------------------------------------------------------ ท้ายบิล */
.doc__bottom { display: grid; grid-template-columns: 1fr 78mm; gap: 8mm; align-items: start; }

.doc__words {
  background: var(--blue-bg); border-radius: 3mm; padding: 4mm 5mm; margin-bottom: 4mm;
}
.doc__words .party__label { color: var(--accent); }
.doc__words b { font-size: 13px; font-weight: 600; }

.doc__note { font-size: 11px; color: var(--ink-soft); line-height: 1.6; white-space: pre-line; }

.doc__totals { font-size: 12px; }
.doc__totals div {
  display: flex; justify-content: space-between; gap: 5mm;
  padding: 2mm 0; font-variant-numeric: tabular-nums;
}
.doc__totals div + div { border-top: .2mm solid var(--line-soft); }
.doc__totals span:first-child { color: var(--ink-soft); }
.doc__totals span:last-child { font-weight: 500; }
.doc__totals .neg span:last-child { color: var(--red); }
.doc__totals .grand {
  margin-top: 2.5mm; background: var(--ink); color: #fff;
  border-radius: 2.5mm; padding: 3.5mm 4mm; border: 0;
  font-size: 14px; font-weight: 600;
}
.doc__totals .grand span:first-child,
.doc__totals .grand span:last-child { color: #fff; }

/* ------------------------------------------------------------------ ลายเซ็น */
.doc__signs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm;
  align-items: end;                 /* ให้เส้นเซ็นชื่อของทุกช่องอยู่ระดับเดียวกัน */
  margin-top: auto; padding-top: 14mm; page-break-inside: avoid;
}
.sign { text-align: center; position: relative; }
.sign__space {
  height: 21mm; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 1mm;
}
.sign__space img { max-height: 16mm; max-width: 44mm; object-fit: contain; }
.sign__rule { border-top: .3mm dashed var(--ink-faint); padding-top: 2mm; }
.sign__name { font-size: 11.5px; font-weight: 500; }
.sign__role { font-size: 10px; color: var(--ink-soft); margin-top: .6mm; }
/* ตราประทับวางเหนือลายเซ็น ไม่ทับกัน */
.sign__stamp {
  display: block; height: 19mm; width: auto;
  margin: 0 auto 2mm; opacity: .9;
}

/* ------------------------------------------------------------------- ท้ายหน้า */
.doc__footer {
  margin-top: 10mm; padding-top: 3mm; border-top: .25mm solid var(--line-soft);
  display: flex; justify-content: space-between; gap: 6mm;
  font-size: 9.5px; color: var(--ink-faint);
}

/* ลายน้ำสำหรับเอกสารร่างและเอกสารยกเลิก */
.doc__watermark {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none; overflow: hidden;
}
.doc__watermark span {
  font-family: var(--display); font-size: 62px; font-weight: 700;
  letter-spacing: .12em; transform: rotate(-24deg);
  color: rgba(29, 29, 31, .06); white-space: nowrap;
}
.doc__watermark--red span { color: rgba(255, 59, 48, .09); }

/* แถบสถานะมุมขวาบนของกระดาษ */
.doc__stamp {
  display: inline-block; font-size: 10px; font-weight: 500;
  padding: 1.4mm 3.5mm; border-radius: 999px; margin-top: 2.5mm;
}

/* --------------------------------------------------------- ย่อบนจอเล็ก */
@media (max-width: 1000px) {
  .paperwrap { padding-left: 0; padding-right: 0; }
  .doc { zoom: .82; }
}
@media (max-width: 820px) {
  .doc { zoom: .62; }
}

/* --------------------------------------------------------------- พิมพ์ */
@page { size: A4 portrait; margin: 0; }

@media print {
  .globalnav, .localnav, .noprint, .modal, .suggests { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .paperwrap { padding: 0; display: block; overflow: visible; }

  .doc {
    width: 210mm; min-height: 297mm; zoom: 1;
    box-shadow: none; border-radius: 0; margin: 0;
    padding: 0 var(--doc-pad) 14mm;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .doc__band { border-radius: 0; }
  .doc__table thead { display: table-header-group; }
  .doc__table tr, .doc__signs { page-break-inside: avoid; }
}

/* กระดาษแบบเดิม เผื่อหน้าอื่นยังเรียกใช้อยู่ */
.paper {
  background: #fff; max-width: 820px; margin: 0 auto;
  padding: 46px 52px; border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.paper h2 { font-size: 24px; }
.paper table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.paper table th { border-bottom: 1.5px solid var(--ink); padding: 9px 6px; text-align: left; font-size: 12px; }
.paper table td { border-bottom: 1px solid var(--line-soft); padding: 9px 6px; }
@media print { .paper { box-shadow: none; border-radius: 0; padding: 0; max-width: none; } }

/* ------------------------------------------------------------ อื่น ๆ */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 32px; }
.hide-sm { }
@media (max-width: 820px) {
  .hide-sm { display: none !important; }
  .globalnav__brand { margin-right: 8px; }
  .wrap { padding-top: 24px; }
}

/* -------------------------------------------------- กล่องคำแนะนำการใช้งาน */
.suggests { display: grid; gap: 12px; margin-bottom: 26px; }

.suggest {
  display: flex; align-items: flex-start; gap: 18px;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); padding: 18px 22px;
  border-left: 3px solid var(--line);
}
.suggest__body { flex: 1; min-width: 0; }
.suggest__body strong { display: block; font-weight: 500; font-size: 15.5px; margin-bottom: 3px; }
.suggest__body p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.6; max-width: 78ch; }
.suggest__act { display: flex; align-items: center; gap: 6px; flex: none; }
.suggest__act form { display: inline; }

.suggest--red   { border-left-color: var(--red); }
.suggest--amber { border-left-color: var(--amber); }
.suggest--green { border-left-color: var(--green); }
.suggest--blue  { border-left-color: var(--accent); }

@media (max-width: 720px) {
  .suggest { flex-direction: column; gap: 12px; }
  .suggest__act { width: 100%; }
  .suggest__act .btn { flex: 1; }
}

/* ------------------------------------------------------------ โลโก้บริษัท */
.logobox {
  display: flex; align-items: center; gap: 16px;
}
.logobox__preview {
  width: 96px; height: 96px; flex: none;
  border-radius: var(--r-md); background: var(--canvas);
  display: grid; place-items: center; overflow: hidden;
}
.logobox__preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logobox__preview span {
  font-family: var(--display); font-size: 30px; font-weight: 600; color: var(--ink-faint);
}

/* ------------------------------------------- ป๊อปอัปแจ้งเตือนค่าบริการ */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .42);
  -webkit-backdrop-filter: saturate(120%) blur(6px);
  backdrop-filter: saturate(120%) blur(6px);
  display: grid; place-items: center; padding: 24px;
  animation: modalIn .22s ease;
}

/*
 * display:grid ด้านบนมีน้ำหนักมากกว่าค่า display:none ที่เบราว์เซอร์ให้กับ
 * แอตทริบิวต์ hidden กล่องจึงเปิดค้างถ้าไม่เขียนกำกับไว้ตรงนี้
 */
.modal[hidden] { display: none; }

@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.modal__box {
  background: var(--surface); border-radius: 22px;
  box-shadow: 0 24px 68px rgba(0, 0, 0, .28);
  max-width: 460px; width: 100%; padding: 36px 34px 30px;
  text-align: center; border-top: 4px solid var(--accent);
  animation: modalPop .26s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes modalPop { from { transform: translateY(14px) scale(.97); } to { transform: none; } }

.modal__box--red   { border-top-color: var(--red); }
.modal__box--amber { border-top-color: var(--amber); }
.modal__box--blue  { border-top-color: var(--accent); }

.modal__icon {
  width: 62px; height: 62px; margin: 0 auto 18px;
  border-radius: 50%; background: var(--canvas);
  display: grid; place-items: center;
  font-family: var(--display); font-size: 26px; font-weight: 600;
  color: var(--ink);
}
.modal__box--red   .modal__icon { background: var(--red-bg);   color: var(--red); }
.modal__box--amber .modal__icon { background: var(--amber-bg); color: var(--amber); }
.modal__box--blue  .modal__icon { background: var(--blue-bg);  color: var(--accent); }

.modal__title {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  letter-spacing: -.02em; margin: 0 0 10px; line-height: 1.35;
}
.modal__body { font-size: 15px; line-height: 1.65; color: var(--ink-soft); margin: 0 0 14px; }
.modal__warn {
  font-size: 13.5px; line-height: 1.6; color: var(--ink-soft);
  background: var(--canvas); border-radius: var(--r-md);
  padding: 12px 15px; margin: 0 0 24px; text-align: left;
}
.modal__act { display: grid; gap: 9px; }
.modal__act form { display: block; }
.modal__act .btn { width: 100%; }

@media (max-width: 520px) {
  .modal__box { padding: 28px 22px 24px; }
  .modal__title { font-size: 19px; }
}

@media print { .modal { display: none !important; } }

/* ------------------------------------------------------ ไอคอนแอปบนหน้าจอ */
.globalnav__brand { display: inline-flex; align-items: center; gap: 8px; }
.globalnav__logo {
  width: 22px; height: 22px; border-radius: 6px; display: block; flex: none;
}

.auth__logo { margin-bottom: 14px; }
.auth__logo img {
  width: 62px; height: 62px; border-radius: 15px; display: block;
  margin: 0 auto; box-shadow: 0 4px 14px rgba(0, 113, 227, .28);
}

/* ----------------------------------------------------- สายงานเอกสาร */
.flow {
  display: flex; align-items: stretch; gap: 10px;
  flex-wrap: wrap; margin-top: 4px;
}
.flow__step {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--canvas); border-radius: var(--r-md);
  padding: 12px 16px; min-width: 150px; text-decoration: none; color: var(--ink);
  border: 1px solid transparent;
}
a.flow__step:hover { background: var(--blue-bg); text-decoration: none; }
.flow__step--now { background: var(--ink); color: #fff; }
.flow__step--now .flow__type,
.flow__step--now .flow__meta { color: rgba(245, 245, 247, .7); }

.flow__type { font-size: 11px; letter-spacing: .04em; color: var(--ink-soft); }
.flow__no   { font-size: 15px; font-weight: 500; }
.flow__meta { font-size: 12px; color: var(--ink-soft); }
.flow__arrow { align-self: center; color: var(--ink-faint); font-size: 18px; }

@media (max-width: 640px) {
  .flow { flex-direction: column; }
  .flow__arrow { transform: rotate(90deg); align-self: flex-start; margin-left: 24px; }
}

/* -------------------------------------------------- ช่องทางติดต่อฝ่ายสนับสนุน */
.support {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px;
}
.support__item {
  display: flex; align-items: center; gap: 13px;
  background: var(--canvas); border-radius: var(--r-md);
  padding: 14px 16px; text-decoration: none; color: var(--ink);
  border: 1px solid transparent; transition: background .15s ease, border-color .15s ease;
}
.support__item:hover { background: #fff; border-color: var(--line); text-decoration: none; }

.support__icon {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: var(--ink-soft);
}
.support__item--line  .support__icon { background: #06c755; color: #fff; }
.support__item--phone .support__icon { background: var(--blue-bg); color: var(--accent); }
.support__item--email .support__icon { background: var(--amber-bg); color: var(--amber); }

.support__body { display: flex; flex-direction: column; min-width: 0; }
.support__label { font-size: 11.5px; color: var(--ink-faint); letter-spacing: .03em; }
.support__value { font-size: 15px; font-weight: 500; word-break: break-word; }
.support__note  { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

/* ปุ่ม LINE บนหน้าที่ไม่มีแถบนำทาง */
.btn--line {
  background: #06c755; color: #fff; border: 0;
}
.btn--line:hover { background: #05b34c; color: #fff; }

/* ปุ่มช่วยเหลือบนแถบนำทาง */
.gn--help { color: #6de08f !important; }
.gn--help:hover { color: #8ff0ab !important; }

/* เอกสารหลายใบ เช่น ต้นฉบับกับสำเนา */
.paperwrap { flex-direction: column; align-items: center; gap: 20px; }
.doc--next { margin-top: 0; }
@media print {
  .paperwrap { gap: 0; }
  .doc { page-break-after: always; }
  .doc:last-child { page-break-after: auto; }
}

/* ------------------------------------------------- กราฟแท่งแนวนอน */
.hbars { display: grid; gap: 14px; }

.hbar {
  display: block; text-decoration: none; color: inherit;
  padding: 2px 4px; margin: -2px -4px; border-radius: var(--r-sm);
}
a.hbar:hover { background: var(--canvas); text-decoration: none; }

.hbar__head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 5px; }
.hbar__label { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__value { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink-soft); flex: none; }
.hbar__track { height: 7px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.hbar__fill  { height: 100%; border-radius: 4px; transition: width .3s ease; }
.hbar__sub   { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }

/* แถบ 24 ชั่วโมง */
.hours { display: flex; gap: 3px; align-items: flex-end; height: 90px; }
.hours__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; align-items: center; }
.hours__bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--accent); min-height: 2px; }
.hours__lab { font-size: 9.5px; color: var(--ink-faint); }

/* แถบเลือกมุมมองในหลังบ้าน */
.viewbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.viewbar a {
  padding: 8px 16px; border-radius: 999px; font-size: 14px;
  background: var(--surface); color: var(--ink-soft); text-decoration: none;
  box-shadow: var(--shadow-card);
}
.viewbar a:hover { color: var(--ink); text-decoration: none; }
.viewbar a[aria-current="true"] { background: var(--ink); color: #fff; }

/* ทางกลับจากหน้ารายละเอียด */
.crumb { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 10px; }
.crumb a { color: var(--ink-soft); }

/* ปุ่มลบในกล่องยืนยัน ต้องเด่นกว่าปุ่มลบทั่วไป */
.modal .btn--danger { background: var(--red); color: #fff; border-color: var(--red); }
.modal .btn--danger:hover { background: #b8000f; color: #fff; }
.btn--del:hover { color: var(--red); }

/* ปุ่มสลับภาษาบนแถบนำทาง */
.gn--lang {
  border: 1px solid rgba(245, 245, 247, .25); border-radius: 6px;
  padding: 3px 9px; font-size: 12px; letter-spacing: .04em;
}
.gn--lang:hover { border-color: rgba(245, 245, 247, .5); }
