:root {
    --primary: #2ecc71;
    --primary-dark: #27ae60;
    --glass-bg: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.22);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --glass-blur: blur(18px) saturate(180%);
    --glass-card-bg: rgba(255, 255, 255, 0.18);
    --glass-input-bg: rgba(255, 255, 255, 0.15);
    --text-primary: #1a2e1a;
    --text-secondary: #3d5a3d;
    --text-muted: #5a7a5a;
}

/* ========== BACKGROUNDS ========== */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.4s ease, color 0.4s ease;
    background:
        linear-gradient(135deg,
            rgba(34, 139, 34, 0.15) 0%,
            rgba(46, 204, 113, 0.1) 25%,
            rgba(26, 188, 156, 0.12) 50%,
            rgba(52, 152, 219, 0.08) 75%,
            rgba(155, 200, 60, 0.1) 100%),
        linear-gradient(45deg,
            #e8f5e9 0%,
            #c8e6c9 20%,
            #a5d6a7 40%,
            #b2dfdb 60%,
            #c5e1a5 80%,
            #dcedc8 100%);
    background-attachment: fixed;
    color: var(--text-primary);
}

main { flex: 1; }

/* ========== GLASS MIXIN ========== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* ========== NAVBAR ========== */
.navbar {
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
.navbar-brand { font-size: 1.25rem; color: #fff !important; }
.navbar .nav-link { color: rgba(255, 255, 255, 0.85) !important; transition: color 0.2s; }
.navbar .nav-link:hover { color: #fff !important; }
.navbar .nav-link.active { font-weight: 600; border-bottom: 2px solid #fff; color: #fff !important; }
.navbar-toggler { border-color: rgba(255, 255, 255, 0.3); }
.navbar-toggler-icon { filter: brightness(1.2); }
.dropdown-menu {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.dropdown-item { color: #fff; }
.dropdown-item:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

/* ========== CARDS ========== */
.card {
    background: var(--glass-card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}
.card-header {
    background: rgba(255, 255, 255, 0.08) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.stat-card {
    border-radius: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.stat-icon { font-size: 2rem; }

/* ========== TABLES ========== */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.table td { vertical-align: middle; }
.table-light {
    --bs-table-bg: rgba(255, 255, 255, 0.08);
    --bs-table-color: inherit;
    --bs-table-border-color: rgba(255, 255, 255, 0.1);
}
.table-hover > tbody > tr:hover {
    --bs-table-hover-bg: rgba(255, 255, 255, 0.1);
}

/* ========== FORMS ========== */
.form-label { font-weight: 500; font-size: 0.9rem; }
.form-control, .form-select {
    background: var(--glass-input-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    background: rgba(255, 255, 255, 0.22);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2);
    color: var(--text-primary);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }
.input-group-text {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
}

/* ========== BUTTONS ========== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #1abc9c);
    border: none;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #16a085);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}
.btn-outline-secondary {
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-secondary);
}
.btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}
.btn-group .btn-check:checked + .btn-outline-warning { background-color: #ffc107; color: #000; }
.btn-group .btn-check:checked + .btn-outline-danger { background-color: #dc3545; color: #fff; }
.btn-group[role="group"] .btn { font-size: 0.85rem; white-space: nowrap; padding: 0.375rem 0.5rem; }
.badge { font-weight: 500; }

/* ========== ALERTS ========== */
.alert {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ========== MODALS ========== */
.modal-content {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    border-radius: 16px;
}
.modal-header { border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.modal-footer { border-top: 1px solid rgba(255, 255, 255, 0.12); }

/* ========== FOOTER ========== */
footer {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary) !important;
}

/* ========== THEME TOGGLE ========== */
.theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* ========== LOGIN PAGE ========== */
.login-page {
    background:
        linear-gradient(135deg,
            rgba(34, 139, 34, 0.2) 0%,
            rgba(46, 204, 113, 0.15) 50%,
            rgba(26, 188, 156, 0.2) 100%),
        linear-gradient(45deg,
            #e8f5e9 0%,
            #c8e6c9 30%,
            #b2dfdb 60%,
            #c5e1a5 100%);
    background-attachment: fixed;
}
.login-page .card {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
}

/* ========== PROGRESS BAR ========== */
.progress {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(46, 204, 113, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(46, 204, 113, 0.5); }

/* ========================================= */
/* ========== DARK MODE ========== */
/* ========================================= */
[data-bs-theme="dark"] {
    --glass-bg: rgba(0, 0, 0, 0.25);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-card-bg: rgba(0, 0, 0, 0.3);
    --glass-input-bg: rgba(0, 0, 0, 0.25);
    --text-primary: #e8f0e8;
    --text-secondary: #b0c8b0;
    --text-muted: #7a9a7a;
}

[data-bs-theme="dark"] body {
    background:
        linear-gradient(135deg,
            rgba(0, 50, 0, 0.6) 0%,
            rgba(0, 60, 40, 0.5) 25%,
            rgba(0, 40, 50, 0.5) 50%,
            rgba(10, 30, 20, 0.6) 75%,
            rgba(0, 45, 25, 0.5) 100%),
        linear-gradient(45deg,
            #0a1f0a 0%,
            #0d2818 20%,
            #0a2520 40%,
            #0f2a1a 60%,
            #0c2215 80%,
            #0a1a12 100%);
    background-attachment: fixed;
    color: var(--text-primary);
}

[data-bs-theme="dark"] .navbar {
    background: rgba(0, 0, 0, 0.3) !important;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .card {
    background: var(--glass-card-bg);
    border-color: var(--glass-border);
}
[data-bs-theme="dark"] .card-header {
    background: rgba(0, 0, 0, 0.15) !important;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: rgba(255, 255, 255, 0.04);
    --bs-table-color: #c9d9c9;
    --bs-table-border-color: rgba(255, 255, 255, 0.06);
}
[data-bs-theme="dark"] .table-hover > tbody > tr:hover {
    --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
}
[data-bs-theme="dark"] .table th { color: var(--text-muted); }

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background: var(--glass-input-bg);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background: rgba(0, 0, 0, 0.35);
    border-color: var(--primary);
    color: var(--text-primary);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-bs-theme="dark"] .input-group-text {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.12);
}
[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .text-muted { color: var(--text-muted) !important; }

[data-bs-theme="dark"] .dropdown-menu {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.08);
}
[data-bs-theme="dark"] .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .modal-content {
    background: rgba(10, 30, 20, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-bs-theme="dark"] .modal-header { border-bottom-color: rgba(255, 255, 255, 0.06); }
[data-bs-theme="dark"] .modal-footer { border-top-color: rgba(255, 255, 255, 0.06); }

[data-bs-theme="dark"] footer {
    background: rgba(0, 0, 0, 0.25) !important;
    border-top-color: rgba(255, 255, 255, 0.06);
    color: var(--text-muted) !important;
}

[data-bs-theme="dark"] .login-page {
    background:
        linear-gradient(135deg,
            rgba(0, 50, 0, 0.7) 0%,
            rgba(0, 60, 40, 0.6) 50%,
            rgba(0, 40, 50, 0.6) 100%),
        linear-gradient(45deg,
            #050f05 0%,
            #0a1a10 30%,
            #081815 60%,
            #0a1a0f 100%);
    background-attachment: fixed;
}
[data-bs-theme="dark"] .login-page .card {
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .alert {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .progress {
    background: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(46, 204, 113, 0.2); }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(46, 204, 113, 0.4); }

/* ========== DASHBOARD WIDGETS (drag & drop) ========== */
.dash-widget {
    position: relative;
}
.widget-drag-handle {
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 1.2rem;
    z-index: 2;
    padding: 0 12px;
    line-height: 1;
}
.dash-widget:hover .widget-drag-handle {
    opacity: 0.6;
}
.widget-drag-handle:hover {
    opacity: 1 !important;
    color: var(--primary);
}
.dash-widget.sortable-ghost {
    opacity: 0.4;
}
.dash-widget.sortable-chosen {
    cursor: grabbing;
}

/* ========== FILE EDITOR ========== */
#excelTable td[contenteditable] {
    padding: 4px 8px;
    min-width: 100px;
    white-space: nowrap;
}
#excelTable td[contenteditable]:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background: rgba(46, 204, 113, 0.08);
}
#excelTable th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
}
[data-bs-theme="dark"] #excelTable th {
    background: rgba(0, 0, 0, 0.3);
}
#wordContent {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 1rem;
}
#wordContent:focus {
    outline: none;
}
#wordContent img {
    max-width: 100%;
    height: auto;
}
#dropZone.drag-over {
    border-color: var(--primary) !important;
    background: rgba(46, 204, 113, 0.08);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .stat-icon { font-size: 1.5rem; }
    .table { font-size: 0.85rem; }
}
