/* PayrollPro - hand-written CSS, no framework */

:root {
    --color-bg: #f4f6fc;
    --color-surface: #ffffff;
    --color-border: #eaedf6;
    --color-border-strong: #dde1ee;
    --color-text: #1a2033;
    --color-text-muted: #8891a6;
    --color-text-faint: #aab1c2;

    --color-primary: #4a63f5;
    --color-primary-dark: #3549d6;
    --color-primary-light: #eef1ff;

    --color-success: #12b76a;
    --color-success-bg: #e6f9f0;
    --color-danger: #f04438;
    --color-danger-bg: #fdecea;
    --color-warning: #f79009;
    --color-warning-bg: #fef3e2;
    --color-purple: #8b5cf6;
    --color-purple-bg: #f2ecff;
    --color-orange: #f79009;
    --color-orange-bg: #fff1de;

    --sidebar-width: 244px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 20px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 10px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 10px 30px rgba(20, 28, 55, 0.08);
    --shadow-lg: 0 24px 60px rgba(20, 28, 55, 0.16);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }

.app-shell { display: flex; height: 100vh; }

/* ------------------------------------------------------------ */
/* Sidebar                                                       */
/* ------------------------------------------------------------ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    color: var(--color-text);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px 26px;
}
.sidebar-brand .brand-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary), #7b8cf9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 99, 245, .35);
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-brand .brand-name { font-weight: 800; font-size: 16.5px; color: var(--color-text); letter-spacing: -.01em; }
.sidebar-brand .brand-tagline { font-size: 10.5px; color: var(--color-text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #5c6478;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}
.sidebar-nav a svg { flex-shrink: 0; opacity: .85; }
.sidebar-nav a:hover { background: #f4f6fc; color: var(--color-text); }
.sidebar-nav a.active { background: var(--color-primary-light); color: var(--color-primary); }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    color: #5c6478;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.sidebar-group-toggle svg:first-child { flex-shrink: 0; opacity: .85; }
.sidebar-group-toggle:hover { background: #f4f6fc; color: var(--color-text); }
.sidebar-group-toggle.has-active { color: var(--color-primary); font-weight: 700; }
.sidebar-group-toggle .group-chevron { margin-left: auto; flex-shrink: 0; color: var(--color-text-faint); transition: transform .18s; }
.sidebar-group-toggle.expanded .group-chevron { transform: rotate(180deg); }

.sidebar-group {
    max-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
    transition: max-height .22s ease;
}
.sidebar-group.open { max-height: 400px; }

.sidebar-subitem {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px 8px 42px;
    border-radius: var(--radius-sm);
    color: #6b7284;
    font-weight: 600;
    font-size: 12.5px;
    transition: background .15s, color .15s;
}
.sidebar-subitem::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .5; flex-shrink: 0; }
.sidebar-subitem:hover { background: #f4f6fc; color: var(--color-text); }
.sidebar-subitem.active { background: var(--color-primary-light); color: var(--color-primary); }
.sidebar-subitem.active::before { opacity: 1; }

.sidebar-promo {
    margin-top: 18px;
    border-radius: var(--radius);
    padding: 18px 16px;
    background: linear-gradient(160deg, #171d3a, #232c58);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.sidebar-promo::after {
    content: "";
    position: absolute;
    width: 120px; height: 120px;
    background: radial-gradient(circle, rgba(123,140,249,.35), transparent 70%);
    top: -40px; right: -40px;
}
.sidebar-promo p { margin: 0 0 12px; font-size: 12.5px; font-weight: 700; line-height: 1.4; position: relative; }
.sidebar-promo span { display: block; font-size: 10.5px; font-weight: 500; color: #b7bfe6; margin-top: 4px; }
.sidebar-promo .promo-arrow {
    width: 30px; height: 30px; border-radius: 50%;
    background: rgba(255,255,255,.12);
    display: flex; align-items: center; justify-content: center;
    position: relative;
}

.sidebar-footer { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--color-border); }
.logout-link { display: flex; align-items: center; gap: 10px; color: #8891a6; padding: 10px 12px; font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm); transition: background .15s, color .15s; }
.logout-link:hover { color: var(--color-danger); background: var(--color-danger-bg); }

/* ------------------------------------------------------------ */
/* Main / Topbar                                                 */
/* ------------------------------------------------------------ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-shrink: 0;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 9px 16px;
    color: var(--color-text-faint);
}
.topbar-search svg { flex-shrink: 0; }
.topbar-search span { font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--color-bg); border-color: var(--color-border-strong); }
.icon-btn .notif-dot {
    position: absolute; top: 8px; right: 9px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--color-danger);
    border: 1.5px solid #fff;
}
.topbar-user { display: flex; align-items: center; gap: 10px; padding-left: 4px; cursor: default; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13.5px; color: #fff; flex-shrink: 0;
    background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
}
.topbar-user-info { text-align: left; line-height: 1.25; }
.user-name { display: block; font-weight: 700; font-size: 13.5px; }
.user-role { display: block; font-size: 11.5px; color: var(--color-text-muted); }

.content { padding: 26px 28px 60px; flex: 1; overflow-y: auto; }
.page-greeting { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.greeting-eyebrow { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-warning); margin-bottom: 6px; }
.page-greeting h1 { font-size: 25px; margin: 0 0 4px; font-weight: 800; letter-spacing: -.015em; }
.page-greeting p { margin: 0; color: var(--color-text-muted); font-size: 13.5px; }
.period-pill {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 999px; padding: 10px 16px; font-weight: 700; font-size: 13px;
    box-shadow: var(--shadow); color: var(--color-text);
}

/* ------------------------------------------------------------ */
/* Cards / panels                                                 */
/* ------------------------------------------------------------ */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.panel-header h2 { font-size: 15.5px; margin: 0; font-weight: 800; }
.panel-header p.hint { margin: 2px 0 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.stat-card .stat-label { font-size: 13px; color: var(--color-text-muted); font-weight: 700; }
.stat-card .stat-value { font-size: 25px; font-weight: 800; letter-spacing: -.01em; }
.stat-card .stat-trend { font-size: 12px; font-weight: 700; margin-top: 6px; display: flex; align-items: center; gap: 4px; color: var(--color-text-muted); }
.stat-card .stat-trend.up { color: var(--color-success); }
.stat-card .stat-trend.down { color: var(--color-danger); }
.stat-card .stat-more { color: var(--color-text-faint); cursor: default; }

.icon-badge {
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-badge.blue { background: var(--color-primary-light); color: var(--color-primary); }
.icon-badge.purple { background: var(--color-purple-bg); color: var(--color-purple); }
.icon-badge.green { background: var(--color-success-bg); color: var(--color-success); }
.icon-badge.orange { background: var(--color-orange-bg); color: var(--color-orange); }
.icon-badge.red { background: #fde8e8; color: #e0393e; }
.icon-badge.sm { width: 34px; height: 34px; border-radius: 10px; }

/* Payroll overview chart panel */
.overview-grid { display: grid; grid-template-columns: 2.1fr 1fr; gap: 20px; align-items: stretch; margin-bottom: 20px; }
.chart-figures { display: flex; flex-direction: column; gap: 16px; padding-top: 6px; }
.chart-figure { display: flex; align-items: center; gap: 12px; }
.chart-figure-label { font-size: 12.5px; color: var(--color-text-muted); font-weight: 600; }
.chart-figure-value { font-size: 16px; font-weight: 800; margin-top: 1px; }
.chart-wrap { position: relative; }
.chart-tooltip {
    position: absolute;
    background: var(--color-text);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 8px;
    transform: translate(-50%, -130%);
    white-space: nowrap;
    pointer-events: none;
}
.chart-tooltip::after {
    content: "";
    position: absolute;
    left: 50%; bottom: -4px; transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-text);
}

.quick-actions-list { display: flex; flex-direction: column; gap: 4px; }
.quick-action-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border-radius: var(--radius-sm);
    transition: background .15s;
    color: var(--color-text);
}
.quick-action-item:hover { background: var(--color-bg); }
.quick-action-item .qa-title { font-weight: 700; font-size: 13px; }
.quick-action-item .qa-sub { font-size: 11.5px; color: var(--color-text-muted); }
.quick-action-item .qa-arrow { margin-left: auto; color: var(--color-text-faint); }

.period-row-icon {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--color-primary-light); color: var(--color-primary);
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 10px; flex-shrink: 0;
}
.period-cell { display: flex; align-items: center; }
.period-cell-text .period-main { font-weight: 700; }
.period-cell-text .period-sub { font-size: 11.5px; color: var(--color-text-muted); }

