:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #637083;
  --line: #dde3ea;
  --brand: #1f4e78;
  --brand-2: #2f6fa8;
  --brand-soft: #e6eef7;
  --ok: #1e7b46;
  --ok-soft: #e3f4ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --radius: 14px;
  --bar: #1f4e78; --primary: #1f4e78; --hero-a: #1f4e78; --hero-b: #2f6fa8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161d; --card: #1a212b; --text: #e7ecf2; --muted: #9aa7b8; --line: #2c3644;
    --brand: #6fa8dc; --brand-2: #8dbbe6; --brand-soft: #1d2d40;
    --ok: #5cc98a; --ok-soft: #173327; --bad: #f28b82; --bad-soft: #3a1c1a;
    --warn: #f2c14e; --warn-soft: #3a3014; --shadow: none;
    --bar: #16273a; --primary: #2f6fa8; --hero-a: #1b3756; --hero-b: #275a8a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #11161d; --card: #1a212b; --text: #e7ecf2; --muted: #9aa7b8; --line: #2c3644;
    --brand: #6fa8dc; --brand-2: #8dbbe6; --brand-soft: #1d2d40;
    --ok: #5cc98a; --ok-soft: #173327; --bad: #f28b82; --bad-soft: #3a1c1a;
    --warn: #f2c14e; --warn-soft: #3a3014; --shadow: none;
    --bar: #16273a; --primary: #2f6fa8; --hero-a: #1b3756; --hero-b: #275a8a; color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Noto Sans Khmer", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
button { font: inherit; color: inherit; }

