/* --- Global Styles & Color Palette --- */
:root {
    --primary-color: #6a11cb;
    --primary-gradient: linear-gradient(to right, #2575fc, #6a11cb);
    --secondary-color: #f0f2f5;
    --secondary-text-color: #333;
    --background-color: #f0f2f5;
    --surface-color: #ffffff;
    --text-color: #1c1e21;
    --text-color-light: #606770;
    --border-color: #dddfe2;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 4px 8px rgba(0, 0, 0, 0.05);
    --font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container,
.login-page {
    flex-grow: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Login Page --- */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    background: var(--background-color);
    padding: 20px;
}

.login-container-v2 {
    display: flex;
    max-width: 900px;
    width: 100%;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: fadeIn 0.6s ease-out;
}

.login-info {
    flex-basis: 50%;
    padding: 50px 40px;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-form-container {
    flex-basis: 50%;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Login Page Logo */
.login-form .logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.login-form .login-logo {
    max-width: 150px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* --- Main Layout & Navbar --- */
.container {
    display: flex;
    min-height: 100vh;
    flex: 1;
    width: 100%;
}

.navbar {
    width: 250px;
    background-color: var(--surface-color);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    min-height: 100%;
}

.navbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
}

.navbar-brand .header-logo {
    height: 30px;
    width: auto;
}

.navbar-brand .logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary-color);
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--primary-gradient);
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    text-decoration: none;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s;
}

.hamburger:hover {
    color: var(--primary-color);
}

.nav-links {
    list-style: none;
    padding: 0 10px;
    margin: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-color-light);
    border-radius: 8px;
    margin-bottom: 10px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    background-color: var(--primary-color);
    color: #fff;
    transform: translateX(5px);
}

.nav-links a .icon {
    width: 20px;
    text-align: center;
}

.logout-link-mobile {
    display: none !important;
}

.nav-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.nav-bottom .logout-btn {
    display: flex;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color-light);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

/* Force the hover effect on the button */
button.logout-btn:hover {
    background-color: #e74c3c !important;
    color: #fff !important;
}

/* Ensure the icon also turns white on hover */
button.logout-btn:hover i {
    color: #fff !important;
}

.content {
    flex-grow: 1;
    padding: 30px;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: var(--background-color);
}

/* --- Forms, Tables & Buttons --- */
.form-section,
.table-section {
    background: var(--surface-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.input-group label {
    font-weight: 500;
    margin-bottom: 5px;
    display: block;
}

input,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 1rem;
    /* --- ADDED --- */
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* --- ADDED: Global Focus Style --- */
input:focus,
select:focus,
input:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.15);
    background: var(--surface-color); /* Changes to white on focus */
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--secondary-text-color);
    border: 1px solid var(--border-color);
}

.btn-edit {
    background: var(--secondary-color);
    color: var(--secondary-text-color);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    font-size: 0.85rem;
}

.btn-danger-link {
    color: #e74c3c;
    text-decoration: none;
    font-weight: 500;
    padding: 5px 10px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-danger-link:hover {
    color: #c0392b;
    text-decoration: underline;
}

.btn-view {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 5px 10px;
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 4px;
    font-weight: 500;
}

.btn-view:hover {
    background: var(--primary-color);
    color: #fff;
}

.actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
}

.styled-table {
    table-layout: auto;
    width: 100%;
    min-width: 950px;
    border-collapse: collapse;
}

.styled-table thead tr {
    background-color: var(--primary-color);
    color: #ffffff;
    text-align: left;
}

.styled-table th,
.styled-table td {
    padding: 14px 12px;
    vertical-align: middle;
    text-align: left;
    white-space: nowrap;
}

.styled-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.styled-table .actions {
    text-align: right;
}

.styled-table th.column-description,
.styled-table td.column-description {
    white-space: normal;
    width: 20%;
}

.styled-table th.column-date,
.styled-table td.column-date {
    width: 130px;
}

.styled-table th.column-bill,
.styled-table td.column-bill {
    width: 90px;
    text-align: center;
}

