/* ============================================
   QualityApp - Food Manufacturing QMS
   Glassmorphic CSS Framework
   Mobile-First | Dark/Light Theme
   ============================================ */

/* ============ THEME VARIABLES ============ */
:root,
[data-theme="light"] {
    /* Brand colors */
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e2f44;
    --secondary: #148f77;
    --secondary-light: #1abc9c;
    --accent: #e67e22;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --light: #f8f9fa;
    --dark: #2c3e50;

    /* Gray scale */
    --gray-100: #f7f9fc;
    --gray-200: #edf2f7;
    --gray-300: #e2e8f0;
    --gray-400: #cbd5e0;
    --gray-500: #a0aec0;
    --gray-600: #718096;
    --gray-700: #4a5568;
    --gray-800: #2d3748;
    --gray-900: #1a202c;

    /* Glass / Theme surfaces */
    --bg-primary: linear-gradient(135deg, #e8f0fe 0%, #f0f4f8 50%, #e8f8f5 100%);
    --bg-body: #f0f4f8;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-bg-solid: #ffffff;
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.08);
    --glass-blur: blur(12px);
    --glass-highlight: rgba(255, 255, 255, 0.8);

    /* Text */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;

    /* Sidebar */
    --sidebar-bg: linear-gradient(180deg, rgba(14, 47, 68, 0.95) 0%, rgba(26, 82, 118, 0.92) 100%);
    --sidebar-text: rgba(255, 255, 255, 0.75);
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(255, 255, 255, 0.15);
    --sidebar-border: rgba(255, 255, 255, 0.08);

    /* Header */
    --header-bg: rgba(255, 255, 255, 0.72);
    --header-border: rgba(226, 232, 240, 0.6);

    /* Inputs */
    --input-bg: rgba(255, 255, 255, 0.7);
    --input-border: rgba(203, 213, 224, 0.6);
    --input-text: #2d3748;
    --input-focus-ring: rgba(41, 128, 185, 0.2);

    /* Tables */
    --table-header-bg: rgba(247, 249, 252, 0.8);
    --table-row-hover: rgba(237, 242, 247, 0.5);
    --table-border: rgba(226, 232, 240, 0.6);

    /* Card header */
    --card-header-bg: rgba(247, 249, 252, 0.7);

    /* Fonts & structure */
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', monospace;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --sidebar-width: 260px;
    --header-height: 60px;
    --transition: all 0.25s ease;
    --theme-transition: background 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

[data-theme="dark"] {
    --primary: #3498db;
    --primary-light: #5dade2;
    --primary-dark: #1a5276;
    --secondary: #1abc9c;
    --secondary-light: #48c9b0;
    --accent: #f0a500;
    --success: #2ecc71;
    --warning: #f1c40f;
    --danger: #e74c3c;
    --info: #5dade2;
    --light: #1e293b;
    --dark: #e2e8f0;

    --gray-100: #0f172a;
    --gray-200: #1e293b;
    --gray-300: #334155;
    --gray-400: #475569;
    --gray-500: #64748b;
    --gray-600: #94a3b8;
    --gray-700: #cbd5e1;
    --gray-800: #e2e8f0;
    --gray-900: #f1f5f9;

    --bg-primary: linear-gradient(135deg, #0f172a 0%, #1a1f3a 50%, #0d1f2d 100%);
    --bg-body: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.65);
    --glass-bg-solid: #1e293b;
    --glass-border: rgba(71, 85, 105, 0.35);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-blur: blur(12px);
    --glass-highlight: rgba(255, 255, 255, 0.05);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --sidebar-bg: linear-gradient(180deg, rgba(10, 15, 30, 0.96) 0%, rgba(15, 23, 42, 0.94) 100%);
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(255, 255, 255, 0.1);
    --sidebar-border: rgba(255, 255, 255, 0.05);

    --header-bg: rgba(30, 41, 59, 0.72);
    --header-border: rgba(51, 65, 85, 0.5);

    --input-bg: rgba(30, 41, 59, 0.6);
    --input-border: rgba(71, 85, 105, 0.5);
    --input-text: #e2e8f0;
    --input-focus-ring: rgba(93, 173, 226, 0.25);

    --table-header-bg: rgba(15, 23, 42, 0.6);
    --table-row-hover: rgba(51, 65, 85, 0.3);
    --table-border: rgba(51, 65, 85, 0.5);

    --card-header-bg: rgba(15, 23, 42, 0.5);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.35);
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--theme-transition);
}

