/* ==========================================================
   Theme variables
   ========================================================== */
:root {
    --navy: #173544;
    --navy-soft: #21495d;
    --green: #6ebe43;
    --green-dark: #5aa636;
    --white: #ffffff;
    --ink: #000000;
    --bg: #f3f6f8;
    --muted: #6b7d87;
    --border: #e3e9ed;

    --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--bg);

    --bs-primary: var(--green);
    --bs-primary-rgb: 110, 190, 67;
    --bs-success: var(--green);
    --bs-success-rgb: 110, 190, 67;
    --bs-link-color: var(--green-dark);
    --bs-link-hover-color: var(--green);
}

* {
    font-family: var(--bs-font-sans-serif);
}

body {
    background-color: var(--bg);
    color: var(--ink);
}

a {
    text-decoration: none;
    transition: color 0.15s ease;
}

/* ==========================================================
   Global polish: smooth, consistent interactions everywhere
   ========================================================== */
.btn {
    border-radius: 0.6rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
        box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:active {
    transform: translateY(1px);
}

.card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 6px 16px rgba(23, 53, 68, 0.1);
    transform: translateY(-2px);
}

.form-control,
.form-select {
    border-radius: 0.6rem;
    border-color: var(--border);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 0.2rem rgba(110, 190, 67, 0.18);
}

.table-hover > tbody > tr {
    transition: background-color 0.1s ease;
}

.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge.bg-navy {
    background-color: var(--navy) !important;
    color: var(--white);
}

.alert {
    border: none;
    border-radius: 0.75rem;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: #c7d2d8;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--navy-soft);
}

/* ==========================================================
   App shell: sidebar + content
   ========================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-admin {
    border-right: 3px solid var(--green);
}

.sidebar-admin .sidebar-brand {
    background: rgba(110, 190, 67, 0.08);
}

.topbar-admin .brand {
    color: var(--green-dark);
}

.topbar-admin .brand i {
    margin-right: 0.35rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.4rem 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--white);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--navy);
    font-weight: 800;
}

.brand-mark .brand-icon {
    width: 24px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 0.75rem 0.35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
    padding: 0.6rem 0.85rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 0.15rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--white);
}

.sidebar-nav .nav-link.active {
    background: var(--green);
    color: var(--navy);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-profile-link {
    display: block;
    text-decoration: none;
    border-radius: 0.5rem;
    margin: -0.4rem -0.5rem;
    padding: 0.4rem 0.5rem;
    transition: background 0.15s ease;
}

.sidebar-profile-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-profile-link:hover .user-name {
    color: var(--green);
}

.sidebar-footer .user-name {
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
}

.sidebar-footer .user-email {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
}

.sidebar-footer form button {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    border: none;
    background: none;
    padding: 0;
    margin-top: 0.5rem;
}

.sidebar-footer form button:hover {
    color: var(--green);
}

.sidebar-footer .sidebar-admin-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--green);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem;
    margin: -0.4rem -0.5rem 0.35rem;
    border-radius: 0.5rem;
    transition: background 0.15s ease;
}

.sidebar-footer .sidebar-admin-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-footer .sidebar-admin-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1030;
}

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

.topbar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar .brand {
    font-weight: 700;
    color: var(--navy);
}

.sidebar-toggle {
    border: none;
    background: var(--bg);
    border-radius: 0.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--navy);
    font-size: 1.1rem;
}

.content-area {
    padding: 1.5rem;
    flex: 1;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        display: flex;
    }
}

/* ==========================================================
   Components
   ========================================================== */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(23, 53, 68, 0.06);
}

.stat-card .label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
}

.stat-card .value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--navy);
}

.text-navy {
    color: var(--navy) !important;
}

/* Icon badges used on dashboard cards */
.icon-circle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.icon-circle.bg-navy-soft {
    background: rgba(23, 53, 68, 0.08);
    color: var(--navy);
}

.icon-circle.bg-green-soft {
    background: rgba(110, 190, 67, 0.18);
    color: var(--green-dark);
}

