/* =====================================================================
   HR & Payroll Lab - styles (on top of Bootstrap 5.3)
   ===================================================================== */
:root {
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --brand-soft: #eef2ff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f4f6fb;
    --card: #ffffff;
    --sidebar-w: 264px;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --bs-body-font-family: "Segoe UI", "Inter", system-ui, -apple-system, "Noto Sans Thai", sans-serif;
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: #4338ca;
}

html, body { background: var(--bg); color: var(--ink); }
body { font-size: .925rem; }
a { text-decoration: none; }
.text-muted { color: var(--muted) !important; }
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: .85em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fw-semi { font-weight: 600; }
.small-caps { text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; font-weight: 700; color: var(--muted); }

.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: #c7d2fe; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.btn { border-radius: 10px; font-weight: 500; }
.btn-sm { border-radius: 8px; }
.form-control, .form-select { border-radius: 10px; border-color: #d7dce6; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .15); }
.form-label { font-weight: 600; font-size: .82rem; color: #334155; margin-bottom: .3rem; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #3b0764 100%);
    color: #c7d2fe; padding: 1.1rem .85rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.brand { display: flex; align-items: center; gap: .7rem; color: #fff; padding: .2rem .45rem 1rem; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem;
    background: linear-gradient(135deg, #818cf8, #c084fc); color: #fff; box-shadow: 0 6px 18px rgba(129, 140, 248, .45);
}
.brand-name { display: block; font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand-sub { display: block; font-size: .72rem; color: #a5b4fc; }
.side-label { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: #818cf8; font-weight: 700; margin: 1rem .6rem .35rem; }
.side-link {
    display: flex; align-items: center; gap: .65rem; padding: .48rem .65rem; border-radius: 10px; color: #c7d2fe;
    font-size: .875rem; transition: background .15s, color .15s;
}
.side-link i { font-size: 1.02rem; width: 1.2rem; text-align: center; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #a5b4fc; }
.side-link .feat { margin-left: auto; font-size: .65rem; padding: .1rem .38rem; border-radius: 6px; background: rgba(255,255,255,.1); color: #c7d2fe; font-weight: 600; }
.side-link .count { margin-left: auto; font-size: .68rem; padding: .08rem .45rem; border-radius: 999px; background: #f43f5e; color: #fff; font-weight: 700; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.6rem; background: rgba(244, 246, 251, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .crumb { font-size: .8rem; color: var(--muted); }
.topbar .page-name { font-weight: 700; font-size: 1.05rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .25rem .35rem .25rem .3rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.user-chip .who { line-height: 1.05; font-size: .8rem; }
.user-chip .who small { color: var(--muted); font-size: .7rem; }
.content { padding: 1.5rem 1.6rem 3rem; max-width: 1480px; width: 100%; }

/* ---------- Avatars ---------- */
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex: 0 0 auto;
    font-weight: 700; font-size: .75rem; color: #fff; letter-spacing: .02em;
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-sm { width: 26px; height: 26px; font-size: .62rem; }
.person { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.person .name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .sub { font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .85rem 1.1rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.card-header .bi { color: var(--brand); }
.card-body { padding: 1.1rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.feature-tag { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: .15rem .5rem; border-radius: 6px; margin-bottom: .35rem; }

/* ---------- Stat tiles ---------- */
.stat { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: 0 0 auto; }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: .78rem; color: var(--muted); }
.tone-indigo { background: #eef2ff; color: #4f46e5; }
.tone-green { background: #ecfdf5; color: #059669; }
.tone-amber { background: #fffbeb; color: #d97706; }
.tone-rose { background: #fff1f2; color: #e11d48; }
.tone-sky { background: #f0f9ff; color: #0284c7; }
.tone-purple { background: #faf5ff; color: #9333ea; }
.tone-slate { background: #f1f5f9; color: #475569; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .62rem .8rem; border-color: #eef1f6; vertical-align: middle; }
.table thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #f8faff; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.table-wrap { overflow-x: auto; }
.row-link { cursor: pointer; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.pill-success { background: #dcfce7; color: #15803d; }
.pill-warning { background: #fef3c7; color: #b45309; }
.pill-danger { background: #ffe4e6; color: #be123c; }
.pill-info { background: #e0f2fe; color: #0369a1; }
.pill-primary { background: #e0e7ff; color: #4338ca; }
.pill-purple { background: #f3e8ff; color: #7e22ce; }
.pill-secondary { background: #e2e8f0; color: #334155; }
.pill-light { background: #f1f5f9; color: #64748b; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Flash / study note ---------- */
.flash-stack { padding: 1rem 1.6rem 0; }
.flash-stack .alert { border-radius: 12px; border: 0; margin-bottom: 0; }
.study-note { border: 1px dashed #c7d2fe; background: #f8f9ff; border-radius: 12px; padding: .8rem 1rem; font-size: .83rem; color: #3730a3; margin-top: 1.5rem; }
.study-note b { color: #312e81; }
.study-note code { color: #7c3aed; background: #fff; padding: .05rem .3rem; border-radius: 4px; }

/* ---------- Filter bar / tabs ---------- */
.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: .32rem .75rem; border-radius: 8px; color: #475569; font-size: .82rem; font-weight: 500; }
.seg a.active { background: var(--brand); color: #fff; }
.seg a:not(.active):hover { background: #f1f5f9; }

/* ---------- Profile ---------- */
.profile-hero { background: linear-gradient(120deg, #4f46e5, #7c3aed 60%, #c026d3); color: #fff; border-radius: var(--radius); padding: 1.4rem 1.5rem; display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; box-shadow: var(--shadow); }
.profile-hero .avatar { border: 3px solid rgba(255,255,255,.6); }
.profile-hero h2 { margin: 0; font-weight: 800; font-size: 1.4rem; }
.profile-hero .meta { color: #e0e7ff; font-size: .85rem; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .45rem .8rem; font-size: .87rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- Timeline (432) ---------- */
.timeline { position: relative; padding-left: 2.2rem; }
.timeline::before { content: ""; position: absolute; left: .9rem; top: .3rem; bottom: .3rem; width: 2px; background: #e2e8f0; }
.tl-item { position: relative; padding-bottom: 1.15rem; }
.tl-dot { position: absolute; left: -2.2rem; top: 0; width: 1.85rem; height: 1.85rem; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .85rem; box-shadow: 0 0 0 4px var(--bg); }
.tl-date { font-size: .74rem; color: var(--muted); font-weight: 600; }
.tl-title { font-weight: 700; }
.tl-body { font-size: .85rem; color: #334155; }

/* ---------- Leave balance cards (434) ---------- */
.balance { border-radius: 12px; padding: .9rem 1rem; border: 1px solid var(--line); background: #fff; height: 100%; }
.balance .big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.progress { height: 6px; border-radius: 999px; background: #eef1f6; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; padding: .2rem 0; }
.cal-day { min-height: 96px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .35rem .45rem; font-size: .75rem; }
.cal-day.other { background: transparent; border-style: dashed; opacity: .45; }
.cal-day.weekend { background: #f8fafc; }
.cal-day.holiday { background: #fff7ed; border-color: #fed7aa; }
.cal-day.today { border-color: var(--brand); box-shadow: 0 0 0 2px #c7d2fe; }
.cal-num { font-weight: 700; font-size: .8rem; }
.cal-chip { display: block; border-radius: 6px; padding: .1rem .35rem; margin-top: 3px; color: #fff; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.pending { opacity: .55; outline: 1px dashed currentColor; }

/* ---------- Attendance grid (436) ---------- */
.att-grid td.d { padding: 0 !important; text-align: center; min-width: 26px; }
.att-cell { display: block; width: 24px; height: 24px; margin: 2px auto; border-radius: 6px; font-size: .66rem; line-height: 24px; font-weight: 700; }
.att-PRESENT { background: #bbf7d0; color: #166534; }
.att-LATE { background: #fde68a; color: #92400e; }
.att-EARLY_LEAVE { background: #fed7aa; color: #9a3412; }
.att-MISSING_OUT { background: #bae6fd; color: #075985; }
.att-WORKING { background: #c7d2fe; color: #3730a3; }
.att-ABSENT { background: #fecdd3; color: #9f1239; }
.att-LEAVE, .att-HALF_LEAVE { background: #e9d5ff; color: #6b21a8; }
.att-HOLIDAY { background: #fed7aa55; color: #c2410c; }
.att-WEEKEND, .att-DAY_OFF, .att-UPCOMING, .att-NOT_EMPLOYED { background: #f1f5f9; color: #cbd5e1; }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .75rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }

/* ---------- Shift grid (438) ---------- */
.shift-grid select { font-size: .76rem; padding: .25rem 1.6rem .25rem .45rem; border-radius: 8px; min-width: 120px; font-weight: 600; }
.shift-grid select.off { color: #94a3b8; background-color: #f8fafc; }
.shift-grid select.assigned { border-color: #a5b4fc; border-width: 2px; }
.shift-grid th.holiday { color: #c2410c; }
.shift-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .6rem; border-radius: 8px; font-size: .78rem; font-weight: 600; background: #f8fafc; border: 1px solid var(--line); }

/* ---------- Time clock (437) ---------- */
.clock-face { text-align: center; padding: 2rem 1rem; }
.clock-time { font-size: 3.6rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.clock-date { color: var(--muted); margin-top: .35rem; }
.punch-btn { width: 210px; height: 210px; border-radius: 50%; border: 0; color: #fff; font-size: 1.35rem; font-weight: 800; display: inline-grid; place-items: center; transition: transform .15s, box-shadow .15s; }
.punch-btn:hover { transform: scale(1.03); }
.punch-btn:active { transform: scale(.98); }
.punch-in { background: radial-gradient(circle at 30% 30%, #34d399, #059669); box-shadow: 0 18px 40px rgba(5, 150, 105, .35), 0 0 0 10px #d1fae5; }
.punch-out { background: radial-gradient(circle at 30% 30%, #fb7185, #e11d48); box-shadow: 0 18px 40px rgba(225, 29, 72, .35), 0 0 0 10px #ffe4e6; }
.punch-btn i { font-size: 2.6rem; display: block; margin-bottom: .2rem; }

/* ---------- Payslip (443) ---------- */
.slip { max-width: 860px; margin: 0 auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.slip-head { background: linear-gradient(120deg, #1e1b4b, #4338ca); color: #fff; padding: 1.4rem 1.6rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.slip-head h2 { margin: 0; font-weight: 800; font-size: 1.3rem; }
.slip-body { padding: 1.4rem 1.6rem; }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.slip table td { padding: .4rem 0; border-bottom: 1px dashed #e2e8f0; }
.slip .net { background: linear-gradient(120deg, #ecfdf5, #f0fdfa); border: 1px solid #a7f3d0; border-radius: 12px; padding: 1rem 1.2rem; display: flex; justify-content: space-between; align-items: center; }
.slip .net .amount { font-size: 1.9rem; font-weight: 800; color: #047857; letter-spacing: -.02em; }

/* ---------- Review stars (445) ---------- */
.score-pick { display: inline-flex; gap: 4px; }
.score-pick input { display: none; }
.score-pick label { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; font-weight: 700; color: #64748b; background: #fff; }
.score-pick input:checked + label { background: var(--brand); border-color: var(--brand); color: #fff; }
.grade { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #fff; }
.grade-A { background: linear-gradient(135deg, #10b981, #059669); }
.grade-B { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.grade-C { background: linear-gradient(135deg, #f59e0b, #d97706); }
.grade-D, .grade-E { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.grade-none { background: #cbd5e1; }

/* ---------- Tax brackets (442) ---------- */
.bracket-bar { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #a5b4fc, #7c3aed); }

/* ---------- Learn page ---------- */
.feature-card { height: 100%; transition: transform .15s, box-shadow .15s; }
.feature-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(79, 70, 229, .12); }
.feature-no { font-size: .72rem; font-weight: 800; color: var(--brand); }
pre.code { background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 1rem 1.1rem; font-size: .8rem; overflow-x: auto; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(140deg, #1e1b4b 0%, #4338ca 45%, #a21caf 100%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -160px; bottom: -180px; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%); }
.login-art h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -.02em; }
.login-art .feat-list { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem 1.2rem; font-size: .88rem; color: #e0e7ff; max-width: 560px; }
.login-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.login-box { width: 100%; max-width: 380px; }
.demo-acc { display: flex; justify-content: space-between; align-items: center; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .85rem; }
.demo-acc:hover { border-color: #a5b4fc; background: #f8f9ff; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .4); }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
    .login-page { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .slip-cols { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 120px 1fr; }
}

/* ---------- Print (contract, payslip, certificate) ---------- */
@media print {
    .sidebar, .topbar, .flash-stack, .no-print, .study-note { display: none !important; }
    body, html { background: #fff; }
    .content { padding: 0; max-width: none; }
    .card, .slip { box-shadow: none; border: 1px solid #ccc; }
    .slip-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
