/* Messenger Desk — สีน้ำเงินสดเป็นตัวนำ แซมพาสเทลประจำงาน · ฟอนต์หัวมนเป็นมิตร · ปุ่มใหญ่ กดง่าย
   ตัวการ์ตูนใช้เฉพาะหน้าต้อนรับ/ตอนไม่มีงาน/ตอนงานสำเร็จ (ดู js/art.js) */
:root {
  --paper: #f3f5ff;
  --surface: #ffffff;
  --surface-2: #f7f8ff;
  --ink: #1b1f3b;
  --ink-2: #5a5f80;
  --ink-3: #8a8fb0;
  --line: #e3e6f5;
  --line-2: #eef0fa;
  --brand: #3b5bfe;
  --brand-deep: #2a44d6;
  --brand-soft: #e4e9ff;
  --brand-ink: #ffffff;
  --accent: #1a9e72;
  --accent-soft: #ddf8ee;
  --warn: #9a6400;
  --warn-soft: #fff3d1;
  --danger: #d1453b;
  --danger-soft: #ffe6e3;
  --info: #3b5bfe;
  --info-soft: #e4e9ff;
  --muted-soft: #f0f2fa;
  /* พาสเทลตามขั้นงาน / ประเภทงาน */
  --p-amber: #fff3d1; --p-amber-ink: #9a6400;
  --p-blue: #e4e9ff; --p-blue-ink: #2a44d6;
  --p-lilac: #efe9ff; --p-lilac-ink: #6a4fd6;
  --p-mint: #ddf8ee; --p-mint-ink: #157a58;
  --p-gray: #f0f2fa; --p-gray-ink: #5a5f80;
  --p-rose: #ffe6e3; --p-rose-ink: #c03a31;
  --sun: #ffc43d; --mint: #2fd6a0; --coral: #ff7b72; --lilac: #9b7bff;
  --road: #dfe4fb;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(27, 31, 59, .04);
  --font: "Anuphan", "Noto Sans Thai", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
  --font-display: "Mitr", "Prompt", "Leelawadee UI", sans-serif;
  --nav-h: 70px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1230; --surface: #171c40; --surface-2: #1c2248; --ink: #eef0ff; --ink-2: #a9aed3; --ink-3: #8186b0;
    --line: #2a3060; --line-2: #222851; --brand: #5c78ff; --brand-deep: #3b5bfe; --brand-soft: #232c66; --brand-ink: #ffffff;
    --accent: #3fe0ab; --accent-soft: #173a36; --warn: #ffcf5c; --warn-soft: #3a3220; --danger: #ff8f87; --danger-soft: #3d2330;
    --info: #8fa4ff; --info-soft: #232c66; --muted-soft: #222851;
    --p-amber: #3a3220; --p-amber-ink: #ffcf5c; --p-blue: #232c66; --p-blue-ink: #a9b8ff; --p-lilac: #2c2556; --p-lilac-ink: #c3b4ff;
    --p-mint: #173a36; --p-mint-ink: #6fe8bf; --p-gray: #222851; --p-gray-ink: #a9aed3; --p-rose: #3d2330; --p-rose-ink: #ff9a92;
    --road: #262d5e; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1230; --surface: #171c40; --surface-2: #1c2248; --ink: #eef0ff; --ink-2: #a9aed3; --ink-3: #8186b0;
  --line: #2a3060; --line-2: #222851; --brand: #5c78ff; --brand-deep: #3b5bfe; --brand-soft: #232c66; --brand-ink: #ffffff;
  --accent: #3fe0ab; --accent-soft: #173a36; --warn: #ffcf5c; --warn-soft: #3a3220; --danger: #ff8f87; --danger-soft: #3d2330;
  --info: #8fa4ff; --info-soft: #232c66; --muted-soft: #222851;
  --p-amber: #3a3220; --p-amber-ink: #ffcf5c; --p-blue: #232c66; --p-blue-ink: #a9b8ff; --p-lilac: #2c2556; --p-lilac-ink: #c3b4ff;
  --p-mint: #173a36; --p-mint-ink: #6fe8bf; --p-gray: #222851; --p-gray-ink: #a9aed3; --p-rose: #3d2330; --p-rose-ink: #ff9a92;
  --road: #262d5e; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
/* ไอคอนทุกตัวมีขนาดเริ่มต้น (กฎเฉพาะด้านล่างกำหนดทับได้) */
svg:not([width]) { width: 20px; height: 20px; flex-shrink: 0; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.num, .money { font-variant-numeric: tabular-nums; }
h1, h2, h3 { line-height: 1.3; margin: 0; font-family: var(--font-display); font-weight: 500; text-wrap: balance; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; }
.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; }
.hidden { display: none !important; }

/* ---------- โครงหน้า ---------- */
.shell { min-height: 100dvh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); padding: 14px 16px 12px; display: flex; align-items: center; gap: 10px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h1 { font-size: 1.22rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .sub { font-size: .8rem; color: var(--ink-2); }
.topbar .iconbtn { background: var(--brand-soft); color: var(--brand); }
.page { padding: 8px 16px 20px; max-width: 1120px; margin: 0 auto; }
.page > * + * { margin-top: 18px; }

.bottomnav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: .72rem; }
.bottomnav a.on { color: var(--brand); font-weight: 600; }
.bottomnav svg { width: 23px; height: 23px; }
.bottomnav a.fab span.ic { width: 54px; height: 54px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; margin-top: -26px; box-shadow: 0 5px 0 var(--brand-deep); }
.bottomnav a.fab { color: var(--ink-2); font-weight: 600; }

@media (min-width: 1024px) {
  .side { display: flex; flex-direction: column; width: 256px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100dvh; padding: 22px 14px; gap: 3px; }
  .side .brand { display: flex; gap: 12px; align-items: center; padding: 4px 10px 22px; }
  .side .brand b { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
  .side a.nav { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; text-decoration: none; color: var(--ink-2); font-size: .95rem; }
  .side a.nav:hover { background: var(--surface-2); }
  .side a.nav.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .side a.nav svg { width: 20px; height: 20px; }
  .side .newbtn { margin: 0 4px 18px; }
  .side .foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); }
  .bottomnav { display: none; }
  .main { padding-bottom: 40px; }
  .topbar { padding: 22px 32px 14px; }
  .topbar .title h1 { font-size: 1.5rem; }
  .page { padding: 8px 32px 32px; }
}

