:root {
    --impact-burgundy: #8b143a;
    --impact-burgundy-dark: #64102a;
    --impact-navy: #2b1b22;
    --impact-navy-light: #4a303b;
    --impact-gold: #d6a24a;
    --impact-cream: #faf6f7;
    --surface: #ffffff;
    --surface-muted: #faf6f7;
    --text: #261b20;
    --muted: #6f5d65;
    --border: #eadde2;
    --success: #198754;
    --danger: #c62828;
    --warning: #a15c00;
    --shadow: 0 12px 34px rgba(139, 20, 58, 0.10);
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--surface-muted);
}

a { color: var(--impact-burgundy); text-decoration: none; }
a:hover { color: var(--impact-burgundy-dark); }

button, input, select, textarea { font: inherit; }

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

.sidebar {
    width: 260px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--impact-navy) 0%, #2b1b22 100%);
    color: #fff;
    box-shadow: 10px 0 30px rgba(100, 16, 42, 0.16);
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 18px;
    background: rgba(255,255,255,.05);
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand img {
    width: 62px;
    height: 42px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
}

.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { display: block; color: rgba(255,255,255,.66); margin-top: 3px; }

.sidebar-nav { padding: 18px 12px; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.78);
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 6px;
    transition: .18s ease;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav a.active {
    color: #fff;
    background: linear-gradient(135deg, var(--impact-burgundy), #d22764);
    box-shadow: 0 8px 20px rgba(180,20,75,.28);
}
.nav-icon { width: 22px; text-align: center; font-size: 18px; }
.nav-section {
    padding: 18px 14px 8px;
    font-size: 11px;
    color: rgba(255,255,255,.44);
    text-transform: uppercase;
    letter-spacing: .11em;
}
.sidebar-footer { margin-top: auto; padding: 18px; color: rgba(255,255,255,.45); }

.main-panel { min-width: 0; flex: 1; margin-left: 260px; display: flex; flex-direction: column; }

.topbar {
    min-height: 82px;
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 28px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.menu-toggle {
    display: none;
    border: 0;
    background: var(--surface-muted);
    color: var(--impact-navy);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
}

.topbar-title { min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 23px; color: var(--impact-navy); }
.topbar-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--impact-burgundy), #d62b69);
    color: #fff; font-weight: 800;
}
.user-meta strong, .user-meta small { display: block; }
.user-meta small { color: var(--muted); margin-top: 2px; }

