/* Postman Around — ธีมกลางแดด: พื้นขาว ตัวอักษรดำสนิท เส้นขอบหนา ปุ่มใหญ่ สีเข้มอิ่ม */
:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #2b2b2b;
  --muted: #4a4a4a;
  --line: #0a0a0a;
  --soft: #f1f1f1;
  --primary: #0a3d91;
  --accent: #ffd400;
  --danger: #b00020;
  --ok: #0b6b2f;
  --warn: #c2410c;
  --purple: #5b21b6;
  --teal: #0f766e;
  --radius: 12px;
  --tap: 52px;
  --shadow: 0 3px 0 rgba(0,0,0,.9);
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Sarabun', 'Leelawadee UI', Tahoma, sans-serif;
  font-size: 17px; line-height: 1.45; color: var(--ink); background: var(--bg);
  overflow: hidden; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); font-weight: 700; }
.hidden { display: none !important; }

/* ---------- ปุ่ม / ฟอร์ม ---------- */
.btn {
  min-height: var(--tap); padding: 0 16px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow);
  touch-action: manipulation; text-align: center; line-height: 1.2;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.9); }
.btn:disabled { opacity: .4; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent  { background: var(--accent); color: var(--ink); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ok      { background: var(--ok); color: #fff; }
.btn-warn    { background: #fff1e6; color: var(--warn); border-color: var(--warn); }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btn-xl { min-height: 64px; font-size: 20px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; font-size: 22px; flex-shrink: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 10px; }
.grid2 > :only-child { grid-column: 1 / -1; }
.stack > * + * { margin-top: 12px; }

label.f { display: block; font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font-size: 18px;
  border: 2px solid var(--line); border-radius: var(--radius); background: #fff;
}
textarea.input { min-height: 64px; resize: vertical; }
.input:focus { outline: 4px solid var(--accent); outline-offset: 0; }
.hint { font-size: 14px; color: var(--muted); margin-top: 4px; }
.note { padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--accent); font-weight: 600; }
.note.info { background: var(--soft); }
.note.warn { background: #fff1e6; border-color: var(--warn); color: #7c2d12; }
.err { color: var(--danger); font-weight: 700; min-height: 1.4em; }
.acting { margin: -2px 0 10px; padding: 8px 12px; border-radius: 10px; background: #ede9fe; border: 2px solid var(--purple); color: #2e1065; font-weight: 700; font-size: 15px; }

/* ---------- login ---------- */
#auth { position: fixed; inset: 0; z-index: 3000; background: var(--bg); overflow-y: auto; }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 28px 16px 40px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark { width: 56px; height: 56px; border-radius: 14px; background: var(--accent); border: 3px solid var(--line); display: grid; place-items: center; font-size: 28px; flex-shrink: 0; }
.brand h1 { font-size: 26px; line-height: 1.1; }
.brand p { color: var(--muted); font-size: 15px; }
.pin-input { letter-spacing: .5em; font-size: 26px; text-align: center; font-weight: 700; }
.switch-link { background: none; border: none; color: var(--primary); font-weight: 700; text-decoration: underline; padding: 8px 0; cursor: pointer; }

/* ---------- แผนที่ ---------- */
#map { position: fixed; inset: 0; z-index: 1; background: #ddd; }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 11px; }
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 900; padding: 10px 10px 0; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.topbar-row { display: flex; gap: 8px; align-items: center; }
body.menu-right .topbar-row { flex-direction: row-reverse; }
.search-pill { flex: 1; min-width: 0; display: flex; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); height: var(--tap); }
.search-pill input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0 12px; font-size: 18px; height: 100%; }
.search-pill input:focus { outline: none; }
.search-pill button { border: 0; background: none; width: 46px; height: 100%; font-size: 20px; cursor: pointer; }
.status-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; max-width: 100%; pointer-events: none; }
.status-row > * { pointer-events: auto; }
body.menu-right .status-row { justify-content: flex-end; }
.role-pill { flex-shrink: 0; display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 13px; border: 2px solid var(--line); background: #fff; color: var(--ink); white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.8); }
.role-pill.sm { padding: 0 8px; font-size: 12px; box-shadow: none; }
.r-superadmin { background: var(--ink); color: var(--accent); }
.r-branch_admin { background: var(--primary); color: #fff; }
.r-zone_head { background: var(--purple); color: #fff; }
.r-delivery { background: var(--ok); color: #fff; }
.r-authorized { background: var(--teal); color: #fff; }
.side-chip { min-width: 0; background: var(--accent); border: 2px solid var(--line); border-radius: 999px; box-shadow: 0 2px 0 rgba(0,0,0,.8);
  padding: 4px 12px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.side-chip .mode { margin-left: 6px; padding: 0 6px; border-radius: 6px; font-weight: 800; font-size: 12px; }
.mode.m-own { background: var(--ok); color: #fff; }
.mode.m-act { background: var(--purple); color: #fff; }
.mode.m-ro { background: #fff; }

.fabs { position: fixed; right: 10px; z-index: 900; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
body.menu-right .fabs { right: auto; left: 10px; align-items: flex-start; }
.fab { width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid var(--line); background: #fff; box-shadow: var(--shadow); font-size: 22px; cursor: pointer; display: grid; place-items: center; font-weight: 800; }
.fab-main { width: auto; height: 60px; border-radius: 30px; padding: 0 18px 0 14px; display: flex; gap: 6px; background: var(--primary); color: #fff; }
.fab-main span { font-size: 28px; line-height: 1; }
.fab-main small { font-size: 16px; font-weight: 800; }
.fab-main.on { background: var(--danger); }
body.tripping #fab-pin { display: none; }

.pin { min-width: 34px; height: 34px; padding: 0 6px; border-radius: 17px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 15px; border: 3px solid #fff; outline: 2px solid var(--ink); box-shadow: 0 2px 4px rgba(0,0,0,.5); }
.pin.hl, .pin.trip { background: var(--accent); color: var(--ink); transform: scale(1.15); }
.pin.sel { background: var(--danger); color: #fff; transform: scale(1.3); }
.pin.done { background: var(--ok); color: #fff; }
.pin.dim { opacity: .35; transform: scale(.75); }
.pin.draft { background: var(--accent); color: var(--ink); font-size: 20px; }
.crosshair { position: fixed; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; z-index: 800; pointer-events: none; }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: var(--danger); box-shadow: 0 0 0 2px #fff; }
.crosshair::before { left: 22px; top: 0; width: 4px; height: 48px; }
.crosshair::after { top: 22px; left: 0; height: 4px; width: 48px; }

/* ---------- เมนูด้านข้าง ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1900; }
#drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 88vw); z-index: 2000; background: #fff;
  border-right: 3px solid var(--line); transform: translateX(-102%); transition: transform .22s ease; display: flex; flex-direction: column; overflow-y: auto; }
body.menu-right #drawer { left: auto; right: 0; border-right: 0; border-left: 3px solid var(--line); transform: translateX(102%); }
#drawer.open { transform: none !important; }
.drawer-head { padding: 18px 16px; background: var(--accent); border-bottom: 3px solid var(--line); }
.drawer-head b { font-size: 20px; display: block; }
.drawer-head span { font-size: 14px; }
.drawer-nav { padding: 6px 0; flex: 1; }
.drawer-nav button { display: flex; width: 100%; align-items: center; gap: 14px; min-height: 54px; padding: 0 18px;
  border: 0; border-bottom: 1px solid #ccc; background: #fff; font-size: 17px; font-weight: 700; text-align: left; cursor: pointer; }
.drawer-nav button .ic { width: 28px; text-align: center; font-size: 20px; }
.drawer-nav button.active { background: var(--soft); box-shadow: inset 6px 0 0 var(--primary); }
.drawer-foot { padding: 14px 16px; border-top: 2px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- Bottom sheet ---------- */
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; background: #fff;
  border-top: 3px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.25);
  display: flex; flex-direction: column; height: 30vh; transition: height .25s ease; max-width: 760px; margin: 0 auto; overflow: hidden; }
#sheet.dragging { transition: none; }
.sheet-grab { flex-shrink: 0; padding: 8px 12px 8px; touch-action: none; cursor: grab; user-select: none; border-bottom: 2px solid var(--soft); }
.grab-bar { width: 56px; height: 6px; border-radius: 3px; background: var(--ink); margin: 0 auto 8px; }
.sheet-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sheet-tabs::-webkit-scrollbar { display: none; }
.sheet-tabs button { flex-shrink: 0; min-height: 40px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; background: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }
.sheet-tabs button.active { background: var(--ink); color: #fff; }
.sheet-tabs button.tripping { background: var(--accent); color: var(--ink); }
.sheet-tabs button.tripping.active { outline: 3px solid var(--ink); }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff; font-size: 13px; font-weight: 800; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 24px; -webkit-overflow-scrolling: touch; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sheet-title h2 { font-size: 20px; }
.form-sticky { padding-bottom: 8px; }
.sticky-actions { position: sticky; bottom: -24px; display: flex; gap: 10px; padding: 10px 0 14px; background: #fff; border-top: 2px solid var(--soft); margin-top: 12px; z-index: 2; }

/* ---------- รายการ ---------- */
.list { list-style: none; }
.item { display: flex; gap: 10px; align-items: center; padding: 10px; border: 2px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: #fff; }
.item.tap, .item .tap { cursor: pointer; }
.item.hl { background: #fff7c2; }
.item.done { background: #ecfdf3; border-color: var(--ok); }
.item.done .t { text-decoration: line-through; text-decoration-thickness: 2px; }
.item.warn { border-color: var(--warn); background: #fff7ed; }
.num { flex-shrink: 0; min-width: 44px; height: 44px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; font-size: 18px; }
.num.big { min-width: 60px; height: 60px; font-size: 26px; }
.num.y { background: var(--accent); color: var(--ink); border: 2px solid var(--line); }
.num.ok { background: var(--ok); }
.num.gray { background: var(--soft); color: var(--ink); border: 2px solid var(--line); }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 800; font-size: 17px; overflow-wrap: anywhere; }
.item .s, .s { font-size: 15px; color: var(--ink-2); overflow-wrap: anywhere; }
.item .acts { display: flex; gap: 6px; flex-shrink: 0; }
.item .acts .btn { min-height: 42px; width: 42px; padding: 0; font-size: 18px; box-shadow: none; }
.tag { display: inline-block; padding: 1px 8px; border: 2px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 700; background: #fff; }
.tag.y { background: var(--accent); }
.tag.r { background: var(--danger); color: #fff; border-color: var(--danger); }
.tag.g { background: var(--ok); color: #fff; border-color: var(--ok); }
.kind { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: 12px; font-weight: 800; color: #fff; vertical-align: middle; }
.k-GEN { background: var(--ok); } .k-PON { background: var(--teal); } .k-ZONE { background: var(--purple); }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); font-weight: 600; }
.section-h { font-size: 16px; font-weight: 800; margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 3px solid var(--ink); }
.pick-box { padding: 10px; border: 2px dashed var(--primary); border-radius: var(--radius); background: #eef4ff; }
.pick-list { max-height: 240px; overflow-y: auto; border: 2px solid var(--line); border-radius: var(--radius); margin-top: 6px; background: #fff; }
.pick-list button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid #bbb; background: #fff; cursor: pointer; font-size: 16px; }
.pick-list button:active { background: var(--accent); }
.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.place-btn { min-height: 56px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; font-size: 13px; line-height: 1.15; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; }
.place-btn span { font-size: 22px; }
.place-btn.on { background: var(--accent); outline: 3px solid var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 2px solid var(--line); border-radius: 999px; background: #fff; padding: 6px 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.chip:active { background: var(--accent); }
.pick-checks { max-height: 50vh; overflow-y: auto; border: 2px solid var(--line); border-radius: var(--radius); }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #bbb; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--primary); flex-shrink: 0; }
.check .num { min-width: 36px; height: 36px; font-size: 15px; }
.kind-btn { flex-direction: column; gap: 2px; min-height: 64px; padding: 4px; }
.kind-btn small { font-size: 12px; }
.code-preview { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: .04em; padding: 10px; border: 3px dashed var(--line); border-radius: 12px; background: var(--soft); }

/* ---------- นำทาง ---------- */
.trip-head { margin-bottom: 10px; }
.progress { height: 12px; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 6px; background: #fff; }
.progress > div { height: 100%; background: var(--ok); transition: width .3s; }
.trip-card { border: 3px solid var(--line); border-radius: 14px; padding: 12px; background: #fffbe6; }
.trip-card.is-done { background: #ecfdf3; border-color: var(--ok); }

/* ---------- modal / toast ---------- */
#modal { position: fixed; inset: 0; z-index: 4000; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(460px, 100%); max-height: 90dvh; overflow-y: auto; background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 18px; }
.modal-card h3 { font-size: 20px; margin-bottom: 10px; }
.big-pin { font-size: 40px; font-weight: 800; letter-spacing: .25em; text-align: center; padding: 12px; background: var(--accent); border: 3px solid var(--line); border-radius: 12px; margin: 10px 0; }
#toast { position: fixed; left: 50%; top: 116px; transform: translateX(-50%); z-index: 5000; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
#toast.bad { background: var(--danger); }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  #sheet { left: auto; right: 12px; width: 480px; margin: 0; }
  body.menu-right #sheet { right: auto; left: 12px; }
  .topbar-row, .status-row { max-width: 560px; }
}

/* ---------- ที่ทำการ / ลิงก์สาขา ---------- */
.branch-banner { margin: -8px 0 16px; padding: 10px 12px; border: 3px solid var(--line); border-radius: 12px; background: var(--accent); font-size: 17px; }
.apply-cta { margin-top: 18px; padding: 12px; border: 2px dashed var(--line); border-radius: 12px; background: var(--soft); }
.link-box { margin: 6px 0 10px; padding: 10px; border: 2px solid var(--primary); border-radius: 12px; background: #eef4ff; }
.link-box code { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