a { color: var(--primary-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary); }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }

/* ============ LAYOUT ============ */
.app-container { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    background: var(--secondary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(20, 143, 119, 0.3);
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-brand small {
    font-size: 10px;
    opacity: 0.7;
    display: block;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav { padding: 12px 0; }

.nav-section {
    padding: 8px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    font-weight: 600;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    gap: 12px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}
.nav-item:focus-visible {
    outline: 2px solid rgba(255,255,255,0.6);
    outline-offset: -2px;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
    border-left-color: var(--secondary-light);
    box-shadow: inset 0 0 20px rgba(26, 188, 156, 0.05);
}

.nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    opacity: 0.85;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============ HEADER ============ */
.top-header {
    background: var(--header-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    height: var(--header-height);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: var(--theme-transition);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
}

/* Theme toggle button */
.theme-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.theme-toggle-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: rotate(20deg);
    box-shadow: 0 4px 15px rgba(41, 128, 185, 0.3);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .separator { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover { background: var(--glass-bg); }

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(26, 82, 118, 0.25);
}

.user-info { line-height: 1.3; }
.user-info .name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-info .role { font-size: 11px; color: var(--text-muted); }

/* ============ PAGE CONTENT ============ */
.page-content { padding: 24px; flex: 1; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============ CARDS ============ */
.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    transition: var(--theme-transition);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-header-bg);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--glass-border);
    background: var(--card-header-bg);
}

/* Glass card utility */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

/* ============ STAT CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: rgba(41, 128, 185, 0.2);
}

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

.stat-icon.blue { background: rgba(52, 152, 219, 0.12); color: var(--info); }
.stat-icon.green { background: rgba(39, 174, 96, 0.12); color: var(--success); }
.stat-icon.orange { background: rgba(243, 156, 18, 0.12); color: var(--warning); }
.stat-icon.red { background: rgba(231, 76, 60, 0.12); color: var(--danger); }
.stat-icon.purple { background: rgba(142, 68, 173, 0.12); color: #8e44ad; }
.stat-icon.teal { background: rgba(20, 143, 119, 0.12); color: var(--secondary); }

[data-theme="dark"] .stat-icon.blue { background: rgba(52, 152, 219, 0.18); }
[data-theme="dark"] .stat-icon.green { background: rgba(39, 174, 96, 0.18); }
[data-theme="dark"] .stat-icon.orange { background: rgba(243, 156, 18, 0.18); }
[data-theme="dark"] .stat-icon.red { background: rgba(231, 76, 60, 0.18); }
[data-theme="dark"] .stat-icon.purple { background: rgba(142, 68, 173, 0.18); }
[data-theme="dark"] .stat-icon.teal { background: rgba(20, 143, 119, 0.18); }

.stat-content { flex: 1; }
.stat-content .stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-content .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-content .stat-change { font-size: 11px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============ TABLES ============ */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--table-header-bg);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--table-border);
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--table-border);
    vertical-align: middle;
    color: var(--text-primary);
}

