/* =========================== หน้า "แผนเดินทาง" (plan.js) =========================== */
.plan { display: flex; flex-direction: column; gap: 12px; }
.plan-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-ttl { flex: 1 1 200px; min-width: 200px; }   /* กว้างพอให้ปุ่มสลับ/แก้แผนตกลงแถวที่สองบนจอเล็ก ไม่บีบชื่อหน้า */
.plan-ttl h1 { font-size: 21px; font-weight: 700; margin: 0; line-height: 1.25; }
.plan-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.plan-top > .btn, .plan-top > .plan-ro { margin-left: auto; }
.plan-top > .btn { padding: 9px 14px; }
.plan-top > .btn .ei { width: 16px; height: 16px; }
.btn.plan-done { background: var(--pass); color: #fff; }
.plan-ro { font-size: 12px; color: var(--muted); border: 1px solid var(--sep-strong); border-radius: 99px; padding: 4px 11px; white-space: nowrap; }
.plan-seg { display: inline-flex; gap: 3px; background: var(--field-alt); border-radius: 99px; padding: 3px; }
.plan-seg button { border: none; background: none; color: var(--text-2); font-family: inherit; font-size: 13px; font-weight: 600; padding: 6px 15px; border-radius: 99px; cursor: pointer; }
.plan-seg button.on { background: var(--accent); color: #fff; }
.plan-body { display: block; }
.plan-side { min-width: 0; }
.plan-map { display: none; border-radius: 16px; overflow: hidden; border: 1px solid var(--sep); height: calc(100vh - 190px); background: var(--field-alt); isolation: isolate; z-index: 0; }
.plan-map #planMap { width: 100%; height: 100%; }
.plan.tab-map .plan-side { display: none; }
.plan.tab-map .plan-map { display: block; }
.plan-empty { text-align: center; color: var(--muted); padding: 34px 16px; line-height: 1.7; }
.plan-empty span { font-size: 12.5px; }
.plan-note { font-size: 12.5px; color: var(--text-2); background: var(--field-alt); border-radius: 11px; padding: 8px 12px; margin-bottom: 10px; line-height: 1.5; }
.plan-note.warn { background: color-mix(in srgb, #f59e0b 16%, var(--card)); color: #92400e; }
.plan-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.plan-metrics.three { grid-template-columns: repeat(3, 1fr); }
.plan-metrics div { background: var(--card); border-radius: 13px; padding: 10px 9px; box-shadow: var(--shadow); min-width: 0; }
.plan-metrics b { display: block; font-size: 21px; font-weight: 700; line-height: 1.2; }
.plan-metrics span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.plan-next { background: var(--accent); color: #fff; border-radius: 16px; padding: 13px 14px; margin-bottom: 14px; }
.plan-next small { display: block; font-size: 12px; opacity: .88; }
.plan-next b { display: block; font-size: 16px; margin-top: 2px; }
.plan-next.ok { background: var(--pass); }
.plan-next-act { display: flex; gap: 8px; margin-top: 10px; }
.plan-next-act a, .plan-next-act button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #fff; color: var(--accent); border: none; border-radius: 11px; padding: 9px 8px; font-family: inherit; font-size: 13.5px; font-weight: 700; text-decoration: none; cursor: pointer; }
.plan-next-act button { background: rgba(255,255,255,.2); color: #fff; }
.plan-next .ei { width: 16px; height: 16px; }
.plan-sec { font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 2px 8px; }
.plan-day { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: var(--card); border: 1.5px solid transparent; border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 11px 12px; margin-bottom: 8px; font-family: inherit; color: var(--text); cursor: pointer; }
.plan-day.cur { border-color: var(--accent); }
.plan-day:active { transform: scale(.985); }
.plan-dn { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.plan-dt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.plan-dt b { font-size: 14.5px; font-weight: 600; }
.plan-dt span { font-size: 12px; color: var(--muted); }
.plan-dt .plan-miss { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; margin-top: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; }
.plan-miss .ei { width: 12px; height: 12px; }
.plan-cnt { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--field-alt); color: var(--muted); white-space: nowrap; flex: none; }
.plan-cnt.ok { background: var(--pass-tint); color: var(--pass); }
.plan-skip { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px dashed var(--sep-strong); border-radius: 13px; padding: 10px 12px; margin-bottom: 8px; }
.plan-skip-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.plan-skip-t span { font-size: 12px; color: var(--muted); }
.plan-foot { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.plan-dateline { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 13px; padding: 9px 12px; margin-bottom: 10px; font-size: 13.5px; box-shadow: var(--shadow); }
.plan-routes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.plan-route { flex: 1 1 200px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--accent); color: #fff; border-radius: 12px; padding: 11px 12px; font-weight: 700; font-size: 14px; text-decoration: none; }
.plan-share { display: inline-flex; align-items: center; gap: 6px; background: var(--card); color: var(--text); border: 1px solid var(--sep-strong); border-radius: 12px; padding: 10px 14px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.plan-route .ei, .plan-share .ei { width: 16px; height: 16px; }
.plan-stop { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 12px; margin-bottom: 10px; border: 1.5px solid transparent; }
.plan-stop.focus { border-color: var(--accent); }
.plan-stop-h { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.plan-num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; margin-top: 1px; }
.plan-num.done { background: var(--pass); }
.plan-num .ei { width: 15px; height: 15px; stroke-width: 3; }
.plan-stop-t { flex: 1; min-width: 0; }
.plan-stop-n { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-stop-n b { font-size: 15px; font-weight: 700; }
.plan-line { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 3px; }
.plan-close.soon { color: #b45309; font-weight: 700; }
.plan-close.closed { color: var(--danger); font-weight: 700; }
.plan-notei { color: var(--text-2); }
.plan-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.plan-chev { color: var(--muted); flex: none; }
.plan-chev .ei { width: 18px; height: 18px; }
.plan-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--field-alt); color: var(--muted); white-space: nowrap; }
.plan-tag.r { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.plan-tag.w { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; }
.plan-act { display: flex; gap: 8px; margin-top: 10px; }
.plan-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--sep-strong); border-radius: 11px; padding: 8px; font-size: 13.5px; font-weight: 600; color: var(--text); text-decoration: none; background: var(--card); }
.plan-btn.p { border-color: var(--accent); color: var(--accent); }
.plan-btn .ei { width: 15px; height: 15px; }
.plan-edit { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--sep-strong); }
.plan-edit .btn { padding: 7px 11px; }
.plan-edit .btn:disabled { opacity: .35; }
.plan-edit .ei { width: 15px; height: 15px; }
.plan-add { width: 100%; border: 1.5px dashed var(--sep-strong); background: none; color: var(--muted); border-radius: 13px; padding: 12px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; margin-bottom: 14px; }
.plan-ms { margin-top: 10px; border-top: 1px solid var(--sep); padding-top: 6px; }
.plan-m { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--sep); }
.plan-chk { width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--sep-strong); background: var(--card); flex: none; display: grid; place-items: center; cursor: pointer; padding: 0; color: #fff; }
.plan-chk.ro { cursor: default; }
.plan-chk.on { background: var(--pass); border-color: var(--pass); }
.plan-chk .ei { width: 16px; height: 16px; stroke-width: 3; }
.plan-m-b { flex: 1; min-width: 0; }
.plan-m-t { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; }
.plan-m-t .mono b { font-size: 15px; }
.plan-m-s { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.plan-m.done .plan-m-t .mono { opacity: .6; }
.plan-m-sum { margin-top: 4px; font-size: 12px; color: var(--text-2); }
.plan-m-sum summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.plan-m-sum div { margin-top: 4px; line-height: 1.55; }
.plan-ms-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 10px; }
.plan-ms-foot a { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--accent); text-decoration: none; font-weight: 600; }
.plan-ms-foot .ei { width: 14px; height: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .plan-dt .plan-miss { color: #fbbf24; } }
:root[data-theme="dark"] .plan-dt .plan-miss { color: #fbbf24; }
/* หมุดบนแผนที่ */
.plan-pin-wrap { background: none; border: none; }
.plan-pin { width: 28px; height: 28px; border-radius: 50%; background: var(--c, #d0202e); color: #fff; font: 700 13px/24px "Prompt", sans-serif; text-align: center; border: 2px solid #fff; box-shadow: 0 2px 7px rgba(0,0,0,.45); }
.plan-pin.done { background: #16a34a; }
.plan-pin { position: relative; }
.plan-pin.approx { border-style: dashed; border-color: #f59e0b; }
.plan-pin.approx::after { content: "?"; position: absolute; top: -8px; right: -8px; width: 15px; height: 15px; border-radius: 50%; background: #f59e0b; color: #fff; font: 700 10px/15px "Prompt", sans-serif; text-align: center; border: 1.5px solid #fff; }
.plan-pin.home { width: auto; height: 22px; border-radius: 7px; background: #111827; font-size: 11px; line-height: 18px; padding: 0 7px; }
@media (max-width: 340px) { .plan-metrics { grid-template-columns: repeat(2, 1fr); } .plan-ttl h1 { font-size: 19px; } }
/* จอคอม: รายการซ้าย + แผนที่ขวา (ไม่มีแท็บสลับ) */
@media (min-width: 1024px) {
  body.authed .content:has(.plan) { padding-bottom: 16px; }
  .plan { height: calc(100vh - 42px); gap: 14px; }
  .plan-ttl { flex: 1; min-width: 0; }
  .plan-seg { display: none; }
  .plan-body { display: grid; grid-template-columns: minmax(380px, 460px) 1fr; gap: 16px; flex: 1; min-height: 0; }
  .plan-side { overflow-y: auto; padding: 2px 6px 24px 2px; }
  .plan-map { display: block !important; height: 100%; }
  .plan.tab-map .plan-side { display: block; }
}

/* ===== หลายแผน: สวิตช์แผน / แผงเลือกแผน / จัดแผนจากแผนที่ ===== */
.plan-switch { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: var(--card); border: 1.5px solid var(--sep-strong); border-radius: 13px; padding: 9px 12px; margin-bottom: 10px; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; }
.plan-switch.ro { cursor: default; border-color: var(--sep); }
.plan-switch > .ei { width: 16px; height: 16px; color: var(--muted); flex: none; }
.plan-sw-ic { display: grid; place-items: center; flex: none; color: var(--accent); }
.plan-sw-ic .ei { width: 17px; height: 17px; }
.plan-sw-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--field-alt); color: var(--muted); white-space: nowrap; flex: none; }
.plan-badge.on { background: var(--pass-tint); color: var(--pass); }
.plan-lockbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.plan-lockbar span { flex: 1 1 180px; }
.plan-dl-b { display: inline-flex; gap: 6px; }
.plan-skip.pool { border-style: solid; border-color: var(--sep); }
/* แผงเลือก/สร้างแผน */
.plan-sheet-ov { position: fixed; inset: 0; z-index: 1300; background: rgba(0,0,0,.42); display: flex; align-items: flex-end; justify-content: center; }
.plan-sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--bg, var(--card)); border-radius: 20px 20px 0 0; padding: 14px 14px 20px; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
@media (min-width: 640px) { .plan-sheet-ov { align-items: center; } .plan-sheet { border-radius: 20px; } }
.plan-sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.plan-sheet-h b { flex: 1; font-size: 17px; }
.plan-hint2 { font-size: 12.5px; color: var(--muted); margin: 0 2px 10px; line-height: 1.5; }
.plan-prow { background: var(--card); border: 1.5px solid transparent; border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 8px; overflow: hidden; }
.plan-prow.on { border-color: var(--accent); }
.plan-prow-main { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; padding: 11px 12px; font-family: inherit; color: var(--text); cursor: pointer; }
.plan-prow-main > .ei { width: 17px; height: 17px; color: var(--accent); flex: none; }
.plan-prow-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.plan-prow-t b { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-prow-t span { font-size: 12px; color: var(--muted); }
.plan-prow-act { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 12px 10px 39px; }
.plan-prow-act button { background: none; border: none; padding: 2px 0; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--accent); cursor: pointer; }
.plan-fl { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
.plan-fl input { font-family: inherit; font-size: 15px; padding: 10px 12px; border-radius: 11px; border: 1.5px solid var(--sep-strong); background: var(--card); color: var(--text); }
.plan-opt { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1.5px solid var(--sep); border-radius: 13px; padding: 11px 12px; margin-bottom: 8px; cursor: pointer; }
.plan-opt:has(input:checked) { border-color: var(--accent); }
.plan-opt input[type=radio] { margin-top: 3px; accent-color: var(--accent); }
.plan-opt > span { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.plan-opt small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.plan-opt select { font-family: inherit; font-size: 14px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--sep-strong); background: var(--field-alt); color: var(--text); max-width: 100%; }
/* แถบเลือกวันบนแผนที่ (โหมดจัดแผน) */
.plan-map { position: relative; }
.plan-pick { position: absolute; top: 8px; left: 56px; right: 8px; z-index: 1000; display: flex; flex-direction: column; gap: 5px; pointer-events: none; }
.plan-pick:empty { display: none; }
.plan-pchips { display: flex; gap: 6px; flex-wrap: wrap; pointer-events: auto; }
.plan-pchip { font-family: inherit; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 99px; border: 2px solid var(--c, var(--accent)); background: var(--card); color: var(--c, var(--accent)); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.plan-pchip.on { background: var(--c, var(--accent)); color: #fff; }
.plan-pchip.add { border-style: dashed; border-color: var(--sep-strong); color: var(--text-2); }
.plan-phint { align-self: flex-start; pointer-events: auto; font-size: 12px; line-height: 1.45; background: color-mix(in srgb, var(--card) 94%, transparent); color: var(--text-2); border-radius: 10px; padding: 6px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.18); max-width: 100%; }
.plan-lockbar .btn { background: var(--card); }
/* ระยะทาง/เวลาขับ (ประมาณ) */
.plan-metrics.two { grid-template-columns: repeat(2, 1fr); margin-top: -4px; }
.plan-metrics.two span { white-space: normal; }
.plan-trip-note { font-size: 11.5px; color: var(--muted); margin: -4px 2px 12px; line-height: 1.45; }
.plan-dt .plan-trip { color: var(--text-2); font-weight: 600; }
.plan-leg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 6px 6px 14px; margin-top: -2px; }
.plan-leg .ei { width: 13px; height: 13px; flex: none; }
