[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", "Noto Sans", sans-serif;
  color: #1f2937; background: #f8fafc; min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }

.navbar { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid #e5e7eb; }
.nav-inner { max-width: 1140px; margin: 0 auto; padding: 0 20px; height: 60px;
             display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 1.5rem; font-weight: 800; letter-spacing: 2px; }
.menu { display: flex; align-items: center; gap: 28px; list-style: none; }
.menu a, .btn-link { font-size: .95rem; color: #4b5563; padding: 6px 0; }
.menu a:hover, .menu a.active, .btn-link:hover { color: #111827; }
.menu .btn-nav { background: #111827; color: #fff; padding: 7px 16px; border-radius: 6px; }
.menu .btn-nav:hover, .menu .btn-nav.active { color: #fff; background: #374151; }
.user { display: flex; align-items: center; gap: 14px; }
.who { font-size: .95rem; font-weight: 600; }
.inline { display: inline; }
.btn-link { background: none; border: 0; cursor: pointer; font-family: inherit; }
.who-top { display: none; }
.toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.toggle span { display: block; width: 22px; height: 2px; background: #1f2937; margin: 5px 0; transition: .2s; }

main { flex: 1; max-width: 1140px; width: 100%; margin: 0 auto; padding: 48px 20px; }
footer { text-align: center; padding: 20px; font-size: .85rem; color: #9ca3af; }

.card { max-width: 380px; margin: 0 auto; background: #fff; border: 1px solid #e5e7eb;
        border-radius: 10px; padding: 32px 28px; }
.card h1 { font-size: 1.4rem; margin-bottom: 20px; text-align: center; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .9rem; margin-bottom: 6px; color: #374151; }
.field input { width: 100%; padding: 10px 12px; font-size: 1rem; border: 1px solid #d1d5db; border-radius: 6px; }
.field input:focus { outline: none; border-color: #111827; }
.btn { width: 100%; padding: 11px; font-size: 1rem; background: #111827; color: #fff; border: 0;
       border-radius: 6px; cursor: pointer; font-family: inherit; }
.btn:hover { background: #374151; }
.alert { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 10px 12px;
         border-radius: 6px; font-size: .9rem; margin-bottom: 16px; }

@media (max-width: 768px) {
  .toggle { display: block; }
  .who-top { display: block; margin-left: auto; margin-right: 6px; font-size: .95rem; font-weight: 600; color: #374151;
             max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
          align-items: stretch; gap: 0; background: #fff; border-bottom: 1px solid #e5e7eb; }
  .menu.open { display: flex; }
  .menu a { display: block; padding: 14px 20px; }
  .menu .btn-nav { margin: 8px 20px 14px; text-align: center; }
  .user { justify-content: space-between; padding: 14px 20px; border-top: 1px solid #f1f5f9; }
  .toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .toggle.open span:nth-child(2) { opacity: 0; }
  .toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .card { padding: 24px 18px; }
}

.who small { display: block; font-size: .72rem; font-weight: 400; color: #6b7280; }
.wide { max-width: 1000px; margin: 0 auto; }
.wide h1 { font-size: 1.4rem; margin-bottom: 18px; }
.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.panel h2 { font-size: 1.05rem; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.grid .field { margin-bottom: 0; }
.field select { width: 100%; padding: 10px 12px; font-size: 1rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; background: #111827; color: #fff; border: 0; border-radius: 6px; cursor: pointer; font-family: inherit; }
.btn-sm.ghost { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; padding: 10px 12px; border-radius: 6px; font-size: .9rem; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
th { font-size: .8rem; color: #6b7280; font-weight: 600; text-transform: uppercase; }
td input, td select { padding: 6px 8px; font-size: .9rem; border: 1px solid #d1d5db; border-radius: 6px; max-width: 100%; }
.muted { color: #9ca3af; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; background: #f1f5f9; }
.badge.off { background: #fef2f2; color: #b91c1c; }
@media (max-width: 768px) {
  /* stacked rows on phones */
  table.stack thead { display: none; }
  table.stack tr { display: block; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px; margin-bottom: 10px; }
  table.stack td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 6px 4px; }
  table.stack td::before { content: attr(data-label); color: #6b7280; font-size: .8rem; }
}

.checks { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chk { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #e5e7eb;
       border-radius: 6px; background: #fff; font-size: .92rem; cursor: pointer; }
.chk-new { flex: 1 1 200px; padding: 7px 10px; font-size: .92rem; border: 1px dashed #d1d5db; border-radius: 6px; }
details.panel summary { cursor: pointer; list-style: none; }
details.panel summary h2 { display: inline; margin: 0; }
details.panel[open] summary { margin-bottom: 14px; }
.switch { min-width: 52px; padding: 4px 10px; border-radius: 99px; border: 1px solid #fecaca; background: #fef2f2;
          color: #b91c1c; font-size: .82rem; cursor: pointer; font-family: inherit; }
.switch.on { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
tr.off td { opacity: .55; }
tr.off td:last-child, tr.off td[data-label="สถานะ"] { opacity: 1; }
a.btn-sm { display: inline-block; }

main.home { max-width: 640px; padding-top: 24px; }
.hello { font-size: 1.3rem; font-weight: 700; }
.today { color: #dc2626; font-size: .95rem; font-weight: 600; margin: 0 0 12px; }
.big-buttons { display: flex; flex-direction: column; gap: 12px; }
.big-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px; padding: 12px 16px;
           border-radius: 12px; color: #fff; font-size: 1.15rem; font-weight: 700; text-align: center;
           box-shadow: 0 2px 8px rgba(0,0,0,.08); transition: transform .1s, filter .15s; }
.big-btn .ico { font-size: 1.4rem; line-height: 1; }
.big-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.big-btn:active { transform: scale(.99); }
.c-blue { background: #1565c0; }  .c-teal { background: #00796b; }  .c-sky { background: #2f6fdb; }
.c-purple { background: #6a1b9a; } .c-dark { background: #1c1c1c; } .c-orange { background: #e65100; }
.c-pink { background: #e91e8c; }
.c-yellow { background: #fbc02d; color: #1f2937; } .c-red { background: #c62828; }
@media (max-width: 768px) {
  main.home { padding: 20px 16px; }
  .big-btn { min-height: 56px; font-size: 1.05rem; }
}

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 10px 0 8px; }
button.big-btn { width: 100%; border: 0; cursor: pointer; font-family: inherit; }
.big-btn[aria-selected="true"] { box-shadow: 0 0 0 3px #f8fafc, 0 0 0 6px #111827; }
.divider { border: 0; border-top: 1px solid #d1d5db; margin: 22px 0 16px; }
.section-title { font-size: 1.05rem; font-weight: 700; color: #374151; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
        min-height: 104px; padding: 14px 8px; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
        text-align: center; transition: transform .1s, box-shadow .15s; }
.tile:hover { box-shadow: 0 3px 10px rgba(0,0,0,.08); transform: translateY(-1px); }
.tile-ico { font-size: 2rem; line-height: 1; }
.tile-label { font-size: .92rem; color: #1f2937; }
.tile.soon { opacity: .55; pointer-events: none; }
@media (min-width: 769px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; vertical-align: middle; border: 1px solid #e5e7eb; }

button.tile { font-family: inherit; cursor: pointer; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(17,24,39,.55); display: flex;
         align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { position: relative; width: 100%; max-width: 420px; max-height: 95vh; overflow-y: auto;
             background: #fff; border-radius: 14px; padding: 22px 18px 18px; text-align: center; }
.modal-box h2 { font-size: 1.1rem; margin: 0 28px 12px; }
.modal-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.8rem;
           line-height: 1; color: #6b7280; cursor: pointer; }
.qr-img { width: 100%; max-width: 280px; border: 1px solid #e5e7eb; border-radius: 8px; }
.qr-link { display: flex; gap: 6px; margin-top: 12px; }
.qr-url { flex: 1; min-width: 0; padding: 7px 9px; font-size: .85rem; border: 1px solid #d1d5db; border-radius: 6px; }
.qr-exp { margin-top: 8px; font-size: .88rem; color: #15803d; }
.qr-exp.expired { color: #b91c1c; }
.qr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.qr-loading { padding: 40px 0; }

.ci-name { font-size: 1.4rem; font-weight: 700; color: #b45309; margin-bottom: 8px; }
.ci-today { font-size: .9rem; margin-bottom: 10px; }
.ci-today .in, .ci-today .out { display: inline-block; padding: 2px 8px; border-radius: 99px; margin: 2px; }
.in { color: #15803d; } .out { color: #b91c1c; }
.ci-today .in { background: #f0fdf4; } .ci-today .out { background: #fef2f2; }
.ci-loc { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 8px 10px; border-radius: 8px;
          border: 1px solid #e5e7eb; background: #f9fafb; font-size: .88rem; color: #6b7280; margin-bottom: 12px; }
.ci-loc.ok { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.ci-loc.bad { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.ci-photo { display: block; cursor: pointer; margin-bottom: 12px; }
.ci-photo-btn { display: inline-block; padding: 10px 20px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 1.05rem; }
.ci-preview { display: block; width: 200px; height: 200px; object-fit: cover; margin: 10px auto 0; border-radius: 10px; }
.ci-type { display: flex; gap: 10px; margin-bottom: 14px; }
.ci-type label { flex: 1; }
.ci-type input { position: absolute; opacity: 0; }
.ci-type span { display: block; padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; font-weight: 700; color: #6b7280; cursor: pointer; }
.ci-type input:checked + .in { background: #f0fdf4; border-color: #22c55e; color: #15803d; }
.ci-type input:checked + .out { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.ci-submit:disabled { background: #d1d5db; cursor: not-allowed; }
.ci-hint { font-size: .8rem; margin-top: 6px; }
.ci-ok { font-size: 1.2rem; font-weight: 700; padding: 18px 0; }

/* quotation page */
main.qt-page { max-width: 1100px; }
.qt-page h1 { font-size: 1.4rem; margin: 6px 0 14px; }
.small { font-size: .82rem; }
.cus-q { width: 100%; padding: 10px 12px; font-size: 1rem; border: 1px solid #d1d5db; border-radius: 6px; }
.cus-results { margin-top: 6px; max-height: 300px; overflow-y: auto; }
.cus-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 9px 10px; text-align: left;
           background: #fff; border: 0; border-bottom: 1px solid #f1f5f9; cursor: pointer; font-family: inherit; font-size: .95rem; }
.cus-opt:hover { background: #f8fafc; }
.cus-opt .muted { font-size: .82rem; }
.cus-picked { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px;
              background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; }
.cus-sub { font-size: .85rem; }
.qt-lines input, .qt-lines select { width: 100%; }
.qt-lines .l-disc { white-space: nowrap; }
.qt-lines .l-disc input { width: 70px; }
.qt-lines .l-disc select { width: auto; }
.num, .l-total { text-align: right; font-variant-numeric: tabular-nums; }
.row-acts { white-space: nowrap; }
.row-acts .btn-sm { padding: 4px 8px; margin-left: 2px; }
.btn-sm.danger { color: #b91c1c; border-color: #fecaca; }
.qt-add { display: flex; gap: 8px; margin: 10px 0; }
.qt-sum { margin-left: auto; max-width: 380px; border-top: 1px solid #e5e7eb; padding-top: 8px; }
.qt-sum > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; font-size: .95rem; }
.qt-sum b { font-variant-numeric: tabular-nums; }
.qt-sum input { width: 80px; padding: 4px 6px; border: 1px solid #d1d5db; border-radius: 6px; }
.qt-sum select { padding: 4px; border: 1px solid #d1d5db; border-radius: 6px; }
.s-grand-row { border-top: 2px solid #111827; font-size: 1.1rem !important; }
.field textarea { width: 100%; padding: 10px 12px; font-size: 1rem; border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit; }
.qt-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.qt-buttons .btn { width: auto; flex: 1 1 180px; text-align: center; }
.btn.alt { background: #2563eb; }
.btn:disabled { opacity: .6; cursor: wait; }
@media (max-width: 768px) {
  .qt-lines td[data-label="Note"] { display: block; }
  .qt-lines td input { max-width: 60%; }
  .qt-lines td[data-label="รายการ"] input, .qt-lines td[data-label="Note"] input { max-width: 100%; }
  .qt-lines td[data-label="รายการ"], .qt-lines td[data-label="Note"] { flex-direction: column; align-items: stretch; gap: 4px; }
  .qt-sum { max-width: none; }
}

.ci-cam { position: relative; width: 240px; max-width: 100%; aspect-ratio: 3 / 4; margin: 0 auto 8px; border-radius: 12px;
          overflow: hidden; background: #111827; display: flex; align-items: center; justify-content: center; }
.ci-cam video, .ci-cam img { width: 100%; height: 100%; object-fit: cover; }
.ci-cam video { transform: scaleX(-1); }   /* mirror the selfie preview only */
.ci-cam-msg { position: absolute; inset: auto 8px; color: #e5e7eb; font-size: .85rem; padding: 8px; }
.ci-cam-msg.bad { color: #fecaca; }
.ci-cam-btns { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.ci-shoot { font-size: 1rem; padding: 8px 20px; }
.chk.unbound { border-color: #fecaca; background: #fef2f2; color: #b91c1c; cursor: default; }

.ci-history { display: inline-block; margin: -4px 0 8px; font-size: .9rem; color: #2563eb; text-decoration: underline; }

/* ประวัติลงเวลา */
main.ch-page { max-width: 1100px; }
.ch-page h1 { font-size: 1.4rem; margin: 6px 0 12px; }
.ch-date { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ch-date input { padding: 6px 8px; font-size: 1rem; border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit; }
.ch-day { color: #dc2626; font-weight: 600; margin: 8px 0 12px; }
.ch-tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.ch-tab { flex: 1; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; font-family: inherit;
          font-size: .95rem; font-weight: 600; color: #6b7280; cursor: pointer; white-space: nowrap; }
.ch-tab.active { background: #111827; color: #fff; border-color: #111827; }
.ch-tab .count { margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: rgba(0,0,0,.08); font-size: .8rem; }
.ch-tab.active .count { background: rgba(255,255,255,.2); }
.ch-map-card { padding: 12px; }
.ch-map-head { font-weight: 600; margin-bottom: 8px; }
.ch-map { height: 300px; border-radius: 8px; z-index: 0; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: .85rem; }
.ch-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ch-card { background: #fff; border: 1px solid #e5e7eb; border-left: 5px solid var(--c); border-radius: 10px; padding: 12px; }
.ch-card.me { box-shadow: 0 0 0 2px #111827; }
.ch-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.ch-none { color: #9ca3af; font-size: .9rem; }
.ch-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid #f1f5f9; }
.ch-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: #f1f5f9; }
.ch-badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 700; }
.ch-badge.in { background: #f0fdf4; color: #15803d; } .ch-badge.out { background: #fef2f2; color: #b91c1c; }
.ch-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.ch-loc { font-size: .82rem; color: #2563eb; }
.qt-search { display: flex; gap: 8px; margin-bottom: 12px; }
.qt-search input { flex: 1; min-width: 0; padding: 8px 10px; font-size: .95rem; border: 1px solid #d1d5db; border-radius: 6px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }

/* แจ้งสั่งของ / ของหมด */
main.req-page { max-width: 820px; }
.req-page h1 { font-size: 1.3rem; margin: 6px 0 14px; }
a.ch-tab { text-align: center; text-decoration: none; }
.req-kind { display: flex; gap: 10px; margin-bottom: 12px; }
.req-kind label { flex: 1; }
.req-kind input { position: absolute; opacity: 0; }
.req-kind span { display: block; padding: 10px; text-align: center; border: 1px solid #e5e7eb; border-radius: 10px; font-weight: 700; color: #6b7280; cursor: pointer; }
.req-kind input:checked + span { border-color: #111827; color: #111827; background: #f3f4f6; }
.req-list { display: grid; gap: 10px; }
.req-card { background: #fff; border: 1px solid #e5e7eb; border-left: 5px solid #f59e0b; border-radius: 10px; padding: 12px 14px; }
.req-card.st-1 { border-left-color: #3b82f6; } .req-card.st-2 { border-left-color: #22c55e; } .req-card.st-9 { border-left-color: #9ca3af; opacity: .7; }
.req-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.req-kind-badge { font-size: .78rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: #eff6ff; color: #1d4ed8; }
.req-kind-badge.k2 { background: #fef2f2; color: #b91c1c; }
.req-st { font-size: .82rem; font-weight: 600; color: #6b7280; }
.req-item { font-size: 1.08rem; font-weight: 700; }
.req-qty { color: #b45309; }
.req-note { margin-top: 2px; font-size: .92rem; color: #374151; }
.req-meta { margin-top: 6px; font-size: .8rem; }
.req-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 768px) { .req-page .grid .field[style] { grid-column: auto !important; } }
.req-qtys { display: flex; gap: 16px; font-size: .92rem; margin-top: 2px; }
.req-qtys b { color: #b45309; }
.req-kind-badge.k2 { background: #fef3c7; color: #92400e; }
.req-pick { display: inline-block; padding: 10px 16px; border: 1px dashed #9ca3af; border-radius: 10px; cursor: pointer; font-weight: 600; }
.req-previews, .req-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.req-m { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #111827; }
.req-m img, .req-m video { width: 100%; height: 100%; object-fit: cover; display: block; }
.req-media .req-m:has(video) { grid-column: span 2; aspect-ratio: 16 / 10; }
.req-media .req-m video { object-fit: contain; }
.req-m-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0;
             background: rgba(0,0,0,.6); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer; }
.req-m-tag { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; }
.req-progress { margin: 8px 0; font-size: .85rem; color: #374151; }
.req-progress .bar { height: 8px; border-radius: 99px; background: #e5e7eb; overflow: hidden; margin-bottom: 4px; }
.req-progress .bar i { display: block; height: 100%; width: 0; background: #2563eb; transition: width .2s; }
.req-add-media { cursor: pointer; }
.req-ordered { margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: #eff6ff; color: #1e40af; font-size: .88rem; }
.req-onote { margin-top: 2px; color: #1f2937; }
.req-order { display: flex; gap: 6px; align-items: flex-end; width: 100%; }
.req-order textarea { flex: 1; min-width: 0; padding: 6px 8px; font-size: .9rem; border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit; }
.req-wait { align-self: center; }
