/* ================================
   RESET & BASE STYLES
   ================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Yellow, White, Orange Theme */
    --primary-color: #f21b23;
    --primary-dark: #d91820;
    --secondary-color: #f21b23;
    --accent-color: #f21b23;
    --success-color: #4caf50;
    --danger-color: #f44336;
    
    --bg-primary: #e5e5e5;
    --bg-secondary: #e5e5e5;
    --bg-card: #ffffff;
    --bg-gray: #e5e5e5;
    --bg-light-gray: #fafafa;
    
    --text-primary: #4d4d4f;
    --text-secondary: #4d4d4f;
    --text-muted: #4d4d4f;
    
    --border-color: #e5e5e5;
    --hover-overlay: #e5e5e5;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 3px 12px rgba(0, 0, 0, 0.18);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Layout */
    --navbar-height: 76px;
    --sidebar-width: 260px;
}

body {
    font-family: var(--theme-font-family, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    background: var(--theme-body-bg, #e5e5e5);
    background-attachment: fixed;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: var(--theme-text-primary, var(--text-primary));
    overflow-x: hidden;
    font-size: var(--theme-font-size, 100%);
}

body.night-mode {
    background: #2e2c2c;
}

body.night-mode::-webkit-scrollbar-track {
    background: #2e2c2c;
}

body.night-mode::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

body.night-mode::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ================================
   NAVBAR
   ================================ */
/* Light Mode Navbar */
.light-mode .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    color: rgba(255, 255, 255, 0.95);
}

/* Night Mode Navbar */
.night-mode .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    color: rgba(255, 255, 255, 0.95);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(242, 27, 35, 0.3);
    position: relative;
    z-index: 1001;
    -webkit-user-select: none;
    user-select: none;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.light-mode .menu-toggle svg {
    width: 24px;
    height: 24px;
    color: rgba(255, 255, 255, 0.95);
}

.night-mode .menu-toggle svg {
    width: 24px;
    height: 24px;
    color: rgba(255, 255, 255, 0.95);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.brand-icon {
    width: 36px;
    height: 36px;
    color: #f87171;
}

.brand-icon--img {
    object-fit: contain;
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-icon-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(242, 27, 35, 0.3);
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.light-mode .nav-icon-btn svg {
    width: 22px;
    height: 22px;
    color: rgba(255, 255, 255, 0.95);
}

.night-mode .nav-icon-btn svg {
    width: 22px;
    height: 22px;
    color: rgba(255, 255, 255, 0.95);
}

.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #f21b23;
    color: var(--text-primary);
    font-size: 0.7rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Light Mode User Pill */
.light-mode .user-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.light-mode .user-profile:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(249, 115, 22, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Night Mode User Pill */
.night-mode .user-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.night-mode .user-profile:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.light-mode .user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.night-mode .user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-icon {
    width: 16px;
    height: 16px;
    display: none;
}

/* ================================
   SIDEBAR
   ================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--navbar-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    max-height: calc(100vh - var(--navbar-height));
    background: var(--theme-sidebar-bg, rgba(255, 255, 255, 0.75));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
    z-index: 900;
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--theme-sidebar-text, #ffffff);
}

/* Light mode: restore previous/original sidebar colors (dark bar, white text, red header) */
.light-mode .sidebar {
    background: rgba(0, 0, 0, 0.95);
    color: #ffffff;
    border-right-color: rgba(255, 255, 255, 0.15);
}
.light-mode .sidebar-header {
    background: #910404e0;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}
.light-mode .sidebar-header h3,
.light-mode .sidebar-close-btn,
.light-mode .menu-link {
    color: #ffffff;
}
.light-mode .menu-link:hover {
    background: #e5e5e5;
    color: #f21b23;
}
.light-mode .menu-item.active .menu-link,
.light-mode .menu-dropdown.open > .menu-link {
    background: #e5e5e5;
    color: #f21b23;
    border-left-color: #f21b23;
}
.light-mode .submenu {
    background: #fafafa;
}
.light-mode .submenu-link {
    color: #4d4d4f;
}
.light-mode .submenu-link:hover {
    background: #e5e5e5;
    color: #f21b23;
}
.light-mode .submenu-item.active .submenu-link {
    background: #e5e5e5;
    color: #f21b23;
}
.light-mode .submenu-nested {
    background: rgba(0, 0, 0, 0.05);
}
.light-mode .sidebar-close-btn:hover {
    background: #e5e5e5;
    color: #f21b23;
}

/* Prevent page scroll when any sidebar dropdown is open */
body.sidebar-dropdown-open {
    overflow: hidden;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
    background: #910404e0;
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--theme-sidebar-text, #ffffff);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0.4rem 0.55rem;
    margin: 0;
}

/* Sidebar close button – visible only on mobile */
.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--theme-sidebar-text, #ffffff);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: rgba(242, 27, 35, 0.3);
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    background: #e5e5e5;
    color: #f21b23;
}

.sidebar-close-btn svg {
    width: 24px;
    height: 24px;
}

.sidebar-menu {
    flex: 1;
    list-style: none;
    padding: var(--spacing-xs) 0;
}

.menu-item {
    margin-bottom: 0.125rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.5rem var(--spacing-md);
    color: var(--theme-sidebar-text, #ffffff);
    text-decoration: none;
    transition: all var(--transition-fast);
    font-weight: 500;
    font-size: 0.8125rem;
    border-left: 3px solid transparent;
}

.menu-link:hover {
    background: #e5e5e5;
    color: #f21b23;
}

.menu-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.menu-item.active .menu-link {
    background: #e5e5e5;
    color: #f21b23;
    border-left-color: #f21b23;
    font-weight: 600;
}

/* Dropdown Menu Styles */
.menu-dropdown .menu-link {
    position: relative;
}

.dropdown-arrow {
    width: 14px;
    height: 14px;
    margin-left: auto;
    transition: transform var(--transition-normal);
}

.menu-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
    background: var(--bg-light-gray);
}

.menu-dropdown.open .submenu {
    max-height: 500px;
}

.submenu-item {
    border-left: 3px solid transparent;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.4rem var(--spacing-md) 0.4rem 2.25rem;
    color: #4d4d4f;
    text-decoration: none;
    transition: all var(--transition-fast);
    font-weight: 500;
    font-size: 0.75rem;
}

.submenu-link:hover {
    background: #e5e5e5;
    color: #f21b23;
}

.submenu-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.submenu-item.active {
    border-left-color: #f21b23;
}

.submenu-item.active .submenu-link {
    background: #e5e5e5;
    color: #f21b23;
    font-weight: 600;
}

/* Nested submenu (e.g. Sites & Workareas under Settings) */
.submenu-item.submenu-dropdown .submenu-link {
    padding-right: 1.5rem;
}
.submenu-item.submenu-dropdown .dropdown-arrow {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform var(--transition-normal);
}
.submenu-item.submenu-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}
.submenu-nested {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
    background: rgba(0, 0, 0, 0.05);
}
.submenu-item.submenu-dropdown.open .submenu-nested {
    max-height: 200px;
}
.submenu-nested .submenu-link {
    padding-left: 2.75rem;
}

.sidebar-footer {
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 2px solid var(--border-color);
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 0.5rem var(--spacing-md);
    background: #f21b23;
    color: white;
    border: none;
    /* border-radius: var(--radius-md); */
    border-radius: 0.35rem;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(242, 27, 35, 0.3);
    min-height: 36px;
}

.logout-btn:hover {
    background: #d91820;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* ================================
   MAIN CONTENT
   ================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
    background: var(--theme-content-bg, var(--bg-gray));
    transition: margin-left var(--transition-normal);
}

/* Create Audit (and similar short forms): don't stretch layout, remove empty space below form */
body.create-audit-route {
    min-height: 0;
}
body.create-audit-route .main-content {
    min-height: 0;
}
.main-content:has(.create-audit-container) {
    min-height: 0;
}

.night-mode .main-content {
    background: #2e2c2c;
}

/* ================================
   SAT DASHBOARD – NIGHT MODE TEXT & LAYOUT
   ================================ */
.night-mode .content-wrapper,
.night-mode .content-wrapper h1,
.night-mode .content-wrapper h2 {
    color: rgba(255, 255, 255, 0.95);
}

.night-mode .content-wrapper h1,
.night-mode .content-wrapper h2 {
    color: rgba(255, 255, 255, 0.98);
}

/* Sidebar – dark theme (consistent Settings menu and submenus) */
.night-mode .sidebar {
    background: #1a1a1a;
    border-right-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

.night-mode .sidebar-header {
    background: #910404e0;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

.night-mode .sidebar-header h3 {
    color: #ffffff;
}

.night-mode .sidebar-header .sidebar-close-btn {
    color: #ffffff;
}

.night-mode .menu-link {
    color: rgba(255, 255, 255, 0.9);
}

.night-mode .menu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f87171;
}

.night-mode .menu-item.active .menu-link,
.night-mode .menu-dropdown.open > .menu-link {
    background: rgba(255, 255, 255, 0.08);
    color: #f87171;
    border-left-color: #f87171;
    font-weight: 600;
}

.night-mode .submenu {
    background: rgba(255, 255, 255, 0.03);
}

.night-mode .submenu-link {
    color: rgba(255, 255, 255, 0.85);
}

.night-mode .submenu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f87171;
}

.night-mode .submenu-item.active .submenu-link {
    background: rgba(255, 255, 255, 0.08);
    color: #f87171;
    border-left-color: #f87171;
    font-weight: 600;
}

.night-mode .submenu-nested {
    background: rgba(0, 0, 0, 0.2);
}

.night-mode .submenu-nested .submenu-link {
    color: rgba(255, 255, 255, 0.85);
}

.night-mode .submenu-nested .submenu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f87171;
}

.night-mode .submenu-nested .submenu-item.active .submenu-link {
    background: rgba(255, 255, 255, 0.08);
    color: #f87171;
    border-left-color: #f87171;
}

.night-mode .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f87171;
}

.night-mode .sidebar-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.night-mode .logout-btn {
    color: rgba(255, 255, 255, 0.95);
}

/* Form & table sections – dark cards, light text */
.night-mode .form-section,
.night-mode .table-section {
    background: #3a3838;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.night-mode .form-header,
.night-mode .table-header {
    border-bottom-color: rgba(255, 255, 255, 0.15);
}

.night-mode .form-header h1,
.night-mode .table-header h2,
.night-mode .table-section h2 {
    color: rgba(255, 255, 255, 0.98);
}

.night-mode .input-label {
    color: rgba(255, 255, 255, 0.85);
}

.night-mode .close-btn svg {
    color: rgba(255, 255, 255, 0.8);
}

.night-mode .close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.night-mode .form-actions,
.night-mode .table-controls {
    border-top-color: rgba(255, 255, 255, 0.12);
}

.night-mode .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
}

.night-mode .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(242, 27, 35, 0.5);
}

