:root {
    --app-navy: #1f3864;
    --app-navy-2: #2a4a80;
    --app-bg: #f4f6fb;
    --app-border: #e5e9f2;
    --app-sidebar-width: 260px;
    --bs-font-sans-serif: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

html, body { font-family: var(--bs-font-sans-serif); }
body { background: var(--app-bg); color: #1d2433; }
code { color: #a3245c; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-content { flex: 1; padding: 1.5rem; }
.app-footer { padding: 1rem 1.5rem; font-size: .8rem; color: #8a94a6; border-top: 1px solid var(--app-border); background: #fff; }

.app-sidebar {
    width: var(--app-sidebar-width);
    background: linear-gradient(180deg, var(--app-navy) 0%, #172a4d 100%);
    color: #dbe3f3;
}
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; overflow-y: auto; }
}
@media (max-width: 991.98px) {
    .app-sidebar.offcanvas-lg { --bs-offcanvas-width: var(--app-sidebar-width); background: var(--app-navy); }
}

.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 1.35rem; color: #fff; }
.brand-title { font-weight: 700; color: #fff; }
.brand-subtitle { font-size: .75rem; color: #9fb0d0; }

.sidebar-nav { padding: .75rem; display: flex; flex-direction: column; gap: 2px; width: 100%; }
.sidebar-nav .nav-section { font-size: .7rem; color: #7f92b8; padding: 1rem .75rem .35rem; letter-spacing: .02em; }
.sidebar-nav .nav-link {
    color: #dbe3f3; border-radius: 10px; padding: .6rem .75rem; display: flex; align-items: center; gap: .65rem; font-size: .92rem;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; opacity: .85; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: #fff; color: var(--app-navy); font-weight: 600; }
.sidebar-nav .nav-link.active i { opacity: 1; }

.app-navbar {
    display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem; background: #fff;
    border-bottom: 1px solid var(--app-border); position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; color: var(--app-navy); }
.user-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--app-border); border-radius: 999px; padding: .25rem .75rem .25rem .35rem; background: #fff; }
.user-chip .avatar { width: 30px; height: 30px; border-radius: 50%; background: #eef2fb; color: var(--app-navy); display: grid; place-items: center; }

/* ---------- cards / tables ---------- */
.card { border-radius: 14px; }
.card-header { border-bottom: 1px solid var(--app-border); padding: .9rem 1.25rem; border-top-left-radius: 14px !important; border-top-right-radius: 14px !important; }
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.table thead th { font-size: .8rem; color: #5b667a; font-weight: 600; white-space: nowrap; }
.detail-list dt { color: #6b7488; font-weight: 500; }
.detail-list dd { margin-bottom: .55rem; }

.stat-card {
    display: flex; align-items: center; gap: 1rem; padding: 1.15rem 1.25rem; border-radius: 14px; background: #fff;
    box-shadow: 0 1px 2px rgba(16,24,40,.05); border: 1px solid var(--app-border); color: inherit;
}
.stat-card > i { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .8rem; color: #6b7488; }
.stat-blue > i { background: #e8effd; color: #2f5bd3; }
.stat-green > i { background: #e6f6ee; color: #1f8f55; }
.stat-purple > i { background: #f1ebfd; color: #7044c9; }
.stat-orange > i { background: #fff1e3; color: #d9730d; }

.summary-list li { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px dashed var(--app-border); }
.summary-list li:last-child { border-bottom: 0; }

.empty-state { text-align: center; padding: 3rem 1rem; color: #7b8496; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; color: #b5bfd1; }

.help-card { background: #fffdf5; }
.help-card li { line-height: 1.9; }

.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 2rem 1rem; border: 2px dashed #b9c6e3;
    border-radius: 14px; background: #f7f9fe; cursor: pointer; text-align: center; transition: .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--app-navy-2); background: #eef3ff; }
.dropzone i { font-size: 2.4rem; color: #1f8f55; }
.dropzone .dz-title { font-weight: 600; }
.dropzone .dz-hint { font-size: .8rem; color: #7b8496; }

/* ---------- employee panel ---------- */
.welcome-card {
    display: flex; align-items: center; justify-content: space-between; padding: 1.5rem 1.75rem; border-radius: 16px; color: #fff;
    background: linear-gradient(120deg, var(--app-navy) 0%, #3b63b0 100%); box-shadow: 0 10px 25px -12px rgba(31,56,100,.6);
}
.welcome-icon { font-size: 3rem; opacity: .35; }

.payslip-card {
    background: #fff; border: 1px solid var(--app-border); border-radius: 16px; padding: 1.15rem 1.25rem; height: 100%;
    display: flex; flex-direction: column; gap: 1rem; transition: box-shadow .15s, transform .15s;
}
.payslip-card:hover { box-shadow: 0 8px 24px -12px rgba(31,56,100,.35); transform: translateY(-2px); }
.payslip-card .period { font-size: 1.15rem; font-weight: 800; color: var(--app-navy); }
.payslip-card .period-badge { width: 38px; height: 38px; border-radius: 10px; background: #eef2fb; color: var(--app-navy); display: grid; place-items: center; }
.payslip-card .amounts { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; }
.payslip-card .amounts > div { display: flex; justify-content: space-between; }
.payslip-card .amounts span { color: #6b7488; }
.payslip-card .amounts .net { margin-top: .35rem; padding-top: .55rem; border-top: 1px dashed var(--app-border); font-size: 1rem; }
.payslip-card .amounts .net strong { color: #1f8f55; }

/* ---------- on-screen payslip (mirrors the PDF / Book2 template) ---------- */
.payslip-sheet { font-size: .88rem; }
.ps-company { text-align: center; font-weight: 800; font-size: 1.25rem; margin-bottom: .5rem; }
.ps-title { background: var(--app-navy); color: #fff; text-align: center; font-weight: 700; padding: .45rem; font-size: 1.05rem; }
.ps-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.ps-table td, .ps-table th { border: 1px solid #000; padding: .35rem .55rem; vertical-align: middle; }
.ps-table td { text-align: center; }
.ps-table .ps-desc { text-align: right; }
.ps-table .ps-num { text-align: center; direction: ltr; unicode-bidi: plaintext; }
.ps-label { background: #f2f2f2; font-weight: 700; text-align: right; }
.ps-sub { background: #d9e1f2; text-align: center; font-weight: 700; }
.ps-head { background: var(--app-navy); color: #fff; text-align: center; font-weight: 700; }
.ps-colhead th { background: #d9e1f2; text-align: center; }
.ps-gap td { border: 0; height: .5rem; padding: 0; }
.ps-total th, .ps-total td { background: #ddebf7; font-weight: 700; }
.ps-total th { text-align: right; }
.ps-total .ps-net { background: #fff2cc; font-size: 1rem; }

/* ---------- auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-employee { background: linear-gradient(135deg, #e8eefc 0%, #f7f9ff 55%, #e6f6ee 100%); }
.auth-admin { background: linear-gradient(135deg, #172a4d 0%, #1f3864 50%, #2a4a80 100%); }
.auth-landing { background: radial-gradient(circle at 20% 20%, #2a4a80 0%, #1f3864 45%, #121f3a 100%); color: #fff; }
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-landing .auth-wrapper { max-width: 640px; }
.auth-card { border-radius: 20px; }
.auth-icon { width: 64px; height: 64px; border-radius: 18px; display: inline-grid; place-items: center; font-size: 1.8rem; background: #e8effd; color: #2f5bd3; }
.auth-icon-admin { background: #1f3864; color: #fff; }
.auth-footer { text-align: center; font-size: .8rem; margin-top: 1.25rem; color: #8a94a6; }
.auth-admin .auth-footer, .auth-landing .auth-footer { color: rgba(255,255,255,.55); }

.landing-icon { width: 76px; height: 76px; border-radius: 22px; display: inline-grid; place-items: center; font-size: 2.2rem; background: rgba(255,255,255,.12); }
.landing-card {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 2rem 1rem; border-radius: 18px; text-decoration: none;
    background: #fff; color: #1d2433; box-shadow: 0 20px 40px -20px rgba(0,0,0,.6); transition: transform .15s;
}
.landing-card:hover { transform: translateY(-3px); color: #1d2433; }
.landing-card i { font-size: 2.3rem; color: #2f5bd3; }
.landing-card .title { font-weight: 800; font-size: 1.1rem; }
.landing-card .hint { font-size: .8rem; color: #6b7488; }
.landing-card-admin i { color: var(--app-navy); }

.app-toast { min-width: 300px; }

@media print {
    .app-sidebar, .app-navbar, .app-footer, .no-print, .toast-container, .alert { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none !important; border: 0 !important; }
    .ps-table { min-width: 0; }
    @page { size: A4 landscape; margin: 10mm; }
}
