:root {

        /* Login Page Palette */
    --login-gradient-start: #667eea;
    --login-gradient-end: #764ba2;
    --login-card-bg: rgba(255, 255, 255, 0.95);
    --login-input-border: #e1e5e9;
    --login-input-focus: #667eea;
    --login-button-gradient-start: #667eea;
    --login-button-gradient-end: #764ba2;
    --login-error-bg: #fee;
    --login-error-text: #c53030;
    --login-error-border: #e53e3e;
    --login-step-active: #667eea;
    --login-step-complete: #48bb78;
    --login-step-inactive: #cbd5e0;
    /* Font Theme */
    --primary-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-base: 14px;
    --font-size-small: 12px;
    --font-size-medium: 16px;
    --font-size-large: 18px;
    --font-size-xl: 24px;
    --font-size-xxl: 28px;

    /* Bar Colors (Top Bar) */
    --bar-background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bar-text-color: white;
    --bar-text-opacity: 0.9;
    --bar-border-color: rgba(255, 255, 255, 0.3);
    --bar-hover-background: rgba(255, 255, 255, 0.2);

    /* Button Colors */
    --button-primary-color: #667eea;
    --button-primary-hover: #5a6fd8;
    --button-text-color: white;
    --button-border-radius: 6px;
    --button-padding: 8px 16px;
    --button-transition: all 0.3s ease;

    /* Table Header Color (same as button primary) */
    --table-header-background: var(--button-primary-color);
    --table-header-border: var(--button-primary-hover);
    --table-header-text: white;

    /* Context Button Colors (in order) */
    --context-btn-color-1: #C15A16;
    --context-btn-color-2: #008031;
    --context-btn-color-3: #1D9CF3;
    --context-btn-text: white;

    /* Background Colors */
    --main-background: #f5f7fa;
    --card-background: white;
    --menu-background: white;
    --context-section-background: #f0f4fa;

    /* Border and Shadow */
    --border-radius: 8px;
    --border-radius-large: 12px;
    --box-shadow-light: 0 2px 8px rgba(0,0,0,0.1);
    --box-shadow-medium: 0 2px 10px rgba(0, 0, 0, 0.05);
    --box-shadow-strong: 0 8px 25px rgba(0, 0, 0, 0.1);
    --border-color: #e1e5e9;
    --border-color-light: #eee;

    /* Text Colors */
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #666;
    --text-light: #999;
    --text-accent: var(--button-primary-color);

    /* Interactive States */
    --hover-background: #f8f9ff;
    --hover-background-light: #f0f4ff;
    --active-border: var(--button-primary-color);
    --input-focus-color: var(--button-primary-color);
    --input-focus-shadow: 0 0 5px rgba(102, 126, 234, 0.3);

    /* Responsive Breakpoints */
    --mobile-breakpoint: 768px;
    --tablet-breakpoint: 900px;

    /* Reduced spacing variables */
    --top-bar-height-reduced: 12vh; /* Reduced from 16.67vh */
    --main-content-height-reduced: 88vh; /* Increased from 83.33vh */
    --minimal-padding: 15px; /* Reduced from 30px */
    --minimal-margin: 10px; /* Reduced from 20px */
    --minimal-card-padding: 15px; /* Reduced from 30px */

    /* Minimal top bar height */
    --top-bar-height-minimal: 60px; /* Fixed pixel height instead of vh */
    --main-content-height-minimal: calc(100vh - 60px); /* Remaining height */
    
    /* Even more reduced spacing */
    --ultra-minimal-padding: 8px;
    --ultra-minimal-margin: 5px;
    --ultra-minimal-card-padding: 10px;
}

/* Alternative Theme Example (uncomment to use) */
/*
:root {
    --primary-font: 'Arial', sans-serif;
    --bar-background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --button-primary-color: #3498db;
    --button-primary-hover: #2980b9;
    --context-btn-color-1: #e74c3c;
    --context-btn-color-2: #27ae60;
    --context-btn-color-3: #f39c12;
    --main-background: #ecf0f1;
}
*/