.night-mode .control-btn {
    color: rgba(255, 255, 255, 0.85);
}

.night-mode .control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f87171;
}

.night-mode .default-password-info {
    color: #f87171;
}

.night-mode .sidebar::-webkit-scrollbar-track {
    background: #1e1d1d;
}

.night-mode .sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.night-mode .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.night-mode .input-field {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
}

.night-mode .input-field::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.night-mode .input-field:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(242, 27, 35, 0.6);
}

/* Disabled inputs: readable in dark mode */
.night-mode .input-field:disabled,
.night-mode .input-field[readonly] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
    cursor: not-allowed;
}

.night-mode .select-field {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
}

.night-mode .select-field option {
    background: #2e2c2c;
    color: rgba(255, 255, 255, 0.95);
}

.night-mode .select-field:disabled {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
    cursor: not-allowed;
}

.night-mode .user-table td {
    color: rgba(255, 255, 255, 0.85);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.night-mode .user-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Tab navigation (Add Site, Add Workarea, etc.) – dark mode */
.night-mode .tab-navigation {
    border-bottom-color: rgba(255, 255, 255, 0.15);
}
.night-mode .tab-btn {
    color: rgba(255, 255, 255, 0.8);
}
.night-mode .tab-btn svg {
    color: rgba(255, 255, 255, 0.8);
}
.night-mode .tab-btn:hover {
    color: #f87171;
    background: rgba(255, 255, 255, 0.06);
}
.night-mode .tab-btn:hover svg {
    color: #f87171;
}
.night-mode .tab-btn.active {
    color: #f87171;
    border-bottom-color: #f87171;
}
.night-mode .tab-btn.active svg {
    color: #f87171;
}

/* Error message (Add Site, Add Workarea, etc.) */
.user-create-error {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border: 1px solid rgba(244, 67, 54, 0.3);
}
.required-asterisk {
    color: var(--primary-color, #f21b23);
}
/* Error message & required asterisk – dark mode */
.night-mode .user-create-error {
    background: rgba(248, 113, 113, 0.15);
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.4);
}
.night-mode .required-asterisk {
    color: #f87171;
}

.user-create-success {
    color: var(--success-color, #4caf50);
}
.night-mode .user-create-success {
    color: #86efac;
}

/* Table header (All Sites tab) – dark mode */
.night-mode .user-table th {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.15);
}

/* Action button (Delete) in tables – dark mode */
.night-mode .action-btn.btn-delete {
    background: rgba(255, 255, 255, 0.1);
    color: #fca5a5;
}
.night-mode .action-btn.btn-delete:hover {
    background: rgba(248, 113, 113, 0.3);
    color: #fecaca;
}

.sidebar.collapsed ~ .main-content {
   margin-left: 0;
}

.content-wrapper {
    padding: var(--spacing-xl);
    max-width: 1600px;
    margin: 0 auto;
}

.content-wrapper > h1,
.content-wrapper > h2 {
    margin-top: 0;
    margin-bottom: var(--spacing-lg);
}

.content-wrapper > .tab-navigation {
    margin-top: 0;
    margin-bottom: var(--spacing-xl);
}

/* Tab navigation base (Add Site, Add Workarea – when TabNavigation.css not in bundle) */
.tab-navigation {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color, #e5e5e5);
    padding-bottom: 0;
}
.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary, #4d4d4f);
    transition: all 0.3s;
    position: relative;
    font-family: inherit;
}
.tab-btn svg {
    width: 20px;
    height: 20px;
}
.tab-btn:hover {
    color: var(--primary-color, #f21b23);
    background: rgba(242, 27, 35, 0.05);
}
.tab-btn:hover svg {
    color: var(--primary-color, #f21b23);
}
.tab-btn.active {
    color: var(--primary-color, #f21b23);
    border-bottom-color: var(--primary-color, #f21b23);
    font-weight: 600;
}
.tab-btn.active svg {
    color: var(--primary-color, #f21b23);
}

.content-wrapper > .table-section:first-child,
.content-wrapper > .form-section:first-child {
    margin-top: 0;
}

.content-wrapper > div:first-child {
    margin-top: 0;
}

/* ================================
   FORM SECTION
   ================================ */
.form-section {
    background: var(--bg-card);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: block;
    width: 100%;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    width: 100%;
    flex-wrap: nowrap;
}

.form-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
}

.close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 152, 0, 0.3);
    min-height: 44px;
    min-width: 44px;
}

.close-btn:hover {
    background: var(--bg-gray);
}

.close-btn svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.user-form {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.input-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.input-label {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.input-label.required::after {
    content: ' *';
    color: var(--accent-color);
}

.input-field {
    width: 100%;
    padding: 0.95rem 1.1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

.input-field::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    transition: all 0.3s ease;
}

.input-field:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

.input-field:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.06), 0 6px 20px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

.input-field:focus::placeholder {
    color: var(--text-muted);
    transform: translateX(4px);
}

/* Enhanced focus effect for parent label */
.input-group:focus-within .input-label {
    color: var(--primary-color);
    transform: translateX(2px);
}

.select-field {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 3rem;
    background-color: rgba(255, 255, 255, 0.95);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ff9800' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 20px 20px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.select-field:hover {
    background-color: rgba(255, 255, 255, 0.97);
    padding-right: 3.2rem;
}

.select-field:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ff9800' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 20px 20px;
}

.select-field option {
    padding: 0.75rem;
    background: #fff;
    color: var(--text-primary);
    font-weight: 500;
}

.select-field option:hover {
    background: rgba(255, 152, 0, 0.1);
}

.default-password-info {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 500;
    margin-top: var(--spacing-xs);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 2px solid var(--border-color);
}

.btn-primary,
.btn-secondary {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 152, 0, 0.3);
    min-height: 44px;
    min-width: 44px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-primary:active {
    background: #ef6c00;
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-gray);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

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

/* ================================
   TABLE SECTION
   ================================ */
.table-section {
    background: var(--bg-card);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: block;
    width: 100%;
}

/* Removed duplicate - now handled above */

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
    width: 100%;
    flex-wrap: nowrap;
}

.table-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4d4d4f;
    margin: 0;
    padding: 0;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
}