.content { width: 100%; max-width: 1540px; margin: 0 auto; padding: 28px; flex: 1; }
.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 28px;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card + .card { margin-top: 22px; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, #fbfbfd);
}
.card-header h2, .card-header h3 { margin: 0; color: var(--impact-navy); }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border); background: #fbfbfd; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}
.kpi-card {
    position: relative;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.kpi-card::after {
    content: "";
    position: absolute;
    width: 120px; height: 120px;
    right: -45px; top: -55px;
    border-radius: 50%;
    background: rgba(180,20,75,.07);
}
.kpi-card .kpi-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-card .kpi-value { margin-top: 8px; color: var(--impact-navy); font-size: 28px; font-weight: 800; }
.kpi-card .kpi-foot { margin-top: 10px; font-size: 12px; color: var(--muted); }
.kpi-card.accent { border-top: 4px solid var(--impact-burgundy); }
.kpi-card.navy { border-top: 4px solid var(--impact-navy); }
.kpi-card.gold { border-top: 4px solid var(--impact-gold); }
.kpi-card.green { border-top: 4px solid var(--success); }

.grid-two { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; }
.grid-equal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th {
    color: var(--impact-navy);
    background: #faf6f7;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
td { font-size: 14px; }
tbody tr:hover { background: #fcfafb; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-burgundy { color: var(--impact-burgundy); }
.nowrap { white-space: nowrap; }

.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
}
.toolbar .grow { flex: 1 1 220px; }

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 10px 15px;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--impact-burgundy), #d42665); box-shadow: 0 7px 16px rgba(180,20,75,.18); }
.btn-primary:hover { color: #fff; background: linear-gradient(135deg, var(--impact-burgundy-dark), var(--impact-burgundy)); }
.btn-navy { color: #fff; background: var(--impact-navy); }
.btn-navy:hover { color: #fff; background: var(--impact-navy-light); }
.btn-success { color: #fff; background: var(--success); }
.btn-danger { color: #fff; background: var(--danger); }
.btn-warning { color: #fff; background: var(--warning); }
.btn-light { color: var(--impact-navy); background: #fff; border-color: var(--border); }
.btn-light:hover { color: var(--impact-burgundy); border-color: #d5afbd; }
.btn-small { padding: 7px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

label { display: block; font-weight: 600; color: var(--impact-navy); }
label > span { display: block; margin-bottom: 7px; font-size: 13px; }

input, select, textarea {
    width: 100%;
    border: 1px solid #ced3dd;
    border-radius: 9px;
    padding: 11px 12px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--impact-burgundy);
    box-shadow: 0 0 0 3px rgba(180,20,75,.09);
}
textarea { min-height: 100px; resize: vertical; }
.form-grid { display: grid; gap: 16px; margin-bottom: 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)); }
.help-text { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }

.alert {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 14px;
}
.alert-success { background: #e9f7f0; color: #11613d; border-color: #bfe6d1; }
.alert-danger { background: #fff0f0; color: #9c1b1b; border-color: #f0c3c3; }
.alert-warning { background: #fff8e8; color: #805000; border-color: #eed69f; }
.alert-info { background: #faf1f4; color: #64102a; border-color: #e5cbd4; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}
.badge-success { background: #e5f6ed; color: #16683f; }
.badge-danger { background: #fde9e9; color: #a31e1e; }
.badge-warning { background: #fff3d6; color: #825300; }
.badge-navy { background: #f5e9ed; color: var(--impact-navy); }
.badge-muted { background: #faf6f7; color: #5f6672; }

.empty-state {
    padding: 45px 20px;
    text-align: center;
    color: var(--muted);
}
.empty-state strong { display: block; color: var(--impact-navy); font-size: 18px; margin-bottom: 7px; }

.upload-zone {
    border: 2px dashed #d7bac5;
    border-radius: 14px;
    background: linear-gradient(180deg, #fff, #fff9fb);
    padding: 28px;
    text-align: center;
}
.upload-zone input { max-width: 520px; margin: 15px auto; }
.upload-zone strong { display: block; color: var(--impact-navy); font-size: 18px; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.pagination a, .pagination span {
    min-width: 36px;
    padding: 8px 10px;
    border-radius: 7px;
    border: 1px solid var(--border);
    text-align: center;
    font-size: 13px;
}
.pagination .active { color: #fff; background: var(--impact-burgundy); border-color: var(--impact-burgundy); }

.stat-list { display: grid; gap: 11px; }
.stat-row { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-row span { color: var(--muted); }
.stat-row strong { color: var(--impact-navy); }

.progress-bar { height: 9px; border-radius: 99px; overflow: hidden; background: #eceef3; }
.progress-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--impact-burgundy), #dc3b72); }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px;
    background:
        radial-gradient(circle at 10% 15%, rgba(180,20,75,.13), transparent 32%),
        radial-gradient(circle at 90% 10%, rgba(31,36,84,.14), transparent 30%),
        #f5f6fa;
}
.auth-shell { width: min(960px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
.install-shell { width: min(1080px, 100%); }
.auth-brand {
    border-radius: 20px;
    padding: 42px;
    color: #fff;
    background: linear-gradient(145deg, var(--impact-navy), #2b1b22);
    box-shadow: var(--shadow);
}
.auth-brand img { width: 200px; max-width: 100%; background: #fff; border-radius: 12px; padding: 10px; }
.auth-brand h1 { margin: 32px 0 10px; font-size: 34px; }
.auth-brand p { color: rgba(255,255,255,.72); line-height: 1.7; }
.auth-card {
    border-radius: 20px;
    padding: 34px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 18px; color: var(--impact-navy); }
.auth-card label { margin-bottom: 16px; }

.invoice-preview-shell { background: #faf6f7; min-height: 100vh; padding: 20px; }
.invoice-toolbar {
    max-width: 1040px;
    margin: 0 auto 16px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.invoice-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 15mm;
    background: #fff;
    box-shadow: 0 14px 45px rgba(139,20,58,.16);
    color: #261b20;
}
.invoice-head { display: flex; justify-content: space-between; gap: 25px; align-items: flex-start; border-bottom: 4px solid var(--impact-burgundy); padding-bottom: 16px; }
.invoice-head img { width: 185px; }
.invoice-company { text-align: right; }
.invoice-company h1 { margin: 0; color: var(--impact-burgundy-dark); font-size: 20px; text-transform: uppercase; }
.invoice-company p { margin: 5px 0 0; font-size: 12px; color: #6F5D65; }
.invoice-meta-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; margin: 22px 0; }
.invoice-box { border: 1px solid #eadde2; border-radius: 10px; padding: 15px; background: #fbfbfd; }
.invoice-box .label { font-size: 10px; color: var(--impact-burgundy); text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.invoice-box strong { display: block; margin-top: 7px; color: var(--impact-burgundy-dark); font-size: 15px; }
.invoice-subject { margin: 18px 0; border-radius: 9px; padding: 12px 16px; color: #fff; background: var(--impact-burgundy-dark); font-weight: 800; text-align: center; letter-spacing: .03em; }
.invoice-table th { color: #fff; background: var(--impact-burgundy); }
.invoice-table td { border-bottom-color: #eadde2; }
.invoice-total-row td { font-size: 17px; font-weight: 800; color: var(--impact-burgundy-dark); background: #f6f2f4; }
.invoice-words { margin-top: 14px; border: 1px solid #eadde2; border-radius: 10px; overflow: hidden; }
.invoice-words .title { padding: 7px 12px; color: #fff; background: var(--impact-burgundy); text-align: center; font-size: 11px; font-weight: 800; }
.invoice-words .content { padding: 13px; text-align: center; font-weight: 700; text-transform: uppercase; line-height: 1.5; }
.invoice-lives { display: flex; justify-content: space-between; padding: 12px 14px; margin-top: 12px; border: 1px solid #eadde2; border-radius: 10px; font-weight: 800; }
.invoice-bottom { display: grid; grid-template-columns: 1.5fr .8fr; gap: 18px; margin-top: 18px; }
.bank-card { border: 1px solid #eadde2; border-radius: 10px; overflow: hidden; }
.bank-card .bank-title { padding: 9px 12px; color: #fff; background: var(--impact-burgundy); font-size: 12px; font-weight: 800; }
.bank-card .bank-content { padding: 13px; line-height: 1.65; font-size: 12px; }
.signature-card { min-height: 160px; border: 1px solid #eadde2; border-radius: 10px; display: flex; flex-direction: column; justify-content: flex-end; text-align: center; padding: 16px; font-weight: 800; }
.invoice-note { margin-top: 16px; color: var(--impact-burgundy); font-size: 11px; font-weight: 700; }
.invoice-footer { margin-top: 22px; padding-top: 10px; border-top: 1px solid #ddd; display: flex; justify-content: space-between; gap: 15px; color: #6f5d65; font-size: 10px; }

.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 25; background: rgba(12,15,35,.5); }
.modal-backdrop.show { display: block; }

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-two, .grid-equal { grid-template-columns: 1fr; }
    .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-panel { margin-left: 0; }
    .menu-toggle { display: block; }
    .topbar { padding: 12px 16px; }
    .user-meta { display: none; }
    .content { padding: 18px 14px; }
    .app-footer { flex-direction: column; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}

@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
    .card-header { align-items: flex-start; flex-direction: column; }
    .user-menu .btn { padding: 7px 9px; }
    .topbar-title p { display: none; }
}

@media print {
    body { background: #fff; }
    .invoice-preview-shell { padding: 0; background: #fff; }
    .invoice-toolbar { display: none !important; }
    .invoice-paper { width: auto; min-height: auto; margin: 0; padding: 12mm; box-shadow: none; }
    @page { size: A4; margin: 0; }
}


/* Invoice colour policy: Impact Life burgundy, cream, charcoal and grey only. */
.invoice-preview-shell .btn-navy {
    color: #fff;
    background: var(--impact-burgundy-dark);
}
.invoice-preview-shell .btn-navy:hover {
    color: #fff;
    background: var(--impact-burgundy);
}
.invoice-paper,
.invoice-paper h1,
.invoice-paper strong,
.invoice-paper td,
.invoice-paper span {
    border-color: #eadde2;
}
