:root {
  --bg: #F4F5FA;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --ink: #0D1430;
  --ink-2: #2A3352;
  --muted: #646D86;
  --line: #E5E8F0;
  --brand: #4F46E5;
  --brand-2: #06B6D4;
  --brand-ink: #3730A3;
  --brand-soft: #EEF0FF;
  --grad: linear-gradient(135deg, #4F46E5 0%, #3B82F6 55%, #06B6D4 100%);
  --good: #059669; --good-soft: #E7F8F1;
  --warn: #D97706; --warn-soft: #FFF4E0;
  --bad: #DC2626; --bad-soft: #FDECEC;
  --info: #2563EB; --info-soft: #E8F0FF;
  --side: #0A0F26;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(13, 20, 48, .06), 0 1px 1px rgba(13, 20, 48, .04);
  --shadow: 0 10px 30px -12px rgba(13, 20, 48, .18), 0 2px 6px rgba(13, 20, 48, .05);
  --shadow-lg: 0 30px 60px -20px rgba(13, 20, 48, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
:where(svg) { width: 16px; height: 16px; flex: none; vertical-align: middle; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, .tabular { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: rgba(255, 255, 255, .86); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 9px; object-fit: cover; }
.brand-text { line-height: 1.1; min-width: 0; }
.brand-text b { font-family: var(--display); font-size: 15px; display: block; white-space: nowrap; }
.brand-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.sample-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border: 1px solid #F8DDAE; padding: 4px 10px; border-radius: 999px; white-space: nowrap; cursor: pointer; }
.mode-toggle { position: relative; display: grid; grid-template-columns: 1fr 1fr; background: #EEF0F6; border-radius: 999px; padding: 4px; min-width: 250px; }
.mode-toggle button { position: relative; z-index: 1; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); transition: color .3s var(--ease); white-space: nowrap; }
.mode-toggle button.on { color: var(--ink); }
.mode-toggle .pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: #fff; box-shadow: var(--shadow-sm); transition: transform .45s var(--ease); }
.mode-toggle.emp .pill { transform: translateX(100%); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 11px; font-weight: 600; font-size: 13.5px; transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s; white-space: nowrap; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -8px rgba(79, 70, 229, .7); }
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(79, 70, 229, .8); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-good { background: var(--good); color: #fff; }
.btn-bad { background: var(--bad-soft); color: var(--bad); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 11px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: #fff; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - 64px); }
.sidebar { background: var(--side); color: #C9CEE4; padding: 18px 12px; position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; display: flex; flex-direction: column; }
.ws-card { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .07); margin-bottom: 16px; }
.ws-card b { color: #fff; font-family: var(--display); font-size: 13.5px; display: block; }
.ws-card span { font-size: 11.5px; color: #8E95B5; }
.nav-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #6A7194; padding: 10px 12px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: #C9CEE4; font-weight: 500; position: relative; transition: background .2s, color .2s; }
.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav a.on { background: linear-gradient(90deg, rgba(79, 70, 229, .45), rgba(79, 70, 229, .12)); color: #fff; }
.nav a.on::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand-2); }
.nav .badge { margin-left: auto; background: #F43F5E; color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; animation: pop .4s var(--ease); }
.side-cta { margin-top: auto; padding: 14px; border-radius: 14px; background: linear-gradient(160deg, rgba(79, 70, 229, .35), rgba(6, 182, 212, .2)); border: 1px solid rgba(255, 255, 255, .1); color: #fff; }
.side-cta p { margin: 4px 0 10px; font-size: 12px; color: #C9CEE4; }
.side-cta .btn { width: 100%; background: #fff; color: var(--ink); }
main#view { padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 16px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); font-weight: 700; }

/* ---------- View transition ---------- */
.view-enter { animation: viewIn .5s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: viewIn .55s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; } .stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; } .stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; } .stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(n+7) { animation-delay: .26s; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .k-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .k-val { font-family: var(--display); font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .k-icon { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi .k-icon svg { width: 18px; height: 18px; }
.hero { position: relative; overflow: hidden; background: var(--side); color: #fff; border: 0; border-radius: 20px; padding: 26px 28px; }
.hero::after { content: ''; position: absolute; right: -120px; top: -140px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(79, 70, 229, .55), transparent 65%); pointer-events: none; }
.hero::before { content: ''; position: absolute; right: 80px; bottom: -160px; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(6, 182, 212, .35), transparent 65%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero h2 { font-size: 24px; }
.hero p { color: #B9C0DE; margin: 6px 0 18px; max-width: 560px; }
.hero .hero-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero .btn-ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #fff; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.chip.ok { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.mute { background: #F0F2F7; color: var(--muted); }
.chip.brand { background: var(--brand-soft); color: var(--brand-ink); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); animation: pulse 1.8s infinite; display: inline-block; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); } 70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }

/* ---------- Avatar ---------- */
.av { width: 36px; height: 36px; border-radius: 11px; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; font-family: var(--display); }
.av.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 19px; }
.av.xl { width: 84px; height: 84px; border-radius: 24px; font-size: 28px; }
.who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.t th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t .r { text-align: right; }
.t tbody tr { transition: background .15s; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: #F7F8FF; }
.t tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.amt-btn { font-variant-numeric: tabular-nums; padding: 3px 7px; margin: -3px -7px; border-radius: 7px; transition: background .15s, color .15s; border-bottom: 1px dashed transparent; }
.amt-btn:hover { background: var(--brand-soft); color: var(--brand-ink); }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Tabs / segmented ---------- */
.seg { display: inline-flex; background: #EBEDF4; padding: 4px; border-radius: 12px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); transition: all .25s var(--ease); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Kiosk ---------- */
.kiosk { border-radius: 24px; overflow: hidden; background: #0A0F26; color: #fff; position: relative; }
.kiosk-top { padding: 28px 28px 22px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; background: radial-gradient(600px 300px at 90% -20%, rgba(79, 70, 229, .5), transparent), radial-gradient(500px 260px at 0% 120%, rgba(6, 182, 212, .25), transparent); }
.k-clock { font-family: var(--display); font-size: 58px; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.k-clock small { font-size: 22px; color: #8E95B5; margin-left: 6px; }
.k-date { color: #B9C0DE; margin-top: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hol-banner { display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(90deg, #F59E0B, #F97316); color: #1A1206; font-weight: 700; font-size: 12.5px; padding: 6px 12px; border-radius: 999px; }
.clock-pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); padding: 7px 12px; border-radius: 999px; font-size: 12.5px; color: #D8DCF0; }
.clock-pill select { background: transparent; border: 0; color: #fff; font-weight: 600; outline: none; cursor: pointer; }
.clock-pill select option { color: #0D1430; }
.k-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; padding: 22px 28px 28px; background: #0E1430; }
.k-emp { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); border-radius: 18px; padding: 16px 14px; text-align: center; transition: transform .25s var(--ease), background .25s, border-color .25s; color: #fff; position: relative; }
.k-emp:hover { transform: translateY(-3px); background: rgba(255, 255, 255, .08); border-color: rgba(129, 140, 248, .5); }
.k-emp .av { margin: 0 auto 10px; }
.k-emp b { display: block; font-size: 13.5px; }
.k-emp .pos { color: #8E95B5; font-size: 11.5px; display: block; }
.k-emp .st { margin-top: 10px; font-size: 11.5px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; padding: 4px 9px; border-radius: 999px; }
.k-emp .st.in { background: rgba(16, 185, 129, .15); color: #6EE7B7; }
.k-emp .st.out { background: rgba(255, 255, 255, .06); color: #A3AACB; }
.k-emp .st.off { background: rgba(255, 255, 255, .04); color: #6A7194; }
.k-emp .st.due { background: rgba(245, 158, 11, .15); color: #FCD34D; }
.k-emp.disabled { opacity: .5; }

/* ---------- Punch modal ---------- */
.punch { background: #0A0F26; color: #fff; border-radius: 26px; width: min(420px, 100%); overflow: hidden; }
.punch-cam { position: relative; height: 300px; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #1E2650, #070B1C 70%); overflow: hidden; }
.punch-cam .noise { position: absolute; inset: 0; opacity: .18; background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 3px); }
.face-frame { position: relative; width: 190px; height: 230px; }
.face-frame .corner { position: absolute; width: 34px; height: 34px; border: 3px solid #fff; opacity: .9; transition: border-color .4s; }
.face-frame .c1 { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 16px 0 0 0; }
.face-frame .c2 { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 16px 0 0; }
.face-frame .c3 { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 16px; }
.face-frame .c4 { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 16px 0; }
.face-frame.matched .corner { border-color: #34D399; }
.face { position: absolute; inset: 26px 22px; border-radius: 50% 50% 46% 46%; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 46px; color: rgba(255, 255, 255, .95); box-shadow: inset 0 -20px 40px rgba(0, 0, 0, .25); }
.scanline { position: absolute; left: 6px; right: 6px; height: 3px; background: linear-gradient(90deg, transparent, #22D3EE, transparent); box-shadow: 0 0 18px #22D3EE; animation: scan 1.4s ease-in-out infinite; }
@keyframes scan { 0% { top: 8%; } 50% { top: 88%; } 100% { top: 8%; } }
.mesh { position: absolute; inset: 20px; border-radius: 50%; background-image: radial-gradient(circle, rgba(34, 211, 238, .7) 1px, transparent 1.5px); background-size: 14px 14px; opacity: .35; mask-image: radial-gradient(circle, #000 45%, transparent 72%); -webkit-mask-image: radial-gradient(circle, #000 45%, transparent 72%); }
.cam-label { position: absolute; top: 14px; left: 14px; font-size: 11px; letter-spacing: .1em; color: #A3AACB; display: flex; gap: 6px; align-items: center; }
.cam-label .rec { width: 7px; height: 7px; border-radius: 50%; background: #F43F5E; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.punch-body { padding: 20px 22px 22px; }
.checks { display: grid; gap: 10px; margin: 4px 0 16px; }
.check { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 13px; background: rgba(255, 255, 255, .05); font-size: 13px; color: #C9CEE4; transition: all .35s var(--ease); }
.check .ci { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .08); flex: none; }
.check .ci svg { width: 14px; height: 14px; }
.check.done { background: rgba(16, 185, 129, .12); color: #fff; }
.check.done .ci { background: #10B981; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.punch-result { text-align: center; padding: 6px 0 4px; animation: viewIn .5s var(--ease); }
.big-check { width: 72px; height: 72px; border-radius: 50%; background: #10B981; display: grid; place-items: center; margin: 0 auto 12px; animation: pop .5s var(--ease); box-shadow: 0 0 0 10px rgba(16, 185, 129, .15); }
.big-check svg { width: 36px; height: 36px; color: #fff; }
.punch-result .t-big { font-family: var(--display); font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.punch-result .chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }

/* ---------- Drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 12, 30, .5); backdrop-filter: blur(3px); z-index: 80; animation: fade .3s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 90; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .45s var(--ease); }
@keyframes slideIn { from { transform: translateX(100%); } }
.drawer.closing { animation: slideOut .3s var(--ease) forwards; }
@keyframes slideOut { to { transform: translateX(100%); } }
.drawer-head { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.drawer-body { padding: 20px 22px 40px; overflow-y: auto; flex: 1; }
.modal-wrap { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 22px; width: min(480px, 100%); box-shadow: var(--shadow-lg); animation: modalIn .45s var(--ease); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { width: min(820px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.modal-pad { padding: 26px; }
.modal h3 { font-size: 19px; }

/* ---------- Trace ---------- */
.trace-amount { font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.formula { background: var(--side); color: #E4E7F5; border-radius: 14px; padding: 14px 16px; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.6; margin: 14px 0; position: relative; overflow: hidden; word-break: break-word; }
.formula::before { content: 'COMPUTATION'; display: block; font-size: 10px; letter-spacing: .14em; color: #7D86B0; margin-bottom: 4px; font-family: var(--font); font-weight: 700; }
.formula .eq { color: #67E8F9; font-weight: 700; }
.rule-box { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; color: var(--ink-2); display: flex; gap: 10px; }
.rule-box svg { width: 16px; height: 16px; color: var(--brand); flex: none; margin-top: 2px; }
.trace-rows { margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.trace-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; align-items: start; animation: viewIn .4s var(--ease) both; }
.trace-row:last-child { border-bottom: 0; }
.trace-row b { font-weight: 600; }
.trace-row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.source-note { margin-top: 14px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* ---------- Pay detail ---------- */
.pay-lines { display: grid; }
.pay-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 13px 4px; border-bottom: 1px dashed var(--line); cursor: pointer; border-radius: 10px; transition: background .15s, padding .2s; }
.pay-line:hover { background: #F7F8FF; padding-left: 10px; padding-right: 10px; }
.pay-line .pl-label { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.pay-line .pl-amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.pay-line .pl-formula { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; }
.pay-line .why { font-size: 11px; color: var(--brand); font-weight: 600; opacity: 0; transition: opacity .2s; }
.pay-line:hover .why { opacity: 1; }
.pay-group-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 18px 0 2px; }
.pay-total { display: flex; justify-content: space-between; padding: 14px 4px; font-weight: 700; font-size: 15px; }
.net-box { background: var(--grad); color: #fff; border-radius: 16px; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.net-box .v { font-family: var(--display); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Payslip ---------- */
.payslip { background: #fff; color: #0D1430; border-radius: 18px; border: 1px solid var(--line); overflow: hidden; font-size: 13px; }
.ps-head { padding: 22px 24px; background: var(--side); color: #fff; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; position: relative; overflow: hidden; }
.ps-head::after { content: ''; position: absolute; right: -60px; top: -80px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(79, 70, 229, .6), transparent 65%); }
.ps-head > * { position: relative; z-index: 1; }
.ps-head h4 { font-size: 17px; }
.ps-head .muted { color: #A3AACB; }
.ps-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ps-meta div span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ps-meta div b { font-size: 13px; }
.ps-cols { display: grid; grid-template-columns: 1fr 1fr; }
.ps-col { padding: 16px 24px; }
.ps-col + .ps-col { border-left: 1px solid var(--line); }
.ps-col h5 { margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ps-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dotted var(--line); cursor: pointer; }
.ps-row:hover { color: var(--brand-ink); }
.ps-row .num { font-weight: 600; }
.ps-row.total { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--ink); margin-top: 6px; padding-top: 8px; cursor: default; }
.ps-net { margin: 0 24px 20px; padding: 16px 20px; border-radius: 14px; background: var(--grad); color: #fff; display: flex; justify-content: space-between; align-items: center; }
.ps-net .v { font-family: var(--display); font-size: 26px; font-weight: 800; }
.ps-foot { padding: 12px 24px 18px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- Bars ---------- */
.bar-row { display: grid; grid-template-columns: 140px 1fr 110px; gap: 12px; align-items: center; padding: 9px 0; }
.bar-track { height: 10px; background: #EEF0F6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--grad); transform-origin: left; animation: grow 1s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.mini-bars i { flex: 1; background: var(--grad); border-radius: 3px 3px 1px 1px; min-height: 2px; animation: rise .8s var(--ease) both; transform-origin: bottom; }
.mini-bars i.proj { background: repeating-linear-gradient(45deg, #C7CCF5 0 3px, #E3E6FA 3px 6px); }
@keyframes rise { from { transform: scaleY(0); } }
.timeline { position: relative; height: 22px; background: #F0F2F7; border-radius: 6px; min-width: 160px; overflow: hidden; }
.timeline .sched { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, #E1E4EE 0 4px, #EAECF3 4px 8px); }
.timeline .work { position: absolute; top: 4px; bottom: 4px; border-radius: 4px; background: var(--grad); animation: grow .7s var(--ease) both; }
.timeline .work.proj { background: repeating-linear-gradient(90deg, #818CF8 0 5px, #A5B4FC 5px 9px); }
.timeline .ot { position: absolute; top: 4px; bottom: 4px; border-radius: 4px; background: #F59E0B; }
.timeline .late { position: absolute; top: 4px; bottom: 4px; background: #F87171; border-radius: 4px; }

/* ---------- Run payroll ---------- */
.run-steps { display: grid; gap: 10px; margin: 18px 0 6px; }
.run-step { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); transition: all .35s var(--ease); }
.run-step .ci { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #E6E8F0; flex: none; transition: background .3s; }
.run-step .ci svg { width: 15px; height: 15px; color: #fff; }
.run-step.active { color: var(--ink); border-color: #C7CCF5; background: #F6F7FF; }
.run-step.active .spinner { border-color: rgba(79, 70, 229, .25); border-top-color: var(--brand); }
.run-step.done { color: var(--ink); }
.run-step.done .ci { background: var(--good); }
.run-step .rs-meta { margin-left: auto; font-size: 12px; font-weight: 600; }
.progress { height: 6px; background: #EBEDF4; border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--grad); width: 0; transition: width .4s var(--ease); }
.precheck { display: grid; gap: 2px; }
.precheck div { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.precheck div:last-child { border-bottom: 0; }
.precheck .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.precheck .ic svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
.input:focus { border-color: #A5B4FC; box-shadow: 0 0 0 4px rgba(99, 102, 241, .12); }
.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.type-opt { border: 1.5px solid var(--line); border-radius: 13px; padding: 10px 12px; text-align: left; transition: all .2s var(--ease); background: #fff; }
.type-opt b { display: block; font-size: 13px; }
.type-opt span { font-size: 11.5px; color: var(--muted); }
.type-opt.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; font-weight: 500; animation: toastIn .45s var(--ease); pointer-events: auto; }
.toast svg { width: 18px; height: 18px; color: #34D399; flex: none; }
.toast.out { animation: toastOut .35s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ---------- Employee (phone) view ---------- */
.emp-stage { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 40px; align-items: start; padding: 10px 0 30px; }
.emp-side { padding-top: 40px; max-width: 320px; justify-self: end; }
.emp-side h2 { font-size: 26px; margin: 8px 0 10px; }
.emp-side p { color: var(--muted); }
.emp-side-r { padding-top: 40px; max-width: 300px; }
.persona-list { display: grid; gap: 6px; margin-top: 14px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.persona-list button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; text-align: left; border: 1px solid transparent; transition: all .2s; }
.persona-list button:hover { background: #fff; border-color: var(--line); }
.persona-list button.on { background: #fff; border-color: #C7CCF5; box-shadow: var(--shadow-sm); }
.persona-list .av { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
.phone { width: 390px; height: min(800px, calc(100vh - 100px)); min-height: 640px; border-radius: 52px; background: #0A0F26; padding: 12px; box-shadow: var(--shadow-lg), inset 0 0 0 2px #2A3152; position: relative; }
.phone::before { content: ''; position: absolute; top: 22px; left: 50%; transform: translateX(-50%); width: 110px; height: 30px; border-radius: 20px; background: #000; z-index: 5; }
.screen { width: 100%; height: 100%; border-radius: 42px; overflow: hidden; background: var(--bg); position: relative; display: flex; flex-direction: column; }
.screen-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.screen-scroll::-webkit-scrollbar { display: none; }
.app-head { background: var(--side); color: #fff; padding: 58px 20px 64px; position: relative; overflow: hidden; }
.app-head::after { content: ''; position: absolute; right: -80px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(79, 70, 229, .6), transparent 65%); }
.app-head > * { position: relative; z-index: 1; }
.app-head .hello { color: #A3AACB; font-size: 13px; }
.app-head h2 { font-size: 22px; margin-top: 2px; }
.app-body { padding: 0 16px 100px; margin-top: -44px; position: relative; z-index: 2; display: grid; gap: 14px; }
.app-body.flat { margin-top: 16px; }
.app-title { padding: 54px 20px 6px; display: flex; align-items: center; gap: 10px; }
.app-title h2 { font-size: 22px; }
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 6px 22px; z-index: 10; }
.tabbar button { display: grid; justify-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted); padding: 4px 0; transition: color .2s; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--brand); }
.punch-card { background: #fff; border-radius: 22px; padding: 18px; box-shadow: var(--shadow); text-align: center; }
.punch-card .pc-time { font-family: var(--display); font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.punch-btn { width: 100%; margin-top: 14px; padding: 16px; border-radius: 16px; font-size: 16px; font-weight: 700; color: #fff; background: var(--grad); box-shadow: 0 14px 30px -12px rgba(79, 70, 229, .8); position: relative; overflow: hidden; }
.punch-btn.out { background: linear-gradient(135deg, #0D1430, #2A3352); box-shadow: 0 14px 30px -12px rgba(13, 20, 48, .6); }
.punch-btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-100%); animation: shine 3s infinite; }
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.m-card { background: #fff; border-radius: 18px; padding: 16px; border: 1px solid var(--line); }
.m-card h4 { font-size: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.m-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.m-stats b { display: block; font-family: var(--display); font-size: 19px; }
.m-stats span { font-size: 10.5px; color: var(--muted); }
.bal-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bal { background: var(--surface-2); border-radius: 14px; padding: 10px; text-align: center; border: 1px solid var(--line); }
.bal b { font-family: var(--display); font-size: 22px; display: block; transition: color .3s; }
.bal span { font-size: 10.5px; color: var(--muted); }
.bal.changed b { animation: pop .6s var(--ease); color: var(--brand); }
.m-list > * { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.m-list > *:last-child { border-bottom: 0; }
.ps-card { background: var(--grad); color: #fff; border-radius: 18px; padding: 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: transform .2s var(--ease); }
.ps-card:hover { transform: translateY(-2px); }
.ps-card .v { font-family: var(--display); font-size: 24px; font-weight: 800; }
.empty { text-align: center; padding: 26px 16px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: #C3C8DA; margin-bottom: 6px; }

/* full-version */
.fv-icon { width: 58px; height: 58px; border-radius: 18px; background: var(--grad); display: grid; place-items: center; margin-bottom: 14px; box-shadow: 0 12px 26px -10px rgba(79, 70, 229, .7); }
.fv-icon svg { width: 28px; height: 28px; color: #fff; }

.footer-cta { margin-top: 30px; border-radius: 20px; padding: 22px 24px; background: #fff; border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-cta b { font-family: var(--display); font-size: 16px; }
.disclaimer { font-size: 11.5px; color: var(--muted); margin-top: 14px; display: flex; gap: 8px; align-items: flex-start; }
.disclaimer svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--warn); }

.mobile-only { display: none; }
.persona-sel { display: none; }
#print-area { display: none; }
@media (max-width: 900px) { .persona-sel { display: block; } }
.menu-btn { display: none; }
.list-cards { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .emp-side-r { display: none; }
  .emp-stage { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .brand-text span { display: none; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 64px; left: 0; bottom: 0; width: 270px; z-index: 70; transform: translateX(-100%); transition: transform .4s var(--ease); height: auto; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-grid; }
  .sample-badge .txt { display: none; }
  .topbar .cta-top { display: none; }
  .g-3 { grid-template-columns: 1fr; }
  .emp-stage { grid-template-columns: 1fr; justify-items: center; }
  .emp-side { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-text { display: none; }
  .mode-toggle { min-width: 0; flex: 1; }
  .mode-toggle button { padding: 7px 8px; font-size: 12px; }
  main#view { padding: 18px 16px 50px; }
  .page-head h1 { font-size: 22px; }
  .g-4, .g-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .k-val { font-size: 19px; }
  .kpi .k-icon { display: none; }
  .k-clock { font-size: 42px; }
  .kiosk-top, .k-grid { padding-left: 16px; padding-right: 16px; }
  .k-grid { grid-template-columns: repeat(2, 1fr); }
  .ps-meta { grid-template-columns: 1fr 1fr; }
  .ps-cols { grid-template-columns: 1fr; }
  .ps-col + .ps-col { border-left: 0; border-top: 1px solid var(--line); }
  .bar-row { grid-template-columns: 96px 1fr 90px; font-size: 12px; }
  .trace-row { grid-template-columns: 1fr auto; }
  .trace-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .hero { padding: 22px 18px; }
  .hide-sm { display: none; }
  /* phone frame becomes the real screen */
  .emp-stage { padding: 0; margin: -18px -16px -50px; display: block; }
  .phone { width: 100%; height: calc(100vh - 64px); height: calc(100dvh - 64px); border-radius: 0; padding: 0; box-shadow: none; }
  .phone::before { display: none; }
  .screen { border-radius: 0; }
  .app-head { padding-top: 22px; }
  .app-title { padding-top: 20px; }
  .mobile-only { display: block; }
  .modal-pad { padding: 20px; }
}

/* ---------- Print: payslip only ---------- */
@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  .payslip { border: 1px solid #ccc; box-shadow: none; }
  .ps-head, .ps-net { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Overflow guards & small-screen top bar ---------- */
.grid > *, .shell > *, .g-main > * { min-width: 0; }
.mode-toggle .lbl-sm { display: none; }
@media (max-width: 640px) {
  .chip { white-space: normal; }
  .mode-toggle .lbl-lg { display: none; }
  .mode-toggle .lbl-sm { display: inline; }
  .sample-badge { padding: 4px 7px; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .brand-mark { width: 30px; height: 30px; }
  .card-head, .card-pad { padding-left: 14px; padding-right: 14px; }
  .page-head .seg { width: 100%; }
  .page-head .seg button { flex: 1; }
  .trace-amount { font-size: 28px; }
}
@media (max-width: 640px) {
  .topbar { gap: 6px; }
  .topbar .spacer { display: none; }
  .mode-toggle { flex: 1 1 auto; margin-left: auto; max-width: 170px; }
  .bar-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) { .g-2 { grid-template-columns: 1fr; } }