.table-section h2 {
    color: #4d4d4f;
    margin: 0;
    padding: 0;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.control-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 152, 0, 0.3);
    min-height: 44px;
    min-width: 44px;
}

.control-btn:hover {
    background: var(--bg-gray);
}

.control-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.btn-export {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-normal);
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 152, 0, 0.3);
    min-height: 44px;
    min-width: 44px;
}

.btn-export:hover {
    background: #e64a19;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-export svg {
    width: 18px;
    height: 18px;
}

.table-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    font-size: 0.9rem;
}

.show-entries {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-secondary);
}

.entries-select {
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-gray);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-secondary);
}

.search-field {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-gray);
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: all var(--transition-normal);
}

.search-field:focus {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.1);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.user-table thead {
    background: linear-gradient(135deg, #f21b23 0%, #d91820 100%);
}

.user-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: white;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.user-table th:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.user-table tbody tr {
    transition: background var(--transition-fast);
}

.user-table tbody tr:hover {
    background: var(--hover-overlay);
}

.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.badge-no {
    background: #ffebee;
    color: #c62828;
}

.badge-yes {
    background: #e8f5e9;
    color: #2e7d32;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    margin-right: var(--spacing-xs);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 152, 0, 0.3);
    min-height: 44px;
    min-width: 44px;
}

.btn-update {
    background: #546e7a;
    color: white;
}

.btn-update:hover {
    background: #455a64;
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.btn-delete {
    background: #546e7a;
    color: white;
}

.btn-delete:hover {
    background: #455a64;
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */
@media (max-width: 1200px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1100;
        width: 280px;
    }
    
    .sidebar:not(.collapsed) {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }

    .sidebar-close-btn {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }
    
    .user-name {
        display: none;
    }
    
    .user-profile {
        padding: 0.25rem;
    }
    
    /* Overlay when sidebar is open on mobile */
    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1099;
        pointer-events: auto;
        animation: fadeIn 0.3s ease;
    }
    
    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    /* Ensure menu toggle is always clickable */
    .menu-toggle {
        z-index: 1101;
    }
}

@media (max-width: 768px) {
    .content-wrapper {
        padding: var(--spacing-md);
    }

    .form-section,
    .table-section {
        padding: var(--spacing-md);
    }

    .form-header,
    .table-header {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: flex-start;
    }

    .table-controls-bar {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    .brand-text {
        display: none;
    }
    
    .navbar {
        padding: 0 var(--spacing-md);
    }
    
    /* Ensure buttons are clickable on mobile */
    button,
    .btn-primary,
    .btn-secondary,
    .action-btn,
    .control-btn,
    .tab-btn,
    .menu-toggle,
    .nav-icon-btn,
    .logout-btn,
    .close-btn {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        pointer-events: auto;
        position: relative;
        z-index: 1;
    }
    
    /* Prevent double-tap zoom on buttons */
    button:active,
    .btn-primary:active,
    .btn-secondary:active,
    .action-btn:active {
        transform: scale(0.98);
    }
}

/* ================================
   ANIMATIONS
   ================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.input-field.error {
    border-color: var(--danger-color);
    animation: shake 0.5s;
}

html {
    scroll-behavior: smooth;
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.sidebar::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.sidebar::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track {
    background: var(--bg-gray);
}

.sidebar::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: var(--radius-sm);
}

.sidebar::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Global Search Styles */
.navbar-search {
    position: relative;
}

.navbar-search input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.3);
    width: 350px;
}