/* ------------------------------------------------------------ */
/* Forms                                                          */
/* ------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 700; color: #374151; }
.form-group .hint { font-size: 12px; color: var(--color-text-muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=file], select, textarea {
    padding: 10px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 99, 245, 0.14);
}
textarea { resize: vertical; min-height: 70px; }
.field-error { color: var(--color-danger); font-size: 12px; }
p.hint { font-size: 12.5px; color: var(--color-text-muted); line-height: 1.55; }

/* ------------------------------------------------------------ */
/* Buttons                                                        */
/* ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 17px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .1s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #5972ff, var(--color-primary)); color: #fff; box-shadow: 0 1px 2px rgba(74,99,245,.15), 0 4px 10px rgba(74,99,245,.22); }
.btn-primary:hover { background: linear-gradient(180deg, #4d66f9, var(--color-primary-dark)); box-shadow: 0 6px 16px rgba(74,99,245,.32); }
.btn-secondary { background: #fff; color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-bg); border-color: #c7cde0; }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #f9c9c4; }
.btn-danger:hover { background: #fbdad6; }
.btn-ghost { background: transparent; color: var(--color-text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-xs { padding: 5px 10px; font-size: 11.5px; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-icon-only { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 9px; }

/* ------------------------------------------------------------ */
/* Tables                                                          */
/* ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th { color: var(--color-text-muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
.kebab-btn { background: none; border: none; color: var(--color-text-faint); cursor: pointer; padding: 6px; border-radius: 7px; }
.kebab-btn:hover { background: var(--color-bg); color: var(--color-text); }

/* ------------------------------------------------------------ */
/* Badges / chips                                                  */
/* ------------------------------------------------------------ */
.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-muted { background: #eef0f6; color: var(--color-text-muted); }

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700;
    background: var(--color-bg); color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}
