:root {
  --navy: #0E2A5C; --navy-2: #081C40; --blue: #1E4FA8; --gold: #C9A23A; --gold-2: #E2C46A; --gold-3: #F3E3B0;
  --ground: #F4F6FA; --card: #FFFFFF; --ink: #0F1B33; --muted: #5B6478; --line: #E3E8F2; --soft: #EEF3FC;
  --warn-bg: #FFF4D6; --warn: #6B5214; --bad-bg: #FDECEA; --bad: #B42318; --ok-bg: #E6F0FF;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--navy); }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; color: var(--ink); font-size: 15px; }
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--ground); position: relative; }
h1, h2, h3, .prompt { font-family: 'Prompt', 'IBM Plex Sans Thai', sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

/* splash / logo */
.splash { min-height: 100dvh; display: grid; place-items: center; background: var(--navy); }
.logo-lg { width: 150px; height: 75px; background: url(icons/logo-gold.svg) no-repeat center / contain; }
.logo-sm { width: 60px; height: 30px; background: url(icons/logo-gold.svg) no-repeat center / contain; flex: none; }

/* login / register */
.auth { min-height: 100dvh; background: var(--navy); color: #fff; padding: calc(80px + var(--safe-t)) 28px 32px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth::before, .auth::after { content: ''; position: absolute; border-radius: 50%; border: 1px solid rgba(226,196,106,.22); pointer-events: none; }
.auth::before { width: 360px; height: 360px; top: -120px; right: -140px; }
.auth::after { width: 240px; height: 240px; top: -60px; right: -80px; }
.auth h1 { margin: 28px 0 0; font-size: 30px; font-weight: 600; }
.auth p.lead { margin: 10px 0 0; color: #C9D4EA; line-height: 1.6; }
.auth .gbtn { margin-top: 44px; min-height: 56px; display: flex; justify-content: center; }
.auth .note { margin-top: 24px; display: flex; gap: 12px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.07); font-size: 13px; line-height: 1.6; color: #DCE3F1; }
.auth .foot { margin-top: auto; padding-top: 24px; text-align: center; font-size: 12px; color: #A9B6D3; }
.auth .foot a, .auth a { color: var(--gold-2); }
.auth label { display: block; margin: 16px 0 6px; font-size: 13px; color: #C9D4EA; }
.auth input[type=text], .auth input[type=tel] { width: 100%; height: 50px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; padding: 0 14px; }
.auth input::placeholder { color: #8FA0C4; }
.auth .check { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 13px; line-height: 1.6; color: #DCE3F1; }
.auth .check input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; margin-top: 1px; }

/* buttons */
.btn { min-height: 52px; border-radius: 16px; border: 0; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 16px; text-decoration: none; }
.btn-block { width: 100%; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-white { background: #fff; color: var(--navy); }
.btn-outline-gold { background: transparent; color: var(--gold-2); border: 1.5px solid var(--gold); }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--navy); min-height: 38px; border-radius: 19px; font-size: 13px; padding: 0 14px; }
.btn-sm { min-height: 38px; border-radius: 19px; font-size: 13px; padding: 0 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255,255,255,.10); color: #fff; display: grid; place-items: center; position: relative; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 5px; background: var(--gold-2); border: 2px solid var(--navy); }

/* headers */
.hdr { background: var(--navy); color: #fff; padding: calc(18px + var(--safe-t)) 16px 18px; }
.hdr.tall { padding-bottom: 72px; }
.hdr .row { display: flex; align-items: center; gap: 10px; }
.hdr .brand { font-family: 'Prompt', sans-serif; font-weight: 600; font-size: 16px; }
.hdr h1 { margin: 0; font-size: 22px; font-weight: 600; }
.hdr .sub { font-size: 13px; color: var(--gold-2); margin-top: 2px; }
.hdr .hello { margin: 22px 0 2px; font-size: 14px; color: #C9D4EA; }
.company-chip { margin-top: 14px; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid rgba(226,196,106,.6); background: rgba(226,196,106,.12); color: var(--gold-3); font-size: 14px; font-weight: 500; max-width: 100%; }
.company-chip b { color: var(--gold-2); }
.company-chip span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,.10); }
.seg button { min-height: 40px; border-radius: 10px; border: 0; background: transparent; color: #DCE3F1; font-weight: 500; font-size: 14px; }
.seg button.on { background: var(--gold); color: var(--navy); font-weight: 700; }

/* content */
.content { padding: 16px 16px calc(110px + var(--safe-b)); }
.card { background: var(--card); border-radius: 18px; padding: 16px; }
.card.lift { margin: -48px 16px 0; box-shadow: 0 8px 24px rgba(14,42,92,.10); }
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.bar { margin-top: 10px; height: 8px; border-radius: 4px; background: #E8ECF4; overflow: hidden; }
.bar > i { display: block; height: 8px; background: var(--gold); border-radius: 4px; }
.types { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.type { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.type.done { background: var(--soft); }
.type.todo { background: #FFFBEF; border: 1px dashed var(--gold); color: var(--warn); }
.type .tick { width: 20px; height: 20px; border-radius: 10px; flex: none; display: grid; place-items: center; }
.type.done .tick { background: var(--navy); color: #fff; }
.type.todo .tick { border: 2px solid var(--gold); }
.cta { margin: 16px 16px 0; min-height: 64px; border-radius: 18px; background: var(--gold); color: var(--navy); display: flex; align-items: center; justify-content: center; gap: 10px; font-family: 'Prompt', sans-serif; font-size: 18px; font-weight: 600; border: 0; width: calc(100% - 32px); }
.sec-title { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; }
.sec-title h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sec-title button { border: 0; background: none; color: var(--navy); font-weight: 600; font-size: 13px; }
.group-label { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.list { background: #fff; border-radius: 16px; padding: 2px 14px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #EEF1F6; }
.item:last-child { border-bottom: 0; }
.item .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--soft); color: var(--navy); display: grid; place-items: center; flex: none; }
.item .ic.dark { background: var(--navy); color: var(--gold-2); }
.item .tx { flex: 1; min-width: 0; }
.item .t1 { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.item .t2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item.col { flex-direction: column; align-items: stretch; gap: 8px; }
.item.col .rowx { display: flex; align-items: center; gap: 12px; }
.timer { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--warn); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 14px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.pill.wait { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--navy); }
.pill.mute { background: #EEF1F6; color: #3D4659; }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.filters select { height: 38px; border-radius: 19px; border: 1px solid #D5DCEA; background: #fff; padding: 0 12px; font-size: 13px; font-weight: 600; }
.hint { margin-top: 12px; font-size: 12px; line-height: 1.6; color: var(--muted); }

/* scan */
.step { margin-top: 18px; }
.step h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid #D5DCEA; background: #fff; font-size: 14px; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.field { width: 100%; height: 48px; border-radius: 12px; border: 1px solid #D5DCEA; background: #fff; padding: 0 14px; font-size: 15px; font-weight: 600; }
.pages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .n { position: absolute; left: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 11px; background: var(--navy); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.thumb .acts { position: absolute; right: 4px; top: 4px; display: flex; flex-direction: column; gap: 4px; }
.thumb .acts button { width: 32px; height: 32px; border-radius: 16px; border: 0; background: rgba(8,28,64,.75); color: #fff; display: grid; place-items: center; }
.thumb.pdf { display: grid; place-items: center; text-align: center; padding: 8px; font-size: 12px; color: var(--navy); background: var(--soft); }
.add { aspect-ratio: 3 / 4; border-radius: 12px; border: 1.5px dashed var(--gold); background: #FFFBEF; color: var(--warn); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 14px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.toggle label { font-size: 14px; font-weight: 600; }
.toggle input { width: 22px; height: 22px; accent-color: var(--navy); flex: none; }
.sendbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; padding: 12px 16px calc(16px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); z-index: 20; }
.sendbar .fname { font-size: 12px; color: var(--muted); margin-bottom: 8px; overflow-wrap: anywhere; }
.sendbar .fname b { color: var(--ink); }

/* bottom nav */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; height: calc(76px + var(--safe-b)); padding: 8px 0 var(--safe-b); background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: flex-start; z-index: 20; }
.nav button { width: 64px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #6B7489; font-size: 11px; font-weight: 500; position: relative; padding: 2px 0; }
.nav button.on { color: var(--navy); font-weight: 700; }
.nav button .badge { position: absolute; top: -2px; right: 12px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--gold); color: var(--navy); font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.nav .fab { margin-top: -30px; width: 64px; height: 64px; border-radius: 32px; background: var(--gold); color: var(--navy); border: 4px solid #fff; box-shadow: 0 6px 16px rgba(201,162,58,.45); display: grid; place-items: center; padding: 0; }

/* sheet / viewer / toast */
.overlay { position: fixed; inset: 0; background: rgba(8,28,64,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; max-height: 80dvh; background: #fff; border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; }
.sheet h2 { margin: 0 0 12px; font-size: 17px; }
.sheet .search { width: 100%; height: 46px; border-radius: 12px; border: 1px solid #D5DCEA; padding: 0 14px; margin-bottom: 8px; }
.sheet .scroll { overflow-y: auto; }
.sheet .opt { width: 100%; text-align: left; border: 0; background: none; padding: 12px 4px; border-bottom: 1px solid #EEF1F6; display: flex; gap: 10px; font-size: 14px; }
.sheet .opt b { color: var(--navy); min-width: 36px; }
.sheet .opt.on { background: var(--soft); border-radius: 10px; }
.viewer { position: fixed; inset: 0; z-index: 60; background: #0B1220; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }
.viewer .vbar { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; background: var(--navy); color: #fff; }
.viewer .vbar .nm { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer iframe, .viewer .imgwrap { flex: 1; border: 0; width: 100%; background: #fff; }
.viewer .imgwrap { overflow: auto; }
.viewer .imgwrap img { width: 100%; display: block; }
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); max-width: 420px; width: calc(100% - 32px); background: var(--navy-2); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 14px; line-height: 1.5; opacity: 0; pointer-events: none; transition: .25s; z-index: 80; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); }
.busy { position: fixed; inset: 0; z-index: 70; background: rgba(8,28,64,.55); display: grid; place-items: center; color: #fff; text-align: center; font-size: 15px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: var(--gold-2); animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 12px; padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--line); margin-bottom: 10px; text-align: left; width: 100%; }
.notice.unread { border: 1.5px solid var(--gold); }
.notice .tx { flex: 1; min-width: 0; }
.notice .t1 { font-weight: 600; font-size: 14px; }
.notice .t2 { font-size: 13px; color: #3D4659; margin-top: 2px; overflow-wrap: anywhere; }
.notice .t3 { font-size: 12px; color: var(--muted); margin-top: 4px; }
.profile-card { display: flex; gap: 14px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 28px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-family: 'Prompt', sans-serif; font-weight: 700; font-size: 22px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.steps { margin: 8px 0 0; padding-left: 20px; line-height: 1.8; font-size: 14px; }