.head { position: sticky; top: 0; z-index: 10; }
.head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; opacity: 0; transition: opacity .2s; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--brand-2), transparent) no-repeat; background-size: 50% 100%;
}
.head.busy::after { opacity: 1; animation: busy-slide 1.1s linear infinite; }
@keyframes busy-slide { from { background-position: -100% 0; } to { background-position: 200% 0; } }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--bar); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; line-height: 1.15; }
.brand small { color: rgba(255,255,255,.75); }
.logo { font-size: 26px; }
.top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.theme-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.theme-btn:focus-visible, .btn:focus-visible, .tab:focus-visible, .type-btn:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.who { min-width: 0; text-align: right; font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.who button { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 8px; padding: 3px 8px; margin-top: 3px; font-size: 12px; cursor: pointer; }
.navbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--card);
  border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(16, 24, 40, .05);
}
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--brand-soft); color: var(--brand);
  border-radius: 999px; padding: 4px 14px 4px 8px; min-height: 40px; font-size: 14px; font-weight: 700; cursor: pointer; line-height: 1.1; text-align: left;
}
.nav-btn.fwd { padding: 4px 8px 4px 14px; text-align: right; }
.nav-btn small { font-size: 10px; color: inherit; opacity: .75; }
.nav-btn svg { flex: none; }
.nav-btn:disabled { opacity: .35; cursor: default; }
.nav-btn:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.nav-title { flex: 1; min-width: 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: 13px; padding: 6px 16px; font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h2 small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label .req { color: var(--bad); }
.label small { display: inline; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

select, input[type=text], input[type=number], input[type=search], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 80px; resize: vertical; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.invalid { border-color: var(--bad) !important; }
.big-input { font-size: 22px; font-weight: 600; letter-spacing: .5px; }

.types { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.type-btn {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px; min-height: 64px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; font-size: 14px; font-weight: 600;
}
.type-btn .emo { font-size: 26px; }
.type-btn.on { border-color: var(--brand-2); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-2) inset; }

.photo-slot {
  display: flex; align-items: center; gap: 12px; padding: 10px; border: 1.5px dashed var(--line); width: 100%; text-align: left;
  border-radius: 12px; cursor: pointer; min-height: 72px; background: var(--bg);
}
.photo-slot .ps-text { flex: 1; min-width: 0; }
.photo-slot .ps-add { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.photo-slot:focus-visible, .picker:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.photo-slot .thumb { width: 64px; height: 64px; border-radius: 8px; background: var(--brand-soft) center/cover no-repeat; display: grid; place-items: center; font-size: 26px; flex: none; }
.photo-slot.has { border-style: solid; border-color: var(--ok); }
.photo-slot .txt { font-size: 14px; font-weight: 600; }

.gps { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.gps .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.gps.ok .dot { background: var(--ok); }
.gps.err .dot { background: var(--bad); }
.gps button { margin-left: auto; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 8px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  padding: 12px 18px; min-height: 48px; font-weight: 700; cursor: pointer; background: var(--brand-soft); color: var(--brand);
}
.btn.primary { background: var(--primary); color: #fff; width: 100%; font-size: 17px; min-height: 54px; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--line); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: wait; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.list-item { display: block; }
.li-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.li-title { font-weight: 700; }
.li-meta { font-size: 13px; color: var(--muted); }
.li-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; font-size: 14px; }
.li-grid div small { font-size: 11px; }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--bg); cursor: zoom-in; }
.photos figcaption { font-size: 11px; color: var(--muted); text-align: center; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.center { text-align: center; }
.success { text-align: center; padding: 30px 16px; }
.success .big { font-size: 56px; }
.idtag { font-family: ui-monospace, Menlo, monospace; font-size: 18px; font-weight: 700; background: var(--brand-soft); color: var(--brand); padding: 6px 12px; border-radius: 8px; display: inline-block; margin: 8px 0 18px; }

.login { text-align: center; padding-top: 40px; }
.login .big { font-size: 64px; }
#gsiButton { display: flex; justify-content: center; margin: 24px 0; min-height: 44px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; border: 0; background: none; padding: 8px 4px 6px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); line-height: 1.2; }
.tab span { display: block; font-size: 20px; }
.tab small { font-size: 10px; }
.tab.on { color: var(--brand); }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1b2430; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 40; display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand-2); border-radius: 50%; animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Searchable picker (plate, equipment, driver) */
.picker {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 48px; font-weight: 600;
}
.picker .ph { color: var(--muted); font-weight: 400; }
.picker .pk-ic { font-size: 15px; opacity: .7; flex: none; }

/* Bottom sheets */
.sheet-bg { position: fixed; inset: 0; z-index: 35; background: rgba(10, 15, 22, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.sheet-bg.open { background: rgba(10, 15, 22, .5); }
.sheet {
  width: 100%; max-width: 640px; background: var(--card); color: var(--text); border-radius: 22px 22px 0 0;
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease-out;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .18);
}
.sheet-bg.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 8px; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sheet-h { font-weight: 700; font-size: 17px; }
.icon-btn { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg); color: var(--text); font-size: 16px; cursor: pointer; display: grid; place-items: center; }
.icon-btn.round { width: 42px; height: 42px; font-size: 20px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.sheet-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 0; cursor: pointer;
  background: var(--bg); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; font-weight: 700; min-height: 60px;
}
.sheet-btn input { display: none; }
.sheet-btn .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--brand-soft); flex: none; }
.sheet-btn.danger { color: var(--bad); }
.sheet-btn.danger .ic { background: var(--bad-soft); }
.picker-sheet { height: min(85vh, 640px); display: flex; flex-direction: column; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; flex: none; }
.search:focus-within { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.search input[type=search] { border: 0; background: transparent; padding: 10px 0; min-height: 46px; box-shadow: none; }
.search input[type=search]:focus { box-shadow: none; }
.pick-list { flex: 1; overflow-y: auto; margin: 10px -16px 0; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.pick-group { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 10px 4px 4px; }
.pick-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 4px; min-height: 52px;
}
.pick-item b { font-weight: 600; }
.pick-item.on { color: var(--brand); }
.pick-item.on b { font-weight: 700; }
.pick-item .tick { font-weight: 700; color: var(--brand); }

/* Reviewer list */
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rv-head h2 { margin: 0; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.seg-btn { border: 0; background: none; border-radius: 12px; padding: 8px 4px; cursor: pointer; line-height: 1.15; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg-btn small { font-size: 10px; }
.seg-n { display: block; font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.seg-btn.on { background: var(--brand-soft); color: var(--brand); }
.seg-btn.on .seg-n, .seg-btn.on small { color: var(--brand); }
.seg-btn.f-pending .seg-n { color: var(--warn); }
.seg-btn:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 1px; }

.rv-year { margin-bottom: 8px; }
.yr-h, .mo-h { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
.yr-h { font-size: 22px; font-weight: 800; padding: 6px 2px 10px; letter-spacing: -.3px; }
.yr-h > span:first-child, .mo-name { flex: 1; }
.mo-h { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-weight: 700; box-shadow: var(--shadow); }
.mo-name small { display: inline; margin-left: 8px; }
.rv-month { margin-bottom: 10px; }
.rv-month.open > .mo-h { border-color: var(--brand-2); }
.chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin: 0 4px; }
.open > button > .chev { transform: rotate(45deg); }
.grp-body { display: none; }
.open > .grp-body { display: block; }
.rv-month > .grp-body { padding: 4px 2px 0; }
.cnt { font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.day-h { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 6px 6px; letter-spacing: .2px; }
.day-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.rv-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; cursor: pointer; min-height: 62px; }
.rv-row:last-child { border-bottom: 0; }
.rv-row:hover, .rv-row:focus-visible { background: var(--bg); outline: none; }
.rv-ic { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; font-size: 22px; flex: none; }
.rv-main { flex: 1; min-width: 0; line-height: 1.3; }
.rv-main b, .rv-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-main b { font-size: 15px; }
.rv-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.rv-right b { font-size: 16px; font-variant-numeric: tabular-nums; }
.rv-right i { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 600; }
.pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.empty .big { font-size: 44px; }

/* Reviewer detail */
.dt-hero { border-radius: 22px; padding: 18px; color: #fff; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); box-shadow: 0 8px 24px rgba(31, 78, 120, .25); }
.dt-top { display: flex; align-items: center; gap: 12px; }
.dt-ic { width: 48px; height: 48px; border-radius: 14px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; font-size: 26px; flex: none; }
.dt-title { flex: 1; min-width: 0; line-height: 1.25; }
.dt-title b { font-size: 21px; display: block; }
.dt-title small { color: rgba(255, 255, 255, .8); font-size: 13px; }
.dt-hero .pill { background: rgba(255, 255, 255, .94); }
.dt-hero .pill.pending { color: #8a5a00; }
.dt-hero .pill.ok { color: #1e7b46; }
.dt-hero .pill.bad { color: #b3261e; }
.dt-big { font-size: 44px; font-weight: 800; letter-spacing: -1px; margin-top: 14px; line-height: 1; font-variant-numeric: tabular-nums; }
.dt-big span { font-size: 14px; font-weight: 600; letter-spacing: 0; margin-left: 8px; opacity: .85; }
.dt-sub { font-size: 13px; opacity: .85; margin-top: 8px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95em; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-width: 0; box-shadow: var(--shadow); }
.tile.wide { grid-column: 1 / -1; }
.tile > small { font-size: 11px; font-weight: 600; margin-bottom: 3px; }
.tile > div { font-weight: 700; overflow-wrap: anywhere; }
.tile > div small { font-weight: 400; margin-top: 2px; }
.sec-h { font-weight: 700; margin: 4px 2px 8px; display: flex; align-items: baseline; gap: 8px; }
.sec-h small { display: inline; }
.gallery { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; margin-bottom: 8px; }
.gallery figure { margin: 0; flex: 0 0 72%; max-width: 300px; scroll-snap-align: start; }
.gallery .ph-box { aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; }
.gallery img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.gallery .noimg { font-size: 13px; color: var(--muted); text-align: center; padding: 8px; }
.gallery figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.gallery .spinner { margin: 0; }
.card.reason { margin-top: 10px; }
.decide {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: sticky; bottom: calc(66px + env(safe-area-inset-bottom));
  padding: 10px; margin: 8px -6px 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 24px rgba(16, 24, 40, .14);
}
.decide .btn { flex-direction: column; gap: 0; padding: 8px 4px; line-height: 1.25; border-radius: 12px; }
.decide .btn small { color: inherit; opacity: .85; font-size: 11px; }

/* Entries still sending */
.badge.sending { background: var(--brand-soft); color: var(--brand); }
.ob-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.ob-note .btn { flex: none; }
.send-state { display: flex; align-items: center; justify-content: center; gap: 10px; text-align: left; margin: 8px 0 18px; font-weight: 600; }
.spinner.sm { width: 20px; height: 20px; border-width: 2.5px; margin: 0; flex: none; }
