:root {
    --primary: #2D7A4F;
    --primary-hover: #24613f;
    --bg: #f8fafc;
    --surface: #ffffff;
    --muted: #64748b;
    --text: #1e293b;
    --glass: rgba(255, 255, 255, 0.85);
    --border-color: #e2e8f0;
    --sidebar-width: 240px;
    --sidebar-bg: #ffffff;
    --sidebar-color: #334155;
    --sidebar-active-bg: rgba(45, 122, 79, 0.1);
    --sidebar-active-color: #2D7A4F;
    --radius: 12px;
}

[data-bs-theme="dark"], [data-theme="dark"] {
    --primary: #22c55e;
    --primary-hover: #16a34a;
    --bg: #0b0f19;
    --surface: #111827;
    --muted: #94a3b8;
    --text: #f1f5f9;
    --glass: rgba(17, 24, 39, 0.85);
    --border-color: #1f2937;
    --sidebar-bg: #111827;
    --sidebar-color: #cbd5e1;
    --sidebar-active-bg: rgba(34, 197, 94, 0.15);
    --sidebar-active-color: #22c55e;
    --bs-body-bg: #0b0f19;
    --bs-body-color: #f1f5f9;
    --bs-card-bg: #111827;
    --bs-border-color: #1f2937;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Global Container */
.container { width: 100%; margin: 0 auto; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.btn.primary {
    background: var(--primary);
    color: #ffffff !important;
    border-color: var(--primary);
}
.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 122, 79, 0.3);
}
.btn.ghost {
    background: transparent;
    color: var(--text);
    border-color: transparent;
}
.btn.ghost:hover {
    background: rgba(0, 0, 0, 0.05);
}
[data-bs-theme="dark"] .btn.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}
.btn.outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text);
}
.btn.outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Public Navigation Bar */
.site-nav {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1020;
    backdrop-filter: blur(12px);
    background: var(--glass);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.site-nav .nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}
.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}
.nav-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
    margin-left: 2rem;
}
.site-nav .nav-links {
    list-style: none;
    display: flex;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}
.site-nav .nav-links .nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.site-nav .nav-links .nav-link:hover, .site-nav .nav-links .nav-link.active {
    color: var(--primary);
    background: rgba(45, 122, 79, 0.08);
}
.nav-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    padding: 0.25rem;
}

@media (max-width: 991px) {
    .mobile-menu-toggle { display: block; }
    .nav-menu {
        display: none;
        width: 100%;
        flex-direction: column;
        padding: 1rem 0;
        gap: 1rem;
        margin-left: 0;
    }
    .nav-menu.active { display: flex; }
    .site-nav .nav-links {
        flex-direction: column;
        width: 100%;
        text-align: center;
    }
    .nav-actions { width: 100%; justify-content: center; }
}

/* Internal Sidebar & Workspace Layout */
#app-wrapper {
    display: flex;
    min-height: 100vh;
}
#app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    transition: width 0.3s ease, transform 0.3s ease;
}
#app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-width: 0;
}
.menu-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 8px;
}
.sidebar-brand {
    padding: 0.75rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-menu {
    padding: 0.5rem;
    flex: 1;
    overflow-y: auto;
}
.sidebar-menu .nav-link {
    color: inherit;
    padding: 0.55rem 0.9rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    text-decoration: none;
}
.sidebar-menu .nav-link:hover, .sidebar-menu .nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-color);
}
.sidebar-menu .collapse .nav-link {
    padding-left: 2.5rem;
    font-size: 0.85rem;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1025;
}
body.mobile-sidebar-open .sidebar-overlay { display: block; }

@media (max-width: 991.98px) {
    #app-sidebar { transform: translateX(-100%); }
    #app-main { margin-left: 0; }
    #app-sidebar.show { transform: translateX(0); }
    .mobile-sidebar-open #sidebarToggle {
        opacity: 0;
        pointer-events: none;
    }
}

/* Desktop Collapsed State (AMMS Parity) */
@media (min-width: 992px) {
    body.sidebar-collapsed #app-sidebar {
        width: 76px;
    }
    body.sidebar-collapsed #app-main {
        margin-left: 76px;
    }
    body.sidebar-collapsed .sidebar-brand span,
    body.sidebar-collapsed .sidebar-menu .nav-link span,
    body.sidebar-collapsed .sidebar-menu .bi-chevron-down,
    body.sidebar-collapsed .user-info-text {
        display: none !important;
    }
    body.sidebar-collapsed .sidebar-menu .nav-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
    body.sidebar-collapsed .sidebar-menu .nav-item {
        position: relative;
    }
    body.sidebar-collapsed .sidebar-menu .nav-item .collapse {
        display: none !important;
    }
    body.sidebar-collapsed .sidebar-menu .nav-item.is-hovered > .collapse {
        display: block !important;
        position: absolute;
        left: 76px;
        top: 0;
        width: 220px;
        z-index: 1030;
        background-color: var(--sidebar-bg);
        border-radius: 0 8px 8px 0;
        padding: 0.5rem;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        border: 1px solid var(--border-color);
    }
    body.sidebar-collapsed .sidebar-menu .nav-item.is-hovered .collapse .nav-link span,
    body.sidebar-collapsed .sidebar-menu .nav-item.is-hovered .collapse .nav-link i {
        display: inline !important;
    }
    body.sidebar-collapsed .sidebar-menu .nav-item.is-hovered .collapse .nav-link {
        justify-content: flex-start;
        padding-left: 1rem;
    }
    body.sidebar-collapsed .sidebar-menu {
        overflow: visible;
    }
}

/* Common Cards & Forms */
.contact-form-card {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.icon-shape {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modern Card & Widget Enhancements */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.15rem;
}
.card.dashboard-widget-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}
.cursor-pointer {
    cursor: pointer;
}
.compact-stat-list .list-group-item {
    background: transparent;
    border-color: var(--border-color);
}


/* Public & Portal Footer */
.site-footer {
    background: #0f172a;
    color: #e2e8f0;
    padding: 4rem 0 2rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.footer-inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.footer-brand .brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    text-decoration: none;
}
.footer-links h5, .footer-contact h5 {
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
}
.footer-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-links li { margin-bottom: 0.65rem; }
.footer-links a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.footer-links a:hover { color: #ffffff; }
.footer-bottom {
    font-size: 0.85rem;
    color: #64748b;
}

@media (max-width: 900px) {
    .footer-inner { grid-template-columns: 1fr 1fr; gap: 2rem; }
}
@media (max-width: 600px) {
    .footer-inner { grid-template-columns: 1fr; text-align: center; }
    .footer-brand .brand-link { justify-content: center; }
}

/* Floating Utilities */
.back-to-top {
    position: fixed;
    display: none;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    background: var(--primary);
    color: #fff;
    width: 42px;
    height: 42px;
    text-align: center;
    line-height: 42px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}