:root {
  --brand: #0B5CAD; --brand-2: #0A4B8C; --brand-soft: #E7F0FA;
  --bg: #F4F6FA; --card: #FFFFFF; --text: #14202E; --muted: #5B6B7D; --line: #E3E8EF;
  --ok: #16A34A; --ok-bg: #E8F7EE; --warn: #B45309; --warn-bg: #FEF3E2; --bad: #DC2626; --bad-bg: #FDECEC;
  --info: #2563EB; --info-bg: #E8EFFD; --extra: #7C3AED; --extra-bg: #F1EBFE; --off: #94A3B8;
  --radius: 16px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.05);
  --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4C9BEA; --brand-2: #7BB5F0; --brand-soft: #16273B;
    --bg: #0E141B; --card: #17202B; --text: #E7EDF4; --muted: #97A6B6; --line: #26323F;
    --ok: #4ADE80; --ok-bg: #12301F; --warn: #FBBF24; --warn-bg: #33270F; --bad: #F87171; --bad-bg: #3A1717;
    --info: #60A5FA; --info-bg: #15263F; --extra: #A78BFA; --extra-bg: #2A1F45; --off: #64748B;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
.splash { min-height: 100vh; display: grid; place-items: center; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- man hinh cai dat / dang nhap ---------- */
.gate { min-height: 100vh; display: flex; flex-direction: column; padding: calc(28px + var(--safe-t)) 20px calc(24px + var(--safe-b)); max-width: 480px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; }
.brand b { display: block; font-size: 19px; }
.brand span { color: var(--muted); font-size: 13px; }
.gate h1 { font-size: 22px; line-height: 1.25; margin: 6px 0 8px; }
.gate p.lead { color: var(--muted); margin: 0 0 18px; }
.steps { list-style: none; padding: 0; margin: 0 0 18px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--card); border-radius: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.ico-inline { display: inline-grid; place-items: center; vertical-align: -5px; width: 24px; height: 24px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); }
.ico-inline svg { width: 16px; height: 16px; }
.note { font-size: 13px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); padding: 10px 12px; border-radius: 12px; }
.note.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.pointer { position: fixed; bottom: calc(10px + var(--safe-b)); left: 50%; transform: translateX(-50%); font-size: 30px; color: var(--brand); animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, 8px); } }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); margin-bottom: 18px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--brand); color: #fff; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; height: 50px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); padding: 0 14px; font-size: 17px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--brand); }
.field small { display: block; color: var(--muted); margin-top: 6px; font-size: 12.5px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border: 0; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.btn:disabled { opacity: .6; }
.btn.ghost { background: var(--card); color: var(--brand); border: 1.5px solid var(--line); }
.btn + .btn { margin-top: 10px; }
.err { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; }
.err:empty { display: none; }
.help { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ---------- khung app ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + var(--safe-t)) 0 8px; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.top h2 { margin: 0; font-size: 22px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; border: 0; }
main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 20px); }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
nav.tabs .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav-h); }
nav.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
nav.tabs svg { width: 24px; height: 24px; }
nav.tabs button[aria-current="page"] { color: var(--brand); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 small { font-weight: 500; color: var(--muted); font-size: 12.5px; }
/* mau co dinh ca 2 che do: chu trang tren xanh dam (tuong phan > 4.5:1) */
.hello { background: linear-gradient(135deg, #0B5CAD, #0A4B8C); color: #fff; }
.hello .hi { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.hello .sub { opacity: .9; font-size: 13.5px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--bg); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.ok b { color: var(--ok); } .stat.warn b { color: var(--warn); } .stat.bad b { color: var(--bad); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.money { font-size: 28px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.eye { border: 0; background: var(--brand-soft); color: var(--brand); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.eye svg { width: 22px; height: 22px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.s-ok { color: var(--ok); background: var(--ok-bg); } .s-late { color: var(--warn); background: var(--warn-bg); }
.s-missing, .s-absent { color: var(--bad); background: var(--bad-bg); } .s-leave, .s-working, .s-pending { color: var(--info); background: var(--info-bg); }
.s-extra { color: var(--extra); background: var(--extra-bg); } .s-off, .s-future { color: var(--muted); background: var(--bg); }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.times div { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.times b { font-size: 20px; font-variant-numeric: tabular-nums; display: block; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty svg { width: 44px; height: 44px; opacity: .5; display: block; margin: 0 auto 8px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin: 6px 0 14px; }

/* ---------- lich cham cong ---------- */
.monthbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.monthbar b { font-size: 17px; }
.nav-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; }
.nav-btn:disabled { opacity: .35; }
.nav-btn svg { width: 20px; height: 20px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.cal button { aspect-ratio: 1 / 1.12; border: 0; border-radius: 11px; background: var(--bg); padding: 4px 0 0; display: flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; position: relative; }
.cal button i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.cal button small { font-size: 9.5px; font-weight: 500; color: var(--muted); line-height: 1; }
.cal button.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal button.blank { visibility: hidden; }
.d-ok i { background: var(--ok); } .d-late i { background: var(--warn); } .d-missing i, .d-absent i { background: var(--bad); }
.d-leave i, .d-working i, .d-pending i { background: var(--info); } .d-extra i { background: var(--extra); }
.d-off { opacity: .55; } .d-future { opacity: .7; } .d-off i, .d-future i { background: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.list .item:last-child { border-bottom: 0; }
.list .date { width: 46px; flex: none; text-align: center; }
.list .date b { display: block; font-size: 18px; line-height: 1.1; }
.list .date span { font-size: 11.5px; color: var(--muted); }
.list .mid { flex: 1; min-width: 0; }
.list .mid div { font-variant-numeric: tabular-nums; }

/* ---------- phieu luong ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.filters .field { margin: 0; }
.slip-head { text-align: center; padding: 18px 16px; }
.slip-head .money { font-size: 32px; margin: 6px 0; }
.slip-head .row { justify-content: center; }
.sec h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.line:last-child { border-bottom: 0; }
.line span:last-child { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.line.total span { font-weight: 800; }
.months { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; }
.months button { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-weight: 600; }

/* ---------- toi ---------- */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; font-weight: 600; word-break: break-word; }
.menu button { width: 100%; display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 13px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 600; }
.menu button:last-child { border-bottom: 0; }
.menu button.danger { color: var(--bad); }
.menu svg { width: 22px; height: 22px; color: var(--muted); }

/* ---------- bottom sheet + toast ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(8,15,25,.45); z-index: 20; display: flex; align-items: flex-end; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); max-height: 88vh; overflow: auto; animation: up .2s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%); background: #1F2937; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }
.offline { background: var(--warn-bg); color: var(--warn); text-align: center; font-size: 13px; padding: 6px; }
.skeleton { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--line), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
