:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --danger-color: #EF4444;
    --danger-hover: #DC2626;
    --text-color: #1F2937;
    --text-muted: #4B5563;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    --bg-grad-1: #e0c3fc;
    --bg-grad-2: #8ec5fc;
    --panel-bg: rgba(255, 255, 255, 0.45);
    --input-bg: rgba(255, 255, 255, 0.5);
    --input-focus: rgba(255, 255, 255, 0.8);
    --option-bg: #ffffff;
    --footer-bg: rgba(255, 255, 255, 0.3);
    --hover-bg: rgba(255, 255, 255, 0.3);
}

body.dark-mode {
    --text-color: #F9FAFB;
    --text-muted: #9CA3AF;
    --glass-bg: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

    --bg-grad-1: #0f172a;
    --bg-grad-2: #1e1b4b;
    --panel-bg: rgba(17, 24, 39, 0.55);
    --input-bg: rgba(17, 24, 39, 0.6);
    --input-focus: rgba(17, 24, 39, 0.9);
    --option-bg: #1f2937;
    --footer-bg: rgba(17, 24, 39, 0.5);
    --hover-bg: rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
    height: 100vh;
    overflow: hidden;
    color: var(--text-color);
    position: relative;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Background Shapes for Glassmorphism effect */
.background-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.8;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #ff9a9e 0%, rgba(255, 154, 158, 0) 70%);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #a1c4fd 0%, rgba(161, 196, 253, 0) 70%);
    bottom: -150px;
    right: -100px;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #fbc2eb 0%, rgba(251, 194, 235, 0) 70%);
    top: 40%;
    left: 30%;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    transform: translateZ(0);
    /* Hardware acceleration */
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    transform: translateZ(0);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-color);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.8);
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.2s;
    margin: 0 5px;
}

.btn-icon:hover {
    transform: scale(1.2);
}

/* Login Container */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    text-align: center;
}

.login-container h2 {
    margin-bottom: 24px;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-color);
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    background: var(--input-focus);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.form-group select option {
    background: var(--option-bg);
    color: var(--text-color);
}

.error-msg {
    color: var(--danger-color);
    margin-bottom: 15px;
    font-size: 14px;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px;
    border-radius: 8px;
}

/* Dashboard */
.dashboard {
    width: 98%;
    max-width: 100%;
    height: calc(100vh - 40px);
    /* Subtract margin from 100vh */
    margin: 20px auto;
    padding: 20px 30px 60px 30px;
    /* Extra padding at bottom for footer */
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.header-left {
    display: flex;
    gap: 20px;
    flex: 1;
    flex-wrap: wrap;
}

.stat-box {
    padding: 15px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 150px;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.branch-stats {
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    flex: 1;
    align-items: center;
}

.branch-item {
    font-size: 13px;
    background: rgba(255, 255, 255, 0.5);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.branch-item span {
    font-weight: 700;
    color: var(--primary-color);
    margin-left: 4px;
}

.header-right {
    display: flex;
    gap: 10px;
}

/* Toolbar (Search) */
.toolbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    transform: translateY(-10px);
}

.search-bar {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    max-width: 400px;
}

.search-icon {
    margin-right: 10px;
    color: var(--text-muted);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 15px;
    color: var(--text-color);
}

/* Table */
.table-container {
    overflow-x: auto;
    padding: 20px;
    flex-grow: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    font-size: 15px;
}

tr:hover td {
    background: var(--hover-bg);
}

tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    padding: 30px;
    width: 100%;
    max-width: 600px;
    position: relative;
    animation: modalIn 0.3s ease forwards;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal h2 {
    margin-bottom: 25px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 40px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary-color);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease forwards;
    transition: opacity 0.3s;
}

.toast.success {
    border-color: #10B981;
}

.toast.error {
    border-color: var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    background: var(--footer-bg);
    backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
    }

    .dashboard {
        width: 100%;
        height: min-content;
        min-height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 20px 15px 80px 15px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .header-left {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-box {
        width: 100%;
    }

    .branch-stats {
        max-height: 150px;
        overflow-y: auto;
        justify-content: center;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: 100%;
        width: 100%;
    }

    .toolbar-actions {
        justify-content: flex-end;
        transform: translateY(0);
        margin-top: 10px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .login-container {
        margin: 40px 15px;
        padding: 30px 20px;
    }

    .modal-content {
        padding: 20px;
        margin: 15px;
        max-height: 90vh;
        overflow-y: auto;
    }
}