/* ---------- ส่วนประกอบ ---------- */
.card { background: var(--surface); border: 2px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
@media (min-width: 720px) { .card.pad { padding: 22px; } }
.card-h { display: flex; align-items: center; gap: 8px; padding: 16px 20px 10px; }
.card-h h2 { flex: 1; }
.section-title { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 12px; }
.section-title h2 { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 20px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* bento: กล่องสีขนาดต่างกันเรียงเป็นกริด */
.bento { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .bento { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.bento > .wide { grid-column: span 2; }
.bento-tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; min-height: 100px; padding: 16px; border-radius: var(--radius); border: 3px solid transparent; background: var(--surface); color: var(--ink); text-decoration: none; text-align: left; cursor: pointer; transition: transform .15s ease; }
.bento-tile:hover { transform: translateY(-2px); }
.bento-tile.on { border-color: var(--ink); }
.bento-tile .bt-v { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.bento-tile .bt-l { font-size: .86rem; font-weight: 600; }
.bento-tile .bt-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--surface); }
.bento-tile .bt-ic svg { width: 22px; height: 22px; }
.bento-tile.ink { background: var(--brand); color: var(--brand-ink); }
.bento-tile.ink.on { border-color: var(--sun); }
.bento-tile.p-amber { background: var(--p-amber); color: var(--p-amber-ink); }
.bento-tile.p-blue { background: var(--p-blue); color: var(--p-blue-ink); }
.bento-tile.p-lilac { background: var(--p-lilac); color: var(--p-lilac-ink); }
.bento-tile.p-mint { background: var(--p-mint); color: var(--p-mint-ink); }
.bento-tile.p-gray { background: var(--p-gray); color: var(--p-gray-ink); }
.bento-tile.p-rose { background: var(--p-rose); color: var(--p-rose-ink); }
.bento-tile.cta { background: var(--brand); color: var(--brand-ink); justify-content: flex-end; box-shadow: 0 5px 0 var(--brand-deep); }
.bento-tile.cta .bt-ic { background: rgba(255,255,255,.18); color: #fff; }
.bento-tile.cta .bt-v { font-size: 1.2rem; font-weight: 500; }
.track-bento { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 719px) {
  .bento-tile { min-height: 88px; padding: 14px; gap: 10px; }
  .bento-tile .bt-v { font-size: 1.65rem; }
  .track-bento { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .track-bento > .wide { grid-column: span 3; flex-direction: row; align-items: baseline; gap: 10px; justify-content: flex-start; }
  .track-bento .bento-tile { min-height: 76px; padding: 11px 13px; border-radius: 18px; }
  .track-bento .bento-tile .bt-v { font-size: 1.4rem; }
  .track-bento .bento-tile .bt-l { font-size: .74rem; line-height: 1.3; }
  .track-bento > .bento-tile.wide { min-height: 0; padding: 13px 16px; }
}
@media (min-width: 720px) { .track-bento { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .track-bento { grid-template-columns: 2fr repeat(6, 1fr); } .track-bento > .wide { grid-column: span 1; } }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.kpi { background: var(--surface); border: 2px solid var(--line-2); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 96px; }
.kpi .v { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi .l { font-size: .86rem; color: var(--ink-2); }
.kpi.hot { background: var(--p-amber); border-color: transparent; }
.kpi.hot .v, .kpi.hot .l { color: var(--p-amber-ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-family: var(--font-display); font-weight: 400; font-size: .95rem; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s ease; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); box-shadow: 0 4px 0 var(--brand-deep); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 92%, #fff); }
.btn.primary:active { box-shadow: 0 1px 0 var(--brand-deep); transform: translateY(3px); }
.btn.accent { background: var(--mint); color: #08352a; border-color: var(--mint); box-shadow: 0 4px 0 color-mix(in srgb, var(--mint) 70%, #000); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: .86rem; }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-size: 1.04rem; }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: .45; pointer-events: none; box-shadow: none; }
.iconbtn { width: 40px; height: 40px; border-radius: 13px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); text-decoration: none; }
.iconbtn:hover { background: var(--muted-soft); }
.iconbtn svg { width: 21px; height: 21px; }

label.f { display: block; }
label.f > span, .flabel { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.req::after { content: " *"; color: var(--danger); }
input.in, select.in, textarea.in { width: 100%; min-height: 48px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); padding: 10px 14px; outline: none; transition: border-color .12s ease; }
textarea.in { min-height: 84px; resize: vertical; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--brand); }
input.in::placeholder, textarea.in::placeholder { color: var(--ink-3); }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 6px; }
.hint.warn { color: var(--warn); }
.hint.err { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 8px 16px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); font-size: .92rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.chip small { opacity: .75; font-size: .75rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--brand-soft); border-radius: 99px; padding: 4px; gap: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 99px; background: transparent; cursor: pointer; font-family: var(--font-display); color: var(--brand); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--muted-soft); color: var(--ink-2); white-space: nowrap; }
.badge.s-REQUESTED { background: var(--p-amber); color: var(--p-amber-ink); }
.badge.s-BOOKED { background: var(--p-blue); color: var(--p-blue-ink); }
.badge.s-ON_THE_WAY { background: var(--p-lilac); color: var(--p-lilac-ink); }
.badge.s-ARRIVED { background: var(--p-mint); color: var(--p-mint-ink); }
.badge.s-HANDED_OVER { background: var(--p-gray); color: var(--p-gray-ink); }
.badge.s-CANCELLED { background: var(--p-rose); color: var(--p-rose-ink); }
.badge.best { background: var(--mint); color: #08352a; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.late { background: var(--p-rose); color: var(--p-rose-ink); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.dir-IN, .badge.dir-OUT { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line); }

.alert { border-radius: 18px; padding: 14px 16px; font-size: .9rem; display: flex; gap: 12px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--accent-soft); color: var(--accent); }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }

/* ---------- เส้นสถานะ ---------- */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.steps .st { height: 6px; border-radius: 3px; background: var(--road); }
.steps .st.done { background: var(--brand); }
.steps .st.now { background: var(--sun); }
.steps.cancel .st { background: var(--danger-soft); }

/* ถนนติดตามงาน (หน้ารายละเอียดงาน) */
.roadbox { display: grid; gap: 12px; }
.roadbox .lvl { text-align: center; display: grid; gap: 2px; }
.roadbox .lvl small { color: var(--ink-2); font-size: .82rem; }
.roadbox .lvl h3 { font-size: 1.35rem; color: var(--brand); }
svg.road { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; overflow: visible; }
.road-base { fill: none; stroke: var(--road); stroke-width: 26; stroke-linecap: round; }
.road-done { fill: none; stroke: var(--brand); stroke-width: 26; stroke-linecap: butt; }
.road-lane { fill: none; stroke: var(--surface); stroke-width: 2.5; stroke-dasharray: 7 9; stroke-linecap: round; }
.stop circle.ring { fill: var(--surface); stroke: var(--road); stroke-width: 5; }
.stop.done circle.ring { fill: var(--brand); stroke: var(--brand); }
.stop.now circle.ring { fill: var(--sun); stroke: var(--surface); }
.stop text { font-family: var(--font-display); font-size: 13px; fill: var(--ink); }
.stop text.t { font-family: var(--font); font-size: 11px; fill: var(--ink-2); }
.stop text.n { font-size: 12px; fill: var(--ink-2); text-anchor: middle; }
.stop.now text.n { fill: #1b1f3b; }
.stop path.tick { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mini { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); }
.mini li { position: relative; text-align: center; padding-top: 26px; font-size: .72rem; color: var(--ink-2); line-height: 1.3; min-width: 0; }
.mini li::before { content: ""; position: absolute; top: 9px; left: 50%; width: 100%; height: 4px; border-radius: 2px; background: var(--road); }
.mini li:last-child::before { display: none; }
.mini li.done::before { background: var(--brand); }
.mini li i { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 4px solid var(--road); z-index: 1; }
.mini li.done i { background: var(--brand); border-color: var(--brand); }
.mini li.now i { background: var(--sun); border-color: var(--surface); box-shadow: 0 0 0 3px var(--sun); }
.mini li.now, .mini li.done { color: var(--ink); }
.mini li.now { font-weight: 600; }
.mini li span { display: block; font-size: .66rem; color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; }
.cheer { display: flex; align-items: center; gap: 12px; background: var(--p-mint); color: var(--p-mint-ink); border-radius: 18px; padding: 8px 16px; }
.cheer svg { flex-shrink: 0; }
.cheer b { font-family: var(--font-display); font-weight: 500; display: block; }
.cheer small { opacity: .85; font-size: .8rem; }

/* ---------- หน้าติดตามงาน (รายการ) ---------- */
.toolbar { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) { .toolbar { flex-direction: row; align-items: center; } .toolbar .in { max-width: 380px; } }
.tabsep { width: 2px; background: var(--line); margin: 4px; flex-shrink: 0; border-radius: 2px; }
.tlist { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .tlist { grid-template-columns: 1fr 1fr; gap: 14px; } }
.tcard { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 2px solid var(--line-2); border-radius: var(--radius); padding: 16px 16px 14px; transition: border-color .12s ease, transform .12s ease; }
.tcard:hover { border-color: var(--brand-soft); transform: translateY(-1px); }
.tcard.late { border-color: var(--p-rose); box-shadow: inset 4px 0 0 var(--coral); }
.tc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-no { font-size: .8rem; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tc-name { font-family: var(--font-display); font-size: 1.02rem; font-weight: 500; margin-top: 8px; line-height: 1.4; }
.tc-next { font-size: .84rem; color: var(--ink-2); margin-top: 2px; }
.tc-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; padding-top: 10px; border-top: 2px solid var(--line-2); font-size: .8rem; color: var(--ink-2); }
.tc-meta span { display: inline-flex; align-items: center; gap: 6px; }
.tc-meta svg { width: 15px; height: 15px; color: var(--ink-3); }
.trk { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); }
.trk li { position: relative; padding-top: 24px; text-align: center; min-width: 0; }
.trk li::before { content: ""; position: absolute; top: 7px; left: 50%; width: 100%; height: 4px; border-radius: 2px; background: var(--road); }
.trk li:last-child::before { display: none; }
.trk li.done::before { background: var(--brand); }
.trk .dot { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 4px solid var(--road); z-index: 1; }
.trk li.done .dot { background: var(--brand); border-color: var(--brand); }
.trk li.now .dot { background: var(--sun); border-color: var(--surface); box-shadow: 0 0 0 3px var(--sun); }
.trk .lb { display: block; font-size: .72rem; color: var(--ink-3); line-height: 1.3; padding: 0 2px; }
.trk li.done .lb { color: var(--ink-2); }
.trk li.now .lb { color: var(--ink); font-weight: 600; }
.trk .at { display: block; font-size: .66rem; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 2px; min-height: 1em; }

/* ---------- หน้าแรก ---------- */
.hello { display: flex; align-items: center; gap: 12px; }
.hello .av { width: 46px; height: 46px; border-radius: 50%; background: #fff3d1; overflow: hidden; flex-shrink: 0; display: grid; place-items: center; }
.hello small { display: block; color: var(--ink-2); font-size: .8rem; }
.hello b { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
.bigq { font-size: clamp(1.4rem, 5vw, 1.8rem); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.tile { border: 0; border-radius: var(--radius); padding: 14px; text-align: left; display: grid; gap: 12px; min-height: 116px; align-content: space-between; text-decoration: none; color: var(--ink); cursor: pointer; transition: transform .15s ease; }
.tile:hover { transform: translateY(-2px); }
.tile .ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); }
.tile .ic svg { width: 22px; height: 22px; }
.tile b { font-family: var(--font-display); font-weight: 500; font-size: 1rem; line-height: 1.3; display: block; }
.tile small { color: var(--ink-2); font-size: .76rem; }
.tile.t0 { background: var(--p-mint); } .tile.t0 .ic { color: var(--accent); }
.tile.t1 { background: var(--p-amber); } .tile.t1 .ic { color: var(--warn); }
.tile.t2 { background: var(--p-lilac); } .tile.t2 .ic { color: var(--p-lilac-ink); }
.tile.t3 { background: var(--p-rose); } .tile.t3 .ic { color: var(--coral); }
.tile.t4 { background: var(--p-blue); } .tile.t4 .ic { color: var(--brand); }
.mine { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); padding: 16px 16px 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; text-decoration: none; }
.mine b { font-family: var(--font-display); font-weight: 500; font-size: 1.08rem; }
.mine small { opacity: .88; font-size: .82rem; }
.mine .dots { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 6px; }
.mine .dots i { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.28); }
.mine .dots i.on { background: var(--sun); }
.mine .go { width: 42px; height: 42px; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; }
.ready { display: flex; align-items: center; gap: 12px; background: var(--p-mint); color: var(--p-mint-ink); border-radius: var(--radius); padding: 12px 16px; text-decoration: none; }
.ready b { font-family: var(--font-display); font-weight: 500; display: block; }
.ready small { opacity: .85; font-size: .8rem; }
.kgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .kgrid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.kt { border: 3px solid transparent; border-radius: var(--radius); padding: 12px 14px; text-align: left; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; cursor: pointer; color: var(--ink); }
.kt b { font-family: var(--font-display); font-weight: 600; font-size: 1.8rem; line-height: 1; grid-row: span 2; font-variant-numeric: tabular-nums; }
.kt span { font-size: .86rem; line-height: 1.25; font-weight: 600; }
.kt em { font-style: normal; font-size: .74rem; color: var(--ink-2); }
.kt em.hot { color: var(--danger); font-weight: 600; }
.kt.sun { background: var(--p-amber); } .kt.sun b { color: var(--p-amber-ink); }
.kt.blue { background: var(--p-blue); } .kt.blue b { color: var(--p-blue-ink); }
.kt.coral { background: var(--p-rose); } .kt.coral b { color: var(--p-rose-ink); }
.kt.mint { background: var(--p-mint); } .kt.mint b { color: var(--p-mint-ink); }
.kt.on { border-color: var(--ink); }
.qlist { display: grid; gap: 8px; }
@media (min-width: 900px) { .qlist { grid-template-columns: 1fr 1fr; } }
.qrow { display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 2px solid var(--line-2); border-radius: 16px; padding: 10px 12px 10px 10px; text-align: left; width: 100%; text-decoration: none; color: inherit; min-width: 0; }
.qrow:hover { border-color: var(--brand-soft); }
.qrow .bar { align-self: stretch; border-radius: 3px; background: var(--line); }
.qrow.URGENT .bar, .qrow.late .bar { background: var(--coral); }
.qrow.TODAY .bar { background: var(--sun); }
.qrow > span:nth-child(2) { min-width: 0; }
.qrow b { font-family: var(--font-display); font-weight: 500; font-size: .95rem; display: block; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow small { color: var(--ink-2); font-size: .76rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow .tag { font-size: .72rem; padding: 3px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; font-weight: 600; }
.qrow .tag.red { background: var(--p-rose); color: var(--p-rose-ink); }
.qrow .tag.ok { background: var(--p-mint); color: var(--p-mint-ink); }
.qrow .tag.amber { background: var(--p-amber); color: var(--p-amber-ink); }

/* ---------- รายการงาน ---------- */
.jobs { display: flex; flex-direction: column; gap: 10px; }
.job { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 2px solid var(--line-2); border-radius: 18px; padding: 14px 16px 12px; position: relative; transition: border-color .12s ease; }
.job:hover { border-color: var(--brand-soft); }
.job.sel { border-color: var(--brand); }
.job .top { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.job .name { font-family: var(--font-display); font-weight: 500; font-size: 1rem; line-height: 1.4; }
.job .meta { font-size: .82rem; color: var(--ink-2); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.job .steps { margin-top: 12px; }
.job .urg { position: absolute; left: 0; top: 16px; bottom: 16px; width: 4px; border-radius: 0 4px 4px 0; }
.job .urg.URGENT { background: var(--coral); }
.job .urg.TODAY { background: var(--sun); }

.split { display: block; }
@media (min-width: 1024px) {
  .split { display: grid; grid-template-columns: minmax(340px, 400px) 1fr; gap: 24px; align-items: start; }
  .split .list-pane { position: sticky; top: 88px; max-height: calc(100dvh - 108px); overflow: auto; padding-right: 4px; }
  .split .detail-pane { min-width: 0; }
}

/* ---------- ตาราง ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th, table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
table.t th { font-size: .76rem; color: var(--ink-2); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.tot td { font-weight: 600; border-top: 2px solid var(--line); }
table.t input.in { min-height: 36px; padding: 6px 8px; border-radius: 10px; }

/* ---------- ตัวเลือกแมส ---------- */
.past { background: var(--brand-soft); border-radius: 16px; padding: 10px 14px; display: grid; gap: 6px; }
.past small { font-size: .76rem; color: var(--ink-2); }
.pastrow { display: flex; flex-wrap: wrap; gap: 6px; }
.pastrow span { background: var(--surface); border-radius: 99px; padding: 3px 12px; font-size: .8rem; }
.pastrow b { font-family: var(--font-display); font-weight: 500; color: var(--brand); font-variant-numeric: tabular-nums; }
.quotes { display: flex; flex-direction: column; gap: 8px; }
.q { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.q.best { border-color: var(--p-mint); background: var(--p-mint); }
.q.pick { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.q.off { opacity: .5; background: var(--surface-2); cursor: default; }
.q .pn { font-family: var(--font-display); font-weight: 500; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.q .pp { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.q .ps { font-size: .76rem; color: var(--ink-2); grid-column: 1 / -1; }
.q .why { color: var(--danger); font-size: .8rem; grid-column: 1 / -1; }

/* ---------- อื่น ๆ ---------- */
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 10px 14px; font-size: .92rem; }
.kv dt { color: var(--ink-2); font-size: .82rem; padding-top: 2px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.copy { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--brand-soft); color: var(--brand); font-size: .74rem; padding: 4px 10px; border-radius: 99px; cursor: pointer; vertical-align: middle; font-weight: 600; }
.copy:hover { filter: brightness(.97); }
.copy svg { width: 13px; height: 13px; }
.msgbox { background: var(--surface-2); border: 2px solid var(--line-2); border-radius: 16px; padding: 12px 14px; font-size: .85rem; white-space: pre-wrap; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline li .w { color: var(--ink-2); min-width: 110px; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); display: grid; justify-items: center; gap: 4px; }
.empty b { display: block; color: var(--ink); font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
.empty svg { color: var(--ink); margin-bottom: 6px; }
.searchres { border: 2px solid var(--line); border-radius: 18px; overflow: hidden; margin-top: 10px; background: var(--surface); }
.searchres button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 12px 16px; cursor: pointer; }
.searchres button:last-child { border-bottom: 0; }
.searchres button:hover { background: var(--surface-2); }
.picked { border: 2px solid var(--brand); background: var(--brand-soft); border-radius: 18px; padding: 14px 16px; }
.addr { border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; cursor: pointer; background: var(--surface); text-align: left; width: 100%; display: block; }
.addr:hover { background: var(--surface-2); }
.addr.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.photo { max-width: 100%; max-height: 280px; border-radius: 16px; border: 2px solid var(--line); display: block; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #fff3d1; color: #1b1f3b; display: grid; place-items: center; font-weight: 600; font-size: .9rem; flex-shrink: 0; overflow: hidden; }
.logo { width: 38px; height: 38px; border-radius: 13px; background: var(--mint); color: #08352a; display: grid; place-items: center; }
.logo svg { width: 22px; height: 22px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 22px; border-radius: 99px; font-size: .9rem; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: calc(100% - 32px); }
@media (min-width: 1024px) { .toast { bottom: 30px; } }
.sheet-bg { position: fixed; inset: 0; background: rgba(14, 18, 48, .45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 620px; max-height: 92dvh; overflow: auto; border-radius: 28px 28px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) { .sheet-bg { align-items: center; } .sheet { border-radius: 28px; padding: 28px; } }
.sheet h2 { margin-bottom: 14px; font-size: 1.15rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs a, .tabs button { flex-shrink: 0; text-decoration: none; padding: 8px 16px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: .87rem; cursor: pointer; }
.tabs .on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.userpick { display: flex; flex-direction: column; gap: 8px; }
.userpick button { display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; }
.userpick button:hover { border-color: var(--brand); }
.pricecell { width: 84px; }
/* เว้นระยะเหนือปุ่ม + ที่ลอยบนแถบเมนูล่าง */
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--paper) 30%); padding: 20px 0 34px; z-index: 5; }
@media (min-width: 1024px) { .sticky-actions { padding-bottom: 10px; } }
@media (min-width: 1024px) { .sticky-actions { bottom: 0; } }
.menu a { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: inherit; }
.menu a:last-child { border-bottom: 0; }
.menu a svg { width: 20px; height: 20px; color: var(--brand); }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; background: var(--brand); padding: 0; }
.welcome { width: 100%; max-width: 460px; min-height: 100dvh; display: flex; flex-direction: column; color: #fff; }
@media (min-width: 520px) { .welcome { min-height: auto; margin: 32px 0; border-radius: 32px; overflow: hidden; box-shadow: 0 30px 60px -30px rgba(0,0,0,.45); background: var(--brand); } }
.welcome .wbrand { display: flex; align-items: center; gap: 10px; padding: calc(22px + env(safe-area-inset-top)) 24px 0; }
.welcome .wbrand .word { font-family: var(--font-display); font-size: 1.5rem; font-weight: 500; }
.welcome .wbrand .word i { font-style: normal; color: var(--sun); }
.welcome .crowd { height: 220px; margin-top: 6px; }
.welcome .crowd svg { width: 100%; height: 100%; display: block; }
.welcome .wsheet { background: var(--surface); color: var(--ink); border-radius: 28px 28px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); margin-top: auto; flex: 1; }
@media (min-width: 520px) { .welcome .wsheet { flex: none; border-radius: 28px 28px 0 0; } }
.welcome .wsheet h1 { font-size: 1.35rem; }

/* ---------- พิมพ์ใบเงินสดย่อย ---------- */
.voucher { background: #fff; color: #000; padding: 24px; font-size: 13px; font-family: var(--font); }
.voucher h2 { text-align: center; font-size: 17px; }
.voucher .vh { display: flex; justify-content: space-between; margin: 10px 0; font-size: 13px; }
.voucher table { width: 100%; border-collapse: collapse; }
.voucher th, .voucher td { border: 1px solid #333; padding: 4px 6px; font-size: 12px; vertical-align: top; }
.voucher th { background: #eee; }
.voucher td.r { text-align: right; font-variant-numeric: tabular-nums; }
.voucher .sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 36px; text-align: center; font-size: 12px; }
.voucher .sign div { border-top: 1px dotted #000; padding-top: 6px; }
@media print {
  body { background: #fff; }
  .side, .bottomnav, .topbar, .noprint, .toast { display: none !important; }
  .main { padding: 0 !important; }
  .page { padding: 0 !important; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .voucher { padding: 0; }
  @page { size: A4 landscape; margin: 12mm; }
}
@media (max-width: 1023px) {
  .split.has-detail .list-pane { display: none; }
  .split:not(.has-detail) .detail-pane { display: none; }
}
/* ตัวเลขใช้ฟอนต์เนื้อหา (ฟอนต์หัวข้อเขียนเลขศูนย์มีขีด อ่านเป็น Ø ได้) */
.bento-tile .bt-v, .kpi .v, .kt b, .q .pp, .pastrow b, .tc-no, .stop text.t, .mini li span, .trk .at { font-family: var(--font); font-weight: 700; }
.stop text.n { font-family: var(--font); font-weight: 700; }
.btn.ghost { color: var(--brand); }

@media (prefers-reduced-motion: reduce) { .tile, .bento-tile, .tcard { transition: none; } }

.copy.line { background: #06c755; color: #fff; text-decoration: none; margin-right: 4px; }
.alert .copy.line { flex-shrink: 0; align-self: center; }
.numf { font-family: var(--font); font-weight: 700; }
