/* ระบบงาน NSP แบบง่าย · หน้าตาแบบระบบเดิม (น้ำเงินเข้ม · ปุ่มน้ำเงิน · พื้นเทาอ่อน · การ์ดขอบมน) */
:root { --navy: #0B2A6F; --blue: #1E4FD8; --bg: #F3F5F9; --line: #E3E8EF; --ink: #0F172A; --mute: #5B6475; --soft: #C7D4F5;
  --red: #B91C1C; --red-bg: #FDECEC; --green: #15803D; --green-bg: #E8F6EC; --amber: #92400E; --amber-bg: #FFF4E0; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--navy); color: #fff; }
.bar b { flex: 1; min-width: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .back { background: transparent; border: 1px solid #ffffff66; color: #fff; border-radius: 8px; padding: 2px 12px; font-size: 18px; cursor: pointer; }
.bar .who { font-size: 12px; color: var(--soft); white-space: nowrap; }
.trial[hidden] { display: none; }   /* ระบบจริงไม่มีแถบนี้ (display: flex ด้านล่างทับ hidden) */
.trial { background: #FFF7E6; border-bottom: 1px solid #F5D9A8; padding: 6px 16px; font-size: 13px; color: #7A4B00; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.trial button { border: 1px solid #E7C98F; background: #fff; border-radius: 8px; padding: 2px 10px; cursor: pointer; color: #7A4B00; }

main { max-width: 860px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.page { display: contents; }   /* กล่องของแต่ละหน้า (app.js route) ไม่เปลี่ยนการจัดวาง */
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--mute); font-size: 13px; }
.center { text-align: center; }
.err { color: var(--red); font-size: 13px; margin: 0; }
.h { font-weight: 700; font-size: 16px; color: var(--navy); }

button.primary, a.primary, button.ghost, a.ghost, button.danger, label.primary, label.ghost { border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--blue); display: inline-block; text-align: center; }
button.primary, a.primary, label.primary { background: var(--blue); color: #fff; }
button.ghost, a.ghost, label.ghost { background: #fff; color: var(--blue); }
button.danger { background: #fff; color: var(--red); border-color: var(--red); }
button:disabled { opacity: .5; cursor: default; }
button.small, a.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--mute); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--blue); font-weight: 700; border-bottom-color: var(--blue); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; width: 100%; }
.item:hover { border-color: var(--soft); }
.pill { border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.gray { background: #EEF1F5; color: var(--mute); }

.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.lines th { text-align: left; color: var(--mute); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 4px; }
.lines td { border-bottom: 1px solid var(--line); padding: 7px 4px; vertical-align: top; }
.lines td.m, .lines th.m { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--red); font-weight: 700; }
.tablewrap { overflow-x: auto; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mute); }
label.f input, label.f select, label.f textarea { border: 1px solid #cfd6e2; border-radius: 10px; padding: 9px 11px; font-size: 15px; color: var(--ink); background: #fff; width: 100%; }
label.chk { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--red); background: var(--red-bg); color: var(--red); font-weight: 600; cursor: pointer; }
label.chk input { width: 20px; height: 20px; accent-color: var(--red); }
.box { border: 1.5px solid var(--soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.money3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #F6F8FC; border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--mute); }
.money3 b { display: block; color: var(--ink); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--mute); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.slips { display: flex; gap: 8px; flex-wrap: wrap; }
.slips a, .slips img { width: 84px; height: 84px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 12px; background: #F6F8FC; }
.warn { background: var(--amber-bg); color: var(--amber); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.bad { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 8px 12px; font-size: 13px; }

/* เช็กลิสต์งาน · ข้อความ TOR แสดงตามไฟล์ทุกตัวอักษร (เว้นวรรคและขึ้นบรรทัดตามไฟล์) */
.tabbody { display: flex; flex-direction: column; gap: 14px; }
.tt { white-space: pre-wrap; overflow-wrap: anywhere; }
.meter { height: 8px; border-radius: 99px; background: #E6EBF3; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--green); }
.chips { gap: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 14px; cursor: pointer; color: var(--mute); }
.chips button.on { border-color: var(--blue); color: var(--blue); font-weight: 700; }
.tlist { gap: 0; padding: 4px 12px; }
.band { background: #EEF2F8; color: var(--navy); border-radius: 8px; padding: 8px 10px; margin: 8px 0 2px; font-size: 14px; }
.titem { display: flex; gap: 10px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.titem.done .tt { color: var(--mute); }
.titem .note { font-size: 12px; }
button.tick { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px; border: 1.5px solid var(--blue); background: #fff; color: var(--blue); font-size: 26px; line-height: 1; cursor: pointer; }
button.tick[aria-pressed="true"] { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.tickro { font-size: 22px; color: var(--mute); padding: 0 6px; }
.leads { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; border: 1px solid #cfd6e2; border-radius: 10px; padding: 8px 10px; }
.leads label { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
.leads input { width: 18px; height: 18px; }

/* รูปถ่าย */
.plink { color: inherit; align-items: center; }
.tt.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
label.f select { border: 1px solid #cfd6e2; border-radius: 10px; padding: 9px 11px; font-size: 15px; background: #fff; width: 100%; color: var(--ink); }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.ph { position: relative; border-radius: 10px; overflow: hidden; background: #EEF1F5; cursor: pointer; }
.ph img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.ph .cap { font-size: 11px; padding: 3px 6px; color: var(--mute); background: #fff; line-height: 1.3; }
.ph.q img { opacity: .55; }
.ph .qa { padding: 4px; background: #fff; gap: 4px; }
.ph .star, .ph .more { position: absolute; top: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(15,23,42,.55); color: #fff; font-size: 17px; line-height: 32px; text-align: center; cursor: pointer; padding: 0; }
.ph .star { left: 4px; } .ph .more { right: 4px; }
.ph .star.on { background: #F5B301; color: #fff; }
label.primary, label.ghost { cursor: pointer; }
dialog.viewer { width: min(96vw, 1000px); padding: 8px; }
dialog.viewer img { display: block; width: 100%; height: auto; max-height: 80vh; object-fit: contain; background: #000; border-radius: 8px; }
dialog.viewer form { flex-direction: row; justify-content: flex-end; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); }
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 560px) {
  main { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .lines .hide-sm { display: none; }
}

/* ช่วง 4: เมนูหน้าแรก · ใบ CF · ไลน์จำลอง · ไฟล์ · ทะเบียนร้าน */
.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.sigimg { height: 40px; max-width: 120px; object-fit: contain; }
.sigbox { border: 1px dashed var(--soft); border-radius: 10px; padding: 10px; background: #fff; text-align: center; }
.sigbox img { max-height: 90px; max-width: 100%; }
.linemsg .bubble { background: #E7F7E4; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.item.dim { opacity: .6; }
dialog.viewer iframe { width: 100%; height: 75vh; border: 0; border-radius: 8px; }
input.search { border: 1px solid #cfd6e2; border-radius: 10px; padding: 9px 11px; font-size: 15px; min-width: 0; }
.sup .row { gap: 6px; }
