:root {
    /* Colors - Verified from "StaffCentral" Design */
    --primary-color: #007AFF;
    --primary-hover: #0056b3;
    --primary-color-rgb: 0, 122, 255;
    --secondary-color: #FF2D55;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;
    
    /* Backgrounds */
    --bg-body: #F5F5F7;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-top-bar: rgba(255, 255, 255, 0.8);
    --bg-input: #f9f9f9;
    
    /* Borders & Dividers */
    --border-color: rgba(0, 0, 0, 0.06);
    --divider-color: rgba(0, 0, 0, 0.05);
    
    /* Text */
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --text-light: #FFFFFF;

    /* Shadows & Radius */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius-lg: 14px;
    --radius-md: 10px;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;

    --sidebar-width: 260px;
    --header-height: 60px;
}

[data-theme="dark"] {
    --bg-body: #0a0a0a;
    --bg-card: #1C1C1E;
    --bg-sidebar: #1C1C1E;
    --bg-top-bar: rgba(28, 28, 30, 0.8);
    --bg-input: #2C2C2E;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --divider-color: rgba(255, 255, 255, 0.1);
    
    --text-primary: #FFFFFF;
    --text-secondary: #AEAEB2;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: -0.01em;
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* Layout */
.app-container { display: flex; width: 100%; height: 100%; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
    z-index: 1000;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 8px;
}

.brand-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 6px;
}

.nav-menu { list-style: none; flex: 1; margin-top: 10px; }
.nav-item { margin-bottom: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(0, 122, 255, 0.08);
    color: var(--primary-color);
}

.nav-icon { margin-right: 10px; font-size: 16px; width: 20px; text-align: center; }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg-body);
}

.top-bar {
    height: var(--header-height);
    background-color: var(--bg-top-bar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    border-bottom: 1px solid var(--divider-color);
    z-index: 900;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-profile {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 500;
    cursor: pointer;
}

.avatar-circle {
    width: 32px; height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}

.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

/* Card & Components */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md); /* Uses new 12px value */
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.03);
    margin-bottom: var(--spacing-md);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

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

/* Forms */
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.1);
}

/* Mobile Menu Toggle */
.mobile-toggle {
    display: none;
    background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-primary);
    margin-right: 12px;
}

/* Overlay for Mobile Drawer */
.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 950;
    backdrop-filter: blur(2px);
}

/* Grid System */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--spacing-md); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-md); }

/* Responsive */
@media (max-width: 768px) {
    .mobile-toggle { display: block; }
    
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
    }
    
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    
    /* Force grids to single column */
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    
    .scroll-area { 
        padding: 12px;
    }
    
    /* Ensure no page-wide horizontal scroll */
    body, .main-content { overflow-x: hidden; width: 100%; }
    
    /* Typography on mobile */
    /* Mobile Header Adjustments */
    .top-bar { padding: 0 12px; gap: 8px; justify-content: space-between; }
    .user-profile { min-width: 32px; }
    
    .page-title {
        flex: 1;
        display: flex;
        align-items: center;
        overflow: hidden;
    }
    
    /* Mobile Header Adjustments */
    
    .page-title { 
        display: flex; 
        align-items: center; 
        flex: 1; 
        min-width: 0; /* Enable flex shrinking */
    }
    
    /* Default: Show Title */
    .page-header-text { 
        font-size: 16px; 
        font-weight: 600; 
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis;
        margin-right: 8px;
    }
    
    /* If Dropdown is present */
    .company-select-wrapper { margin-left: 0 !important; }
    .page-title form { flex: 1; min-width: 0; }
    
    /* On Mobile specifically */
    @media (max-width: 480px) {
        /* If a form (dropdown) exists inside page-title, hide the text to give full width to dropdown */
        .page-title form ~ .page-header-text,
        .page-title:has(form) .page-header-text {
            display: none;
        }
        
        /* Fallback for compatibility: If we can't reliably detect, 
           we prioritize key elements. Content usually has a header anyway. */
           
        /* Make dropdown 100% width of the title area */
        .company-select-wrapper { width: 100%; max-width: none; }
        .company-select { width: 100%; }
    }
    
    /* ---- MOBILE TABLE AS CARDS ---- */
    .table-responsive table, 
    .table-responsive thead, 
    .table-responsive tbody, 
    .table-responsive th, 
    .table-responsive td, 
    .table-responsive tr { 
        display: block; 
    }
    
    .table-responsive thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .table-responsive tr { 
        background: white;
        border: 1px solid #f0f0f0;
        border-radius: 12px;
        margin-bottom: 12px; /* Reduced */
        padding: 12px; /* Reduced */
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    
    .table-responsive td { 
        border: none;
        position: relative;
        padding: 8px 0 !important;
        display: flex;
        justify-content: space-between;
        align-items: flex-start; /* Align to top for multi-line */
        text-align: right;
        min-height: 32px;
    }
    
    .table-responsive td::before { 
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 11px;
        text-transform: uppercase;
        margin-right: 16px;
        text-align: left;
        flex-shrink: 0; /* Prevent label from shrinking */
        padding-top: 2px; /* Align with text baseline */
    }
    
    /* Content Wrapper Helper for Mobile */
    .mobile-cell-content {
        text-align: right;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }
    
    /* Hide table-responsive wrapper scroll */
    .table-responsive { overflow-x: visible; }
    
    /* Disable min-width */
    table { min-width: 0; }
}

/* Ensure images/cards don't overflow */
img, .card { max-width: 100%; }

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; /* Allow clicking through container */
}

.toast {
    pointer-events: auto;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    min-width: 300px;
    max-width: 400px;
    gap: 12px;
    animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
}

@keyframes slideInToast {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.toast-content i { font-size: 16px; }

/* Toast Variants */
.toast-success { border-left-color: var(--success-color); }
.toast-success i { color: var(--success-color); }

.toast-error, .toast-danger { border-left-color: var(--danger-color); }
.toast-error i, .toast-danger i { color: var(--danger-color); }

.toast-warning { border-left-color: var(--warning-color); }
.toast-warning i { color: var(--warning-color); }

.toast-info { border-left-color: var(--primary-color); }
.toast-info i { color: var(--primary-color); }

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.toast-close:hover { color: var(--text-primary); }

@media (max-width: 480px) {
    .toast-container {
        left: 12px;
        right: 12px;
        top: 12px;
        align-items: center;
    }
    .toast {
        width: 100%;
        min-width: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
}
