/**
 * Simba Security Management Service
 * Safety Checklist System - Main Stylesheet
 * Brand Colors: #171445 (Navy) and #c52428 (Red)
 */

/* CSS Variables */
:root {
    --primary: #171445;
    --primary-light: #2a2875;
    --primary-dark: #0d0c2b;
    --accent: #c52428;
    --accent-light: #e63946;
    --accent-dark: #9a1c1f;
    
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --white: #ffffff;
    --black: #000000;
    
    --font-primary: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 4px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Outfit:wght@100..900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    font-family: var(--font-primary);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--gray-800);
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent);
}

img {
    max-width: 100%;
    height: auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-900);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

/* Layout */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

.page-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--primary);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition-slow);
}

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

.sidebar-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: var(--white);
    border-radius: var(--radius);
    padding: 4px;
}

.sidebar-brand {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-brand small {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 0.5rem 1.5rem;
    margin-top: 1rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.8);
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-item.active {
    background: rgba(255,255,255,0.15);
    border-left-color: var(--accent);
    color: var(--white);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.125rem;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    color: var(--white);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    width: calc(100% - 280px);
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Top Header */
.top-header {
    background: var(--white);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
}

.header-icon-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.header-icon-btn .notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--white);
}

/* User Account Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    padding-right: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.user-dropdown-toggle:hover {
    background: var(--gray-100);
}

.user-dropdown.open .user-dropdown-toggle {
    background: var(--gray-100);
}

.dropdown-arrow {
    font-size: 0.75rem;
    color: var(--gray-400);
    transition: transform 0.2s ease;
    margin-left: 0.25rem;
}

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

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-info {
    line-height: 1.2;
    text-align: left;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-800);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Dropdown Menu */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 260px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
}

.dropdown-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.dropdown-user-info {
    flex: 1;
    min-width: 0;
}

.dropdown-user-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-user-email {
    font-size: 0.8rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.25rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9375rem;
}

.dropdown-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    color: var(--gray-400);
    transition: var(--transition);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-item-danger {
    color: var(--danger);
}

.dropdown-item-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.dropdown-item-danger i {
    color: var(--danger);
}

