:root { --brand: #4f46e5; --bg: #f5f5f7; --card: #ffffff; --text: #1f2430; --muted: #6b7280; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "Noto Sans Thai", "Sarabun", system-ui, sans-serif;
  font-size: 16px; padding: 0 12px calc(24px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
#app { max-width: 560px; margin: 0 auto; }
[hidden] { display: none !important; }

.card { background: var(--card); border-radius: 14px; padding: 18px; margin: 14px 0; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.login-card { margin-top: 15vh; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 16px 0 6px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: #dc2626; }

label { display: block; margin: 10px 0; font-size: 15px; }
input, textarea {
  width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 16px;
  border: 1px solid #d1d5db; border-radius: 10px; font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.row3 { display: flex; gap: 10px; }
.row3 label { flex: 1; }

button { font-family: inherit; font-size: 16px; border-radius: 10px; padding: 12px 16px; border: none; cursor: pointer; }
button.primary { background: var(--brand); color: #fff; width: 100%; margin-top: 14px; font-weight: 600; }
button.secondary { background: #e0e7ff; color: var(--brand); width: 100%; margin-top: 8px; }
button.ghost { background: transparent; color: var(--brand); padding: 8px 10px; }
button:active { opacity: .8; }

#topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px 0; }
#topbar .muted { margin-left: 6px; }

.segmented { display: flex; gap: 16px; margin: 6px 0; }
.segmented label { display: flex; align-items: center; gap: 6px; margin: 0; }
.segmented input { width: auto; }

.banner { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 15px; }
.banner.ok { background: #dcfce7; color: #166534; }
.banner.warn { background: #fef9c3; color: #854d0e; }

.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dash-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px;
  border-bottom: 1px solid #eee;
}
.dash-row.clickable { cursor: pointer; }
.dash-row.clickable:hover { background: #f8f8ff; }
.chev { color: var(--muted); font-size: 20px; width: 14px; text-align: center; flex: none; }
button:disabled { opacity: .35; cursor: default; }
.dash-row:last-child { border-bottom: none; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.dot.ontime { background: #22c55e; }
.dot.late { background: #eab308; }
.dot.missed { background: #ef4444; }
.dot.pending { background: #9ca3af; }
.dash-row .who { flex: 1; }
.dash-row .who .muted { display: block; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 999px; flex: none; }
.pill.ontime { background: #dcfce7; color: #166534; }
.pill.late { background: #fef9c3; color: #854d0e; }
.pill.missed { background: #fee2e2; color: #991b1b; }
.pill.pending { background: #f3f4f6; color: #4b5563; }

.tabs { display: flex; gap: 8px; margin-top: 14px; }
.tab { flex: 1; background: #e5e7eb; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--brand); color: #fff; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 12px 8px; border-bottom: 1px solid #eee; cursor: pointer; }
.user-row:last-child { border-bottom: none; }
.user-row.inactive { opacity: .45; }
.user-row .who { flex: 1; }
.user-row .who .muted { display: block; }
.badge { font-size: 14px; flex: none; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-box { width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; }
.report-detail dt { font-weight: 600; margin-top: 10px; }
.report-detail dd { margin: 2px 0 0; white-space: pre-wrap; }