.styled-table th.column-actions,
.styled-table td.column-actions {
    width: 120px;
    text-align: right;
}

.no-bill {
    color: var(--text-color-light);
    font-style: italic;
    font-size: 0.9em;
}

/* --- Admin Page Layout --- */
.admin-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.admin-container .form-section {
    display: flex;
    flex-direction: column;
}

.admin-container .form-section h2 {
    margin-bottom: 20px;
}

.admin-container .form-section form {
    margin-bottom: 25px;
}

.admin-container .form-section form button {
    margin-top: 15px;
    width: 100%;
}

.admin-container .table-wrapper {
    flex-grow: 1;
}

.admin-container .styled-table th:last-child,
.admin-container .styled-table td:last-child {
    text-align: right;
}

.admin-container .styled-table tbody tr:nth-of-type(even) {
    background-color: var(--background-color);
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--surface-color);
    margin: auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    z-index: 10; /* Ensures it's on top */
}

.close-button:hover {
    color: #333;
}

.modal-content .btn-primary {
    margin-top: 30px !important;
    width: 100%;
}

/* --- Bill/Invoice Management in Modal --- */
.bill-management-section {
    margin-top: 25px;
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
}

.bill-management-section h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1em;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.current-bill-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.current-bill-info span {
    font-weight: 500;
    color: var(--text-color);
}

.input-group-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.input-group-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.input-group-checkbox label {
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.form-divider {
    display: none;
}

.view-bill-link {
    font-weight: 500;
    text-decoration: underline;
    color: var(--primary-color);
    transition: color 0.2s;
}

.view-bill-link:hover {
    color: #2575fc;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 20px 0;
}

.pagination a {
    color: var(--primary-color);
    padding: 8px 16px;
    text-decoration: none;
    transition: background-color .3s;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.pagination a.active {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}

.pagination a:hover:not(.active) {
    background-color: var(--secondary-color);
}

.pagination-ellipsis {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-color-light);
    border: 1px solid transparent;
}

/* --- Tab Navigation --- */
.tab-navigation {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    margin-top: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-link {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-color-light);
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.tab-link.active {
    color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
    padding-top: 10px;
}

.tab-content.active {
    display: block;
}

.tab-content .form-section,
.tab-content .table-section {
    padding: 20px;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.tab-content .print-header {
    margin-bottom: 20px;
}

/* --- Admin Tab Styling --- */
.admin-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 30px;
}

.admin-tab-link {
    padding: 15px 25px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-color-light);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease-in-out;
}

.admin-tab-link:hover {
    color: var(--text-color);
}

.admin-tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
    animation: fadeIn 0.5s;
}

/* --- Select2 Professional Dropdown Styling --- */
.select2-container {
    box-sizing: border-box;
}

.form-grid .select2-container,
.input-group .select2-container {
    width: 100% !important;
}

.filter-bar .select2-container,
.filter-form .select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    width: 100%;
    height: 46px !important;
    padding: 0;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    background: var(--background-color) !important;
    /* --- ADDED --- */
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* --- ADDED: Global Focus for Select2 --- */
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default .select2-selection--single:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.15) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-color);
    padding-left: 12px;
    padding-right: 25px;
    line-height: 44px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px;
    top: 1px;
    right: 5px;
}

.select2-dropdown {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.select2-search__field {
    background: var(--background-color) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 4px;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--primary-color);
    color: white;
}

.select2-container--default .select2-results__option--selected {
    background-color: #f0f2f5;
    color: #555;
}

.select2-results__option {
    white-space: normal;
    word-wrap: break-word;
}

/* --- Sort & Filter Bar Styling --- */
.filter-bar {
    background-color: var(--secondary-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}



.filter-form {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-color-light);
    white-space: nowrap;
}

.filter-group select,
.filter-group input {
    width: 100%;
}

.filter-group button {
    flex: 0 0 auto;
    width: auto;
    min-width: 100px;
    height: 46px;
    align-self: flex-end;
}