tbody tr:hover { background: var(--table-row-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); color: white; box-shadow: 0 4px 15px rgba(41, 128, 185, 0.35); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--secondary-light); color: white; box-shadow: 0 4px 15px rgba(26, 188, 156, 0.35); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { box-shadow: 0 4px 15px rgba(39, 174, 96, 0.35); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { box-shadow: 0 4px 15px rgba(243, 156, 18, 0.35); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { box-shadow: 0 4px 15px rgba(231, 76, 60, 0.35); }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { box-shadow: 0 4px 15px rgba(52, 152, 219, 0.35); }
.btn-outline { background: var(--glass-bg); color: var(--text-secondary); border: 1px solid var(--glass-border); }
.btn-outline:hover { background: var(--glass-highlight); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-family);
    color: var(--input-text);
    background: var(--input-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--input-focus-ring);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-check label {
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-critical { background: rgba(192, 57, 43, 0.12); color: #e74c3c; }
.badge-major { background: rgba(230, 126, 34, 0.12); color: #e67e22; }
.badge-minor { background: rgba(243, 156, 18, 0.12); color: #f39c12; }
.badge-observation { background: rgba(41, 128, 185, 0.12); color: #3498db; }

.badge-draft { background: var(--glass-bg); color: var(--text-muted); border: 1px solid var(--glass-border); }
.badge-open { background: rgba(41, 128, 185, 0.12); color: #3498db; }
.badge-in-progress, .badge-in_progress, .badge-under_investigation { background: rgba(230, 126, 34, 0.12); color: #e67e22; }
.badge-closed { background: rgba(39, 174, 96, 0.12); color: #27ae60; }
.badge-verified { background: rgba(20, 143, 119, 0.12); color: #1abc9c; }
.badge-overdue { background: rgba(192, 57, 43, 0.12); color: #e74c3c; }
.badge-approved { background: rgba(39, 174, 96, 0.12); color: #27ae60; }
.badge-active { background: rgba(39, 174, 96, 0.12); color: #27ae60; }
.badge-planned { background: rgba(41, 128, 185, 0.12); color: #3498db; }
.badge-rejected { background: rgba(192, 57, 43, 0.12); color: #e74c3c; }
.badge-received { background: rgba(142, 68, 173, 0.12); color: #9b59b6; }

.badge-low { background: rgba(39, 174, 96, 0.12); color: #27ae60; }
.badge-medium { background: rgba(243, 156, 18, 0.12); color: #f39c12; }
.badge-high { background: rgba(230, 126, 34, 0.12); color: #e67e22; }

/* Badge pill (landing page compliance) */
.badge-pill {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Severity colors */
.severity-critical { color: #e74c3c; font-weight: 700; }
.severity-major { color: #e67e22; font-weight: 600; }
.severity-minor { color: #f39c12; }
.severity-observation { color: #3498db; }

/* ============ ALERTS ============ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.alert-success { background: rgba(39, 174, 96, 0.1); border-color: var(--success); color: #27ae60; }
.alert-danger { background: rgba(231, 76, 60, 0.1); border-color: var(--danger); color: #e74c3c; }
.alert-warning { background: rgba(243, 156, 18, 0.1); border-color: var(--warning); color: #f39c12; }
.alert-info { background: rgba(52, 152, 219, 0.1); border-color: var(--info); color: #3498db; }

.alert .close-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    color: inherit;
}

.alert .close-btn:hover { opacity: 1; }

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.pagination a {
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    transition: var(--transition);
}

.pagination a:hover { background: var(--primary); color: white; border-color: var(--primary); }
.pagination a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pagination .active { background: var(--primary); color: white; border: 1px solid var(--primary); }
.pagination .disabled { opacity: 0.5; pointer-events: none; }

/* ============ FILTERS ============ */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters-bar .form-group { margin-bottom: 0; flex: 1; min-width: 180px; }
.filters-bar .form-control { padding: 8px 12px; font-size: 13px; }

/* ============ RISK MATRIX ============ */
.risk-matrix {
    display: grid;
    grid-template-columns: auto repeat(5, 1fr);
    gap: 2px;
    max-width: 600px;
}

.risk-matrix .cell {
    padding: 12px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.risk-cell-low { background: rgba(46, 204, 113, 0.3); color: #27ae60; }
.risk-cell-medium { background: rgba(241, 196, 15, 0.3); color: #f39c12; }
.risk-cell-high { background: rgba(243, 156, 18, 0.35); color: #e67e22; }
.risk-cell-critical { background: rgba(231, 76, 60, 0.3); color: #e74c3c; }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ============ DETAIL VIEW ============ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.detail-section { margin-bottom: 24px; }
.detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--glass-border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--table-border);
}

.detail-label {
    width: 160px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.detail-value {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

/* ============ WORKFLOW STATUS BAR ============ */
.status-workflow {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 16px 0;
    overflow-x: auto;
}

.workflow-step {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    background: var(--glass-bg);
    color: var(--text-muted);
    white-space: nowrap;
    position: relative;
    border: 1px solid var(--glass-border);
}

.workflow-step.active { background: var(--primary); color: white; border-color: var(--primary); }
.workflow-step.completed { background: var(--success); color: white; border-color: var(--success); }
.workflow-step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.workflow-step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* ============ CHARTS ============ */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 400px;
    padding: 16px;
}

/* ============ LANDING PAGE ============ */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.landing-page {
    min-height: 100vh;
    background: linear-gradient(-45deg, #0e2f44, #1a5276, #148f77, #0e2f44, #1a3a5c);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .landing-page {
    background: linear-gradient(-45deg, #0a0f1e, #0f172a, #0d1f2d, #1a1f3a, #0a1628);
    background-size: 400% 400%;
}

.landing-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(26, 188, 156, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.landing-container {
    display: flex;
    gap: 40px;
    max-width: 1200px;
    width: 100%;
    align-items: center;
    position: relative;
    z-index: 1;
}

.landing-hero {
    flex: 1.2;
    color: white;
}

.hero-brand { margin-bottom: 32px; }

.hero-logo {
    font-size: 48px;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 12px rgba(26, 188, 156, 0.4));
}

.hero-brand h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.hero-tagline {
    font-size: 18px;
    opacity: 0.9;
    font-weight: 500;
}

.hero-subtitle {
    font-size: 14px;
    opacity: 0.6;
    margin-top: 4px;
}

/* Feature grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 28px;
}

.feature-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 12px 10px;
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-2px);
    border-color: rgba(26, 188, 156, 0.3);
}

.feature-icon { font-size: 22px; margin-bottom: 6px; }
.feature-title { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.feature-standard { font-size: 9px; opacity: 0.5; }

/* Landing stats */
.landing-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.landing-stats .stat-item { text-align: center; }
.landing-stats .stat-value { font-size: 24px; font-weight: 800; color: var(--secondary-light); }
.landing-stats .stat-label { font-size: 11px; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.5px; }

/* Compliance badges */
.compliance-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Landing login section */
.landing-login {
    flex: 0 0 380px;
}

/* Login card on landing */
.login-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

[data-theme="dark"] .login-card {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.3);
}

.login-header {
    padding: 28px 32px 16px;
    text-align: center;
    color: white;
}

.login-logo {
    font-size: 36px;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 8px rgba(26, 188, 156, 0.4));
}

.login-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.login-header h3 { font-size: 14px; font-weight: 400; opacity: 0.7; }

.login-body {
    padding: 24px 32px 28px;
}

.login-body .form-group label { color: rgba(255, 255, 255, 0.7); }
.login-body .form-control {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
}
.login-body .form-control::placeholder { color: rgba(255, 255, 255, 0.55); }
.login-body .form-control:focus {
    border-color: var(--secondary-light);
    box-shadow: 0 0 0 3px rgba(26, 188, 156, 0.2);
}
.login-body .form-check label { color: rgba(255, 255, 255, 0.6); }
.login-body .btn-primary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
    border: none;
    padding: 12px 24px;
    font-size: 15px;
}
.login-body .btn-primary:hover {
    box-shadow: 0 8px 25px rgba(26, 188, 156, 0.4);
}

.login-footer {
    text-align: center;
    padding: 14px 32px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* Flash messages on login */
.flash-messages { margin-bottom: 16px; }
.flash-messages .alert {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: rgba(255, 255, 255, 0.3);
}

/* Login page theme toggle */
.landing-page .theme-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.landing-page .theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Theme icon visibility */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: inline; }
[data-theme="dark"] .theme-icon-sun { display: inline; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* ============ TABS ============ */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--glass-border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-link {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
    cursor: pointer;
}

.tab-link:hover { color: var(--primary); }
.tab-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============ MODALS ============ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-primary);
}

.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ UTILITIES ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; }
.gap-1 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.align-end { align-items: flex-end; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.form-inline { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 16px; }
.empty-row td { text-align: center; padding: 24px; }
.no-text-decoration { text-decoration: none; }
.roadmap-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}
.roadmap-card p { color: var(--text-secondary); margin-bottom: 12px; }
.roadmap-card ul { list-style: disc; padding-left: 20px; color: var(--text-primary); font-size: 13px; line-height: 1.8; }
.roadmap-empty { color: var(--text-muted); text-align: center; padding: 24px; }

/* Status pipeline */
.status-pipeline { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.status-pipeline-step {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.status-pipeline-arrow { color: var(--text-muted); }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ============ PRINT ============ */
@media print {
    .sidebar, .top-header, .btn, .filters-bar, .theme-toggle-btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; backdrop-filter: none; background: white; }
}

/* ============ RESPONSIVE ============ */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

/* Landing responsive */
@media (max-width: 960px) {
    .landing-container {
        flex-direction: column;
        align-items: stretch;
    }
    .landing-hero { text-align: center; }
    .landing-login { flex: none; max-width: 440px; margin: 0 auto; width: 100%; }
    .feature-grid { grid-template-columns: repeat(3, 1fr); }
    .landing-stats { justify-content: center; }
    .compliance-badges { justify-content: center; }
}

/* Mobile */
@media (max-width: 768px) {
    html { font-size: 13px; }
    .page-content { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .card-body { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .detail-row { flex-direction: column; gap: 2px; }
    .detail-label { width: 100%; }
    .filters-bar { flex-direction: column; }
    .filters-bar .form-group { min-width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-content .stat-value { font-size: 22px; }
    .btn-group { width: 100%; }
    .btn-group .btn { flex: 1; justify-content: center; }
    .status-workflow { overflow-x: auto; }

    table { font-size: 12px; }
    thead th, tbody td { padding: 8px 10px; }

    .top-header { padding: 0 16px; }
    .breadcrumb { display: none; }

    .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .hero-brand h1 { font-size: 28px; }
    .landing-stats { gap: 16px; }
}

/* Small Mobile */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { flex-direction: column; text-align: center; }
    .login-body { padding: 20px; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
    .landing-page { padding: 16px; }
}

/* ============ SIDEBAR OVERLAY ============ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 999;
}

.sidebar-overlay.active { display: block; }

/* ============ FOOTER ============ */
footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    transition: var(--theme-transition);
    color: var(--text-muted);
    border-top: 1px solid var(--glass-border);
}

/* ============ ERROR PAGES ============ */
.error-page {
    text-align: center;
    padding: 64px 16px;
}
.error-page-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.error-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
    padding: 48px 32px;
}
.error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}
.error-title {
    margin-bottom: 8px;
}
.error-message {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ============ STATUS PIPELINE (NCR/HACCP) ============ */
.status-flow {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}
.status-flow-arrow {
    color: var(--gray-400);
}
.status-actions-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ============ STATUS STEP STATES ============ */
.status-step {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-500);
}
.status-step-current {
    background: var(--primary);
    color: #fff;
}
.status-step-completed {
    background: var(--success);
    color: #fff;
}

/* ============ FORM LAYOUT UTILITIES ============ */
.align-self-end {
    align-self: flex-end;
}
.flex-center-gap {
    display: flex;
    justify-content: center;
    gap: 8px;
}
.form-actions-end {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 16px;
}
.form-actions-end-sm {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-body-separator {
    border-top: 1px solid var(--gray-200);
}
.pagination-ellipsis {
    padding: 4px;
}
.canvas-responsive {
    width: 100%;
    max-height: 400px;
}

/* ============ RISK MATRIX STAT BORDERS ============ */
.stat-border-success { border-left: 4px solid var(--success); }
.stat-border-warning { border-left: 4px solid var(--warning); }
.stat-border-orange { border-left: 4px solid #e67e22; }
.stat-border-danger { border-left: 4px solid var(--danger); }

/* ============ ADMIN CARD DESCRIPTION ============ */
.admin-card-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ DEMO PAGE ============ */
.demo-list {
    margin-left: 20px;
    margin-bottom: 16px;
    line-height: 1.8;
}
.demo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

/* ============ TRAINING MATRIX ============ */
.training-matrix-header {
    text-align: center;
    min-width: 100px;
}
.training-matrix-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ============ ACCESSIBILITY ============ */
.theme-toggle-btn:focus-visible,
.menu-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