.icon-circle.bg-danger-soft {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Dashboard account balances list */
.account-row + .account-row {
    border-top: 1px solid var(--border);
    margin-top: 0.85rem;
    padding-top: 0.85rem;
}

.account-row .progress {
    height: 0.4rem;
}

.account-balance-bar {
    background-color: var(--green);
}

.total-row {
    border-top: 2px solid var(--border);
}

/* Dashboard debt summary */
.debt-stat .label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.table-responsive {
    background: var(--white);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(23, 53, 68, 0.06);
    padding: 0.25rem;
}

.table-responsive > .table {
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.85rem 1.15rem;
}

table thead.table-light th {
    background-color: var(--bg);
    color: var(--navy);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    border-bottom: none;
}

table thead.table-light tr:first-child th:first-child {
    border-top-left-radius: 0.6rem;
}

table thead.table-light tr:first-child th:last-child {
    border-top-right-radius: 0.6rem;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: rgba(23, 53, 68, 0.035);
    color: var(--ink);
}

.table > tbody > tr:last-child > td {
    border-bottom: none;
}

/* Account type badges */
.badge-account-cash {
    background: rgba(110, 190, 67, 0.18);
    color: var(--green-dark);
}

.badge-account-bank {
    background: rgba(23, 53, 68, 0.1);
    color: var(--navy);
}

.badge-account-mobile_money {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.badge-account-other {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
}

/* Page header icon */
.page-header h3 i {
    color: var(--green);
    margin-right: 0.5rem;
    font-size: 0.9em;
    vertical-align: -0.05em;
}

/* Total balance banner (e.g. Accounts index) */
.total-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, var(--navy) 0%, #21495d 100%);
    color: var(--white);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
}

.total-banner .icon-circle {
    background: rgba(255, 255, 255, 0.12);
    color: var(--green);
}

.total-banner .label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
}

.total-banner .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--white);
}

.progress {
    height: 0.6rem;
    background-color: var(--bg);
    border-radius: 1rem;
}

/* Buttons */
.btn-primary {
    --bs-btn-bg: var(--green);
    --bs-btn-border-color: var(--green);
    --bs-btn-hover-bg: var(--green-dark);
    --bs-btn-hover-border-color: var(--green-dark);
    --bs-btn-active-bg: var(--green-dark);
    --bs-btn-active-border-color: var(--green-dark);
    --bs-btn-color: var(--navy);
    --bs-btn-hover-color: var(--white);
    --bs-btn-active-color: var(--white);
    font-weight: 600;
}

.btn-outline-primary {
    --bs-btn-color: var(--green-dark);
    --bs-btn-border-color: var(--green);
    --bs-btn-hover-bg: var(--green);
    --bs-btn-hover-border-color: var(--green);
    --bs-btn-hover-color: var(--navy);
    --bs-btn-active-bg: var(--green);
    --bs-btn-active-border-color: var(--green);
    --bs-btn-active-color: var(--navy);
}

.nav-pills .nav-link.active {
    background-color: var(--navy);
}

.nav-pills .nav-link {
    color: var(--navy);
    font-weight: 500;
}

/* Page header */
.page-header h3 {
    color: var(--navy);
    font-weight: 700;
}

/* Form labels */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--navy);
}

/* Form card header (create/edit pages) */
.form-card-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.form-card-header .icon-circle {
    background: var(--bg);
    color: var(--green-dark);
}

.form-card-header h4 {
    margin: 0;
    color: var(--navy);
    font-weight: 700;
}

.form-card-header p {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ==========================================================
   Auth pages (login / register)
   ========================================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
}

.auth-brand-panel {
    flex: 1;
    background: linear-gradient(160deg, var(--navy) 0%, #0e2129 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}

.auth-brand-panel::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: rgba(110, 190, 67, 0.15);
    right: -140px;
    bottom: -140px;
}

.auth-brand-panel::before {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    right: 60px;
    top: 60px;
}

.auth-brand-panel .brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--green);
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}

.auth-brand-panel .brand-mark .brand-icon {
    width: 36px;
    height: auto;
}

.auth-brand-panel h1 {
    font-weight: 800;
    font-size: 2.4rem;
    max-width: 22rem;
}

.auth-brand-panel p {
    color: rgba(255, 255, 255, 0.65);
    max-width: 24rem;
    font-size: 1.02rem;
}

.auth-form-panel {
    width: 460px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    background: var(--white);
}

.auth-form-panel .form-card {
    width: 100%;
    max-width: 360px;
}

.auth-form-panel h2 {
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 0.25rem;
}

.auth-form-panel .subtitle {
    color: var(--muted);
    margin-bottom: 1.75rem;
}

.auth-form-panel .form-control {
    padding: 0.65rem 0.9rem;
    border-radius: 0.6rem;
    border-color: var(--border);
}

.auth-form-panel .form-control:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 0.2rem rgba(110, 190, 67, 0.18);
}

.auth-form-panel .btn-primary {
    padding: 0.65rem;
    border-radius: 0.6rem;
}

@media (max-width: 991.98px) {
    .auth-brand-panel {
        display: none;
    }

    .auth-form-panel {
        width: 100%;
    }
}