.filter-group .select2-container .select2-selection--single {
    height: 46px !important;
    display: flex;
    align-items: center;
}

/* --- New History Page Controls (Search + Filter) --- */
.history-controls {
    display: flex;
    flex-wrap: wrap; /* Allows items to wrap on small screens */
    gap: 20px;
    align-items: flex-end; /* Aligns items at the bottom */
    margin-bottom: 20px;
    background-color: var(--secondary-color);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.history-controls .search-bar {
    flex: 1 1 300px; /* Grow, shrink, base width 300px */
    min-width: 250px;
}

.history-controls .history-filter-form {
    flex: 1 1 300px; /* Grow, shrink, base width 300px */
    min-width: 250px;
}

.history-controls .history-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0; /* Don't shrink buttons */
}

/* Override default input-group margin */
.history-controls .input-group,
.history-controls .filter-group {
    margin-bottom: 0;
}

.history-controls .filter-group label {
    margin-bottom: 5px; /* Add space between label and select */
}

/* Responsive adjustments for the new bar */
@media (max-width: 768px) {
    .history-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .history-controls .search-bar,
    .history-controls .history-filter-form,
    .history-controls .history-buttons {
        flex-basis: auto;
        width: 100%;
    }
    .history-controls .history-buttons {
        flex-direction: column;
    }
    .history-controls .history-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

/* --- Footer --- */
.site-footer {
    width: 100%;
    text-align: center;
    padding: 15px 20px;
    color: var(--text-color-light);
    font-size: 0.85em;
    background-color: #e8eaed;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.site-footer a:hover {
    text-decoration: underline;
}

body.login-page {
    display: flex;
    flex-direction: column;
}

body.login-page .site-footer {
    background-color: transparent;
    border-top: none;
}

/* --- Sortable Table Header Links --- */
.styled-table th a.sortable-link {
    color: inherit; /* Inherits the white color from the <thead> */
    text-decoration: none;
    display: block;
    transition: color 0.2s;
}

.styled-table th a.sortable-link:hover {
    color: #eee; /* Slightly lighter on hover */
}

.styled-table th a.sortable-link .fa-solid {
    font-size: 0.9em;
    margin-left: 5px;
}

/* --- Print Styles --- */
.print-header {
    display: none;
}

@media print {
    body,
    html {
        background: #fff !important;
        color: #000 !important;
        font-family: Arial, sans-serif;
        font-size: 9pt;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
    }

    .navbar,
    .tab-navigation,
    .form-section,
    .table-section h2,
    .btn,
    .actions,
    .hamburger,
    .nav-bottom,
    .modal,
    .print-hide,
    .view-bill-link,
    .btn-danger-link,
    .btn-edit {
        display: none !important;
        visibility: hidden !important;
    }

    body>* {
        display: none !important;
        visibility: hidden !important;
    }

    .container,
    .content,
    .tab-content,
    .table-section,
    .table-wrapper {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        overflow: visible !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    .tab-content.active {
        display: block !important;
    }

    .print-header {
        display: flex !important;
        visibility: visible !important;
        justify-content: space-between;
        align-items: baseline;
        margin-bottom: 20px;
        border-bottom: 2px solid #333;
        padding-bottom: 10px;
    }

    .print-header-logo {
        visibility: visible !important;
        font-size: 18pt;
        font-weight: bold;
        color: #000;
    }

    .print-header-logo img {
        visibility: visible !important;
        height: 25px;
        width: auto;
        vertical-align: middle;
    }

    .print-header-info {
        visibility: visible !important;
        font-size: 9pt;
        color: #555;
        text-align: right;
    }

    h1 {
        display: block !important;
        visibility: visible !important;
        font-size: 16pt;
        color: #000;
        margin-top: 0;
        margin-bottom: 20px;
        page-break-after: avoid;
    }

    .styled-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 8pt;
        border: 1px solid #999;
        margin-top: 15px;
        page-break-inside: auto;
    }

    .styled-table thead tr {
        background-color: #f2f2f2 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        page-break-inside: avoid;
    }

    .styled-table th,
    .styled-table td {
        visibility: visible !important;
        border: 1px solid #ccc;
        padding: 6px 8px;
        color: #000 !important;
        text-align: left;
        white-space: normal;
    }

    .styled-table th {
        font-weight: bold;
    }

    .styled-table tbody tr {
        page-break-inside: avoid;
    }

    .column-bill,
    .column-actions {
        display: none !important;
    }

    @page {
        size: A4 landscape;
        margin: 0.75in;
    }

    a,
    a:visited {
        text-decoration: none;
        color: inherit;
    }

    a[href]:after {
        content: none !important;
    }
}

/* --- Responsive Styles --- */
@media (max-width: 900px) {
    .login-container-v2 {
        flex-direction: column;
    }

    .login-info {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .navbar {
        width: 100%;
        height: auto;
        min-height: auto;
    }

    .hamburger {
        display: block !important;
    }

    .nav-links {
        display: none !important;
        flex-direction: column;
        width: 100%;
        text-align: left;
        padding: 10px;
        background-color: var(--surface-color);
        position: relative;
        z-index: 100;
    }

    .nav-links.active {
        display: flex !important;
    }

    .nav-links a {
        display: flex !important;
        width: 100%;
        padding: 12px 20px;
    }

    .nav-links a span {
        display: inline-block !important;
    }

    .nav-bottom {
        display: none !important;
    }

    .logout-link-mobile {
        display: block !important;
    }

    .content {
        padding: 20px;
    }

    .site-footer {
        padding: 12px 15px;
        font-size: 0.8em;
    }

    .filter-form {
        flex-direction: column !important;
        flex-wrap: wrap;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
        max-width: 100%;
        min-width: unset;
    }

    .filter-group button {
        width: 100%;
    }

    .navbar-brand .header-logo {
        height: 25px;
    }

    .navbar-brand .logo-text {
        font-size: 1.3rem;
    }
}

@media (min-width: 769px) {
    .logout-link-mobile {
        display: none !important;
    }
}


/* Mobile Responsive */
@media (max-width: 768px) {
    .admin-cards-container {
        grid-template-columns: 1fr;
    }
    
    .admin-card-actions {
        flex-direction: column;
    }
    
    .admin-card-actions .btn-edit-admin,
    .admin-card-actions .btn-danger-link {
        width: 100%;
        justify-content: center;
    }
    
    /* --- ADD THIS NEW RULE --- */
    .admin-tabs {
        overflow-x: auto; /* Allows horizontal scrolling */
        white-space: nowrap; /* Prevents tabs from wrapping */
    }
    /* --- END OF NEW RULE --- */
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .admin-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop */
@media (min-width: 1025px) {
    .admin-cards-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================
   ADMIN CONTROLS - PROFESSIONAL LAYOUT
   ========================================== */

/* Two-Column Layout */
.admin-two-column {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
    align-items: start;
}

/* Form Card (Left Side) */
.admin-form-card {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 20px;
}

.admin-form-card h2 {
    font-size: 1.3rem;
    color: var(--text-color);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-form-card h2 i {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.admin-form-card .input-group {
    margin-bottom: 20px;
}

.admin-form-card .input-group:last-of-type {
    margin-bottom: 0;
}

.btn-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

/* List Card (Right Side) */
.admin-list-card {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    min-height: 400px;
}

.admin-list-card h2 {
    font-size: 1.3rem;
    color: var(--text-color);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.admin-list-card h2 i {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* --- Admin List Header --- */
.admin-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px 10px 15px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-list-header .header-main {
    flex: 1; /* Gives main text all available space */
}

.admin-list-header .header-actions {
    flex-shrink: 0; /* Prevents it from shrinking */
    margin-left: 15px;
    text-align: right;
    width: 80px; /* Aligns it above the action buttons */
}

/* List Items */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.admin-list-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateX(2px);
}

.admin-item-info {
    flex: 1;
    min-width: 0;
}

.admin-item-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-item-meta {
    font-size: 0.85rem;
    color: var(--text-color-light);
    text-transform: capitalize;
}

.admin-item-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

/* Action Buttons */
.admin-btn-edit,
.admin-btn-delete {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
    text-decoration: none;
}

.admin-btn-edit {
    background: var(--primary-color);
    color: white;
}

.admin-btn-edit:hover {
    background: #5a0db8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(106, 17, 203, 0.3);
}

.admin-btn-delete {
    background: #fee;
    color: #e74c3c;
}

.admin-btn-delete:hover {
    background: #e74c3c;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* Empty State */
.admin-list:empty::after {
    content: 'No items found';
    display: block;
    text-align: center;
    padding: 40px;
    color: var(--text-color-light);
    font-style: italic;
}

/* Modal Specific for Admin */
#adminEditModal .modal-content {
    max-width: 500px;
}

#adminEditModal h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

#adminEditModal h2 i {
    color: var(--primary-color);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .admin-two-column {
        grid-template-columns: 350px 1fr;
        gap: 20px;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {

    /* --- Admin Responsive Layout --- */
    .admin-two-column {
        grid-template-columns: 1fr; /* Stack columns */
        gap: 20px;
    }

    .admin-form-card {
        position: static;
        order: 1; /* Form comes first */
    }
    
    .admin-list-card {
        order: 2; /* List comes second */
        min-height: auto; /* Remove fixed desktop height */
    }
    
    .admin-form-card,
    .admin-list-card {
        padding: 20px; /* Unified padding for mobile */
    }
    
    .admin-form-card h2,
    .admin-list-card h2 {
        font-size: 1.1rem; /* Smaller headings for mobile */
    }

    /* This rule was missing and is now added */
    .admin-list-header {
        display: none;
    }
    
    .admin-list {
        max-height: none; /* Remove height limit */
        overflow-y: visible;
        padding-right: 0;
        margin-right: 0;
    }
    
    .admin-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 5px;
    }
    
    .admin-item-actions {
        justify-content: flex-end;
        margin-left: 0;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    
    .admin-btn-edit,
    .admin-btn-delete {
        flex: 1;
        max-width: 120px;
        height: 40px;
    }
    
    /* Hide text on mobile, show only icon */
    .admin-btn-edit::after {
        content: ''; 
        margin-left: 0;
    }
    
    .admin-btn-delete::after {
        content: ''; 
        margin-left: 0;
    }

    /* Ensure icons are centered */
    .admin-btn-edit,
    .admin-btn-delete {
        justify-content: center;
        padding: 0; /* Remove padding to make them square */
        width: 40px; /* Fixed width for square look */
        flex: 0 0 40px; /* Prevent stretching */
    }
    
    /* --- ADD THIS NEW RULE --- */
    .admin-tabs {
        overflow-x: auto; /* Allows horizontal scrolling */
        white-space: nowrap; /* Prevents tabs from wrapping */
    }
    /* --- END OF NEW RULE --- */
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    .admin-form-card,
    .admin-list-card {
        padding: 15px;
        border-radius: 8px;
    }
    
    .admin-list-item {
        padding: 12px;
    }
    
    .admin-item-name {
        font-size: 0.95rem;
    }
    
    .admin-item-meta {
        font-size: 0.8rem;
    }
}

/* ==========================================
   ADMIN SECTION ANIMATIONS
   ========================================== */

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .admin-form-card,
    .admin-item-actions,
    .admin-tabs {
        display: none !important;
    }
    
    .admin-two-column {
        grid-template-columns: 1fr;
    }
    
    .admin-list-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* --- Admin Page - Two Column Layout --- */

.admin-two-column {
    display: grid;
    grid-template-columns: 350px 1fr; /* Form on left, list on right */
    gap: 30px;
    align-items: flex-start;
}

.admin-form-card,
.admin-list-card {
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 25px;
}

.admin-form-card h2,
.admin-list-card h2 {
    margin-top: 0;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    color: var(--text-color);
}

.btn-block {
    width: 100%;
    margin-top: 15px; /* Add some space above the button */
}

.admin-list {
    display: flex;
    flex-direction: column;
    max-height: 450px; /* Give the list a max height */
    overflow-y: auto; /* Add scrolling if list is long */
    padding-right: 10px; /* Space for scrollbar */
    margin-right: -10px; /* Offset scrollbar */
}

.admin-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 10px;
    border-bottom: 1px solid var(--border-color);
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-item-name {
    font-weight: 500;
    color: var(--text-color);
}

.admin-item-meta {
    font-size: 0.9em;
    color: var(--text-color-light);
}

.admin-item-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0; /* Prevent action buttons from shrinking */
}

.admin-btn-edit,
.admin-btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.admin-btn-edit {
    color: var(--primary-color);
}
.admin-btn-edit:hover {
    background-color: #f0f2f5;
    color: #2575fc;
}

.admin-btn-delete {
    color: #e74c3c;
}
.admin-btn-delete:hover {
    background-color: #fbebee;
    color: #c0392b;
}

/* --- Admin Modal (from your new admin.php) --- */
#adminEditModal .modal-content {
    max-width: 450px; /* Make the simple modal a bit smaller */
}

#adminEditForm .input-group {
    margin-bottom: 0; /* Remove default form margin */
}

#adminModalTitle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
}

/* --- Admin Guidance & Empty States --- */
.form-instruction {
    font-size: 0.9rem;
    color: var(--text-color-light);
    margin: -15px 0 25px 0;
    line-height: 1.5;
}

.admin-list-empty,
.admin-list-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color-light);
    font-style: italic;
    background: var(--background-color);
    border-radius: 8px;
    margin-top: 10px;
}

/* --- Admin List Search Box --- */
.admin-list-search {
    position: relative;
    margin-bottom: 20px;
}

.admin-list-search .fa-solid {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color-light);
    font-size: 0.9rem;
}

.admin-search-input {
    width: 100%;
    padding: 12px 15px 12px 40px; /* Left padding for icon */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-search-input::placeholder {
    color: var(--text-color-light);
}

/* =================================================== */
/* --- NEW MOBILE TABBED INTERFACE (OVERRIDE) --- */
/* =================================================== */

/* --- Default State (Desktop) --- */
/* Hide mobile-only elements on desktop */
.admin-mobile-nav,
.admin-mobile-content {
    display: none;
}

/* --- Mobile State (< 768px) --- */
@media (max-width: 768px) {
    
    /* 1. Hide the desktop layout */
    .admin-desktop-layout {
        display: none;
    }

    /* 2. Show the mobile-only elements */
    .admin-mobile-nav,
    .admin-mobile-content {
        display: block;
    }

    /* 3. Style the mobile tab navigation */
    .admin-mobile-nav {
        display: flex;
        background-color: var(--surface-color);
        border-radius: 12px 12px 0 0;
        overflow: hidden;
        border: 1px solid var(--border-color);
        border-bottom: none;
    }

    .mobile-tab-link {
        flex: 1; /* Make buttons equal width */
        padding: 15px 10px;
        font-size: 0.9rem;
        font-weight: 600;
        text-align: center;
        background: #f9f9f9;
        color: var(--text-color-light);
        border: none;
        border-bottom: 3px solid transparent;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .mobile-tab-link:first-child {
        border-right: 1px solid var(--border-color);
    }

    .mobile-tab-link.active {
        background: var(--surface-color);
        color: var(--primary-color);
        border-bottom-color: var(--primary-color);
    }

    /* 4. Style the mobile tab content */
    .admin-mobile-content {
        border: 1px solid var(--border-color);
        border-radius: 0 0 12px 12px;
        box-shadow: var(--shadow);
        overflow: hidden; /* Ensures rounded corners */
    }

    .mobile-tab-pane {
        display: none;
    }
    
    .mobile-tab-pane.active {
        display: block;
        animation: fadeInUp 0.3s ease; /* Use existing animation */
    }

    /* 5. Reset card styles to fit inside the tab pane */
    .mobile-tab-pane .admin-form-card,
    .mobile-tab-pane .admin-list-card {
        position: static;
        box-shadow: none;
        border-radius: 0;
        padding: 20px;
        min-height: 0;
    }

    /* 6. Hide the card titles (tabs are the new titles) */
    .mobile-tab-pane .admin-form-card h2,
    .mobile-tab-pane .admin-list-card h2 {
        display: none;
    }

    /* 7. Fix list styles */
    .mobile-tab-pane .admin-list {
        max-height: none;
        overflow-y: visible;
    }
    
    .mobile-tab-pane .admin-list-header {
        display: none; /* Hide desktop list header */
    }

    .mobile-tab-pane .admin-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .mobile-tab-pane .admin-item-actions {
        justify-content: flex-end;
        margin-left: 0;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    
    .mobile-tab-pane .admin-btn-edit,
    .mobile-tab-pane .admin-btn-delete {
        flex: 1;
        max-width: 120px;
        height: 40px;
    }
    
    .mobile-tab-pane .admin-btn-edit::after {
        content: ' Edit';
        margin-left: 4px;
    }
    
    .mobile-tab-pane .admin-btn-delete::after {
        content: ' Delete';
        margin-left: 4px;
    }
}

/* ==========================================
   DASHBOARD CARD STYLES (RE-ADDED)
   ========================================== */

.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 20px; 
    align-items: start; /* Fixes cards stretching */
}
.card { 
    background: var(--surface-color); 
    padding: 20px; 
    border-radius: 12px; 
    box-shadow: var(--shadow); 
    transition: transform 0.2s, box-shadow 0.2s; 
    position: relative;
}

/* --- Clickable Card Link Wrapper --- */
.dashboard-card-link {
    text-decoration: none;
    color: inherit;
    display: block; /* Ensures the link takes up the full card space */
}

.dashboard-card-link:hover .card {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.card h3 { 
    margin-top: 0; 
    color: var(--primary-color); 
    font-weight: 500; 
    font-size: 1rem; 
    display: flex;
    align-items: center;
    gap: 8px;
}
.card p { 
    font-size: 2rem; 
    font-weight: 700; 
    margin: 10px 0 0; 
    color: var(--text-color);
}

/* Responsive Styles for Cards */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr; /* Stack KPI cards on mobile */
    }
}

/* --- Grouped Form Grid --- */
.form-grid-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Make grouped dropdowns stack on mobile */
@media (max-width: 768px) {
    .form-grid-group {
        grid-template-columns: 1fr;
    }
}

/* --- Grouped Form Grid --- */
.form-grid-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Make grouped dropdowns stack on mobile */
@media (max-width: 768px) {
    .form-grid-group {
        grid-template-columns: 1fr;
    }

    /* Fix for main form layout on mobile */
    #payment_mode_wrapper,
    #bank_account_container {
        width: 100% !important;
    }
}

/* --- Responsive Fix for Table Action Buttons --- */
@media (max-width: 480px) {
    .styled-table .column-actions {
        width: auto; /* Allow width to be flexible */
        padding-right: 10px; /* Add a little space */
    }
    .styled-table .actions {
        flex-direction: column; /* Stack buttons vertically */
        align-items: flex-end; /* Align them to the right */
        gap: 8px; /* Add space between stacked buttons */
        justify-content: center;
    }
    .admin-btn-edit,
    .admin-btn-delete {
        width: 40px; /* Give them a slightly larger, consistent tap size */
        height: 40px;
    }
}

/* ==========================================
   FIX: Delete Button Overflow on Mobile
   ========================================== */

/* Ensure inline forms don't overflow */
.admin-item-actions form {
    display: inline-flex; /* Changed from inline */
    margin: 0;
    padding: 0;
}

/* Make sure action buttons container wraps properly */
.admin-item-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
    flex-wrap: wrap; /* Allow wrapping if needed */
    align-items: center;
}

