:root {
    --sidebar-width: 260px;
    --primary: #1a5276;
    --primary-dark: #154360;
    --accent: #e67e22;
    --sidebar-bg: #1a252f;
    --sidebar-hover: #2c3e50;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6f9;
    margin: 0;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    max-height: 100vh;
    background: var(--sidebar-bg);
    color: #ecf0f1;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.logo-box {
    width: auto;
    height: auto;
    max-width: var(--logo-width, 140px);
    border-radius: var(--logo-radius, 8px);
    background: var(--logo-bg, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    padding: 2px;
}

.logo,
.site-logo,
.navbar-logo,
.logo-box img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.navbar-logo,
.sidebar-brand .logo-box img,
.sidebar-brand .site-logo,
.content-card .logo-box img {
    max-height: 60px;
}

.report-logo,
.certificate-logo,
.receipt-logo {
    max-height: 80px;
}

.logo-box img {
    object-fit: var(--logo-fit, contain);
}

.sidebar-brand {
    padding: 1.25rem 1rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ecf0f1;
    line-height: 1.3;
    word-break: break-word;
}

.sidebar-brand .logo-box {
    margin: 0 auto;
}

.sidebar-user {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.user-name { font-weight: 600; font-size: 0.9rem; }
.user-role { font-size: 0.75rem; color: #95a5a6; text-transform: capitalize; }

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.5rem 0 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 4px;
}

.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem 0.55rem 1.15rem;
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.875rem;
    line-height: 1.35;
}

.sidebar-nav .nav-link span,
.sidebar-footer .nav-link span {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: var(--sidebar-hover);
    color: #fff;
    border-left: 3px solid var(--accent);
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    flex-shrink: 0;
    text-align: center;
}

.nav-group { margin-bottom: 2px; }
.nav-group-header {
    display: flex;
    align-items: center;
}
.nav-group-header .nav-link {
    flex: 1;
    min-width: 0;
}
.nav-group-chevron {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.nav-group-chevron:hover { color: #fff; }
.nav-group-chevron i { transition: transform 0.2s ease; }
.nav-group.expanded .nav-group-chevron i { transform: rotate(180deg); }
.nav-submenu {
    display: none;
    padding-left: 0.5rem;
}
.nav-group.expanded .nav-submenu { display: block; }
.nav-sublink {
    padding-left: 2.5rem !important;
    padding-right: 0.75rem !important;
    font-size: 0.84rem;
}
.nav-link.active-parent {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.35rem 0 0.5rem;
    flex-shrink: 0;
    background: inherit;
}

.sidebar-footer .nav-link-logout {
    color: #e74c3c !important;
    font-weight: 600;
}

.sidebar-footer .nav-link-logout:hover {
    background: rgba(231, 76, 60, 0.15) !important;
    color: #ff6b6b !important;
    border-left-color: #e74c3c !important;
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

.account-menu .btn-account {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 50px;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.account-menu .btn-account:hover,
.account-menu .btn-account:focus {
    background: #eef2f6;
    border-color: #c5d0db;
    color: var(--primary-dark);
}

.account-menu .btn-account::after {
    margin-left: 0.25rem;
}

.account-menu .account-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: #fff;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    align-items: center;
    text-decoration: none;
}

.btn-logout:hover {
    background: #e74c3c;
    color: #fff;
}

.btn-notification {
    position: relative;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    padding: 0;
}

.btn-notification:hover {
    background: #f8f9fa;
    color: var(--primary-dark);
}

.btn-notification::after {
    display: none;
}

.activity-item:last-child {
    border-bottom: none !important;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f4f6f9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-heading { color: var(--primary); font-weight: 600; }

/* Stat Cards */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border-left: 4px solid var(--primary);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: #7f8c8d; font-size: 0.85rem; }

.stat-card.orange { border-left-color: var(--accent); }
.stat-card.green { border-left-color: #27ae60; }
.stat-card.red { border-left-color: #e74c3c; }
.stat-card.purple { border-left-color: #8e44ad; }
.stat-card.teal { border-left-color: #16a085; }

/* Cards */
.content-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.content-card .card-header-custom {
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables */
.table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}

/* Login page — see assets/css/login.css for guest auth layout */

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

.badge-status-pending { background: #f39c12; }
.badge-status-approved, .badge-status-cleared, .badge-status-active { background: #27ae60; }
.badge-status-rejected, .badge-status-inactive { background: #e74c3c; }
.badge-status-partial { background: #3498db; }

.admin-search-form {
    min-width: 200px;
    max-width: 260px;
}

.admin-search-form .form-control {
    border-radius: 50px 0 0 50px;
}

.admin-search-form .btn {
    border-radius: 0 50px 50px 0;
}

@media print {
    .sidebar,
    .topbar,
    .portal-footer,
    .btn,
    .alert,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-area {
        padding: 0 !important;
    }

    .content-card {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }

    body {
        background: #fff !important;
    }

    a[href]:after {
        content: none !important;
    }
}
