:root {
    --primary-blue: #0D2B5B;
    --primary-green: #7CB342;
    --bg-gray: #f4f7f6;
    --success-bg: #e8f5e9;
    --success-text: #2e7d32;
    --danger-bg: #ffebee;
    --danger-text: #c62828;
    --text-dark: #333;
    --text-muted: #6c757d;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    transition: all 0.3s ease;
}

body {
    background-color: var(--bg-gray);
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    color: var(--text-dark);
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--primary-blue);
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-header {
    flex-shrink: 0;
    background-color: var(--primary-blue);
    z-index: 11;
    padding-bottom: 5px;
}

.sidebar-brand {
    padding: 1.5rem 1rem; /* Reduced horizontal padding */
    font-size: 1.3rem; /* Reduced font size from 1.5rem */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap; /* Prevent breaking into 2 lines */
}

.sidebar-user {
    padding: 1.5rem 1rem;
    text-align: center;
    background: rgba(0,0,0,0.15);
    margin: 10px;
    border-radius: 20px;
    border-bottom: none;
}

.user-photo-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
}

.user-photo-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--primary-green);
    object-fit: cover;
    background: rgba(255,255,255,0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    background-clip: padding-box;
    margin: 0 auto;
}

.online-indicator {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: var(--primary-green);
    border: 3px solid var(--primary-blue);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(124, 179, 66, 0.5);
}

.user-name {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: #fff;
    letter-spacing: 0.5px;
}

.user-role-badge {
    display: inline-block;
    font-size: 0.7rem;
    color: #fff;
    background: rgba(124, 179, 66, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(124, 179, 66, 0.4);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
}

/* Custom scrollbar for sidebar */
.sidebar-body::-webkit-scrollbar {
    width: 8px;
}
.sidebar-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--primary-green);
    border-radius: 10px;
    border: 2px solid var(--primary-blue);
}
.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: #8bc34a; /* Slightly lighter green on hover */
}

.sidebar-menu {
    padding: 1rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 5px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    gap: 12px;
    font-weight: 500;
}

.sidebar-link:hover, .sidebar-link.active {
    color: white;
    background-color: rgba(255,255,255,0.1);
    border-left: 4px solid var(--primary-green);
}

.sidebar-link i {
    width: 20px;
    text-align: center;
}

/* Sub-menu Styles */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.1);
}

.sidebar-submenu .sidebar-link {
    padding-left: 3.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.sidebar-submenu .sidebar-link:hover, .sidebar-submenu .sidebar-link.active-sub {
    border-left: none;
    background-color: rgba(255,255,255,0.05);
    color: var(--primary-green);
}

/* Main Content Area */
.main-layout {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.sidebar.sidebar-collapsed {
    transform: translateX(-100%);
}

.main-layout.sidebar-collapsed {
    margin-left: 0 !important;
}

body.sidebar-collapsed #sidebarMarginToggleBtn {
    left: 15px !important;
}

.top-bar {
    height: 80px;
    background: white;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.container {
    padding: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0;
}

.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    padding: 30px;
    margin-bottom: 20px;
    border: none;
}

/* Modern Table Styles */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

th {
    background-color: #f8f9fa;
    color: var(--text-dark);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 15px 12px;
    border-bottom: 2px solid #edf2f7;
    text-align: left;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
    font-size: 0.9rem;
    color: #4a5568;
}

tbody tr {
    position: relative;
}

tbody tr:nth-child(even) {
    background-color: #fcfdfe;
}

tbody tr:hover {
    background-color: #f7fafc;
    position: relative;
    z-index: 9999 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success { background: #e6fffa; color: #234e52; border: 1px solid #b2f5ea; }
.badge-danger { background: #fff5f5; color: #822727; border: 1px solid #feb2b2; }
.badge-warning { background: #fffaf0; color: #7b341e; border: 1px solid #fbd38d; }
.badge-info { background: #ebf8ff; color: #2c5282; border: 1px solid #bee3f8; }
.badge-cyan { background: #00bcd4; color: white; border: 1px solid #00acc1; }
.badge-primary { background: #ebf4ff; color: #2a4365; border: 1px solid #c3dafe; }

/* Forms & Buttons */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
    background: #fff;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(13, 43, 91, 0.1);
}

.btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background-color: #1a3a6e;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(13, 43, 91, 0.2);
}

.btn-block {
    display: block;
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stats-card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    border-left: 5px solid var(--primary-blue);
    display: flex;
    flex-direction: column;
}

.stats-card.green {
    border-left-color: var(--primary-green);
}

.stats-card .label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stats-card .value {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-dark);
}

.text-center { text-align: center; }
.mt-3 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* Simple Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.col-md-12, .col-md-9, .col-md-8, .col-md-6, .col-md-4, .col-md-3 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

@media (min-width: 768px) {
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
}

.btn-outline {
    background: transparent;
    border: 1px solid #ddd;
    color: var(--text-dark);
}

.btn-outline:hover {
    background: #f8f9fa;
    border-color: #ccc;
}

/* Action Dropdown Styles */
.action-dropdown {
    position: relative;
    display: inline-block;
}
.action-dropdown .dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #ffffff !important;
    background-color: #ffffff !important;
    min-width: 165px;
    box-shadow: 0px 10px 25px rgba(0,0,0,0.2) !important;
    z-index: 99999 !important;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    margin-top: 4px;
    opacity: 1 !important;
}
.action-dropdown .dropdown-content a,
.action-dropdown .dropdown-content button {
    color: #334155 !important;
    padding: 10px 14px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    width: 100%;
    border: none;
    background: #ffffff !important;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s ease;
}
.action-dropdown .dropdown-content a:hover,
.action-dropdown .dropdown-content button:hover {
    background-color: #f1f5f9 !important;
    color: #0284c7 !important;
}
.action-dropdown:hover .dropdown-content {
    display: block !important;
}

/* Responsive & Scrollable Modal Base Rules */
#quickRadModal, #captureScanModal, #resultModal, #duplicateModal, #consultationModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    box-sizing: border-box !important;
    backdrop-filter: blur(4px) !important;
}

#quickRadModal > div,
#captureScanModal > div,
#resultModal > div,
#duplicateModal > div,
#consultationModal > div {
    position: relative !important;
    width: 95% !important;
    max-width: 680px !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    padding: 22px !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3) !important;
    box-sizing: border-box !important;
    margin: auto !important;
    scrollbar-width: thin !important;
    scrollbar-color: #0284c7 #f1f5f9 !important;
}

@media (max-width: 640px) {
    #quickRadModal > div,
    #captureScanModal > div,
    #resultModal > div,
    #duplicateModal > div,
    #consultationModal > div {
        width: 98% !important;
        max-width: 98% !important;
        padding: 15px !important;
        max-height: 88vh !important;
        border-radius: 12px !important;
    }

    #quickRadModal div[style*="display:flex"],
    #captureScanModal div[style*="display:flex"],
    #resultModal div[style*="display:flex"] {
        flex-wrap: wrap !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    .sidebar-brand span, .sidebar-link span, .sidebar-user .user-name, .sidebar-user .user-role {
        display: none;
    }
    .sidebar-user .user-photo {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    .main-layout {
        margin-left: 70px;
    }
}