:root {
  --bg: #f4f5f9; --card: #fff; --ink: #141826; --muted: #6b7182; --line: #eceef3;
  --primary: #2f4ade; --primary-2: #4a63e6; --primary-soft: #e8ecfd;
  --sick: #12917c; --sick-soft: #ddf3ef; --biz: #e5600f; --biz-soft: #fdece1;
  --other: #9aa1b1; --warn: #b35a00; --warn-soft: #fff1e0; --ok: #12804f; --ok-soft: #e1f5ea;
  --bad: #c42b2b; --bad-soft: #fde7e7; --purple: #6b3fd4; --purple-soft: #efe8fc;
  --teal: #19707f; --teal-soft: #dff2f5;
  --radius: 22px; --shadow: 0 6px 24px rgba(20, 24, 38, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
#app { max-width: 520px; margin: 0 auto; padding: 18px 16px 120px; min-height: 100vh; }
.center { text-align: center; padding: 40px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1 { font-size: 30px; margin: 4px 0 2px; font-weight: 700; }
h2 { font-size: 22px; margin: 26px 0 14px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }

/* banners */
#mode-banner { background: var(--warn-soft); color: var(--warn); font-size: 13px; text-align: center; padding: 6px 12px; }
#toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: #141826; color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: 15px; z-index: 50; max-width: 90vw; box-shadow: var(--shadow); }
#toast.err { background: var(--bad); }

/* header */
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.avatar.sm { width: 46px; height: 46px; font-size: 16px; }
.top .who { flex: 1; min-width: 0; }
.top .who small { color: var(--muted); display: block; }
.top .who b { font-size: 22px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round { width: 52px; height: 52px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); display: grid; place-items: center; flex: none; }
.back { margin-bottom: 14px; }
.titlebar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.titlebar h1 { margin: 0; font-size: 26px; }

/* hero */
.hero { background: var(--primary); color: #fff; border-radius: 30px; padding: 24px 22px; margin-bottom: 18px; }
.hero .row { display: flex; justify-content: space-between; align-items: flex-start; }
.hero .label { opacity: .85; }
.hero .big { font-size: 64px; font-weight: 700; line-height: 1; margin: 8px 0 18px; }
.hero .big span { font-size: 26px; font-weight: 600; margin-left: 6px; }
.chip-btn { background: rgba(255,255,255,.15); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 15px; }
.hero .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.hero .tile { background: var(--primary-2); border-radius: 16px; padding: 10px 12px; }
.hero .tile small { opacity: .85; display: block; font-size: 14px; }
.hero .tile b { font-size: 20px; }
.btn-white { width: 100%; background: #fff; color: var(--ink); border-radius: 18px; padding: 15px; font-weight: 700; font-size: 18px; }
.btn { width: 100%; background: var(--primary); color: #fff; border-radius: 18px; padding: 16px; font-weight: 700; font-size: 18px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: var(--bad); }
.link { color: var(--primary); font-weight: 600; }

/* status pills */
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill.confirm, .pill.validate1, .pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.validate { background: var(--ok-soft); color: var(--ok); }
.pill.refuse { background: var(--bad-soft); color: var(--bad); }
.pill.cancelled, .pill.draft { background: #eef0f4; color: var(--muted); }

.latest .head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.latest .title { font-size: 20px; font-weight: 700; margin: 10px 0 2px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.steps i { height: 7px; border-radius: 9px; background: var(--line); display: block; }
.steps i.on { background: var(--primary); }
.steps i.wait { background: #f29a12; }
.steps i.bad { background: var(--bad); }
.steps-label { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 13px; color: var(--muted); margin-top: 6px; }

/* menu grid */
.menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 10px; text-align: center; }
.menu button { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 16px; }
.menu .ic { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; }
.ic svg { width: 30px; height: 30px; }
.c-blue { background: var(--primary-soft); color: var(--primary); }
.c-purple { background: var(--purple-soft); color: var(--purple); }
.c-teal { background: var(--teal-soft); color: var(--teal); }
.c-red { background: var(--bad-soft); color: var(--bad); }
.c-orange { background: var(--warn-soft); color: var(--warn); }
.c-green { background: var(--ok-soft); color: var(--ok); }

/* bottom nav */
nav.bottom { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  width: min(500px, calc(100% - 24px)); background: #fff; border-radius: 28px; box-shadow: 0 8px 30px rgba(20,24,38,.12);
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 10px 6px 8px; z-index: 20; }
nav.bottom button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
nav.bottom svg { width: 26px; height: 26px; }
nav.bottom button.on { color: var(--primary); font-weight: 700; }
nav.bottom button.on svg { background: var(--primary-soft); border-radius: 12px; padding: 3px 10px; width: 46px; height: 32px; }
nav.bottom .fab { margin-top: -34px; }
nav.bottom .fab span { width: 62px; height: 62px; border-radius: 50%; background: var(--primary); color: #fff; display: grid;
  place-items: center; box-shadow: 0 0 0 6px #fff, 0 10px 24px rgba(47,74,222,.35); }
nav.bottom .fab span svg { width: 30px; height: 30px; }
nav.bottom .fab { color: var(--ink); font-weight: 700; }

/* form */
.label { font-weight: 700; font-size: 18px; margin: 22px 0 10px; }
.label small { font-weight: 400; color: var(--muted); }
.list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.opt { display: flex; align-items: center; gap: 14px; padding: 18px 20px; width: 100%; text-align: left; border-top: 1px solid var(--line); }
.opt:first-child { border-top: 0; }
.opt.sel { background: var(--primary-soft); }
.opt .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.opt .name { flex: 1; font-size: 18px; font-weight: 600; }
.opt .meta { color: var(--muted); font-size: 15px; }
.radio { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #c9ccd6; flex: none; }
.opt.sel .radio { border: 7px solid var(--primary); background: #fff; }
.sub-opts { padding: 0 20px 12px 46px; background: var(--primary-soft); display: flex; flex-wrap: wrap; gap: 8px; }
.sub-opts button { background: #fff; padding: 6px 14px; border-radius: 999px; font-size: 15px; box-shadow: inset 0 0 0 1.5px var(--line); }
.sub-opts button.on { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); font-weight: 600; }
.datepick { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--line); position: relative; }
.datepick:first-child { border-top: 0; }
.datepick .ic { width: 46px; height: 46px; border-radius: 14px; background: var(--bg); display: grid; place-items: center; }
.datepick .ic svg { width: 24px; height: 24px; }
.datepick small { color: var(--muted); display: block; font-size: 14px; }
.datepick b { font-size: 19px; }
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.datepick .chev { margin-left: auto; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: #e9ebf1; border-radius: 18px; padding: 5px; margin-top: 12px; }
.seg button { padding: 11px; border-radius: 14px; color: var(--muted); font-size: 16px; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.seg button[disabled] { opacity: .4; }
textarea, input.text { width: 100%; border: 0; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-height: 110px; resize: vertical; font-size: 17px; outline: none; }
input.text { min-height: 0; }
textarea:focus, input.text:focus { box-shadow: 0 0 0 2px var(--primary); }
.note { font-size: 14px; color: var(--muted); margin-top: 10px; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 16px; padding: 12px 14px; font-size: 14px; margin-top: 12px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 26px 26px 0 0; box-shadow: 0 -6px 24px rgba(20,24,38,.08);
  padding: 16px 16px max(16px, env(safe-area-inset-bottom)); z-index: 25; }
.sheet .inner { max-width: 488px; margin: 0 auto; }
.sheet .sum { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 12px; }
.sheet .sum b { color: var(--ink); }
.with-sheet { padding-bottom: 180px !important; }

/* filters */
.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.tabs button { padding: 9px 16px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); white-space: nowrap; font-size: 15px; }
.tabs button.on { background: var(--ink); color: #fff; }

/* leave list */
.lv { display: flex; gap: 14px; align-items: flex-start; }
.badge-days { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 17px; }
.lv .body { flex: 1; min-width: 0; }
.lv .t { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.lv .t b { font-size: 18px; }
.lv .d { color: var(--muted); font-size: 15px; }
.lv .m { font-size: 14px; color: var(--muted); margin-top: 6px; }
.lv .m.bad { color: var(--bad); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.actions button { padding: 11px; border-radius: 14px; font-weight: 600; font-size: 15px; }
.actions .a1 { background: var(--bad-soft); color: var(--bad); }
.actions .a2 { background: var(--primary-soft); color: var(--primary); }

/* calendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-head b { font-size: 20px; }
.cal-head .nav { display: flex; gap: 8px; align-items: center; }
.cal-head .nav button { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); }
.cal-head .today-btn { width: auto !important; padding: 0 14px; border-radius: 999px !important; color: var(--primary); font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 4px 0; }
.cal .dow { color: var(--muted); font-size: 14px; padding-bottom: 6px; }
.cal .day { position: relative; height: 44px; display: grid; place-items: center; font-size: 16px; border-radius: 12px; }
.cal .day.out { color: #c3c7d1; }
.cal .day.weekend { color: var(--muted); }
.cal .day.hol { color: var(--bad); font-weight: 600; }
.cal .day.mine { background: var(--primary); color: #fff; font-weight: 700; }
.cal .day.mine.pend { background: var(--primary-soft); color: var(--primary); }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal .day .dots { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: center; gap: 3px; }
.cal .day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--biz); }
.cal .day .dots i.ev { background: var(--teal); }
.legend { display: flex; gap: 16px; font-size: 14px; color: var(--muted); margin-top: 14px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.ev-row { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.ev-row:first-of-type { border-top: 0; }
.date-box { width: 60px; text-align: center; border-radius: 14px; background: var(--bad-soft); color: var(--bad); padding: 8px 0; flex: none; line-height: 1.15; }
.date-box b { font-size: 20px; display: block; }
.date-box.teal { background: var(--teal-soft); color: var(--teal); }
.date-box.blue { background: var(--primary-soft); color: var(--primary); }
.date-box.orange { background: var(--biz-soft); color: var(--biz); }

/* cancel */
.pick { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.pick:first-child { border-top: 0; }
.pick.sel { background: var(--primary-soft); }
.pick.sel .radio { border: 7px solid var(--primary); background: #fff; }
.pick .body { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { padding: 10px 16px; background: #fff; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); font-size: 15px; }
.chips button.on { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.two { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

/* news */
.news-pin { background: var(--primary); color: #fff; }
.news-pin .muted { color: rgba(255,255,255,.8); }
.news-item { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.news-item:first-child { border-top: 0; }
.news-item .tag { font-size: 13px; font-weight: 600; }

/* dashboard */
.ring-row { display: flex; align-items: center; gap: 22px; }
.ring { position: relative; flex: none; }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .val b { font-size: 40px; display: block; }
.ring.sm .val b { font-size: 22px; }
.stat small { color: var(--muted); display: block; }
.stat b { font-size: 28px; display: block; margin-bottom: 8px; }
.stat b.warn { color: var(--warn); }
.rings3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.rings3 .card { text-align: center; padding: 16px 8px; margin: 0; }
.rings3 .card b { display: block; font-size: 17px; margin-top: 8px; }
.rings3 .card small { color: var(--muted); }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 150px; margin-top: 18px; }
.bars .bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bars .bar i { width: 100%; max-width: 30px; border-radius: 8px; background: #a9b6f5; min-height: 6px; display: block; }
.bars .bar i.zero { background: var(--line); }
.bars .bar i.cur { background: var(--primary); }
.bars .bar span { font-size: 13px; font-weight: 700; margin-bottom: 4px; min-height: 18px; }
.bar-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; text-align: center; font-size: 11px; color: var(--muted); margin-top: 6px; }
.person { display: flex; gap: 14px; align-items: center; padding: 10px 0; }
.spread { display: flex; justify-content: space-between; align-items: baseline; }

/* login */
.login { padding-top: 10vh; }
.login .logo { width: 72px; height: 72px; border-radius: 22px; background: var(--primary); color: #fff; display: grid; place-items: center; margin-bottom: 18px; }
.login .logo svg { width: 36px; height: 36px; }
.login input { margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 380px) {
  .hero .big { font-size: 52px; }
  .menu .ic { width: 66px; height: 66px; }
  h1 { font-size: 26px; }
}