/* Override top bar height globally */
.top-bar {
    height: var(--top-bar-height-minimal) !important;
    min-height: var(--top-bar-height-minimal) !important;
    padding: var(--ultra-minimal-padding) var(--minimal-padding) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Centered content in top bar */
.top-bar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

/* Adjust main container height accordingly */
.main-container {
    height: var(--main-content-height-minimal) !important;
    min-height: var(--main-content-height-minimal) !important;
}

/* Global minimal content padding */
.main-content {
    padding: var(--ultra-minimal-padding) !important;
    height: 100%;
    overflow-y: auto;
}

/* Global minimal card styling */
.content-card {
    padding: var(--ultra-minimal-card-padding) !important;
    margin: var(--ultra-minimal-margin) !important;
}

/* Reduce dashboard flex row spacing */
.dashboard-flex-row {
    margin-bottom: var(--ultra-minimal-margin) !important;
    height: calc(100vh - 60px - 20px) !important; /* Account for minimal top bar */
    gap: var(--ultra-minimal-margin);
}

/* Global minimal table styling */
.data-table th {
    padding: 5px 8px !important; /* Further reduced */
    font-size: 0.85em !important;
    line-height: 1.1;
}

.data-table td {
    padding: 6px 8px !important; /* Further reduced */
    font-size: 0.85em !important;
    line-height: 1.2;
}

/* Global minimal summary card styling */
.summary-card {
    padding: 10px !important; /* Further reduced */
    border-radius: 6px !important;
}

.summary-icon {
    font-size: 1.8em !important; /* Further reduced */
    margin-left: 8px !important;
}

.summary-value {
    font-size: 1.4em !important; /* Further reduced */
    margin-bottom: 2px !important;
}

.summary-label {
    font-size: 0.8em !important;
}

/* Global minimal button styling */
.btn {
    padding: 3px 6px; /* Reduced from 4px 8px */
    font-size: 10px; /* Reduced from 11px */
    margin: 0 1px; /* Reduced from 2px */
    border-radius: 3px; /* Reduced from 4px */
}

.btn-sm {
    padding: 2px 4px; /* Reduced from 3px 6px */
    font-size: 9px; /* Reduced from 10px */
}

/* Global minimal context button styling */
.context-btn {
    padding: 8px 16px; /* Reduced from default */
    font-size: 0.9em; /* Slightly smaller */
    margin: 0 5px; /* Reduced margin */
}

/* Global minimal section titles */
h2 {
    margin-bottom: 15px !important; /* Reduced from 20px */
    font-size: 1.5em; /* Reduced font size */
    line-height: 1.2; /* Tighter line height */
}

h3 {
    margin-bottom: 10px !important; /* Reduced from 15px */
    font-size: 1.2em; /* Reduced font size */
}

/* Global minimal table container styling */
.table-container {
    border-radius: 6px; /* Reduced from 8px */
}

/* Global minimal status and category badges */
.status-badge {
    padding: 2px 6px; /* Reduced from 4px 8px */
    border-radius: 8px; /* Reduced from 12px */
    font-size: 0.8em; /* Reduced from 0.85em */
}

.category-badge {
    padding: 2px 6px; /* Reduced from 3px 8px */
    border-radius: 6px; /* Reduced from 10px */
    font-size: 0.75em; /* Reduced from 0.8em */
}

/* Mobile responsiveness for minimal top bar */
@media (max-width: 900px) {
    .top-bar {
        height: 50px !important; /* Even smaller on mobile */
        padding: 5px 8px !important;
    }
    
    .main-container {
        height: calc(100vh - 50px) !important;
    }
    
    .system-logo img {
        height: 28px !important;
    }
    
    .system-info .app-title {
        font-size: 12px !important;
    }
    
    .entity-logo {
        font-size: 16px !important;
    }
    
    .entity-name,
    .entity-type,
    .user-name,
    .user-role {
        font-size: 9px !important;
    }
    
    .logout-btn {
        padding: 3px 6px !important;
        font-size: 9px !important;
    }
    
    /* Hide some elements on very small screens */
    .entity-type,
    .user-role {
        display: none;
    }
}

/* Ultra-mobile (phones) */
@media (max-width: 480px) {
    .top-bar {
        height: 45px !important;
        padding: 3px 5px !important;
    }
    
    .main-container {
        height: calc(100vh - 45px) !important;
    }
    
    .system-info .app-title {
        display: none; /* Hide title on very small screens */
    }
    
    .entity-info,
    .user-section {
        margin: 0 4px;
    }
}

/* Debug button styles */
.debug-btn {
    padding: 6px 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    color: #495057;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.debug-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

/* Debug modal styles */
.debug-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    direction: ltr; /* Force LTR for JSON display */
}

.debug-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.debug-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.debug-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.debug-modal-close:hover {
    color: black;
}

.debug-json-container {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    direction: ltr;
    text-align: left;
}

/* Modal overlay and content */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    direction: rtl;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header .close-btn:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary:hover:not(:disabled) {
    background-color: #0056b3;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: 1px solid #6c757d;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.autocomplete-arrow {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #6b7280;
    pointer-events: none;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

/* Rotate arrow when dropdown is open */
.autocomplete-dropdown.show ~ .autocomplete-arrow {
    transform: translateY(-50%) rotate(180deg);
}