:root {
  --bg: #F3F5F1; --card: #FFFFFF; --ink: #1B2B22; --mute: #55655B; --line: #E1E6DF;
  --green: #17603A; --green-soft: #DDF0E3; --line-green: #06C755; --on-line-green: #0B2A17;
  --yellow: #F6C445; --yellow-soft: #FCEBC2; --yellow-ink: #7A4B00;
  --red: #A12A2A; --red-soft: #FADCDC; --blue-soft: #E8EEF7; --blue-ink: #1E3556;
  --field: #FFFFFF; --nav: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101612; --card: #19211C; --ink: #E8EEE9; --mute: #A5B2A9; --line: #2A3530;
    --green: #2E8A57; --green-soft: #1E3A2A; --yellow-soft: #3B311A; --yellow-ink: #F2CE7A;
    --red: #E27676; --red-soft: #3D1F1F; --blue-soft: #1E2A3D; --blue-ink: #BBD0EE;
    --field: #19211C; --nav: #151C17;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* ปิดแถบสีฟ้าตอนแตะของมือถือแล้ว จึงใช้การจางลงเล็กน้อยแทน ให้รู้ว่าแตะโดน */
a:active, button:not(:disabled):active, summary:active, label.choice:active { opacity: .7; }
[hidden] { display: none !important; }
.icon { display: inline-flex; flex: none; width: 20px; height: 20px; }
.icon svg { width: 100%; height: 100%; display: block; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Noto Sans Thai', system-ui, sans-serif; font-size: 15px; line-height: 1.5; }
main { max-width: 480px; margin: 0 auto; padding: 16px 16px 96px; }
h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
.sub { color: var(--mute); font-size: 13px; margin: 0 0 12px; }
.muted { color: var(--mute); font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: 14px; padding: 14px 16px; }
.card.flush { padding: 0; overflow: hidden; }
.divider { border-top: 1px dashed var(--line); margin: 10px 0; }

/* ปุ่ม: ใหญ่พอแตะง่าย */
button, .btn { font: inherit; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; }
button:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--line-green); border-color: var(--line-green); color: var(--on-line-green); font-weight: 700; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 18px; }
.btn-outline-green { border-color: var(--green); color: var(--green); }

