html {
  font-size: 16px;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 0;
  overflow-x: hidden;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Equal height summary cards - used across Dashboard, User Management, Bills, Credit Cards */
.summary-cards .card,
.row.mb-4 > .col-md-3 > .card,
.row.mb-4 > .col-md-4 > .card,
.row.mb-4 > .col-md-6 > .card {
    height: 100%;
}

.summary-cards .card-body,
.row.mb-4 > .col-md-3 > .card .card-body,
.row.mb-4 > .col-md-4 > .card .card-body,
.row.mb-4 > .col-md-6 > .card .card-body {
    display: flex;
    flex-direction: column;
    min-height: 120px;
}

.summary-cards .card-body h3,
.row.mb-4 > .col-md-3 > .card .card-body h3,
.row.mb-4 > .col-md-4 > .card .card-body h3,
.row.mb-4 > .col-md-6 > .card .card-body h3 {
    margin-top: auto;
}

.summary-cards .card-body small,
.row.mb-4 > .col-md-3 > .card .card-body small,
.row.mb-4 > .col-md-4 > .card .card-body small,
.row.mb-4 > .col-md-6 > .card .card-body small {
    margin-top: 0.5rem;
}

/* Sticky header styles */
header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background-color: white;
}

/* ?? Sidebar ?? */
:root {
--sidebar-width: 240px;
--sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-transition: 0.25s ease;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--sidebar-transition);
    overflow: hidden;
}

/* Sidebar header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 60px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-brand:hover {
    color: #fff;
    text-decoration: none;
}

.sidebar-brand-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-close-btn:hover {
    color: var(--sidebar-text-hover);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-item {
    margin: 2px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 6px;
    margin: 0 0.5rem;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.sidebar-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
    text-decoration: none;
}

.sidebar-link.active,
.sidebar-link[aria-current="page"] {
    color: #fff;
    background: var(--sidebar-active-bg);
}

.sidebar-link-admin {
    color: #fca5a5;
}

.sidebar-link-admin:hover {
    color: #fef2f2;
    background: rgba(239, 68, 68, 0.15);
}

.sidebar-icon {
    font-size: 1.1rem;
    width: 1.3rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-label {
    transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
    opacity: 1;
}

/* Sidebar footer (user area) */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 0.5rem 0;
}

.sidebar-user {
    margin: 0;
}

.sidebar-user-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    margin: 0 0.5rem;
    color: var(--sidebar-text);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sidebar-user-toggle:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
}

.sidebar-user-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    font-size: 0.875rem;
}

.sidebar-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.sidebar-user-toggle[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0 0 0.25rem 0;
}

.sidebar-submenu .sidebar-link {
    padding-left: 1.5rem;
    font-size: 0.8125rem;
}

.sidebar-link-logout {
    width: calc(100% - 1rem);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    color: #fca5a5;
    font-size: 0.8125rem;
}

.sidebar-link-logout:hover {
    color: #fef2f2;
    background: rgba(239, 68, 68, 0.15);
}

/* Toggle button (inside sidebar header) */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
}

/* Content wrapper */
.content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--sidebar-transition);
}

.content-wrapper > .container-fluid {
    flex: 1;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

.sidebar-overlay.active {
    display: block;
}

/* Mobile floating toggle */
.sidebar-mobile-toggle {
    position: fixed;
    top: 0.65rem;
    left: 0.65rem;
    z-index: 1050;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-mobile-toggle:hover {
    background: #334155;
}

/* ?? Mobile Responsive ?? */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

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

    .content-wrapper {
        margin-left: 0;
        padding-top: 4rem;
    }
}

/* Remove all default spacing */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

/* Footer styles to match header */
footer {
    background-color: white;
    margin: 0;
}

/* Add small margin between content and footer */
main {
    padding-bottom: 0 !important;
    margin-bottom: 2rem;
}

/* ???????????????????????????????????????????????????????
   Mobile Readability & Accessibility Enhancements
   Target: phones / small tablets (< 768px)
   ??????????????????????????????????????????????????????? */
@media (max-width: 767.98px) {

    /* ?? Global touch targets & spacing ?? */
    .btn {
        min-height: 44px;
        padding: 0.5rem 1rem;
        font-size: 0.95rem;
    }

    .btn-sm {
        min-height: 40px;
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }

    .badge {
        font-size: 0.8rem;
        padding: 0.35em 0.65em;
    }

    /* ?? Form controls – taller, easier to tap ?? */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 1rem;
    }

    .form-label {
        font-size: 0.95rem;
        font-weight: 600;
    }

    .form-text {
        font-size: 0.85rem;
    }

    /* ?? Page headers – stack title above buttons ?? */
    .container > .d-flex.justify-content-between.align-items-center.mb-4,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .container > .d-flex.justify-content-between.align-items-center.mb-4 > h1,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > h1,
    .container > .d-flex.justify-content-between.align-items-center.mb-4 > h2,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > h2 {
        font-size: 1.5rem;
    }

    .container > .d-flex.justify-content-between.align-items-center.mb-4 > div,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > div,
    .container-fluid > .row.mb-4 > .col-auto {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .container > .d-flex.justify-content-between.align-items-center.mb-4 > div > .btn,
    .container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 > div > .btn,
    .container-fluid > .row.mb-4 > .col-auto > .btn {
        flex: 1 1 auto;
        text-align: center;
    }

    /* ?? Summary cards – bigger values ?? */
    .summary-cards .card-body h3,
    .row.mb-4 > .col-md-3 > .card .card-body h3,
    .row.mb-4 > .col-md-4 > .card .card-body h3,
    .row.mb-4 > .col-md-6 > .card .card-body h3 {
        font-size: 1.6rem;
    }

    .summary-cards .card-body h6,
    .row.mb-4 > .col-md-3 > .card .card-body h6,
    .row.mb-4 > .col-md-4 > .card .card-body h6,
    .row.mb-4 > .col-md-6 > .card .card-body h6 {
        font-size: 0.9rem;
    }

    .summary-cards .card-body small,
    .row.mb-4 > .col-md-3 > .card .card-body small,
    .row.mb-4 > .col-md-4 > .card .card-body small,
    .row.mb-4 > .col-md-6 > .card .card-body small {
        font-size: 0.85rem;
    }

    /* 2-col grid for 4-card summary rows on mobile */
    .row.mb-4 > .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
        padding-bottom: 0.75rem;
    }

    /* ?? Table readability ?? */
    .table {
        font-size: 0.95rem;
    }

    .table th {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .table td,
    .table th {
        padding: 0.6rem 0.5rem;
    }
}

/* Dashboard specific styles */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.table-responsive {
    border-radius: 0.375rem;
}

.card-header h5[data-bs-toggle="collapse"]:hover,
.card-header i[data-bs-toggle="collapse"]:hover {
    opacity: 0.7;
}

#upcomingPaymentsChevron {
    transition: transform 0.3s ease;
}

#upcomingPaymentsChevron.rotated {
    transform: rotate(180deg);
}

/* Sticky table header for projection modal */
.table-sticky-header thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--bs-table-bg, #fff);
}