* { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
/* overflow-x:clip (not hidden) — clip does NOT create a scroll container, so the sticky .hdr
   keeps working. Safety net only; every known overflow source is fixed at the root below. */
html { overflow-x:clip; }
body { font-family:'Sarabun',sans-serif; background:#FFF8E7; font-size:22px; color:#3e2000; overflow-x:clip; }

/* ── SCREENS ── */
.screen { display:none; min-height:100vh; flex-direction:column; }
.screen.active { display:flex; }

/* ── HEADER ── */
.hdr {
  background:linear-gradient(135deg,#7B1FA2,#6A1B9A);
  padding:20px 22px; display:flex; align-items:center; gap:16px;
  position:sticky; top:0; z-index:10;
  box-shadow:0 3px 12px rgba(74,20,140,.3);
}
.hdr-back {
  font-size:36px; cursor:pointer; color:#FFD700; line-height:1; user-select:none;
  min-width:44px; min-height:44px; display:inline-flex; align-items:center; justify-content:center;
  margin-left:-8px;   /* keep the glyph optically where it was after growing the hit area */
}
.hdr h1 { font-size:26px; font-weight:900; color:#FFD700; }
.hdr-right { margin-left:auto; }
.hdr-user { font-size:14px; color:rgba(255,215,0,.7); text-align:right; }
.hdr-logout { font-size:13px; color:#E0A8EA; cursor:pointer; text-decoration:underline; margin-top:2px; }

/* ── SUMMARY BANNER ── */
.summary {
  background:linear-gradient(135deg,#7B1FA2 0%,#4A148C 100%);
  padding:28px 20px; text-align:center; position:relative; overflow:hidden;
}
.summary::before { content:'◆'; position:absolute; top:8px; left:14px; font-size:70px; opacity:.08; color:#FFD700; }
.summary::after  { content:'◆'; position:absolute; bottom:4px; right:14px; font-size:90px; opacity:.08; color:#FFD700; }
.sum-label  { font-size:17px; color:#E1BEE7; }
/* clamp: .summary has overflow:hidden, so a fixed 58px silently CLIPPED 7-digit totals on phones.
   Floor raised now that satang are hidden — the string is 3 chars shorter. */
.sum-amount { font-size:clamp(40px,13vw,58px); font-weight:900; color:#FFD700; line-height:1.1; text-shadow:0 2px 8px rgba(0,0,0,.2); }
.sum-count  { font-size:16px; color:#E0A8EA; margin-top:6px; }

/* ── GOLD DIVIDER ── */
.gold-bar { height:4px; background:linear-gradient(90deg,transparent,#FFD700,transparent); }

/* ── LIST ── */
.list { flex:1; padding:16px; display:flex; flex-direction:column; gap:14px; padding-bottom:100px; }
.card {
  background:#fff; border:2px solid #F3E5F5; border-radius:20px;
  padding:20px; display:flex; align-items:center; gap:16px;
  cursor:pointer; transition:all .12s;
  box-shadow:0 3px 12px rgba(74,20,140,.08);
}
.card:active { background:#F3E5F5; border-color:#7B1FA2; transform:scale(.98); }
.av {
  width:64px; height:64px; border-radius:50%;
  background:linear-gradient(135deg,#7B1FA2,#4A148C);
  color:#FFD700; font-size:22px; font-weight:900;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
/* min-width:0 = let the text column shrink. Thai names have no spaces, so min-content is the
   whole string — without this the card pushes the page wider than the viewport. */
.ci { flex:1; min-width:0; }
/* clamp to 2 lines + ellipsis — Thai has no word breaks, so a long name would otherwise stack
   one syllable per line and stretch the card vertically */
.cn {
  font-size:clamp(19px,5.2vw,22px); font-weight:800; color:#3e2000; line-height:1.3;
  overflow-wrap:anywhere; overflow:hidden;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
}
/* phone / "ค้างตั้งแต่..." — one line, ellipsis. Never break a phone number across lines. */
.cp { font-size:16px; color:#AB47BC; margin-top:4px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cp-green  { color:#2E7D32; }
.cp-orange { color:#E65100; }
.cp-red    { color:#C62828; }
.ca { text-align:right; flex-shrink:0; }
/* clamp: 7-digit amounts stay on one line on a 360px phone without pushing the row wider */
.ca-val   { font-size:clamp(22px,6vw,26px); font-weight:900; color:#7B1FA2; white-space:nowrap; }
.ca-label { font-size:13px; color:#9C4FAE; white-space:nowrap; }
.ca-val.over-credit   { color:#E65100; }
.ca-label.over-credit { color:#E65100; font-weight:700; }
.credit-warn-badge {
  background:#FFF3E0; color:#E65100; border:2px solid #FFCC80;
  border-radius:12px; padding:8px 16px; font-size:15px; font-weight:700;
  text-align:center; margin-top:6px;
}
.arrow { font-size:28px; color:#CE93D8; flex-shrink:0; }

/* narrow phones (≤400px): tighten the row so name + amount both stay readable */
@media (max-width:400px) {
  .card  { padding:16px 14px; gap:11px; }
  .av    { width:52px; height:52px; font-size:19px; }
  /* drop the decorative chevron — the whole card is tappable, and the ~21px it frees
     goes to the name/phone column so amounts can stay big */
  .arrow { display:none; }
  .list  { padding:12px; gap:12px; padding-bottom:100px; }
  .cp    { font-size:15px; }
}

/* ── FAB ── */
.fab {
  /* safe-area: keep the FAB clear of the iOS home indicator / notch gutter in landscape */
  position:fixed; bottom:calc(24px + env(safe-area-inset-bottom)); right:calc(20px + env(safe-area-inset-right)); z-index:50;
  width:70px; height:70px; border-radius:50%;
  background:linear-gradient(135deg,#FFD700,#FFA000);
  color:#4A148C; font-size:36px; font-weight:900;
  border:none; cursor:pointer;
  box-shadow:0 6px 20px rgba(74,20,140,.35);
  display:flex; align-items:center; justify-content:center;
  transition:transform .15s;
}
.fab:active { transform:scale(.93); }
.fab-label {
  position:fixed; bottom:calc(30px + env(safe-area-inset-bottom)); right:calc(100px + env(safe-area-inset-right)); z-index:50;
  background:#4A148C; color:#FFD700; border-radius:12px;
  padding:8px 14px; font-size:15px; font-weight:700;
  box-shadow:0 3px 10px rgba(0,0,0,.2); white-space:nowrap;
  max-width:calc(100vw - 140px); overflow:hidden; text-overflow:ellipsis;
}

/* ── DETAIL ── */
.det-top {
  background:linear-gradient(135deg,#7B1FA2,#4A148C);
  padding:28px 20px; text-align:center; position:relative; overflow:hidden;
}
.det-top::before { content:'◆'; position:absolute; top:6px; left:12px; font-size:60px; opacity:.08; color:#FFD700; }
.det-av {
  width:90px; height:90px; border-radius:50%;
  background:rgba(255,215,0,.15); color:#FFD700;
  font-size:32px; font-weight:900;
  display:flex; align-items:center; justify-content:center;
  margin:0 auto 14px; border:3px solid rgba(255,215,0,.4);
}
.det-name       { font-size:clamp(22px,7vw,28px); font-weight:900; color:#FFD700; overflow-wrap:anywhere; }
.det-phone      { font-size:18px; color:#E0A8EA; margin-top:6px; }
.det-debt-label { font-size:15px; color:#E1BEE7; margin-top:10px; }
/* clamp — same clipping issue as .sum-amount (.det-top is overflow:hidden) */
.det-debt       { font-size:clamp(38px,12.5vw,52px); font-weight:900; color:#FFD700; line-height:1.1; text-shadow:0 2px 8px rgba(0,0,0,.3); }

/* ── BIG BUTTONS ── */
.btn-row { padding:20px; display:flex; flex-direction:column; gap:14px; }
.big-btn {
  width:100%; padding:24px; font-size:24px; font-weight:900;
  border:none; border-radius:20px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:12px;
  transition:transform .1s; font-family:inherit;
}
.big-btn:active { transform:scale(.97); }
.btn-pay  { background:linear-gradient(135deg,#7B1FA2,#4A148C); color:#FFD700; font-size:26px; box-shadow:0 4px 14px rgba(74,20,140,.3); }
.btn-hist { background:#F3E5F5; color:#7B1FA2; border:3px solid #CE93D8; }
.btn-add-debt { background:#FFF8E1; color:#E65100; border:3px solid #FFCC80; font-size:22px; }
.btn-link { background:#F3E5F5; color:#6A1B9A; border:3px solid #CE93D8; font-size:20px; }

/* ── PAYMENT ── */
.pay-wrap { flex:1; padding:20px; display:flex; flex-direction:column; gap:16px; }
.pay-info-box { background:#F3E5F5; border:2px solid #CE93D8; border-radius:20px; padding:20px; text-align:center; }
.pib-label { font-size:15px; color:#8E24AA; }
.pib-name  { font-size:22px; font-weight:800; color:#4A148C; overflow-wrap:anywhere; }
/* phone under the name — Thai first names repeat, so the name alone is not enough to
   confirm you are charging the right person */
.pib-phone { font-size:16px; font-weight:700; color:#7B1FA2; margin-top:2px; }
.pib-phone:empty { display:none; }
.pib-debt  { font-size:36px; font-weight:900; color:#7B1FA2; margin-top:4px; }
.pay-input-label { font-size:19px; font-weight:700; color:#7B1FA2; }
.pay-input {
  width:100%; padding:20px; font-size:38px; font-weight:900;
  border:3px solid #CE93D8; border-radius:18px;
  text-align:center; color:#4A148C; outline:none; font-family:inherit; background:#fff;
}
.pay-input:focus { border-color:#7B1FA2; background:#FAF0FF; }
.quick-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.qb {
  background:#F3E5F5; color:#7B1FA2;
  border:2px solid #CE93D8; border-radius:16px;
  padding:20px; font-size:24px; font-weight:800;
  cursor:pointer; text-align:center; font-family:inherit; transition:transform .1s;
}
.qb:active { background:#E1BEE7; transform:scale(.96); }
.qb-full-row { display:flex; justify-content:center; }
.qb-full {
  background:#FFF8E1; color:#E65100; border:2px solid #FFCC80; border-radius:12px;
  padding:11px 22px; font-size:16px; font-weight:700; cursor:pointer; font-family:inherit; transition:transform .1s;
}
.qb-full:active { background:#FFE0B2; transform:scale(.96); }

/* "close the debt then re-open it at the same amount" — deliberately NOT the orange of .qb-full:
   the two used to sit side by side in the same colour and a mis-tap silently created a new debt */
.qb-renew-wrap { margin-top:14px; padding-top:14px; border-top:2px dashed #E1BEE7; text-align:center; }
.qb-renew {
  width:100%; padding:16px; min-height:44px;
  background:#E8EAF6; color:#283593; border:2px solid #9FA8DA; border-radius:16px;
  font-size:17px; font-weight:800; font-family:inherit; cursor:pointer;
}
.qb-renew:active { background:#C5CAE9; transform:scale(.98); }
.qb-renew-hint { font-size:13px; color:#6B5E8C; margin-top:7px; line-height:1.5; }
.confirm-big {
  background:linear-gradient(135deg,#7B1FA2,#4A148C); color:#FFD700;
  border:none; border-radius:20px; padding:24px; font-size:26px; font-weight:900;
  cursor:pointer; font-family:inherit; margin-top:4px;
  box-shadow:0 4px 14px rgba(74,20,140,.3); transition:transform .1s;
}
.confirm-big:active { transform:scale(.97); }
.cancel-big {
  background:#F3E5F5; color:#AB47BC; border:2px solid #CE93D8;
  border-radius:18px; padding:18px; font-size:20px; font-weight:700;
  cursor:pointer; font-family:inherit;
}
.pay-note-btn {
  background:#fff; color:#7B1FA2; border:2px dashed #CE93D8;
  border-radius:16px; padding:14px; font-size:18px; font-weight:700;
  cursor:pointer; font-family:inherit; text-align:left;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.pay-note-btn.has-note {
  background:#F3E5F5; border-style:solid; color:#4A148C;
}

/* ── HISTORY ── */
.hist-wrap { flex:1; padding:14px 14px 90px; }   /* bottom room so the fixed #offline-bar never covers the last row's buttons */
.hist-item {
  background:#fff; border-radius:18px; padding:18px 16px; margin-bottom:14px;
  display:flex; align-items:center; gap:14px;
  box-shadow:0 2px 10px rgba(74,20,140,.07); border:2px solid #F3E5F5;
}
.hist-ic  { width:56px; height:56px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:26px; flex-shrink:0; }
.hist-ic.p { background:#E8F5E9; }
.hist-ic.d { background:#F3E5F5; }
.hist-body { flex:1; min-width:0; }   /* ให้ส่วนข้อความหดก่อน — กัน amount/ปุ่มถูกบีบจนตัดบรรทัด */
.hist-type { font-size:19px; font-weight:800; color:#3e2000; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* วัน/เดือน/เวลา = ข้อมูลที่ต้องเน้น → ไม่ตัดทิ้ง (ขึ้นบรรทัดใหม่ได้ถ้าจอแคบมาก) */
.hist-date { font-size:15px; color:#AB47BC; margin-top:4px; font-weight:800; }
.hist-amt   { font-size:23px; font-weight:900; white-space:nowrap; flex-shrink:0; }
.hist-amt.p { color:#2E7D32; }
.hist-amt.d { color:#7B1FA2; }
/* จอแคบ (เช่น iPhone SE 320px) — ย่อไอคอน/ยอดเงิน เพื่อให้ชนิดรายการ + วัน/เวลาแสดงครบ */
@media (max-width:380px){
  .hist-item { padding:14px 12px; gap:11px; }
  .hist-ic   { width:46px; height:46px; font-size:22px; }
  .hist-type { font-size:17px; }
  .hist-amt  { font-size:20px; }
}
/* ยอดเงิน + ปุ่มจัดการ แยกเป็นคอลัมน์ขวาสุด: ยอดอยู่บน ปุ่มอยู่ล่าง — กันเบียดกันแนวนอน */
.hist-right   { flex-shrink:0; display:flex; flex-direction:column; align-items:flex-end; gap:10px; }
/* ปุ่ม ✏️/🗑️ ซ่อนปกติ (แสดงข้อมูลเต็ม) — โผล่เมื่อกด "จัดการ" ที่ header */
.hist-actions { display:none; gap:8px; }
.hist-wrap.manage-on .hist-actions { display:flex; }
.hist-edit-btn {
  flex-shrink:0; width:44px; height:44px; border-radius:50%;
  border:2px solid #E1BEE7; background:#F8F0FF; color:#4A148C;
  font-size:17px; cursor:pointer; font-family:inherit; padding:0;
}
.hist-edit-btn:active { transform:scale(.9); background:#EDE7F6; }
.hist-del-btn {
  flex-shrink:0; width:44px; height:44px; border-radius:50%;
  border:2px solid #FFCDD2; background:#FFEBEE; color:#C62828;
  font-size:17px; cursor:pointer; font-family:inherit; padding:0;
}
.hist-del-btn:active { transform:scale(.9); background:#FFCDD2; }
.hist-item.hist-voided { opacity:.55; background:#FAFAFA; border-color:#EEE; }
.hist-item.hist-voided .hist-type,
.hist-item.hist-voided .hist-amt { text-decoration:line-through; }
.hist-voided-badge { font-size:13px; font-weight:900; color:#C62828; margin-top:4px; }

/* ── FORM ── */
.form-wrap { flex:1; padding:20px; display:flex; flex-direction:column; gap:18px; }
.form-group { display:flex; flex-direction:column; gap:8px; }
.form-label { font-size:18px; font-weight:800; color:#7B1FA2; }
.form-input {
  width:100%; padding:18px; font-size:22px; font-weight:700;
  border:3px solid #CE93D8; border-radius:16px;
  color:#3e2000; outline:none; font-family:inherit; background:#fff;
}
.form-input:focus { border-color:#7B1FA2; background:#FAF0FF; }
.form-hint { font-size:14px; color:#AB47BC; }
/* แถว input + ปุ่มเครื่องคิดเลขเล็ก */
.calc-input-row { display:flex; gap:8px; align-items:stretch; }
.calc-input-row > input { flex:1; min-width:0; }
.calc-mini-btn {
  flex:0 0 auto; display:none; align-items:center; justify-content:center;
  width:54px; border:3px solid #CE93D8; border-radius:16px;
  background:#F3E5F5; color:#7B1FA2; font-size:24px; cursor:pointer; font-family:inherit;
}
.calc-mini-btn:active { transform:scale(.94); }
.calc-mini-btn.show { display:flex; }
/* หน้าประวัติรายวัน — พื้นเข้มให้เข้ากับสีตัวอักษร (ทอง/เขียว) */
#s-daily-hist { background:linear-gradient(180deg,#3B0764 0%,#1A0033 100%); }
.submit-btn {
  background:linear-gradient(135deg,#7B1FA2,#4A148C); color:#FFD700;
  border:none; border-radius:20px; padding:24px; font-size:24px; font-weight:900;
  cursor:pointer; font-family:inherit; margin-top:8px;
  box-shadow:0 4px 14px rgba(74,20,140,.3);
}
.submit-btn:disabled { opacity:.5; cursor:not-allowed; }
.form-cancel {
  background:#F3E5F5; color:#AB47BC; border:2px solid #CE93D8;
  border-radius:18px; padding:18px; font-size:20px; font-weight:700;
  cursor:pointer; font-family:inherit; text-align:center;
}
.form-cust-box {
  background:linear-gradient(135deg,#7B1FA2,#4A148C);
  border-radius:18px; padding:18px 20px; display:flex; gap:14px; align-items:center;
}
.form-cust-av {
  width:56px; height:56px; border-radius:50%;
  background:rgba(255,215,0,.2); color:#FFD700;
  font-size:20px; font-weight:900; border:2px solid rgba(255,215,0,.4);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.form-cust-name { font-size:20px; font-weight:800; color:#FFD700; }
.form-cust-debt { font-size:15px; color:#CE93D8; margin-top:3px; }

/* ── LOGIN (Cosmixon premium dark) ── */
#s-login {
  background:
    radial-gradient(1000px 620px at 12% 0%, rgba(123,31,162,.38), transparent 62%),
    radial-gradient(760px 520px at 96% 96%, rgba(255,193,7,.10), transparent 60%),
    radial-gradient(600px 460px at 50% 40%, rgba(0,207,255,.05), transparent 65%),
    linear-gradient(165deg, #1c0834 0%, #0d0420 100%);
  background-attachment:fixed;
}
.login-wrap {
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:32px 24px; gap:20px; position:relative; z-index:1;
}
.login-logo {
  text-align:center; margin-bottom:8px;
}
.login-logo-icon { font-size:64px; line-height:1;
  background:linear-gradient(135deg,#FFE082 0%,#FFC107 45%,#FF8F00 100%);
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent;
  filter:drop-shadow(0 2px 10px rgba(255,176,0,.35)); }
.login-logo-title {
  font-size:28px; font-weight:900; margin-top:10px; letter-spacing:.2px;
  background:linear-gradient(135deg,#fff 30%,#E5CFFF 100%);
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent;
}
.login-logo-sub   { font-size:15px; color:#B8A0DE; margin-top:4px; font-weight:600; letter-spacing:.3px; }

/* trust badges — small balance-filler + reassurance row under the subtitle */
.login-trust { display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; }
.login-trust span {
  display:inline-flex; align-items:center; gap:5px;
  background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.09);
  border-radius:20px; padding:6px 12px; font-size:12.5px; font-weight:600; color:#C9AEE8;
}

.login-box {
  width:100%; max-width:420px;
  background:rgba(255,255,255,.055); border-radius:24px; padding:28px 24px;
  border:1px solid rgba(255,255,255,.14);
  box-shadow:0 24px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.07);
  backdrop-filter:blur(24px); -webkit-backdrop-filter:blur(24px);
  display:flex; flex-direction:column; gap:18px;
}
.login-btn {
  position:relative; overflow:hidden;
  background:linear-gradient(135deg,#9C6ADE,#7B1FA2); color:#FFE9A3;
  border:none; border-radius:18px; padding:22px; font-size:24px; font-weight:900;
  cursor:pointer; font-family:inherit;
  box-shadow:0 6px 20px rgba(123,31,162,.45); transition:transform .1s, box-shadow .15s;
}
.login-btn::after {
  content:''; position:absolute; inset:0; border-radius:inherit;
  background:linear-gradient(115deg, transparent 30%, rgba(255,255,255,.22) 48%, transparent 66%);
  background-size:250% 100%; background-position:150% 0; pointer-events:none;
  transition:background-position .55s ease;
}
@media (hover:hover) {
  .login-btn:hover:not(:disabled) { box-shadow:0 8px 26px rgba(123,31,162,.6); }
  .login-btn:hover:not(:disabled)::after { background-position:-50% 0; }
}
.login-btn:active { transform:scale(.97); }
.login-btn:disabled { opacity:.5; cursor:not-allowed; }
.login-err {
  background:rgba(239,83,80,.14); color:#FF8A80; border:1px solid rgba(239,83,80,.35);
  border-radius:14px; padding:14px; font-size:16px; font-weight:700; text-align:center;
  display:none;
}
.login-err.show { display:block; }

/* form fields — scoped dark override (shared .form-* classes are light elsewhere in the app) */
#s-login .form-label { color:#D8C4F0; }
#s-login .form-input {
  background:rgba(255,255,255,.05); border:1.5px solid rgba(255,255,255,.16); color:#fff;
  transition:border-color .15s, background .15s, box-shadow .15s;
}
#s-login .form-input::placeholder { color:rgba(255,255,255,.32); }
#s-login .form-input:focus {
  border-color:#B583E0; background:rgba(255,255,255,.08);
  box-shadow:0 0 0 4px rgba(156,106,222,.16);
}

/* hub link + feature cards */
.login-hub-link {
  display:inline-flex; align-items:center; gap:8px;
  color:#D8B4FE; font-size:14px; font-weight:600; text-decoration:none;
  background:rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.14);
  border-radius:11px; padding:8px 15px; margin-bottom:8px;
  opacity:.75; transition:opacity .15s, border-color .15s, transform .15s; cursor:pointer;
}
@media (hover:hover) {
  .login-hub-link:hover { opacity:1; border-color:rgba(216,180,254,.5); transform:translateY(-1px); }
}
.login-feature {
  display:flex; gap:10px; align-items:flex-start;
  background:rgba(255,255,255,.045); border:1px solid rgba(255,255,255,.1);
  border-radius:12px; padding:11px 13px; font-size:13.5px; color:#E4D9F5; line-height:1.4;
  backdrop-filter:blur(6px); transition:border-color .15s, background .15s, transform .15s;
}
@media (hover:hover) {
  .login-feature:hover {
    border-color:rgba(216,180,254,.35); background:rgba(255,255,255,.07);
    transform:translateX(3px);
  }
}
.login-feature b { color:#fff; }
.login-feature .lf-icon { font-size:17px; flex-shrink:0; filter:drop-shadow(0 0 4px rgba(255,193,7,.3)); }

/* auth tabs (login/signup) */
.auth-tab {
  flex:1; padding:14px 10px; min-height:44px; border:1px solid rgba(255,255,255,.14); border-radius:10px;
  font-weight:700; font-size:14px; cursor:pointer; font-family:inherit;
  background:rgba(255,255,255,.04); color:#C9AEE8; transition:background .15s, color .15s, border-color .15s;
}
@media (hover:hover) {
  .auth-tab:not(.active):hover { background:rgba(255,255,255,.08); color:#fff; }
}
.auth-tab.active {
  background:linear-gradient(135deg,#9C6ADE,#7B1FA2); color:#fff; border-color:transparent;
}

/* language toggle — dark variant (scoped: .lang-seg elsewhere in the app stays light) */
.lang-login .lang-btn { transition:background .15s, color .15s, border-color .15s;
  padding:11px 16px; min-height:44px; border:1px solid rgba(255,255,255,.16); border-radius:20px;
  background:rgba(255,255,255,.05); color:#C9AEE8; font-size:13px; font-weight:700;
  cursor:pointer; font-family:inherit;
}
.lang-login .lang-btn.lang-on { background:#7B1FA2; color:#FFE9A3; border-color:#7B1FA2; }

/* changelog accordion (rendered by renderChangelog() in 01-config-i18n.js) — collapsed by default to balance column height */
.login-changelog {
  background:rgba(255,255,255,.045); border:1px solid rgba(255,255,255,.1);
  border-radius:14px; backdrop-filter:blur(6px); overflow:hidden;
}
.login-changelog-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 14px; cursor:pointer; user-select:none; gap:10px;
  transition:background .15s;
}
@media (hover:hover) { .login-changelog-head:hover { background:rgba(255,255,255,.04); } }
.login-changelog-chev { transition:transform .2s ease; color:#C9AEE8; font-size:12px; flex-shrink:0; }
.login-changelog.open .login-changelog-chev { transform:rotate(180deg); }
.login-changelog-body {
  max-height:0; overflow:hidden; transition:max-height .28s ease;
  padding:0 14px;
}
.login-changelog.open .login-changelog-body { max-height:240px; overflow-y:auto; padding:0 14px 14px; }
.login-changelog-row { border-left:2px solid rgba(216,180,254,.4); padding-left:10px; }
.login-changelog-row + .login-changelog-row { margin-top:10px; }

/* ── entrance (one-shot, respects prefers-reduced-motion — no continuous/decorative loops) ── */
@keyframes loginFadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.login-hub-link, .login-logo, .login-trust, .login-feature, .login-panel > * {
  animation:loginFadeUp .45s ease both;
}
.login-hub-link  { animation-delay:.02s; }
.login-logo      { animation-delay:.07s; }
.login-trust     { animation-delay:.12s; }
.login-promo .login-feature:nth-child(1) { animation-delay:.16s; }
.login-promo .login-feature:nth-child(2) { animation-delay:.21s; }
.login-promo .login-feature:nth-child(3) { animation-delay:.26s; }
.login-promo .login-feature:nth-child(4) { animation-delay:.31s; }
.login-panel > *:nth-child(1) { animation-delay:.10s; }
.login-panel > *:nth-child(2) { animation-delay:.15s; }
.login-panel > *:nth-child(3) { animation-delay:.20s; }
.login-panel > *:nth-child(4) { animation-delay:.25s; }
.login-panel > *:nth-child(5) { animation-delay:.30s; }
.login-panel > *:nth-child(6) { animation-delay:.35s; }
.login-panel > *:nth-child(7) { animation-delay:.40s; }
@media (prefers-reduced-motion: reduce) {
  .login-hub-link, .login-logo, .login-trust, .login-feature, .login-panel > * { animation:none; }
  .login-btn::after { display:none; }
  .login-feature, .login-hub-link, .login-changelog-body, #s-login .form-input { transition:none; }
}

/* ── LOGIN responsive groups ── */
.login-hero  { width:100%; max-width:420px; display:flex; flex-direction:column; align-items:center; gap:14px; }
.login-panel { width:100%; max-width:420px; display:flex; flex-direction:column; gap:18px; }
.login-promo { width:100%; }

/* ── DESKTOP: split สองคอลัมน์ (≥900px) — anchored to the same top line, not center, so the two columns of very different height don't look adrift ── */
@media (min-width:900px) {
  #s-login .login-wrap {
    flex-direction:row; align-items:flex-start; justify-content:center;
    gap:56px; max-width:1060px; margin:0 auto; padding:64px 40px;
  }
  #s-login .login-hero {
    flex:1; max-width:520px; align-items:flex-start; text-align:left; padding-top:6px;
  }
  #s-login .login-logo      { text-align:left; margin-bottom:2px; }
  #s-login .login-logo-icon { font-size:88px; }
  #s-login .login-logo-title{ font-size:40px; margin-top:14px; }
  #s-login .login-logo-sub  { font-size:18px; }
  #s-login .login-promo     { margin:20px 0 0 !important; gap:10px !important; }
  #s-login .login-panel     { flex-shrink:0; width:420px; max-width:420px; }
  #s-login .login-box       { box-shadow:0 26px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.07); }
}
@media (min-width:1280px) {
  #s-login .login-wrap { gap:80px; }
}

/* ── DESKTOP: app frame กลางจอ (≥768px) — ทุกหน้ายกเว้น login ── */
@media (min-width:768px) {
  body {
    min-height:100vh;
    display:flex; align-items:flex-start; justify-content:center;
    background:
      radial-gradient(900px 520px at 50% -8%, rgba(123,31,162,.55), transparent 70%),
      radial-gradient(700px 500px at 100% 100%, rgba(255,176,0,.10), transparent 60%),
      linear-gradient(165deg, #2a0d4a 0%, #1c0834 100%);
    background-attachment:fixed;
  }
  /* login มี layout/พื้นหลังของตัวเอง — ให้เต็มจอเหมือนเดิม */
  #s-login.active { width:100%; min-height:100vh; }

  /* ทุกหน้าแอป = แผงกลางจอ กว้างคงที่ มีเงานุ่ม */
  .screen:not(#s-login).active {
    width:480px; max-width:480px; min-height:100vh;
    background:#FFF8E7;
    box-shadow:0 0 0 1px rgba(255,255,255,.06), 0 26px 80px rgba(0,0,0,.5);
  }

  /* FAB + label ชิดขอบขวาของเฟรม (ไม่ลอยไปมุมจอ) */
  .fab       { right:calc(50% - 220px); }
  .fab-label { right:calc(50% - 140px); }

  /* modal → จัดกลางจอ + มุมโค้งรอบด้าน (ไม่ใช่ bottom-sheet เต็มกว้าง) */
  .modal-overlay { align-items:center; justify-content:center; }
  .modal {
    width:440px; max-width:92vw; border-radius:28px;
    border-top:5px solid #FFD700; padding-bottom:32px;
    box-shadow:0 24px 70px rgba(0,0,0,.4);
  }

  /* offline bar ชิดในกรอบ (inline style → ต้อง !important) */
  #offline-bar {
    left:50% !important; right:auto !important;
    transform:translateX(-50%); width:480px; max-width:480px;
    border-radius:14px 14px 0 0;
  }

  /* บอกว่าพื้นที่ลากเลื่อนได้ */
  .list, .group-filter { cursor:grab; }
}

/* ── MODAL ── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(74,20,140,.6);
  display:none; align-items:flex-end; z-index:200;
}
.modal-overlay.open { display:flex; }
.modal {
  background:#fff; border-radius:28px 28px 0 0;
  border-top:5px solid #FFD700; padding:28px 22px 48px; width:100%; text-align:center;
}
.modal-icon   { font-size:52px; margin-bottom:10px; }
.modal-title  { font-size:24px; font-weight:900; color:#4A148C; margin-bottom:6px; }
.modal-body   { font-size:18px; color:#7B1FA2; margin-bottom:6px; }
#confirm-cust { font-size:30px; font-weight:900; color:#4A148C; margin-bottom:0; }
.confirm-phone { font-size:17px; font-weight:700; color:#7B1FA2; margin-top:2px; }
.confirm-phone:empty { display:none; }
.confirm-inv  { font-size:16px; color:#8E24AA; margin-top:4px; margin-bottom:6px; letter-spacing:1px; }
.modal-amount { font-size:42px; font-weight:900; color:#4A148C; margin:10px 0 20px; }
.modal-yes {
  width:100%; background:linear-gradient(135deg,#7B1FA2,#4A148C); color:#FFD700;
  border:none; border-radius:18px; padding:22px; font-size:24px; font-weight:900;
  cursor:pointer; font-family:inherit; margin-bottom:12px;
}
.modal-no {
  width:100%; background:#F3E5F5; color:#AB47BC;
  border:2px solid #CE93D8; border-radius:16px; padding:18px;
  font-size:20px; font-weight:700; cursor:pointer; font-family:inherit;
}

/* ── LOADING ── */
.loading {
  position:fixed; inset:0; background:rgba(255,248,231,.85);
  display:none; align-items:center; justify-content:center;
  z-index:300; font-size:20px; color:#7B1FA2; font-weight:700; flex-direction:column; gap:16px;
}
.loading.show { display:flex; }
.spinner {
  width:48px; height:48px; border:5px solid #F3E5F5;
  border-top-color:#7B1FA2; border-radius:50%; animation:spin .8s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* ── TOAST ── */
.toast {
  position:fixed; top:80px; left:50%; transform:translateX(-50%);
  background:#2E7D32; color:#fff; border-radius:16px;
  padding:14px 24px; font-size:18px; font-weight:800;
  z-index:400; display:none; white-space:normal;
  max-width:calc(100vw - 32px); text-align:center; line-height:1.4;
  box-shadow:0 4px 16px rgba(0,0,0,.2);
}
.toast.show { display:block; animation:fadeInOut 2.5s ease forwards; }
.toast.err  { background:#C62828; }
.toast.tap  { background:#4A148C; cursor:pointer; animation:none !important; }
@keyframes fadeInOut {
  0%  { opacity:0; transform:translateX(-50%) translateY(-10px); }
  15% { opacity:1; transform:translateX(-50%) translateY(0); }
  75% { opacity:1; }
  100%{ opacity:0; }
}

/* ── EMPTY STATE ── */
.empty { text-align:center; padding:40px; color:#AB47BC; font-size:18px; }
.empty-icon { font-size:52px; display:block; margin-bottom:12px; }

/* ── EDIT / DELETE BUTTONS ── */
.hdr-edit {
  font-size:28px; cursor:pointer; color:#FFD700; user-select:none; margin-left:auto;
  min-width:44px; min-height:44px; display:inline-flex; align-items:center; justify-content:center;
}
.hdr-edit.on { background:rgba(255,215,0,.22); border-radius:10px; }
.delete-btn {
  background:#FCE4EC; color:#C62828; border:2px solid #EF9A9A;
  border-radius:18px; padding:18px; font-size:20px; font-weight:700;
  cursor:pointer; font-family:inherit; text-align:center; width:100%;
  transition:background .1s;
}
.delete-btn:active { background:#FFCDD2; }

/* ── DELETED LIST ── */
.del-card {
  background:#fff; border:2px solid #FFCDD2; border-radius:16px;
  padding:16px 18px; margin-bottom:12px;
  display:flex; align-items:center; gap:14px;
}
.del-info { flex:1; }
.del-name { font-size:20px; font-weight:800; color:#3e2000; }
.del-meta { font-size:13px; color:#AB47BC; margin-top:3px; }
.restore-btn {
  background:linear-gradient(135deg,#7B1FA2,#4A148C); color:#FFD700;
  border:none; border-radius:12px; padding:10px 16px;
  font-size:15px; font-weight:800; cursor:pointer; font-family:inherit;
  white-space:nowrap;
}

/* ── SEARCH ── */
.search-wrap { padding:12px 16px 4px; position:relative; }
.search-input {
  width:100%; padding:14px 52px 14px 18px; font-size:18px; font-weight:600;
  border:2px solid #E1BEE7; border-radius:16px;
  color:#3e2000; outline:none; font-family:inherit; background:#fff;
  box-sizing:border-box;
}
.search-input:focus { border-color:#7B1FA2; background:#FAF0FF; }
.search-input::placeholder { color:#9C4FAE; font-weight:400; }
.search-clear {
  position:absolute; right:20px; top:50%; transform:translateY(-50%);
  /* 44px hit area; the visible dot stays small via the inset background */
  width:44px; height:44px; border-radius:50%; border:none; cursor:pointer;
  background:radial-gradient(circle, #9C4FAE 0 14px, transparent 14px);
  color:#fff; font-size:16px; font-weight:700;
  display:none; align-items:center; justify-content:center;
  line-height:1; padding:0;
}
.search-clear:active { background:radial-gradient(circle, #4A148C 0 14px, transparent 14px); }

/* ── GROUP FILTER CHIPS ── */
.group-filter {
  display:flex; gap:8px; padding:8px 16px 2px; overflow-x:auto;
  -webkit-overflow-scrolling:touch; scrollbar-width:none;
}
.group-filter::-webkit-scrollbar { display:none; }
.gf-chip {
  flex:0 0 auto; padding:12px 16px; min-height:44px; display:inline-flex; align-items:center; border-radius:20px; cursor:pointer;
  font-size:15px; font-weight:700; font-family:inherit; white-space:nowrap;
  border:2px solid var(--gc); color:var(--gc); background:#fff;
  transition:background .15s,color .15s;
}
.gf-chip:hover { background:color-mix(in srgb, var(--gc) 12%, #fff); }
.gf-chip.active:hover { background:var(--gc); }
.gf-chip.active { background:var(--gc); color:#fff; }
.gf-chip:active { transform:scale(.96); }

/* ── GROUP ORDER SCREEN ── */
.go-item {
  background:#fff; border-radius:16px; padding:14px 16px;
  display:flex; align-items:center; gap:12px;
  box-shadow:0 2px 8px rgba(74,20,140,.08); border:2px solid #F3E5F5;
}
.go-dot { width:12px; height:12px; border-radius:50%; flex-shrink:0; }
.go-name { flex:1; font-size:17px; font-weight:800; }
.go-badge { font-size:12px; color:#AB47BC; font-weight:600; }
.go-btn {
  width:44px; height:44px; border-radius:10px; border:none;
  background:#F3E5F5; color:#7B1FA2; font-size:16px; font-weight:900;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.go-btn:disabled { opacity:.25; cursor:default; }

/* ── GROUP HEADER ── */
.group-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 4px 6px; margin-top:4px;
}
.group-dot { width:11px; height:11px; border-radius:50%; flex-shrink:0; }
.group-lbl { font-size:16px; font-weight:900; letter-spacing:0.5px; }
.group-cnt { font-size:13px; color:#AB47BC; }

/* ── USER DROPDOWN ── */
.user-menu {
  cursor:pointer; display:flex; align-items:center; gap:6px;
  background:rgba(255,255,255,.12); border-radius:10px; padding:6px 12px;
  transition:background .15s; user-select:none;
}
.user-menu:active { background:rgba(255,255,255,.22); }
.menu-arrow { color:#FFD700; font-size:13px; }
.user-dropdown {
  position:absolute; top:58px; right:0;
  background:#fff; border-radius:18px;
  box-shadow:0 8px 32px rgba(74,20,140,.28);
  border:2px solid #F3E5F5; z-index:100;
  min-width:220px; display:none; overflow:hidden;
}
.user-dropdown.open { display:block; }
.dd-item {
  padding:16px 20px; font-size:18px; font-weight:700;
  color:#4A148C; cursor:pointer;
  border-bottom:1px solid #F3E5F5; transition:background .1s;
}
.dd-item:last-child { border-bottom:none; }
.dd-item:active { background:#F3E5F5; }
.dd-logout { color:#C62828; }

/* ── SETTINGS SCREEN ── */
.set-section-label {
  font-size:14px; font-weight:800; color:#AB47BC; letter-spacing:.5px;
  margin:18px 4px 8px; text-transform:uppercase;
}
.set-item {
  display:flex; align-items:center; justify-content:space-between;
  background:#fff; border:2px solid #F3E5F5; border-radius:16px;
  padding:18px 20px; margin-bottom:10px; font-size:18px; font-weight:700;
  color:#4A148C; cursor:pointer; transition:background .1s;
}
.set-item:active { background:#F3E5F5; }
.set-arrow { color:#CE93D8; font-size:24px; font-weight:900; }
.set-toggle-row {
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  background:#fff; border:2px solid #F3E5F5; border-radius:16px;
  padding:18px 20px; margin-bottom:10px;
}
.set-toggle-title { font-size:18px; font-weight:800; color:#4A148C; }
.set-toggle-sub   { font-size:13px; color:#AB47BC; margin-top:4px; line-height:1.5; }
/* 44px tall hit area, slider still looks 56x32 (inset by the same 6px padding) */
.switch { position:relative; display:inline-block; width:56px; height:44px; padding:6px 0; flex-shrink:0; }
.switch input { opacity:0; width:0; height:0; }
.switch-slider {
  position:absolute; inset:6px 0; cursor:pointer; background:#E1BEE7;
  border-radius:32px; transition:.2s;
}
.switch-slider::before {
  content:""; position:absolute; height:24px; width:24px; left:4px; bottom:4px;
  background:#fff; border-radius:50%; transition:.2s; box-shadow:0 2px 4px rgba(0,0,0,.2);
}
.switch input:checked + .switch-slider { background:linear-gradient(135deg,#7B1FA2,#4A148C); }
.switch input:checked + .switch-slider::before { transform:translateX(24px); }

/* ── CALCULATOR OVERLAY ── */
.calc-overlay {
  position:fixed; inset:0; background:rgba(74,20,140,.6);
  display:none; align-items:flex-end; z-index:300;
}
.calc-overlay.open { display:flex; }
.calc-sheet {
  background:#fff; border-radius:28px 28px 0 0; border-top:5px solid #FFD700;
  width:100%; padding:18px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow:0 -6px 24px rgba(74,20,140,.3);
  max-height:94vh; overflow-y:auto;
}
.calc-display {
  background:#FFF8E7; border:2px solid #F3E5F5; border-radius:16px;
  padding:14px 18px; margin-bottom:14px; text-align:right;
}
.calc-expr   { font-size:18px; color:#AB47BC; min-height:22px; word-break:break-all; }
.calc-result { font-size:40px; font-weight:900; color:#4A148C; line-height:1.1; }
.calc-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.calc-key {
  border:none; border-radius:16px; padding:20px 0; font-size:26px; font-weight:800;
  background:#F3E5F5; color:#4A148C; cursor:pointer; font-family:inherit;
  user-select:none; transition:transform .05s;
}
.calc-key:active { transform:scale(.94); }
.calc-key.op   { background:#EDE7F6; color:#7B1FA2; }
.calc-key.fn   { background:#FFE0B2; color:#E65100; }
.calc-key.eq   { background:linear-gradient(135deg,#7B1FA2,#4A148C); color:#FFD700; }
.calc-key.wide { grid-column:span 2; }
.calc-ok {
  width:100%; margin-top:12px; background:linear-gradient(135deg,#FFD700,#FFA000);
  color:#4A148C; border:none; border-radius:18px; padding:18px; font-size:22px;
  font-weight:900; cursor:pointer; font-family:inherit;
}

/* ── HISTORY RECORDER ── */
.hist-rec { font-size:13px; color:#7B1FA2; margin-top:3px; }   /* was #CE93D8 = 2.4:1 on white; this is the "who recorded it" line used to settle disputes */

/* ── HISTORY ITEM — slip variant ── */
.hist-item.has-slip {
  border-color:#CE93D8; cursor:pointer;
  touch-action:manipulation;
  -webkit-tap-highlight-color:rgba(74,20,140,.08);
  transition:transform .08s, background .08s;
}
.hist-item.has-slip:active { background:#F3E5F5; transform:scale(.984); }
.hist-slip-hint {
  display:inline-flex; align-items:center; gap:4px;
  margin-top:5px; font-size:12px; color:#AB47BC; font-weight:700;
}
.hist-note-hint {
  display:inline-flex; align-items:center; gap:4px;
  margin-top:6px; padding:6px 10px; font-size:12px; color:#E65100; font-weight:700;
  background:rgba(230,81,0,.1); border:1px solid rgba(230,81,0,.28); border-radius:9px;
  cursor:pointer; touch-action:manipulation; min-height:30px; box-sizing:border-box;
  -webkit-tap-highlight-color:rgba(230,81,0,.15);
}
.hist-note-hint:active { background:rgba(230,81,0,.2); }

/* ── CONFIRM RECORDER ── */
.confirm-rec { font-size:16px; color:#AB47BC; margin-bottom:8px; }

/* ── SLIP NOTIFICATION BAR ── */
.slip-notify {
  margin:10px 16px 0; border-radius:16px; padding:14px 18px;
  background:linear-gradient(135deg,#FF6F00,#E65100);
  color:#fff; display:flex; align-items:center; gap:12px;
  cursor:pointer; box-shadow:0 4px 14px rgba(230,81,0,.3);
  transition:transform .1s;
}
.slip-notify:active { transform:scale(.98); }
.slip-notify-icon { font-size:24px; }
.slip-notify-text { flex:1; font-size:16px; font-weight:800; }
.slip-notify-badge {
  background:rgba(255,255,255,.25); border-radius:20px;
  padding:4px 12px; font-size:15px; font-weight:900;
}

/* ── SLIP IMAGE in history ── */
.slip-img-wrap {
  margin:10px 0 0; border-radius:14px; overflow:hidden;
  border:2px solid #E1BEE7; cursor:pointer; position:relative;
}
.slip-img-wrap img { width:100%; max-height:220px; object-fit:cover; display:block; }
.slip-img-tap { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,.0); }
.slip-img-wrap:active .slip-img-tap { background:rgba(0,0,0,.15); }

/* ── SLIP CONFIRM BUTTONS ── */
.slip-action-row { display:flex; gap:10px; margin-top:12px; }
.slip-confirm-btn {
  flex:1; background:linear-gradient(135deg,#2E7D32,#388E3C);
  color:#fff; border:none; border-radius:14px;
  padding:14px; font-size:17px; font-weight:800;
  cursor:pointer; font-family:inherit; transition:transform .1s;
}
.slip-confirm-btn:active { transform:scale(.97); }
.slip-reject-btn {
  background:#FCE4EC; color:#C62828; border:2px solid #EF9A9A;
  border-radius:14px; padding:14px; font-size:17px; font-weight:700;
  cursor:pointer; font-family:inherit; white-space:nowrap;
}

/* ── PENDING SLIPS SCREEN ── */
.slip-card {
  background:#fff; border-radius:20px; padding:18px;
  margin-bottom:14px; box-shadow:0 3px 12px rgba(74,20,140,.08);
  border:2px solid #F3E5F5;
}
.slip-card-name { font-size:20px; font-weight:900; color:#3e2000; margin-bottom:4px; }
.slip-card-debt { font-size:15px; color:#AB47BC; font-weight:700; margin-bottom:12px; }
.slip-card-time { font-size:13px; color:#7B1FA2; margin-top:8px; }   /* was #CE93D8 = 2.4:1 on white */

/* ── LIGHTBOX ── */
.lbox {
  position:fixed; inset:0; background:rgba(0,0,0,.93);
  display:none; align-items:center; justify-content:center;
  z-index:9999; padding:16px;
}
.lbox.open { display:flex; }
.lbox img { max-width:100%; max-height:90vh; border-radius:14px; }
.lbox-close {
  position:absolute; top:14px; right:14px; color:#fff;
  font-size:28px; width:44px; height:44px; border-radius:50%;
  background:rgba(255,255,255,.18); display:flex;
  align-items:center; justify-content:center; cursor:pointer;
}

/* ── RECORDER BADGE (in forms) ── */
.rec-badge {
  background:rgba(255,215,0,.15); border-radius:12px;
  padding:10px 16px; font-size:15px; color:#CE93D8;
  text-align:center; margin-top:-4px;
}

/* ── PHOTO UPLOAD ── */
.photo-preview {
  width:90px; height:90px; border-radius:50%;
  background:linear-gradient(135deg,#F3E5F5,#E1BEE7);
  border:3px dashed #CE93D8; display:flex;
  align-items:center; justify-content:center;
  font-size:28px; cursor:pointer; overflow:hidden; flex-shrink:0;
}
.photo-upload-btn {
  background:#F3E5F5; color:#7B1FA2; border:2px solid #CE93D8;
  border-radius:14px; padding:10px 20px; font-size:16px; font-weight:700;
  cursor:pointer; font-family:inherit; margin-top:4px;
}
.photo-upload-btn:active { background:#E1BEE7; }

/* ── VERSION ── */
.dd-version {
  padding:8px 20px; font-size:13px; font-weight:600;
  color:#AB47BC; text-align:center; letter-spacing:.5px;
  background:#FAFAFA; border-top:1px solid #F3E5F5;
}
/* ── RELOGIN MODAL ── */
#relogin-overlay {
  display:none; position:fixed; inset:0; z-index:9000;
  background:rgba(74,20,140,.55); align-items:center; justify-content:center;
}
#relogin-overlay.open { display:flex; }
.relogin-card {
  background:#fff; border-radius:24px; padding:28px 24px 20px;
  width:320px; max-width:92vw; box-shadow:0 8px 32px rgba(74,20,140,.25);
}
.relogin-title { font-size:18px; font-weight:800; color:#4A148C; margin-bottom:4px; }
.relogin-sub   { font-size:13px; color:#888; margin-bottom:18px; }
.relogin-user  {
  width:100%; padding:12px 16px; font-size:15px; border-radius:12px;
  border:2px solid #E1BEE7; background:#F9F0FF; color:#555;
  font-family:inherit; box-sizing:border-box; margin-bottom:10px;
}
.relogin-pw {
  width:100%; padding:12px 16px; font-size:16px; font-weight:600;
  border:2px solid #E1BEE7; border-radius:12px; outline:none;
  font-family:inherit; box-sizing:border-box; margin-bottom:16px;
  color:#3e2000;
}
.relogin-pw:focus { border-color:#7B1FA2; background:#FAF0FF; }
.relogin-btns { display:flex; gap:10px; }
.relogin-btn-ok {
  flex:1; padding:13px; background:#7B1FA2; color:#fff;
  border:none; border-radius:12px; font-size:16px; font-weight:700;
  cursor:pointer; font-family:inherit;
}
.relogin-btn-ok:active { background:#4A148C; }
.relogin-btn-out {
  padding:13px 16px; background:#F3E5F5; color:#7B1FA2;
  border:none; border-radius:12px; font-size:14px; font-weight:600;
  cursor:pointer; font-family:inherit;
}

/* ── LANGUAGE SWITCH ── */
.lang-seg { display:flex; gap:8px; }
.lang-seg .lang-btn {
  flex:1; padding:11px 8px; border:2px solid #E1BEE7; border-radius:12px;
  background:#fff; color:#7B1FA2; font-size:15px; font-weight:700;
  cursor:pointer; font-family:inherit; transition:all .15s;
}
.lang-seg .lang-btn.lang-on {
  background:linear-gradient(135deg,#7B1FA2,#6A1B9A); color:#FFD700;
  border-color:#7B1FA2; box-shadow:0 3px 10px rgba(123,31,162,.3);
}
.lang-login { display:flex; gap:6px; justify-content:center; margin-bottom:6px; }
.lang-login .lang-btn {
  padding:5px 14px; border:1.5px solid rgba(123,31,162,.25); border-radius:20px;
  background:rgba(255,255,255,.7); color:#7B1FA2; font-size:13px; font-weight:700;
  cursor:pointer; font-family:inherit;
}
.lang-login .lang-btn.lang-on { background:#7B1FA2; color:#FFD700; border-color:#7B1FA2; }

/* ── ACCESS LOCK (paywall / offline-lock) ── */
#access-lock {
  display:none; position:fixed; inset:0; z-index:11000;
  background:linear-gradient(160deg,#4A148C,#6A1B9A); color:#fff;
  flex-direction:column; align-items:center; justify-content:center;
  padding:32px 24px; text-align:center;
}
#access-lock.open { display:flex; }
#access-lock .al-icon { font-size:64px; margin-bottom:14px; }
#access-lock .al-title { font-size:24px; font-weight:900; color:#FFD700; margin-bottom:10px; }
#access-lock .al-msg { font-size:15px; line-height:1.6; color:rgba(255,255,255,.9); max-width:360px; margin-bottom:8px; }
#access-lock .al-sub { font-size:13px; color:rgba(255,215,0,.8); margin-bottom:22px; }
#access-lock .al-btn {
  background:#FFD700; color:#4A148C; border:none; border-radius:14px;
  font-size:16px; font-weight:800; padding:14px 26px; cursor:pointer;
  font-family:inherit; margin:6px; min-width:200px;
}
#access-lock .al-btn.ghost { background:transparent; color:#fff; border:2px solid rgba(255,255,255,.4); }
/* ── SUBSCRIPTION WARNING BANNER ── */
#sub-banner {
  display:none; position:fixed; top:0; left:0; right:0; z-index:8000;
  background:linear-gradient(135deg,#E65100,#F57C00); color:#fff;
  padding:9px 40px 9px 14px; font-size:13.5px; font-weight:700; text-align:center;
  box-shadow:0 2px 8px rgba(0,0,0,.2);
}
#sub-banner.show { display:block; }
#sub-banner .sb-close {
  position:absolute; right:6px; top:50%; transform:translateY(-50%); cursor:pointer; opacity:.9; font-size:16px;
  width:44px; height:44px; display:flex; align-items:center; justify-content:center;
}

/* ── BILLING (ชำระค่าบริการ) ── */
#billing-overlay { display:none; position:fixed; inset:0; z-index:11500; background:rgba(74,20,140,.6); align-items:center; justify-content:center; padding:18px; }
#billing-overlay.open { display:flex; }
.billing-card { background:#fff; border-radius:22px; width:380px; max-width:94vw; max-height:90vh; overflow-y:auto; padding:24px 22px; position:relative; box-shadow:0 10px 40px rgba(0,0,0,.3); }
.billing-close {
  position:absolute; right:8px; top:6px; font-size:22px; color:#5F5570; cursor:pointer; line-height:1;
  width:44px; height:44px; display:flex; align-items:center; justify-content:center;
}
.billing-title { font-size:20px; font-weight:900; color:#4A148C; margin-bottom:14px; }
.bill-row { display:flex; justify-content:space-between; gap:8px; padding:9px 0; border-bottom:1px solid #F3E5F5; font-size:14px; color:#5A4A65; }
.bill-row b { color:#4A148C; }
.bill-pay-box { background:#FAF5FF; border:2px solid #E1BEE7; border-radius:14px; padding:13px 15px; margin:14px 0; font-size:14px; line-height:1.75; color:#3e2000; white-space:pre-wrap; }
.bill-pay-box .bp-amt { font-size:26px; font-weight:900; color:#7B1FA2; }
.bill-btn { width:100%; padding:14px; border:none; border-radius:14px; background:linear-gradient(135deg,#7B1FA2,#6A1B9A); color:#fff; font-size:16px; font-weight:800; cursor:pointer; font-family:inherit; margin-top:6px; }
.bill-btn.ok { background:linear-gradient(135deg,#2E7D32,#388E3C); }
.bill-slip { display:flex; justify-content:space-between; align-items:center; font-size:13px; padding:9px 0; border-bottom:1px solid #F3E5F5; color:#5A4A65; }
.bill-badge { font-size:11px; font-weight:800; border-radius:10px; padding:2px 10px; }
.bb-pending { background:#FFF3E0; color:#E65100; }
.bb-confirmed { background:#E8F5E9; color:#2E7D32; }
.bb-rejected { background:#FFEBEE; color:#C62828; }

/* ── FOCUS VISIBILITY (a11y) ─────────────────────────────────────────────────
   `-webkit-tap-highlight-color:transparent` (top of this file) plus the absence of any
   focus style left keyboard / switch-access users with no indicator at all. Keyboard-only
   (`:focus-visible`), so touch users never see a stray ring. */
:focus-visible {
  outline:3px solid #FFD700;
  outline-offset:2px;
  border-radius:6px;
}
/* inside clipping containers (.modal, .summary, .det-top use overflow:hidden) an outline is
   cut off — use a shadow ring there instead */
.modal :focus-visible,
.summary :focus-visible,
.det-top :focus-visible,
#s-login :focus-visible {
  outline:none;
  box-shadow:0 0 0 3px rgba(255,215,0,.95);
}

/* ── REDUCED MOTION (global) ─────────────────────────────────────────────────
   The block near the login styles only covers login-scoped selectors. The toast fires on
   every saved payment, so its slide-in is the animation users see most. */
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.show { animation:none !important; }
  .spinner { animation-duration:2.4s; }
  .card, .big-btn, .fab, .gf-chip, .modal { transition:none !important; }
}