input, select, textarea { font: inherit; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink); }
textarea { min-height: 84px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
:focus-visible { outline: 3px solid var(--line-green); outline-offset: 2px; }

/* ป้ายสถานะ: สีเหลือง = รออนุมัติ, เขียว = อนุมัติ, แดง = หักแต้ม (ตามบรีฟ) */
.chip { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.chip-pending { background: var(--yellow-soft); color: var(--yellow-ink); }
.chip-approved { background: var(--green-soft); color: var(--green); }
.chip-penalty, .chip-rejected { background: var(--red-soft); color: var(--red); }
.chip-info { background: var(--blue-soft); color: var(--blue-ink); }
.pts { font-size: 18px; font-weight: 700; white-space: nowrap; }
.pts-plus { color: var(--green); } .pts-minus { color: var(--red); } .pts-pending { color: var(--yellow-ink); }

/* การ์ดสมุดบัญชี */
.passbook { background: #17603A; color: #fff; border-radius: 16px; padding: 20px; }
.passbook .label { font-size: 12px; color: #CFE6D6; }
.passbook .balance { font-size: 44px; font-weight: 700; line-height: 1.1; }
.passbook .mini { flex: 1; background: rgba(255,255,255,.14); border-radius: 10px; padding: 8px 12px; }
.passbook .mini b { display: block; font-size: 16px; }

.list > * { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: 0; }

/* แถวเลือก (ฟอร์ม) */
.choice { display: flex; gap: 12px; align-items: center; min-height: 56px; padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); cursor: pointer; font-weight: 500; }
.choice:has(input:checked) { border: 2px solid var(--green); background: var(--green-soft); }
.choice input { width: 20px; min-height: 20px; flex: none; }
.notice { padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.notice-warn { background: var(--yellow-soft); color: var(--yellow-ink); }
.notice-info { background: var(--blue-soft); color: var(--blue-ink); }
.notice-ok { background: var(--green-soft); color: var(--green); }
.notice-err { background: var(--red-soft); color: var(--red); }

.qrbox { background: #fff; border-radius: 12px; padding: 12px; width: 240px; height: 240px; margin: 0 auto; }
.qrbox img { width: 100%; height: 100%; display: block; }
.big-code { font-size: 28px; font-weight: 700; letter-spacing: 3px; text-align: center; }
.center { text-align: center; }
.video { width: 100%; aspect-ratio: 4 / 3; background: #101612; border-radius: 14px; object-fit: cover; }

/* หน้าบันทึกความดี: ช่องค้นหาติดด้านบน + หมวดพับได้ */
.searchbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 10px; }
.searchbar .box { position: relative; }
.searchbar input { padding: 10px 48px 10px 42px; }
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar .icon { position: absolute; left: 12px; top: 14px; color: var(--mute); pointer-events: none; }
.searchbar button { position: absolute; right: 0; top: 0; min-height: 48px; width: 48px; padding: 0; border: 0; background: none; color: var(--mute); }
.searchbar button .icon { position: static; }

.group { background: var(--card); border-radius: 14px; overflow: hidden; scroll-margin-top: 72px; }
.group summary { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; cursor: pointer;
  font-weight: 600; list-style: none; }
.group summary::-webkit-details-marker { display: none; }
.group summary:focus-visible { outline-offset: -3px; }
.group-icon { display: flex; align-items: center; justify-content: center; flex: none; width: 38px; height: 38px;
  border-radius: 10px; background: var(--green-soft); color: var(--green); }
.group .chevron { color: var(--mute); transition: transform .15s; }
.group[open] .chevron { transform: rotate(180deg); }
.group[open] summary { border-bottom: 1px solid var(--line); }

.deeds { background: var(--card); border-radius: 14px; overflow: hidden; }
.deed { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px;
  border: 0; border-radius: 0; background: none; color: var(--ink); font-weight: 500; text-align: left; line-height: 1.45; }
.deed + .deed { border-top: 1px solid var(--line); }
.deed:focus-visible { outline-offset: -3px; }
.deed b { flex: none; color: var(--green); font-size: 14px; }

/* รูปหลักฐาน */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 84px; height: 84px; min-height: 0; padding: 0; overflow: hidden; border-radius: 10px; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-wrap { position: relative; width: 84px; height: 84px; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 10px; }
.thumb-wrap button { position: absolute; top: -6px; right: -6px; width: 32px; height: 32px; min-height: 0; padding: 6px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.65); color: #fff; }
.thumb-wrap button .icon { width: 100%; height: 100%; }
.evidence-full { width: 100%; max-height: 70vh; object-fit: contain; display: block; border-radius: 10px; }

/* แท็บ */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { min-height: 40px; border-radius: 20px; padding: 0 16px; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--green); border-color: var(--green); color: #fff; }

nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; background: var(--nav); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
nav.bottom .inner { display: flex; width: 100%; max-width: 480px; }
nav.bottom a { flex: 1 1 0; min-width: 0; padding: 7px 1px 6px; min-height: 58px; font-size: 11px; line-height: 1.3; font-weight: 600;
  white-space: nowrap; color: var(--mute); text-decoration: none; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; border-top: 3px solid transparent; }
nav.bottom a .icon { width: 24px; height: 24px; }
nav.bottom a[aria-current="page"] { color: var(--green); border-top-color: var(--green); }
nav.bottom a[aria-current="page"] svg { stroke-width: 2.4; }

.devbar { background: #1B2B22; color: #fff; font-size: 12px; padding: 6px 12px; display: flex; gap: 8px; align-items: center; }
.devbar select { min-height: 32px; padding: 2px 8px; width: auto; font-size: 12px; background: #fff; color: #1B2B22; }

dialog { border: 0; border-radius: 20px 20px 0 0; padding: 22px 20px 28px; width: 100%; max-width: 480px;
  max-height: 90vh; max-height: 90dvh; overflow-y: auto; margin: auto auto 0; background: var(--card); color: var(--ink); }
.icon-btn { flex: none; width: 48px; padding: 0; border: 0; background: none; color: var(--mute); }
dialog::backdrop { background: rgba(20, 30, 24, .5); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
