:root {
  --bg: #101113; --surface: #17181A; --surface2: #1E2023; --line: #2A2C30;
  --ink: #ECEDEE; --muted: #8B8D93;
  --yellow: #F0B429; --green: #3FB27F; --red: #D6432E; --blue: #2E7DD1;
}
* { 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: 520px; 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: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--yellow); }
button { cursor: pointer; }

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

/* ---------- Login / landing ---------- */
.landing { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; gap: 20px; }
.landing-logo { font-family: 'IBM Plex Mono', monospace; font-weight: 700; font-size: 13px; letter-spacing: 2px; background: var(--surface2); border: 1px solid var(--line); color: var(--yellow); padding: 5px 14px; border-radius: 8px; }
.landing-title { font-size: 20px; font-weight: 700; margin: 0; text-align: center; }
.login-box { width: 100%; max-width: 320px; }
.error-msg { color: var(--red); font-size: 12.5px; margin: -6px 0 12px; font-weight: 600; }
.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(--yellow); color: #17181A; font-weight: 700; border: none; border-radius: 12px; padding: 14px; font-size: 15px; }
.primary-btn:disabled { opacity: 0.5; }
.secondary-btn { width: 100%; background: var(--surface2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 600; margin-top: 8px; }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.topbar-tag { font-family: 'IBM Plex Mono', monospace; font-weight: 700; font-size: 11px; color: var(--yellow); background: var(--surface2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }
.role-pill { font-size: 10.5px; font-weight: 700; border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; background: var(--surface); color: var(--ink); }
.back-btn { background: none; border: none; color: var(--yellow); font-weight: 600; font-size: 13px; }

/* ---------- Job list ---------- */
.job-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.job-card-title { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.job-card-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.job-progress-bar { height: 6px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.job-progress-fill { height: 100%; background: var(--green); }
.job-progress-label { font-size: 10.5px; color: var(--muted); margin-top: 4px; text-align: right; }
.fab-btn { position: fixed; bottom: 22px; right: 50%; transform: translateX(240px); background: var(--yellow); color: #17181A; border: none; border-radius: 50px; padding: 14px 22px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.4); z-index: 8; }
@media (max-width: 520px) { .fab-btn { right: 16px; transform: none; } }
.empty-state { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 20px; line-height: 1.7; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }
.search-box input { border: none; background: none; padding: 0; flex: 1; }

/* ---------- Job detail ---------- */
.render-img-box { width: 100%; aspect-ratio: 16/10; background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; position: relative; }
.render-img-box img { width: 100%; height: 100%; object-fit: cover; }
.render-img-placeholder { color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px; }
.render-upload-btn { position: absolute; bottom: 10px; right: 10px; background: rgba(23,24,26,0.85); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 7px 12px; font-size: 11.5px; font-weight: 600; }

.section-label { font-weight: 700; font-size: 13px; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-label .count { color: var(--muted); font-weight: 500; font-size: 11.5px; }

/* progress grid */
.grid-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.grid-table th { background: var(--surface2); color: var(--muted); font-weight: 600; padding: 8px 4px; text-align: center; border: 1px solid var(--line); }
.grid-table th:first-child { text-align: left; padding-left: 8px; }
.grid-table td { border: 1px solid var(--line); padding: 4px; text-align: center; }
.grid-table td:first-child { text-align: left; padding-left: 8px; font-weight: 600; background: var(--surface); }
.grid-cell { width: 100%; height: 46px; border: none; border-radius: 8px; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 1px; cursor: pointer; }
.grid-cell.done { background: rgba(63,178,127,0.15); color: var(--green); }
.grid-cell .cell-date { font-size: 8px; color: var(--muted); }
.grid-cell.done .cell-date { color: var(--green); opacity: 0.8; }

/* equipment */
.equip-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.equip-name { flex: 1; font-size: 13px; }
.equip-qty { font-family: 'IBM Plex Mono', monospace; color: var(--yellow); font-size: 12.5px; }
.equip-qty-stepper { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.qty-step-btn { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface2); color: var(--yellow); font-weight: 700; font-size: 15px; padding: 0; display: flex; align-items: center; justify-content: center; }
.qty-step-btn:disabled { opacity: 0.35; }
.equip-qty-input { width: 44px; text-align: center; padding: 5px 2px; font-size: 12.5px; color: var(--yellow); border-color: var(--line); }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 14px; padding: 2px 6px; }
.icon-btn.danger { color: var(--red); }

/* plank log */
.plank-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.plank-thumb { width: 48px; height: 48px; border-radius: 8px; background: var(--surface2); object-fit: cover; flex-shrink: 0; }
.plank-info { flex: 1; }
.plank-matno { font-weight: 700; font-size: 13.5px; }
.plank-date { font-size: 10.5px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); 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: 520px; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.toggle-row { display: flex; gap: 6px; margin: 8px 0 14px; }
.toggle-row button { flex: 1; border: 1px solid var(--line); background: var(--surface2); border-radius: 9px; padding: 10px 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.toggle-row button.active { background: var(--green); color: #0F1710; border-color: var(--green); }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line); color: var(--ink); padding: 11px 18px; border-radius: 30px; font-size: 13px; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.toast.err { border-color: var(--red); color: var(--red); }

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