@media (max-width: 768px) {
    .navbar-search {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        margin-top: 0.5rem;
        z-index: 1001;
    }
    
    .navbar-search input {
        width: 100% !important;
    }
    
    #searchResults {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
    }
}

/* ----- Logout modal (same as Master Dashboard sign-out popup) ----- */
.master-logout-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
}

.master-logout-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, 92vw);
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(148, 163, 184, 0.2);
    padding: 1.5rem 1.75rem 1.25rem;
}

.master-logout-modal-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1f2933;
}

.master-logout-modal-text {
    margin: 0 0 1.25rem 0;
    font-size: 0.9375rem;
    color: #4b5563;
    line-height: 1.6;
}

.master-logout-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.master-logout-modal-btn {
    min-width: 100px;
    padding: 0.5rem 0.9rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease-in-out;
}

.master-logout-modal-btn--secondary {
    background: #ffffff;
    color: #4b5563;
    border-color: rgba(148, 163, 184, 0.5);
}

.master-logout-modal-btn--secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: rgba(148, 163, 184, 0.9);
}

.master-logout-modal-btn--primary {
    background: linear-gradient(135deg, #f21b23 0%, #d91820 100%);
    color: #ffffff;
    border-color: rgba(248, 113, 113, 0.6);
    box-shadow: 0 2px 8px rgba(248, 113, 113, 0.45);
}

.master-logout-modal-btn--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #d91820 0%, #c2151d 100%);
    box-shadow: 0 4px 14px rgba(248, 113, 113, 0.55);
}

.master-logout-modal-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    box-shadow: none;
}

.master-logout-modal-btn:active:not(:disabled) {
    transform: translateY(1px);
}

/* Sign-out modal dark mode (same color scheme as ConfirmPopup) */
body.night-mode .master-logout-modal {
    background: #3a3838;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

body.night-mode .master-logout-modal-title {
    color: rgba(255, 255, 255, 0.98);
}

body.night-mode .master-logout-modal-text {
    color: rgba(255, 255, 255, 0.85);
}

body.night-mode .master-logout-modal-btn--secondary {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.25);
}

body.night-mode .master-logout-modal-btn--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.98);
}

body.night-mode .master-logout-modal-btn--primary {
    background: linear-gradient(135deg, #f21b23 0%, #d91820 100%);
    color: #ffffff;
    border-color: rgba(248, 113, 113, 0.6);
}

body.night-mode .master-logout-modal-btn--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #f87171 0%, #f21b23 100%);
    border-color: rgba(248, 113, 113, 0.7);
}
