:root {
  --bg: #FAFAF8; --surface: #FFFFFF; --surface2: #FFF4E8; --line: #ECE6DD;
  --ink: #1A1A1A; --muted: #797369;
  --orange: #F1621B; --orange-dark: #C94E12; --yellow: #F5B722; --red: #D6432E; --black: #17171A;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
.mono { font-family: 'IBM Plex Mono', monospace; }
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
button, input, select, textarea { font-family: inherit; font-size: 15px; }
input, select, textarea { background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); }
button { cursor: pointer; }

.screen { padding: 20px 18px 90px; flex: 1; }

/* ---------- Landing ---------- */
.landing { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; gap: 28px; text-align: center; background: linear-gradient(180deg, #FFF7EC 0%, var(--bg) 45%); }
.landing-logo { font-family: 'IBM Plex Mono', monospace; font-weight: 700; font-size: 13px; letter-spacing: 0.08em; color: #fff; background: var(--black); border-radius: 8px; padding: 5px 12px; }
.landing-title { font-size: 24px; font-weight: 700; margin: 0; color: var(--black); }
.landing-sub { color: var(--muted); font-size: 13.5px; margin: -14px 0 6px; max-width: 320px; line-height: 1.6; }
.landing-choices { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 340px; }
.landing-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 26px 20px; box-shadow: 0 2px 10px rgba(23,23,26,0.05); transition: transform 0.1s; }
.landing-choice:active { transform: scale(0.98); }
.landing-choice-icon { font-size: 30px; }
.landing-choice-title { font-weight: 700; font-size: 16px; color: var(--black); }
.landing-choice-hint { color: var(--muted); font-size: 12px; }
.landing-choice.customer { border-color: var(--yellow); background: linear-gradient(135deg, #FFFDF7 0%, #FFF9EC 100%); }
.landing-choice.staff { border-color: var(--orange); background: linear-gradient(135deg, #FFFDF7 0%, #FFF1E5 100%); }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 2px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 5; }
.topbar-tag { font-family: 'IBM Plex Mono', monospace; font-weight: 700; font-size: 11px; letter-spacing: 0.06em; color: #fff; background: var(--orange); border-radius: 6px; padding: 4px 9px; }
.topbar-back { background: none; border: none; color: var(--orange); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.role-pill { font-size: 10.5px; font-weight: 700; border: 1.5px solid var(--line); border-radius: 20px; padding: 4px 10px; background: var(--surface2); color: var(--orange-dark); }

/* ---------- Cards / forms ---------- */
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.primary-btn { width: 100%; background: var(--orange); color: #fff; font-weight: 700; border: none; border-radius: 12px; padding: 14px; font-size: 15px; box-shadow: 0 3px 10px rgba(241,98,27,0.3); }
.primary-btn:active { background: var(--orange-dark); }
.primary-btn:disabled { opacity: 0.5; box-shadow: none; }
.secondary-btn { width: 100%; background: var(--surface); color: var(--black); border: 1.5px solid var(--line); border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 600; margin-top: 8px; }
.error-msg { color: var(--red); font-size: 12.5px; margin: -6px 0 12px; font-weight: 600; }

/* ---------- Job cards ---------- */
.job-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(23,23,26,0.04); }
.job-ref { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); }
.job-model { font-weight: 700; font-size: 15.5px; margin: 3px 0 10px; color: var(--black); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; border-radius: 20px; padding: 5px 12px; }
.status-badge.received { background: #FFF3D6; color: #9A6B0A; }
.status-badge.sealing { background: #FFE4D2; color: var(--orange-dark); }
.status-badge.returned { background: var(--black); color: #fff; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.timeline { display: flex; align-items: center; margin: 16px 0 10px; }
.timeline-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.timeline-circle { width: 26px; height: 26px; border-radius: 50%; background: var(--surface2); border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; z-index: 1; color: var(--muted); font-weight: 700; }
.timeline-step.done .timeline-circle { background: var(--black); border-color: var(--black); color: #fff; }
.timeline-step.active .timeline-circle { background: var(--orange); border-color: var(--orange); color: #fff; }
.timeline-label { font-size: 10px; color: var(--muted); text-align: center; }
.timeline-step.done .timeline-label, .timeline-step.active .timeline-label { color: var(--black); font-weight: 600; }
.timeline-line { position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.timeline-step:first-child .timeline-line { display: none; }
.timeline-step.done .timeline-line { background: var(--black); }

.job-detail-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.job-detail-row:last-child { border-bottom: none; }
.job-detail-row .label { color: var(--muted); }
.job-detail-row .value { text-align: right; max-width: 60%; color: var(--black); font-weight: 500; }

/* ---------- Staff dashboard ---------- */
.filter-tabs { display: flex; gap: 6px; background: var(--surface2); border: 1.5px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.filter-tabs button { flex: 1; background: none; border: none; color: var(--muted); font-weight: 600; font-size: 12px; padding: 9px 4px; border-radius: 9px; }
.filter-tabs button.active { background: var(--orange); color: #fff; }

.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }
.search-box input { border: none; background: none; padding: 0; flex: 1; }

.fab-btn { position: fixed; bottom: 24px; right: 50%; transform: translateX(190px); background: var(--orange); color: #fff; border: none; border-radius: 50px; padding: 14px 22px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 20px rgba(241,98,27,0.45); z-index: 8; }
@media (max-width: 480px) { .fab-btn { right: 18px; transform: none; } }

.empty-state { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 20px; line-height: 1.7; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,23,26,0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal { background: var(--surface); border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; font-size: 17px; color: var(--black); }
.status-action-btn { width: 100%; border: none; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 14px; margin-bottom: 10px; color: #fff; }
.status-action-btn.sealing { background: var(--orange); }
.status-action-btn.returned { background: var(--black); }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--black); border: none; color: #fff; padding: 11px 18px; border-radius: 30px; font-size: 13px; z-index: 50; box-shadow: 0 4px 16px rgba(23,23,26,0.3); font-weight: 500; }
.toast.err { background: var(--red); }

.spinner { border: 2.5px solid var(--line); border-top-color: var(--orange); border-radius: 50%; width: 22px; height: 22px; animation: spin 0.7s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