.dropdown-badge {
    margin-left: auto;
    background: var(--accent);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

/* Page Content */
.page-content {
    padding: 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card.primary { border-left-color: var(--primary); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card.primary .stat-icon { background: rgba(23, 20, 69, 0.1); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.info .stat-icon { background: var(--info-bg); color: var(--info); }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-display);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.stat-trend {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* Clearance Status Cards */
.clearance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.clearance-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.clearance-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Dynamic background colors based on status */
.clearance-card.clearance-status-cleared {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-left: 4px solid #10b981;
}

.clearance-card.clearance-status-pending {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
}

.clearance-card.clearance-status-not_cleared {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-left: 4px solid #ef4444;
}

.clearance-card.clearance-status-alert {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-left: 4px solid #ef4444;
    animation: alert-pulse 2s infinite;
}

@keyframes alert-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.95; }
}

.clearance-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
}

.clearance-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.clearance-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.clearance-subtitle {
    font-size: 0.8rem;
    opacity: 0.8;
}

.clearance-body {
    padding: 1.5rem;
}

.clearance-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-indicator {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.status-indicator.cleared {
    background: var(--success-bg);
    color: var(--success);
}

.status-indicator.not-cleared {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-indicator.pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-indicator.alert {
    background: var(--danger-bg);
    color: var(--danger);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.status-text {
    font-size: 1.25rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-text.cleared { color: var(--success); }
.status-text.not-cleared { color: var(--danger); }
.status-text.pending { color: var(--warning); }
.status-text.alert { color: var(--danger); }

.clearance-meta {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.clearance-meta strong {
    color: var(--gray-700);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

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

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

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

.btn-success:hover {
    background: #059669;
    color: var(--white);
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

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

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-label .required {
    color: var(--accent);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-800);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 20, 69, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-control.error {
    border-color: var(--danger);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.9375rem;
    cursor: pointer;
    line-height: 1.4;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    transition: var(--transition);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    background: var(--gray-50);
}

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

.table tbody tr:hover {
    background: var(--gray-50);
}

.table .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-primary { background: rgba(23, 20, 69, 0.1); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.badge-dot.success { background: var(--success); }
.badge-dot.warning { background: var(--warning); }
.badge-dot.danger { background: var(--danger); }
.badge-dot.info { background: var(--info); }

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success { background: var(--success-bg); color: #065f46; }
.alert-warning { background: var(--warning-bg); color: #92400e; }
.alert-danger { background: var(--danger-bg); color: #991b1b; }
.alert-info { background: var(--info-bg); color: #1e40af; }

.alert i {
    font-size: 1.25rem;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.875rem;
}

/* Duress Alert */
.duress-banner {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: duress-pulse 1s infinite;
}

@keyframes duress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

.duress-banner i {
    font-size: 1.5rem;
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Checklist Form */
.checklist-section {
    margin-bottom: 2rem;
}

.checklist-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kpi-item {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
    border: 2px solid transparent;
}

.kpi-item:hover {
    background: var(--white);
    border-color: var(--gray-200);
}

.kpi-item.critical {
    border-left: 4px solid var(--accent);
}

.kpi-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.kpi-name {
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kpi-name .critical-badge {
    background: var(--accent);
    color: var(--white);
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.kpi-description {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.kpi-response {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.kpi-toggle {
    display: flex;
    gap: 0.5rem;
}

.kpi-toggle .btn {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
}

.kpi-toggle .btn.pass {
    background: var(--gray-100);
    color: var(--gray-600);
}

.kpi-toggle .btn.pass.active {
    background: var(--success);
    color: var(--white);
}

.kpi-toggle .btn.fail {
    background: var(--gray-100);
    color: var(--gray-600);
}

.kpi-toggle .btn.fail.active {
    background: var(--danger);
    color: var(--white);
}

/* Progress Indicator */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-fill.success { background: linear-gradient(90deg, var(--success) 0%, #34d399 100%); }
.progress-fill.warning { background: linear-gradient(90deg, var(--warning) 0%, #fbbf24 100%); }
.progress-fill.danger { background: linear-gradient(90deg, var(--danger) 0%, #f87171 100%); }

/* Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-300);
    border: 2px solid var(--white);
}

.timeline-item.success::before { background: var(--success); }
.timeline-item.warning::before { background: var(--warning); }
.timeline-item.danger::before { background: var(--danger); }

.timeline-content {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.timeline-text {
    font-size: 0.875rem;
}

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(197, 36, 40, 0.3) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(197, 36, 40, 0.2) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 3rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--gray-500);
    font-size: 0.9375rem;
}

.pin-input-wrapper {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin: 2rem 0;
}

.pin-input {
    width: 52px;
    height: 64px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: var(--font-mono);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    transition: var(--transition);
}

.pin-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(23, 20, 69, 0.1);
}

/* Modal */
.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: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-200);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* ================================
   RESPONSIVE DESIGN
   Mobile-First Approach
   ================================ */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--gray-700);
    transition: var(--transition);
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background: var(--gray-200);
}

.mobile-menu-toggle:active {
    background: var(--gray-300);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Close Button (Mobile) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    transition: var(--transition);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ======== TABLET (1024px and below) ======== */
@media (max-width: 1024px) {
    /* Sidebar transforms to mobile drawer */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: flex;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Top Header adjustments */
    .top-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .page-title {
        font-size: 1.25rem;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    /* User dropdown simplified for tablet */
    .user-dropdown-toggle .user-info {
        display: none;
    }
    
    .user-dropdown-toggle .dropdown-arrow {
        display: none;
    }
    
    .user-dropdown-toggle {
        padding: 0.375rem;
        border-radius: 50%;
    }
    
    .user-dropdown-menu {
        min-width: 240px;
    }
    
    /* Stats grid 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Clearance grid 2 columns */
    .clearance-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Page content padding */
    .page-content {
        padding: 1.25rem;
    }
    
    /* Cards */
    .card-header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Tables scroll horizontally */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    /* Modal adjustments */
    .modal {
        max-width: 90%;
        margin: 1rem;
    }
    
    /* Grid layouts */
    [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
    }
}

/* ======== MOBILE LANDSCAPE (768px and below) ======== */
@media (max-width: 768px) {
    /* Typography */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    h4 { font-size: 1rem; }
    
    /* Stats grid single column */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    /* Clearance grid single column */
    .clearance-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .clearance-header {
        padding: 1rem;
    }
    
    .clearance-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .clearance-title {
        font-size: 1rem;
    }
    
    .clearance-body {
        padding: 1rem;
    }
    
    /* Page content */
    .page-content {
        padding: 1rem;
    }
    
    /* Cards */
    .card {
        border-radius: var(--radius);
    }
    
    .card-header {
        padding: 0.875rem 1rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Forms */
    .form-control {
        padding: 0.625rem 0.875rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .form-label {
        font-size: 0.8125rem;
    }
    
    /* Form groups in flex wrap */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
    
    .d-flex.gap-2 > .form-group {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    /* Filter forms stack vertically */
    form.d-flex {
        flex-direction: column;
        gap: 0.75rem !important;
    }
    
    form.d-flex > .form-group {
        width: 100%;
        min-width: 100% !important;
    }
    
    form.d-flex > .btn {
        width: 100%;
    }
    
    /* Tables */
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }
    
    .table {
        min-width: 500px;
    }
    
    /* Timeline */
    .timeline {
        padding-left: 1.5rem;
    }
    
    .timeline-content {
        padding: 0.75rem;
    }
    
    /* Login page */
    .login-wrapper {
        padding: 1rem;
    }
    
    .login-card {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }
    
    .login-logo {
        max-width: 150px;
    }
    
    .login-title {
        font-size: 1.25rem;
    }
    
    .login-subtitle {
        font-size: 0.875rem;
    }
    
    /* PIN input */
    .pin-input-wrapper {
        gap: 0.5rem;
    }
    
    .pin-input {
        width: 42px;
        height: 52px;
        font-size: 1.25rem;
    }
    
    /* Alerts */
    .alert {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Badges */
    .badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    
    /* KPI Items */
    .kpi-item {
        padding: 0.875rem 1rem;
    }
    
    .kpi-name {
        font-size: 0.9375rem;
    }
    
    .kpi-description {
        font-size: 0.75rem;
    }
    
    .kpi-response {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .kpi-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .kpi-toggle .btn {
        flex: 1;
    }
    
    /* Progress bar */
    .checklist-progress {
        margin-top: 1.5rem;
    }
    
    /* Modal */
    .modal {
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-body {
        max-height: calc(100vh - 120px);
    }
    
    /* User dropdown - mobile */
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
    
    .user-dropdown-menu {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        left: auto;
        bottom: auto;
        min-width: 220px;
        border-radius: var(--radius-lg);
        max-height: none;
        overflow-y: visible;
    }
    
    .dropdown-header {
        padding: 1rem 1.25rem;
    }
    
    .dropdown-user-avatar {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }
    
    .dropdown-item {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }
    
    .dropdown-item i {
        width: 22px;
        font-size: 1rem;
    }
    
    /* Header icon buttons */
    .header-icon-btn {
        width: 36px;
        height: 36px;
    }
    
    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state i {
        font-size: 3rem;
    }
    
    .empty-state h3 {
        font-size: 1.125rem;
    }
    
    /* Team member cards */
    .team-member-card {
        padding: 1rem !important;
    }
    
    /* Review items */
    .review-item {
        padding: 1rem !important;
    }
    
    /* Duress alert items */
    .duress-alert-item {
        padding: 1rem !important;
    }
    
    /* Evidence preview */
    .evidence-item {
        width: 60px !important;
        height: 60px !important;
    }
}

/* ======== MOBILE PORTRAIT (480px and below) ======== */
@media (max-width: 480px) {
    /* Even smaller typography */
    h1 { font-size: 1.25rem; }
    h2 { font-size: 1.125rem; }
    h3 { font-size: 1rem; }
    
    /* Top header ultra compact */
    .top-header {
        padding: 0.5rem 0.75rem;
    }
    
    .page-title {
        font-size: 1rem;
        max-width: 150px;
    }
    
    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
    
    /* Page content minimal padding */
    .page-content {
        padding: 0.75rem;
    }
    
    /* Cards ultra compact */
    .card-header {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .card-title {
        font-size: 0.9375rem;
    }
    
    /* Stats more compact */
    .stat-card {
        padding: 0.875rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9375rem;
    }
    
    /* Clearance cards compact */
    .clearance-header {
        padding: 0.875rem;
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .clearance-icon {
        width: 48px;
        height: 48px;
    }
    
    .clearance-body {
        padding: 0.875rem;
    }
    
    .clearance-status {
        flex-direction: column;
        text-align: center;
    }
    
    .status-indicator {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
    }
    
    /* Login ultra compact */
    .login-card {
        padding: 1.25rem;
    }
    
    .login-logo {
        max-width: 120px;
    }
    
    .login-title {
        font-size: 1.125rem;
    }
    
    .login-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        padding: 0.625rem;
        font-size: 0.8125rem;
    }
    
    /* PIN input smaller */
    .pin-input {
        width: 36px;
        height: 46px;
        font-size: 1.125rem;
    }
    
    /* Buttons full width */
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .btn-sm {
        width: auto;
    }
    
    .d-flex.gap-2 > .btn {
        flex: 1 1 100%;
    }
    
    /* Tables even more compact */
    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }
    
    /* Hide less important table columns on mobile */
    .table .hide-mobile {
        display: none;
    }
    
    /* KPI toggle buttons */
    .kpi-toggle .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Sidebar wider on small screens */
    .sidebar {
        width: 85vw;
        max-width: 300px;
    }
    
    /* Notification items */
    .notification-item {
        padding: 0.75rem;
    }
    
    .notification-icon {
        width: 36px;
        height: 36px;
    }
    
    .notification-title {
        font-size: 0.875rem;
    }
    
    .notification-message {
        font-size: 0.75rem;
    }
}

/* ======== FIX FOR INLINE STYLE GRIDS ======== */
/* Override inline grid styles that use fixed minmax values */
@media (max-width: 768px) {
    /* Dashboard row grid override */
    .row[style*="grid-template-columns"],
    div[style*="minmax(400px"],
    div[style*="minmax(350px"],
    div[style*="grid-template-columns: repeat"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* KPI Modal inner grid */
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Filter forms with inline min-width */
    .form-group[style*="min-width"] {
        min-width: 100% !important;
        width: 100% !important;
    }
    
    /* Quick actions buttons */
    .d-flex[style*="flex-wrap"] {
        flex-direction: column !important;
    }
    
    .d-flex[style*="flex-wrap"] > .btn {
        width: 100% !important;
    }
    
    /* Category status items */
    .d-flex.align-center.justify-between[style*="padding"] {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    /* Even smaller gap for tiny screens */
    .row[style*="grid-template-columns"],
    div[style*="minmax(400px"],
    div[style*="minmax(350px"],
    div[style*="grid-template-columns: repeat"] {
        gap: 0.75rem !important;
    }
}

/* ======== LANDSCAPE ORIENTATION FIXES ======== */
@media (max-height: 500px) and (orientation: landscape) {
    .login-wrapper {
        padding: 0.5rem;
        align-items: flex-start;
        overflow-y: auto;
    }
    
    .login-card {
        margin: 0.5rem auto;
    }
    
    .login-header {
        margin-bottom: 1rem;
    }
    
    .login-logo {
        max-width: 80px;
        margin-bottom: 0.75rem;
    }
    
    .modal-body {
        max-height: 60vh;
    }
}

/* ======== TOUCH DEVICE OPTIMIZATIONS ======== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
    }
    
    .nav-item {
        min-height: 48px;
    }
    
    .form-check-input {
        width: 24px;
        height: 24px;
    }
    
    /* Remove hover effects that don't work on touch */
    .btn:hover {
        transform: none;
    }
    
    .stat-card:hover {
        transform: none;
    }
    
    .card:hover {
        box-shadow: var(--shadow);
    }
    
    /* Add active states instead */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    .nav-item:active {
        background: rgba(255, 255, 255, 0.15);
    }
}

/* ======== SAFE AREA INSETS (for notched phones) ======== */
@supports (padding: max(0px)) {
    .sidebar {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .top-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .page-content {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .login-wrapper {
        padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    }
}

/* ======== DARK MODE SUPPORT (optional) ======== */
@media (prefers-color-scheme: dark) {
    /* Users can enable this by uncommenting */
    /*
    :root {
        --gray-50: #1f2937;
        --gray-100: #374151;
        --gray-200: #4b5563;
        --gray-800: #f3f4f6;
        --gray-900: #f9fafb;
        --white: #111827;
    }
    */
}

/* Print Styles */
@media print {
    .sidebar,
    .top-header,
    .btn,
    .header-actions {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--gray-200);
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--gray-500); }

.bg-primary { background-color: var(--primary); }
.bg-accent { background-color: var(--accent); }
.bg-success { background-color: var(--success); }
.bg-warning { background-color: var(--warning); }
.bg-danger { background-color: var(--danger); }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }

.hidden { display: none !important; }
.visible { display: block !important; }

/* ======== RESPONSIVE GRID LAYOUTS ======== */
/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Form 2-column Grid */
.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Filter Form Layout */
.filter-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-field {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

.filter-checkbox {
    margin-top: 1.5rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-actions .btn {
    flex: 0 0 auto;
}

/* Responsive Grid Overrides */
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .dashboard-grid,
    .settings-grid {
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        grid-template-columns: 1fr !important;
    }
    
    .form-grid-2col {
        grid-template-columns: 1fr;
    }
    
    .filter-row {
        flex-direction: column;
    }
    
    .filter-field {
        width: 100%;
        min-width: 100%;
    }
    
    .filter-checkbox {
        margin-top: 0.5rem;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .filter-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .dashboard-grid,
    .settings-grid {
        gap: 0.75rem;
    }
}

/* Quick Actions Grid */
.quick-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.quick-actions-grid .btn {
    flex: 0 0 auto;
}

/* Category Status Item */
.category-status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.category-status-item:last-child {
    margin-bottom: 0;
}

.category-status-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.category-status-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-sm {
    font-size: 0.8rem;
}

/* Evidence upload optional text */
.evidence-upload-wrapper .text-muted {
    font-size: 0.7rem;
    font-weight: normal;
}

/* Checklist Info Grid (for assignment pre-filled data) */
.checklist-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* Static form control (read-only display) */
.form-control-static {
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.form-control-static i {
    margin-right: 0.5rem;
}

.form-control-static .badge {
    margin-left: 0.5rem;
}

@media (max-width: 768px) {
    .checklist-info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .form-control-static {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Responsive Quick Actions */
@media (max-width: 768px) {
    .quick-actions-grid {
        flex-direction: column;
    }
    
    .quick-actions-grid .btn {
        width: 100%;
        justify-content: center;
    }
    
    .category-status-item {
        flex-wrap: wrap;
    }
    
    .category-status-info {
        flex: 1 1 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    .category-status-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 0.875rem;
    }
    
    .category-status-item strong {
        font-size: 0.875rem;
    }
}

/* ======== RESPONSIVE TABLE IMPROVEMENTS ======== */
/* Hide columns on mobile for better fit */
@media (max-width: 768px) {
    .table-responsive-hide-cols .hide-tablet {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .table-responsive-hide-cols .hide-mobile {
        display: none !important;
    }
}

/* Table row states */
.row-inactive {
    opacity: 0.5;
}

/* Audit Log Specific Styles */
.action-code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    word-break: break-all;
}

.entity-text {
    font-size: 0.85rem;
}

.ip-text {
    font-size: 0.85rem;
    font-family: var(--font-mono);
}

/* KPI Management Responsive */
@media (max-width: 768px) {
    /* KPI table actions */
    .table td form {
        display: inline-block;
    }
    
    /* Make action buttons stack if needed */
    .table .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Stats grid improvements for mobile */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }
    
    .stat-value {
        font-size: 1.125rem;
    }
    
    .stat-label {
        font-size: 0.6875rem;
    }
}

/* Header adjustments for page titles on mobile */
@media (max-width: 480px) {
    .d-flex.justify-between.align-center.mb-4 {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .d-flex.justify-between.align-center.mb-4 h2 {
        text-align: center;
        font-size: 1.125rem;
    }
    
    .d-flex.justify-between.align-center.mb-4 .btn {
        width: 100%;
    }
}

/* VIP Overview Table */
.vip-overview-table {
    min-width: auto;
}

.vip-overview-table th {
    white-space: nowrap;
}

.vip-overview-table .category-name {
    display: inline;
}

@media (max-width: 768px) {
    .vip-overview-table {
        min-width: 100%;
    }
    
    .vip-overview-table .category-name {
        display: none;
    }
    
    .vip-overview-table th,
    .vip-overview-table td {
        padding: 0.5rem 0.375rem;
    }
}

@media (max-width: 480px) {
    .vip-overview-table th i,
    .vip-overview-table td i {
        font-size: 1rem;
    }
}

/* Category Report Item (Reports Page) */
.category-report-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.category-report-item:last-child {
    margin-bottom: 0;
}

.category-report-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-report-stats {
    text-align: right;
}

@media (max-width: 480px) {
    .category-report-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .category-report-stats {
        text-align: left;
        width: 100%;
        display: flex;
        gap: 1rem;
    }
}

/* Users Page Layout */
.users-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.users-layout.with-panel {
    grid-template-columns: 1fr 400px;
}

.filter-field-lg {
    flex: 2;
    min-width: 200px;
}

.contact-text {
    font-size: 0.85rem;
}

.login-time {
    font-size: 0.85rem;
}

@media (max-width: 992px) {
    .users-layout.with-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .filter-field-lg {
        min-width: 100%;
    }
}

/* Trend Chart Responsive */
.trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 200px;
    padding: 1rem 0;
    overflow-x: auto;
}

.trend-bar-wrapper {
    flex: 1;
    min-width: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trend-bar {
    width: 100%;
    max-width: 40px;
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
}

.trend-label {
    font-size: 0.65rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

@media (max-width: 768px) {
    .trend-bars {
        height: 150px;
    }
    
    .trend-bar-wrapper {
        min-width: 25px;
    }
}

@media (max-width: 480px) {
    .trend-bars {
        height: 120px;
        gap: 2px;
    }
    
    .trend-bar-wrapper {
        min-width: 20px;
    }
    
    .trend-label {
        font-size: 0.55rem;
    }
}

