:root {
  --bg: #F7F7F5; --surface: #FFFFFF; --surface2: #FAFAF8; --line: #E7E5E0;
  --ink: #1C1C1E; --muted: #82807A;
  --yellow: #EAB308; --green: #2E9B5C; --red: #DC3B2E; --blue: #2E7DD1; --orange: #EA7317;
}
* { 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(--yellow); }
button { cursor: pointer; }

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

/* ---------- Login ---------- */
.landing { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; gap: 22px; }
.landing-logo { font-family: 'IBM Plex Mono', monospace; font-weight: 700; font-size: 13px; letter-spacing: 0.08em; color: #fff; background: var(--ink); border-radius: 8px; padding: 5px 12px; }
.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; }

/* ---------- 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(--surface); z-index: 5; }
.topbar-title { font-weight: 700; font-size: 15px; }
.topbar-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.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(--ink); }

/* ---------- Tabs ---------- */
.tab-bar { display: flex; background: var(--surface2); border-bottom: 1px solid var(--line); }
.tab-bar button { flex: 1; background: none; border: none; padding: 12px 4px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab-bar button.active { color: var(--ink); border-bottom-color: var(--yellow); }

/* ---------- Date nav ---------- */
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.date-nav-btn { background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.date-nav-label { flex: 1; text-align: center; font-weight: 700; font-size: 14.5px; }
.date-nav-today { font-size: 10.5px; color: var(--muted); text-align: center; margin-top: 1px; }

/* ---------- Task cards ---------- */
.task-card { background: var(--surface); border: 1.5px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.task-card.priority-high { border-left-color: var(--red); }
.task-card.priority-normal { border-left-color: var(--yellow); }
.task-card.priority-low { border-left-color: var(--blue); }
.task-title { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.task-details { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 8px; white-space: pre-wrap; }
.task-meta { font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }
.task-status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 4px 10px; }
.task-status-badge.pending { background: #F1F1EE; color: var(--muted); }
.task-status-badge.in_progress { background: rgba(46,125,209,0.12); color: var(--blue); }
.task-status-badge.done { background: rgba(46,155,92,0.12); color: var(--green); }
.task-status-badge.not_done { background: rgba(220,59,46,0.12); color: var(--red); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.task-note { font-size: 11.5px; color: var(--ink); background: var(--surface2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }

.status-btn-row { display: flex; gap: 6px; margin-top: 10px; }
.status-btn { flex: 1; border: 1.5px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.status-btn.active.in_progress { background: var(--blue); color: #fff; border-color: var(--blue); }
.status-btn.active.done { background: var(--green); color: #fff; border-color: var(--green); }
.status-btn.active.not_done { background: var(--red); color: #fff; border-color: var(--red); }

/* ---------- Forms / buttons ---------- */
.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: #1C1C1E; 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(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 12px; padding: 13px; font-size: 14px; font-weight: 600; margin-top: 8px; }

.fab-btn { position: fixed; bottom: 22px; right: 50%; transform: translateX(190px); background: var(--yellow); color: #1C1C1E; border: none; border-radius: 50px; padding: 14px 22px; font-weight: 700; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.18); z-index: 8; }
@media (max-width: 480px) { .fab-btn { right: 16px; transform: none; } }

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

/* ---------- Overview grid (supervisor dashboard) ---------- */
.overview-person { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.overview-person-name { font-weight: 700; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.overview-progress { font-size: 11px; color: var(--muted); font-weight: 600; }
.overview-task-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; }
.overview-task-row .status-dot-lg { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.overview-task-row .status-dot-lg.pending { background: var(--line); }
.overview-task-row .status-dot-lg.in_progress { background: var(--blue); }
.overview-task-row .status-dot-lg.done { background: var(--green); }
.overview-task-row .status-dot-lg.not_done { background: var(--red); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); 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; }
.priority-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
.priority-toggle button { flex: 1; border: 1.5px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.priority-toggle button.active.low { background: var(--blue); color: #fff; border-color: var(--blue); }
.priority-toggle button.active.normal { background: var(--yellow); color: #1C1C1E; border-color: var(--yellow); }
.priority-toggle button.active.high { background: var(--red); color: #fff; border-color: var(--red); }

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