.chip.chip-active { background: var(--color-primary-light); color: var(--color-primary); border-color: transparent; }
.chip.chip-muted { color: var(--color-text-faint); }
button.chip { font-family: inherit; cursor: pointer; }

/* ------------------------------------------------------------ */
/* Alerts / flash                                                  */
/* ------------------------------------------------------------ */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; font-weight: 600; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.alert-info { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ------------------------------------------------------------ */
/* Login / install pages                                           */
/* ------------------------------------------------------------ */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #10142b, #212d63); padding: 20px; }
.auth-card { background: #fff; border-radius: var(--radius-lg); padding: 38px 34px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card h1 { font-size: 21px; margin: 0 0 4px; font-weight: 800; }
.auth-card p.subtitle { color: var(--color-text-muted); margin: 0 0 22px; font-size: 13.5px; }
.install-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.install-steps span { flex: 1; height: 4px; border-radius: 999px; background: var(--color-border); }
.install-steps span.done { background: var(--color-primary); }

/* ------------------------------------------------------------ */
/* Settings - tabs (premium segmented-control style)               */
/* ------------------------------------------------------------ */
.tabs {
    display: inline-flex;
    gap: 2px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tab-button {
    background: none;
    border: none;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: background .15s, color .15s, box-shadow .15s;
}
.tab-button:hover { color: var(--color-text); }
.tab-button.active { color: var(--color-text); background: #fff; box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.tab-panel { display: none; animation: fadeIn .18s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
}

/* Branding uploads - styled like a modern SaaS upload card */
.upload-box {
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1.5px dashed var(--color-border-strong);
    border-radius: var(--radius);
    padding: 16px;
    background: #fafbff;
    transition: border-color .15s, background .15s;
}
.upload-box:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.upload-box .upload-preview {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    background: #fff;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.upload-box .upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-box .upload-preview svg { color: var(--color-text-faint); }
.upload-box .upload-info { flex: 1; min-width: 0; }
.upload-box .upload-info .upload-title { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.upload-box .upload-info .upload-filename { font-size: 12px; color: var(--color-text-muted); word-break: break-all; }
.upload-box .upload-action { flex-shrink: 0; }
.upload-box input[type=file] { display: none; }
.upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: #fff;
    border: 1px solid var(--color-border-strong);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}
.upload-label:hover { background: var(--color-bg); }

.branding-preview { display: none; }

/* Toggle switch (nicer than a bare checkbox for on/off rules) */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--color-border-strong); border-radius: 999px; cursor: pointer; transition: background .15s;
}
.toggle-slider::before {
    content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Buttons - loading state */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
    content: "";
    position: absolute;
    width: 15px; height: 15px;
    top: 50%; left: 50%;
    margin: -7.5px 0 0 -7.5px;
    border: 2px solid rgba(255,255,255,.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin .6s linear infinite;
}
.btn-secondary.btn-loading::after { border-color: rgba(74,99,245,.25); border-top-color: var(--color-primary); }
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 13px 14px;
    box-shadow: 0 10px 30px rgba(16,24,40,.15), 0 2px 6px rgba(16,24,40,.08);
    border-left: 4px solid var(--color-primary);
    opacity: 0;
    transform: translateX(24px);
    transition: opacity .22s ease, transform .22s ease;
}
.toast-visible { opacity: 1; transform: translateX(0); }
.toast-leaving { opacity: 0; transform: translateX(24px); }
.toast-success { border-left-color: var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info { border-left-color: var(--color-primary); }
.toast-info .toast-icon { color: var(--color-primary); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-message { flex: 1; font-size: 13px; line-height: 1.45; color: var(--color-text); padding-top: 1px; }
.toast-close { background: none; border: none; color: var(--color-text-muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 0 0 6px; flex-shrink: 0; }
.toast-close:hover { color: var(--color-text); }

/* ------------------------------------------------------------ */
/* Modals (confirm dialog + the payroll Adjust modal share this)   */
/* ------------------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16,20,35,0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    transition: background .18s ease, visibility .18s;
    padding: 20px;
    /* Closed by default: even though display stays "flex" (so the
       background-fade transition can play), it must NOT sit on top of
       the page capturing clicks/hovering everywhere - that silently
       "freezes" the whole page (nothing clickable) until a modal is
       opened at least once. Only .modal-visible turns it back on. */
    visibility: hidden;
    pointer-events: none;
}
.modal-overlay.modal-visible { background: rgba(16,20,35,.5); visibility: visible; pointer-events: auto; }
.modal-card {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 380px;
    margin: 20px;
    box-shadow: var(--shadow-lg);
    transform: scale(.94) translateY(8px);
    opacity: 0;
    transition: transform .18s ease, opacity .18s ease;
}
.modal-overlay.modal-visible .modal-card { transform: scale(1) translateY(0); opacity: 1; }
.modal-body { padding: 26px 24px 10px; }
.modal-body p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--color-text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 24px; }

/* Adjust modal (Tax + LOP + Reimbursements + Deductions) - wider card */
.modal-card.modal-lg { max-width: 620px; }
.adjust-modal-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 22px 24px 0;
}
.adjust-modal-header h3 { margin: 0 0 3px; font-size: 16.5px; font-weight: 800; }
.adjust-modal-header p { margin: 0; font-size: 12.5px; color: var(--color-text-muted); }
.adjust-modal-close { background: var(--color-bg); border: none; width: 32px; height: 32px; border-radius: 50%; color: var(--color-text-muted); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.adjust-modal-close:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.adjust-modal-body { padding: 18px 24px 4px; max-height: 62vh; overflow-y: auto; }
.adjust-section { border-top: 1px solid var(--color-border); }
.adjust-section:first-child { border-top: none; }
.adjust-section-title {
    display: flex; align-items: center; gap: 9px;
    font-size: 13.5px; font-weight: 800;
    padding: 14px 2px;
    cursor: pointer;
    user-select: none;
}
.adjust-section-title .icon-badge { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }
.adjust-section-title .adjust-section-summary {
    margin-left: auto;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.adjust-section-title .adjust-chevron {
    flex-shrink: 0;
    color: var(--color-text-faint);
    transition: transform .15s;
}
.adjust-section.open .adjust-chevron { transform: rotate(180deg); }
.adjust-section-body {
    display: none;
    padding: 0 2px 16px;
}
.adjust-section.open .adjust-section-body { display: block; }

.tax-options { display: flex; flex-direction: column; gap: 8px; }
.tax-option {
    display: flex; align-items: center; gap: 10px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.tax-option:hover { border-color: var(--color-border-strong); }
.tax-option.selected { border-color: var(--color-primary); background: var(--color-primary-light); }
.tax-option input[type=radio] { margin: 0; accent-color: var(--color-primary); flex-shrink: 0; }
.tax-option-label { font-size: 13px; font-weight: 700; flex: 1; }
.tax-option-sub { font-size: 11.5px; color: var(--color-text-muted); font-weight: 500; }
.tax-option input[type=number] {
    width: 100px; padding: 7px 9px; font-size: 12.5px; flex-shrink: 0;
}

.adj-row-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.adj-row {
    display: flex; gap: 8px; align-items: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px;
}
.adj-row input[type=text] { flex: 1.4; min-width: 0; font-size: 12.5px; padding: 7px 9px; }
.adj-row input[type=number] { flex: 0.7; min-width: 0; font-size: 12.5px; padding: 7px 9px; }
.adj-row select { flex: 0.8; min-width: 0; font-size: 12px; padding: 6px 6px; }
.adj-row-remove {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: none;
    border-radius: 7px;
    width: 26px;
    height: 26px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 15px;
}
.adj-row-remove:hover { background: #fbdad6; }
.adj-empty-hint { font-size: 12px; color: var(--color-text-faint); padding: 4px 2px 8px; }

/* ------------------------------------------------------------ */
/* Payroll generation table                                       */
/* ------------------------------------------------------------ */
.payroll-gen-table th, .payroll-gen-table td { white-space: normal; vertical-align: middle; }

/* Selection checkboxes (payroll generation table + payroll run breakdown
   table) - bigger, on-brand, and a narrow fixed-width first column so
   they stay compact and vertically centred no matter how tall a row
   gets (e.g. a row with an "Already generated" badge under the name). */
.employee-check, .item-check, #selectAllEmployees, #selectAllItems {
    width: 17px;
    height: 17px;
    accent-color: var(--color-primary);
    cursor: pointer;
    vertical-align: middle;
}
.payroll-gen-table td:first-child, .payroll-gen-table th:first-child,
#breakdownTable td:first-child, #breakdownTable th:first-child {
    width: 36px;
    text-align: center;
    vertical-align: middle;
}
.emp-cell { display: flex; align-items: center; gap: 10px; }
.emp-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11.5px; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
}
.emp-name { font-weight: 700; }
.emp-code { font-size: 11.5px; color: var(--color-text-muted); }
.chip-group { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-btn { cursor: pointer; border: 1px solid var(--color-border); background: var(--color-surface); }
.chip-btn:hover { border-color: var(--color-primary); }
.adjust-btn { display: inline-flex; align-items: center; gap: 6px; }

#payrollContent { position: relative; min-height: 120px; }
#payrollContent.is-loading { opacity: .45; pointer-events: none; transition: opacity .15s; }
.inline-spinner {
    display: inline-block; width: 15px; height: 15px;
    border: 2px solid rgba(74,99,245,.25); border-top-color: var(--color-primary);
    border-radius: 50%; animation: btnSpin .6s linear infinite;
}

footer.page-footer { text-align: center; color: var(--color-text-muted); font-size: 12px; padding: 20px 0 0; }

.sidebar-toggle-btn { display: none; }

@media (max-width: 880px) {
    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 20; transition: left .2s; box-shadow: var(--shadow-lg); }
    .sidebar.open { left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
    .overview-grid { grid-template-columns: 1fr; }
    .sidebar-toggle-btn { display: flex; }
}