/* Consistent button sizing */
.admin-btn-edit,
.admin-btn-delete {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
    text-decoration: none;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

/* Mobile Specific Fixes */
@media (max-width: 768px) {
    
    .admin-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 15px; /* Added horizontal padding */
        overflow: visible; /* Changed from hidden to allow buttons to show fully */
    }
    
    .admin-item-actions {
        justify-content: flex-end;
        margin-left: 0;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
        gap: 10px;
        flex-wrap: nowrap; /* Prevent wrapping */
    }
    
    /* Professional button styling with proper width */
    .admin-btn-edit,
    .admin-btn-delete {
        flex: 0 0 auto;
        min-width: 80px; /* Enough space for icon + text */
        height: 40px;
        padding: 0 12px;
        font-size: 0.9rem;
        white-space: nowrap; /* Prevent text wrapping */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    
    /* Text labels with proper spacing */
    .admin-btn-edit::after {
        content: 'Edit';
    }
    
    .admin-btn-delete::after {
        content: 'Delete';
    }
    
    /* Alternative: Full-width buttons with text */
    .admin-item-actions.full-width-mobile {
        flex-direction: column;
        gap: 8px;
    }
    
    .admin-item-actions.full-width-mobile .admin-btn-edit,
    .admin-item-actions.full-width-mobile .admin-btn-delete {
        width: 100%;
        justify-content: center;
    }
}

/* Small Mobile (< 480px) - Extra Safe */
@media (max-width: 480px) {
    .admin-list-item {
        padding: 12px 10px; /* Reduce padding even more */
    }
    
    .admin-item-actions {
        gap: 8px;
    }
    
    /* Option 1: Keep icon-only buttons but smaller */
    .admin-btn-edit,
    .admin-btn-delete {
        width: 40px;
        height: 40px;
    }
    
    /* Remove text labels if space is too tight */
    .admin-btn-edit::after,
    .admin-btn-delete::after {
        content: none;
    }
}

/* ==========================================
   FIX: Landscape Mode on Mobile Devices
   ========================================== */

/* Target mobile devices in landscape orientation */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    
    /* Hide the sidebar completely in landscape */
    .navbar {
        display: none !important;
    }
    
    /* Make content take full width */
    .content {
        width: 100%;
        padding: 15px;
    }
    
    /* Reduce heading sizes for better fit */
    h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    /* Make form sections more compact */
    .form-section,
    .table-section,
    .admin-form-card,
    .admin-list-card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    /* Adjust form inputs for landscape */
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    input,
    select,
    .select2-container--default .select2-selection--single {
        height: 40px !important;
        font-size: 0.9rem;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 38px !important;
    }
    
    /* Make buttons more compact */
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

/* Mobile Specific Fixes */
@media (max-width: 768px) {
    
    .admin-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 15px; /* Added horizontal padding */
        overflow: visible; /* Changed from hidden to allow buttons to show fully */
    }
    
    .admin-item-actions {
        justify-content: flex-end;
        margin-left: 0;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
        gap: 10px;
        flex-wrap: nowrap; /* Prevent wrapping */
    }
    
    /* Professional button styling with proper width */
    .admin-btn-edit,
    .admin-btn-delete {
        flex: 0 0 auto;
        min-width: 80px; /* Enough space for icon + text */
        height: 40px;
        padding: 0 12px;
        font-size: 0.9rem;
        white-space: nowrap; /* Prevent text wrapping */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    
    /* Text labels with proper spacing */
    .admin-btn-edit::after {
        content: 'Edit';
    }
    
    .admin-btn-delete::after {
        content: 'Delete';
    }
    
    /* Alternative: Full-width buttons with text */
    .admin-item-actions.full-width-mobile {
        flex-direction: column;
        gap: 8px;
    }
    
    .admin-item-actions.full-width-mobile .admin-btn-edit,
    .admin-item-actions.full-width-mobile .admin-btn-delete {
        width: 100%;
        justify-content: center;
    }
}