:root {
    --bg: #090b10;
    --panel: #10141d;
    --panel-2: #151a25;
    --panel-3: #1b2230;
    --border: #252e3f;
    --text: #f5f7fb;
    --muted: #8f9aad;
    --gold: #e1b84b;
    --gold-2: #ffd879;
    --green: #54d69a;
    --red: #ff6b77;
    --blue: #6fa8ff;
    --purple: #a586ff;
    --shadow: 0 20px 55px rgba(0,0,0,.35);
    --radius: 16px;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 85% 0%, rgba(225,184,75,.08), transparent 28%),
        radial-gradient(circle at 0% 100%, rgba(111,168,255,.06), transparent 32%),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

.auth-body { display: grid; place-items: center; padding: 28px; }
.auth-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    background: rgba(16,20,29,.96);
}
.auth-brand {
    min-height: 600px;
    padding: 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        linear-gradient(145deg, rgba(225,184,75,.16), transparent 55%),
        linear-gradient(180deg, #121824, #0b0e15);
    position: relative;
    overflow: hidden;
}
.auth-brand::after {
    content: "";
    position: absolute;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    border: 55px solid rgba(225,184,75,.035);
    right: -120px;
    bottom: -120px;
}
.auth-brand h1 { font-size: clamp(34px, 5vw, 58px); line-height: 1.04; margin: 18px 0; letter-spacing: -.045em; max-width: 640px; }
.auth-brand p { color: #b1bac9; font-size: 17px; max-width: 540px; }
.auth-card { padding: 56px; display: flex; flex-direction: column; justify-content: center; background: var(--panel); }
.auth-card h2 { font-size: 30px; margin: 0 0 4px; }
.install-shell { width: min(1160px, 100%); }
.install-shell .auth-card { padding-top: 42px; padding-bottom: 42px; }
.brand-mark {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,216,121,.35);
    border-radius: 18px;
    color: var(--gold-2);
    font-weight: 900;
    font-size: 22px;
    background: linear-gradient(145deg, rgba(225,184,75,.15), rgba(225,184,75,.02));
    box-shadow: inset 0 0 25px rgba(225,184,75,.06);
}
.eyebrow { color: var(--gold) !important; font-size: 12px !important; letter-spacing: .22em; font-weight: 800; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0,1fr); min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: rgba(10,13,19,.96);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 26px; }
.sidebar-brand .brand-mark { width: 44px; height: 44px; border-radius: 13px; font-size: 16px; }
.sidebar-brand strong { display:block; letter-spacing: .06em; }
.sidebar-brand span { display:block; color: var(--muted); font-size: 12px; }
.nav-group { margin: 10px 0; }
.nav-label { display:block; padding: 0 12px 8px; color: #667184; text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    color: #aeb7c6;
    border-radius: 10px;
    margin: 3px 0;
    font-size: 14px;
    transition: .18s ease;
}
.nav-link:hover { color: #fff; background: var(--panel-2); }
.nav-link.active { color: var(--gold-2); background: linear-gradient(90deg, rgba(225,184,75,.14), rgba(225,184,75,.035)); border: 1px solid rgba(225,184,75,.15); }
.nav-icon { width: 20px; text-align:center; opacity:.95; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 18px 8px 0; }
.user-mini { display:flex; align-items:center; gap:10px; margin-bottom: 12px; }
.avatar { width: 36px; height:36px; display:grid; place-items:center; border-radius:50%; background: var(--panel-3); color:var(--gold-2); font-size:12px; font-weight:800; border:1px solid var(--border); }
.user-mini strong { display:block; font-size:13px; }
.user-mini span { display:block; color:var(--muted); font-size:11px; text-transform:capitalize; }

.main { min-width:0; }
.topbar {
    min-height: 74px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 16px 30px;
    border-bottom:1px solid var(--border);
    background:rgba(9,11,16,.76);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 8;
}
.topbar h1 { margin:0; font-size:20px; letter-spacing:-.02em; }
.topbar p { margin:2px 0 0; color:var(--muted); font-size:12px; }
.topbar-actions { display:flex; align-items:center; gap:10px; }
.content { padding: 30px; max-width: 1600px; margin: 0 auto; }

.stats-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:22px; }
.stat-card, .card {
    background: linear-gradient(180deg, rgba(21,26,37,.98), rgba(15,19,28,.98));
    border:1px solid var(--border);
    border-radius:var(--radius);
    box-shadow: 0 12px 35px rgba(0,0,0,.16);
}
.stat-card { padding:20px; position:relative; overflow:hidden; }
.stat-card::after { content:""; position:absolute; width:70px; height:70px; border-radius:50%; right:-25px; top:-25px; background:rgba(225,184,75,.05); }
.stat-card .label { color:var(--muted); font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; }
.stat-card .value { font-size:28px; font-weight:800; margin:10px 0 2px; letter-spacing:-.04em; }
.stat-card .sub { color:#788397; font-size:12px; }
.card { margin-bottom:20px; }
.card-header { display:flex; justify-content:space-between; align-items:center; gap:15px; padding:20px 22px; border-bottom:1px solid var(--border); }
.card-header h2 { font-size:16px; margin:0; }
.card-header p { margin:3px 0 0; color:var(--muted); font-size:12px; }
.card-body { padding:22px; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-sidebar { display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:20px; }

.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:14px 16px; border-bottom:1px solid var(--border); white-space:nowrap; }
th { color:#788397; text-transform:uppercase; font-size:10px; letter-spacing:.09em; font-weight:800; }
td { font-size:13px; color:#d5dbe5; }
tr:last-child td { border-bottom:0; }
tbody tr:hover { background:rgba(255,255,255,.018); }
.table-person { display:flex; align-items:center; gap:10px; }
.table-person strong { display:block; color:#fff; }
.table-person span { color:var(--muted); font-size:11px; }
.actions { display:flex; gap:7px; align-items:center; }

.btn {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    min-height:38px;
    padding:8px 14px;
    border:1px solid var(--border);
    border-radius:9px;
    background:var(--panel-2);
    color:#dce2eb;
    font-weight:700;
    font-size:12px;
    transition:.18s ease;
}
.btn:hover { transform:translateY(-1px); border-color:#3a455a; }
.btn-primary { color:#17130a; border-color:#e7c460; background:linear-gradient(180deg,#f3d675,#d9ae3e); box-shadow:0 8px 22px rgba(225,184,75,.15); }
.btn-danger { color:#ffb5bc; border-color:rgba(255,107,119,.25); background:rgba(255,107,119,.08); }
.btn-success { color:#a9f2cf; border-color:rgba(84,214,154,.25); background:rgba(84,214,154,.08); }
.btn-ghost { background:transparent; }
.btn-sm { min-height:31px; padding:5px 10px; font-size:11px; }
.btn-block { width:100%; }

label { display:block; color:#b8c1cf; font-size:12px; font-weight:700; }
input, select, textarea {
    width:100%;
    margin-top:7px;
    border:1px solid var(--border);
    border-radius:10px;
    background:#0d1119;
    color:#f5f7fb;
    padding:11px 12px;
    outline:none;
    transition:.18s ease;
}
input:focus, select:focus, textarea:focus { border-color:rgba(225,184,75,.7); box-shadow:0 0 0 3px rgba(225,184,75,.08); }
textarea { min-height:110px; resize:vertical; }
.form-grid { display:grid; gap:16px; }
.form-grid.two { grid-template-columns:repeat(2,minmax(0,1fr)); }
.form-grid.three { grid-template-columns:repeat(3,minmax(0,1fr)); }
.form-grid.four { grid-template-columns:repeat(4,minmax(0,1fr)); }
.stack-form { display:grid; gap:16px; }
.form-help { color:var(--muted); font-size:11px; margin-top:5px; }
.form-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:8px; }
.searchbar { display:flex; gap:10px; align-items:center; }
.searchbar input, .searchbar select { margin:0; min-width:180px; }

.alert { border-radius:10px; padding:12px 14px; margin-bottom:16px; font-size:13px; border:1px solid; }
.alert-success { color:#b9f5d7; background:rgba(84,214,154,.08); border-color:rgba(84,214,154,.22); }
.alert-error { color:#ffc2c7; background:rgba(255,107,119,.08); border-color:rgba(255,107,119,.22); }
.alert-info { color:#c4dbff; background:rgba(111,168,255,.08); border-color:rgba(111,168,255,.22); }
.muted { color:var(--muted); }
.badge { display:inline-flex; align-items:center; padding:4px 8px; border-radius:999px; font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.05em; border:1px solid; }
.badge-active, .badge-paid, .badge-approved { color:#9ce9c4; border-color:rgba(84,214,154,.25); background:rgba(84,214,154,.08); }
.badge-inactive, .badge-draft { color:#c3cad5; border-color:#394256; background:rgba(143,154,173,.08); }
.badge-admin { color:#ffe5a1; border-color:rgba(225,184,75,.3); background:rgba(225,184,75,.08); }
.badge-payroll { color:#c9baff; border-color:rgba(165,134,255,.3); background:rgba(165,134,255,.08); }
.badge-employee { color:#bdd5ff; border-color:rgba(111,168,255,.3); background:rgba(111,168,255,.08); }

.pay-summary { display:grid; gap:0; }
.pay-row { display:flex; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--border); font-size:13px; }
.pay-row.total { font-size:17px; font-weight:800; color:var(--gold-2); border-bottom:0; padding-top:16px; }
.progress-list { display:grid; gap:14px; }
.progress-item-head { display:flex; justify-content:space-between; font-size:12px; margin-bottom:7px; }
.progress-track { height:7px; background:#0b0f16; border-radius:999px; overflow:hidden; }
.progress-fill { height:100%; background:linear-gradient(90deg,var(--gold),var(--gold-2)); border-radius:999px; }
.empty-state { text-align:center; padding:46px 20px; color:var(--muted); }
.empty-state h3 { color:#fff; margin-bottom:8px; }

.payslip { max-width:900px; margin:0 auto; background:#fff; color:#1c2430; border-radius:16px; overflow:hidden; }
.payslip-head { background:#111722; color:#fff; padding:34px; display:flex; justify-content:space-between; gap:20px; }
.payslip-head h1 { margin:4px 0; font-size:28px; }
.payslip-body { padding:34px; }
.payslip-meta { display:grid; grid-template-columns:1fr 1fr; gap:24px; margin-bottom:28px; }
.payslip table th { color:#687486; background:#f3f5f8; }
.payslip table td, .payslip table th { border-color:#e3e7ed; }
.payslip-total { margin-left:auto; max-width:360px; margin-top:24px; }
.payslip-total .pay-row { border-color:#e3e7ed; }
.payslip-total .total { color:#7b5d09; }
.payslip-foot { color:#687486; border-top:1px solid #e4e8ee; margin-top:28px; padding-top:18px; font-size:12px; }

.mobile-menu { display:none; }
@media (max-width:1100px) {
    .stats-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .grid-sidebar { grid-template-columns:1fr; }
    .form-grid.four { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:820px) {
    .auth-shell { grid-template-columns:1fr; }
    .auth-brand { min-height:auto; padding:42px; }
    .auth-card { padding:40px; }
    .app-shell { display:block; }
    .sidebar { position:fixed; left:-270px; width:250px; transition:.2s ease; box-shadow:var(--shadow); }
    .sidebar.open { left:0; }
    .mobile-menu { display:inline-flex; }
    .topbar { padding:14px 18px; }
    .content { padding:20px 16px; }
    .grid-2, .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns:1fr; }
    .payslip-meta { grid-template-columns:1fr; }
}
@media (max-width:520px) {
    .stats-grid { grid-template-columns:1fr; }
    .auth-body { padding:0; }
    .auth-shell { border-radius:0; min-height:100vh; }
    .auth-brand { padding:32px 24px; }
    .auth-card { padding:32px 24px; }
    .topbar-actions .desktop-only { display:none; }
}
@media print {
    body { background:#fff; }
    .sidebar, .topbar, .no-print, .alert { display:none !important; }
    .app-shell { display:block; }
    .content { padding:0; max-width:none; }
    .payslip { box-shadow:none; border-radius:0; max-width:none; }
}

/* Payroll v2 visibility and email controls */
.auth-link { color: var(--gold-2); font-size: 12px; font-weight: 700; }
.auth-link:hover { text-decoration: underline; }
.checkbox-row { display:flex; align-items:center; gap:10px; min-height:42px; padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:#0d1119; color:#dce2eb; }
.checkbox-row input { width:auto; margin:0; }
.wrap-cell { white-space:normal; min-width:260px; max-width:520px; }

/* Keep payslip text dark and readable against the white paper. */
.payslip,
.payslip-body,
.payslip-body h1,
.payslip-body h2,
.payslip-body h3,
.payslip-body p,
.payslip-body div,
.payslip-body span,
.payslip-body strong { color:#1c2430; }
.payslip .muted { color:#657287; }
.payslip table td { color:#253043; background:#fff; }
.payslip table th { color:#526075; background:#f1f4f8; }
.payslip table tbody tr:hover { background:transparent; }
.payslip-total .pay-row,
.payslip-total .pay-row span,
.payslip-total .pay-row strong { color:#1c2430; }
.payslip-total .pay-row.total,
.payslip-total .pay-row.total span,
.payslip-total .pay-row.total strong { color:#7b5d09; }
.payslip-foot,
.payslip-foot strong { color:#5f6b7d; }
.payslip-head div,
.payslip-head strong,
.payslip-head h1 { color:#fff; }
.payslip-head .eyebrow { color:var(--gold) !important; }


/* Payroll v3 branding, welcome, and self-service profiles */
.brand-image-mark { overflow:hidden; padding:0; background:#0d1119; }
.brand-image-mark img { width:100%; height:100%; object-fit:contain; display:block; }
.brand-logo { display:block; max-width:240px; max-height:72px; object-fit:contain; }
.auth-logo { display:block; max-width:280px; max-height:100px; object-fit:contain; position:relative; z-index:1; }
.topbar-profile { display:inline-flex; border-radius:50%; }
.avatar-photo { overflow:hidden; padding:0; }
.avatar-photo img { width:100%; height:100%; object-fit:cover; display:block; }
.avatar-xl { width:58px; height:58px; font-size:17px; flex:0 0 58px; }
.avatar-profile { width:104px; height:104px; font-size:28px; flex:0 0 104px; }
.welcome-banner {
    display:flex; align-items:center; justify-content:space-between; gap:20px;
    margin-bottom:22px; padding:24px;
    border:1px solid rgba(225,184,75,.2); border-radius:var(--radius);
    background:linear-gradient(120deg, rgba(225,184,75,.14), rgba(21,26,37,.98) 58%, rgba(111,168,255,.06));
    box-shadow:0 12px 35px rgba(0,0,0,.16);
}
.welcome-user { display:flex; align-items:center; gap:16px; min-width:0; }
.welcome-user h2 { margin:3px 0 2px; font-size:24px; letter-spacing:-.025em; }
.welcome-user p { margin:0; color:#aeb7c6; }
.profile-photo-row { display:grid; grid-template-columns:auto minmax(0,1fr); gap:22px; align-items:start; }
.profile-photo-row p { margin:4px 0 12px; }
.profile-summary-card { text-align:center; position:sticky; top:95px; }
.profile-summary-card .avatar-profile { margin:0 auto 14px; }
.profile-summary-card h2 { margin:0 0 4px; }
.profile-summary-card p { color:var(--muted); margin:0 0 12px; overflow-wrap:anywhere; }
.checkbox-row.compact { display:inline-flex; width:auto; min-height:34px; padding:7px 10px; margin-top:10px; }
.branding-grid { display:grid; grid-template-columns:1.5fr 1fr 1fr; gap:16px; }
.upload-tile { display:flex; flex-direction:column; gap:8px; padding:14px; border:1px solid var(--border); border-radius:12px; background:#0d1119; }
.upload-tile > span:first-child { color:#dce2eb; }
.upload-tile input[type=file] { margin:0; padding:9px; }
.upload-tile small { color:var(--muted); font-weight:500; }
.upload-preview { min-height:96px; display:grid; place-items:center; border:1px dashed #364155; border-radius:10px; background:#111722; overflow:hidden; color:var(--gold-2); }
.upload-preview.square { width:96px; }
.upload-preview.square.small { width:72px; min-height:72px; }
.upload-preview img { width:100%; height:96px; object-fit:contain; display:block; }
.upload-preview.square img { height:96px; object-fit:cover; }
.upload-preview.square.small img { height:72px; }
.payslip-brand { display:flex; align-items:center; gap:18px; margin-bottom:8px; }
.payslip-logo { max-width:190px; max-height:54px; object-fit:contain; display:block; }

@media (max-width:900px) {
    .branding-grid { grid-template-columns:1fr; }
    .upload-preview.square, .upload-preview.square.small { width:100%; }
}
@media (max-width:620px) {
    .welcome-banner { align-items:flex-start; flex-direction:column; }
    .profile-photo-row { grid-template-columns:1fr; }
    .payslip-brand { align-items:flex-start; flex-direction:column; }
}
