/* ─────────────────────────────────────────────────────
   QMS TOOL — Enterprise Shell & Design System
   ───────────────────────────────────────────────────── */
:root {
    /* Brand & surfaces */
    --primary:          #0f172a;
    --primary-hover:    #020617;
    --primary-light:    #e2e8f0;
    --accent:           #2563eb;
    --accent-hover:     #1d4ed8;
    --accent-soft:      rgba(37, 99, 235, 0.08);

    --bg-main:          #f1f5f9;
    --bg-main-gradient: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 48%, #eef2f7 100%);
    --bg-card:          #ffffff;
    --bg-elevated:      #ffffff;

    --text-main:        #0f172a;
    --text-muted:       #64748b;
    --text-on-dark:     #f8fafc;
    --text-on-dark-muted: #94a3b8;

    --border:           #e2e8f0;
    --border-strong:    #cbd5e1;

    --success:          #047857;
    --danger:           #b91c1c;
    --warning:          #b45309;

    /* Sidebar (deep slate shell) */
    --sidebar-bg:       #0f172a;
    --sidebar-bg-2:     #020617;
    --sidebar-border:   rgba(148, 163, 184, 0.12);
    --sidebar-link:     #94a3b8;
    --sidebar-link-hover: #e2e8f0;
    --sidebar-active-bg: #ffffff;
    --sidebar-active-text: #0f172a;
    --sidebar-width:    272px;
    --sidebar-collapsed: 64px;

    --radius-sm:        6px;
    --radius-md:        10px;
    --radius-lg:        14px;

    --shadow-xs:        0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm:        0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow:           0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg:        0 12px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);

    --font-family:      "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --header-tracking:  -0.02em;

    /* Premium / patrol tokens (merged) */
    --bg-primary-dark:  #0b0f19;
    --bg-secondary-dark:#161e2f;
    --bg-card-dark:     rgba(22, 30, 47, 0.7);
    --text-pearl:       #f8fafc;
    --text-cool-gray:   #94a3b8;
    --color-pass:       #10b981;
    --color-fail:       #ef4444;
    --color-warning:    #f59e0b;
    --color-accent:     #3b82f6;
    --glass-blur:       12px;
    --border-glow:      1px solid rgba(255, 255, 255, 0.08);
    --shadow-premium:   0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition-smooth: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Global Reset ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.qms-app {
    background: var(--bg-main);
    background-image: var(--bg-main-gradient);
    color: var(--text-main);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    line-height: 1.55;
    font-size: 14px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "ss03";
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    color: var(--text-on-dark);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 4px 0 24px rgba(2, 6, 23, 0.12);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); overflow: hidden; }

.sidebar.collapsed .sidebar-default-brand,
.sidebar.collapsed .sidebar-brand-title > .nav-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .btn-link.text-danger { display: none; }

.sidebar.collapsed .sidebar-brand-bar {
    justify-content: center !important;
    padding: 12px 0 !important;
}

.sidebar.collapsed .nav {
    padding-left: 0 !important;
    padding-right: 0 !important;
    align-items: center;
}

.sidebar.collapsed .nav-link {
    justify-content: center !important;
    padding: 12px 0 !important;
    margin: 3px 6px !important;
    border-left: none !important;
    width: calc(var(--sidebar-collapsed) - 12px);
}

.sidebar.collapsed .nav-link i {
    margin-right: 0 !important;
    font-size: 18px;
    width: auto;
}

.sidebar.collapsed .flex-shrink-0 { margin: 0 auto; }

.sidebar.collapsed .sidebar-footer {
    display: flex;
    justify-content: center;
    padding: 12px 0 !important;
}

/* Sidebar Nav */
.sidebar .nav-link {
    color: var(--sidebar-link);
    padding: 10px 14px;
    margin: 2px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.sidebar .nav-link:hover {
    background: rgba(248, 250, 252, 0.06);
    color: var(--sidebar-link-hover);
}

.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    border-left: 3px solid var(--accent);
    box-shadow: var(--shadow-xs);
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
    margin-right: 12px;
}

.sidebar-section-label {
    padding: 14px 24px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.85);
}

.sidebar .nav-link.nav-qcs-child {
    padding-left: 2.35rem;
    font-size: 0.8125rem;
}

.sidebar .nav-link.nav-qcs-parent {
    cursor: pointer;
}

.sidebar .nav-qcs-chevron {
    margin-left: auto;
    font-size: 0.65rem;
    opacity: 0.65;
    transition: transform 0.2s ease;
}

.sidebar .nav-qcs-block.is-collapsed .nav-qcs-chevron {
    transform: rotate(-90deg);
}

.sidebar .nav-qcs-block.is-collapsed .nav-qcs-children {
    display: none;
}

.sidebar.collapsed .nav-qcs-chevron,
.sidebar.collapsed .nav-qcs-children {
    display: none !important;
}

.sidebar.collapsed .nav-modules-section-label {
    display: none !important;
}

.sidebar.collapsed .nav-link.nav-qcs-child {
    padding-left: 0;
}

.sidebar .nav-link.nav-upcoming {
    opacity: 0.92;
}

.sidebar .nav-soon-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-soon-badge,
.sidebar.collapsed .sidebar-section-label {
    display: none !important;
}

.upcoming-feature-card {
    max-width: 560px;
    padding: 3rem 2rem;
    margin-top: 1rem;
}

.upcoming-feature-card__icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(99, 102, 241, 0.08));
    color: var(--accent, #3b82f6);
    font-size: 1.75rem;
}

.upcoming-feature-card__badge {
    background: rgba(251, 191, 36, 0.15) !important;
    color: #b45309 !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.45em 0.85em;
}

.upcoming-feature-card__text {
    max-width: 420px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px 32px 40px;
    transition: margin-left 0.3s cubic-bezier(0.2, 0, 0, 1);
    min-width: 0;
    overflow-x: hidden;
    position: relative;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* Optional max width for readability on ultra-wide displays */
.main-content-inner {
    max-width: 1600px;
    margin: 0 auto;
}

/* ── Cards ──────────────────────────────────────────── */
.fluent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.fluent-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--border-strong);
}

/* ── Typography ─────────────────────────────────────── */
h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
    letter-spacing: var(--header-tracking);
    line-height: 1.25;
}
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; color: var(--text-main); letter-spacing: var(--header-tracking); }
h5 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.875rem; color: var(--text-main); letter-spacing: var(--header-tracking); }
.text-muted { color: var(--text-muted) !important; }

/* Page chrome */
.page-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.page-header .page-header__eyebrow {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.page-header .page-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: var(--header-tracking);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.page-header .page-header__title i { color: var(--accent); }
.page-header .page-header__desc {
    margin: 0.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.9375rem;
    max-width: 52rem;
}

.section-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.section-card-header h5 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-card-header h5 i { color: var(--accent); }

.badge-pill-muted {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--text-main);
    border: 1px solid var(--border);
}

/* KPI stat tiles */
.kpi-stat {
    position: relative;
    border-left: 4px solid var(--primary);
    overflow: hidden;
}
.kpi-stat::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, transparent 55%);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.kpi-stat:hover::after { opacity: 1; }

.kpi-stat .kpi-stat__label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.kpi-stat .kpi-stat__value {
    font-size: 2.125rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.kpi-stat .kpi-stat__hint { font-size: 0.8125rem; margin-top: 0.35rem; }

.kpi-stat--accent-neutral { border-left-color: var(--primary); }
.kpi-stat--accent-danger { border-left-color: var(--danger); }
.kpi-stat--accent-success { border-left-color: var(--success); }
.kpi-stat--accent-warning { border-left-color: var(--warning); }
.kpi-stat--accent-ocean { border-left-color: #1d4ed8; }
.kpi-stat--accent-forest { border-left-color: #047857; }
.kpi-stat--accent-gold { border-left-color: #ca8a04; }

.activity-feed-item {
    display: flex;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.75rem 0.65rem 1rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: rgba(241, 245, 249, 0.85);
}
.activity-feed-item .activity-feed-item__title { font-size: 0.8125rem; font-weight: 700; color: var(--text-main); }
.activity-feed-item .activity-feed-item__meta { font-size: 0.75rem; color: var(--text-muted); }

.portfolio-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}
.portfolio-row .portfolio-row__title { font-size: 0.95rem; font-weight: 700; color: var(--text-main); }

.activity-feed-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.badge-status-active {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid rgba(4, 120, 87, 0.25);
}

/* Sidebar chrome */
.sidebar-brand-bar {
    border-bottom: 1px solid var(--sidebar-border);
    padding: 1rem 1rem;
}
.sidebar-brand-title {
    margin: 0;
    color: var(--text-on-dark);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: var(--header-tracking);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-brand-title .sidebar-brand-icon { color: var(--accent); opacity: 0.95; }
.sidebar-company-logo {
    max-height: 36px;
    max-width: 140px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}
.sidebar.collapsed .sidebar-company-logo {
    max-height: 28px;
    max-width: 36px;
    margin: 0 auto;
}
.sidebar.collapsed .sidebar-brand-title {
    justify-content: center;
    width: 100%;
}
.mobile-company-logo {
    max-height: 28px;
    max-width: 120px;
    object-fit: contain;
    vertical-align: middle;
}
.sidebar-toggle-btn {
    color: var(--text-on-dark-muted) !important;
    padding: 0 !important;
    border: none;
    background: transparent;
}
.sidebar-toggle-btn:hover { color: var(--text-on-dark) !important; }

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 1rem;
}
.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffffff 0%, #e2e8f0 100%);
    color: var(--primary);
    font-size: 0.8125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xs);
}
.sidebar-user-block { max-width: 140px; }
.sidebar-user-name { color: var(--text-on-dark); font-size: 0.8125rem; font-weight: 600; }
.sidebar-user-role { color: var(--text-on-dark-muted); font-size: 0.72rem; line-height: 1.25; }
.sidebar-user-company { color: #93c5fd; font-size: 0.66rem; line-height: 1.25; margin-top: 2px; font-weight: 500; }
.sidebar-logout-btn { color: var(--text-on-dark-muted) !important; }
.sidebar-logout-btn:hover { color: var(--text-on-dark) !important; }

/* Mobile top bar */
.app-mobile-topbar {
    z-index: 1001;
    box-shadow: var(--shadow-sm);
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border) !important;
}
.app-mobile-topbar .app-mobile-topbar__title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.app-mobile-topbar .app-mobile-topbar__title i { color: var(--accent); }
.app-mobile-topbar .app-mobile-menu-btn { color: var(--text-main) !important; }
.app-mobile-topbar .user-avatar-small {
    width: 34px;
    height: 34px;
    font-size: 0.75rem;
    background: var(--primary) !important;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-fluent-primary {
    background: linear-gradient(180deg, #1e293b 0%, var(--primary) 100%);
    color: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.5);
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
}

.btn-fluent-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
    border: 1px solid var(--accent);
    color: var(--accent);
    background: transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8125rem;
    transition: all 0.15s ease;
}

.btn-outline-primary:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.btn-outline-secondary {
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    background: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.btn-outline-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-outline-danger { border-radius: var(--radius-sm); }
.btn-outline-info   { border-radius: var(--radius-sm); }
.btn-success        { border-radius: var(--radius-sm); }

/* ── Forms ──────────────────────────────────────────── */
.fluent-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-size: 0.875rem;
    background: #ffffff;
    font-family: var(--font-family);
}

.fluent-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    padding: 0.55rem 0.75rem;
}

/* Bootstrap form controls override */
.form-control, .form-select {
    border-radius: var(--radius-sm) !important;
    border-color: var(--border-strong);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Tables ─────────────────────────────────────────── */
.table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 0;
}

.table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-strong);
    white-space: nowrap;
}

.table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.875rem;
}

.table tr:hover td { background: rgba(248, 250, 252, 0.85); }

/* Enterprise Table (admin) */
.enterprise-table thead tr { background: var(--primary); }
.enterprise-table thead th {
    background: var(--primary);
    color: #f1f5f9;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.75rem 1rem;
    border: none;
    white-space: nowrap;
}
.enterprise-table tbody tr:nth-child(even) { background: #FAFAFA; }
.enterprise-table tbody tr:hover td { background: #F3F2F1 !important; }
.enterprise-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #EDEBE9;
    vertical-align: middle;
    font-size: 13.5px;
}

.nav-tabs-enterprise {
    border-bottom: 2px solid var(--border);
    gap: 0.25rem;
}
.nav-tabs-enterprise .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.nav-tabs-enterprise .nav-link:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
}
.nav-tabs-enterprise .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

/* Fluent-style right slide-out drawer (Admin user edit, Reports filters) */
.modal.qms-right-drawer {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: 450px !important;
    max-width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    background: transparent !important;
    transform: translateX(100%) !important;
    transition: transform 0.28s cubic-bezier(0.1, 0.9, 0.2, 1) !important;
    display: block !important;
    opacity: 1 !important;
    z-index: 1055 !important;
}
.modal.qms-right-drawer.show {
    transform: translateX(0) !important;
}
.modal.qms-right-drawer .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    transition: none !important;
}
.modal.qms-right-drawer .modal-content {
    height: 100% !important;
    border-radius: 0 !important;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.16) !important;
    border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
}
.modal.qms-right-drawer .modal-header {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
    padding: 20px 24px !important;
    background: #faf9f8 !important;
    color: #323130 !important;
    flex-shrink: 0;
}
.modal.qms-right-drawer .modal-header .btn-close {
    filter: none !important;
    opacity: 0.75 !important;
    background-color: transparent !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0.5rem !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    box-shadow: none !important;
}
.modal.qms-right-drawer .modal-header .btn-close:hover,
.modal.qms-right-drawer .modal-header .btn-close:focus {
    opacity: 1 !important;
    filter: none !important;
}
.modal.qms-right-drawer .modal-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 24px !important;
}
.modal.qms-right-drawer .modal-title {
    font-weight: 600 !important;
    color: #323130 !important;
    font-size: 1.15rem !important;
}
.modal.qms-right-drawer .modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding: 16px 24px;
    background: #faf9f8;
    flex-shrink: 0;
}

/* Table toolbar */
.table-search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.table-search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    outline: none;
    font-family: var(--font-family);
}
.table-search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    font-size: 12.5px;
    color: #6B6B6B;
}
.pagination-bar .page-btns { display: flex; gap: 2px; }
.page-btn {
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-main);
    transition: background 0.1s;
}
.page-btn:hover { background: #f8fafc; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Modals ─────────────────────────────────────────── */
.modal-content {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    background: #ffffff;
}

.modal-header {
    background: linear-gradient(180deg, #1e293b 0%, var(--primary) 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.1rem 1.5rem;
    color: #ffffff !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.modal-header .modal-title { 
    color: #FFFFFF !important; 
    font-size: 15px; 
    font-weight: 600; 
    margin: 0;
}

.modal-header .modal-title span { color: #FFFFFF !important; } /* Fix for spans inside titles */

.modal-header .btn-close { 
    filter: invert(1) grayscale(100%) brightness(200%); 
    opacity: 0.8;
}
.modal-header .btn-close:hover { opacity: 1; }

/* Offcanvas / right panels — light header, dark visible close (not inverted) */
.offcanvas-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    background: #faf9f8 !important;
    padding: 1.25rem 1.5rem !important;
}
.offcanvas-header .btn-close {
    filter: none !important;
    opacity: 0.75 !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0.5rem !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    background-color: transparent !important;
    box-shadow: none !important;
}
.offcanvas-header .btn-close:hover,
.offcanvas-header .btn-close:focus {
    opacity: 1 !important;
    filter: none !important;
}
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.55rem;
    font-weight: 600;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
}

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

/* ── Login Page ─────────────────────────────────────── */
.login-split-container { display: flex; min-height: 100vh; }

.login-visual {
    flex: 2;
    background:
        radial-gradient(1200px 600px at 20% 20%, rgba(37, 99, 235, 0.22) 0%, transparent 55%),
        radial-gradient(900px 500px at 80% 60%, rgba(14, 165, 233, 0.12) 0%, transparent 50%),
        linear-gradient(165deg, var(--sidebar-bg) 0%, #020617 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    padding: 2.4rem 1.5rem;
}

.visual-content { position: relative; z-index: 2; max-width: 52rem; }
.visual-icon { font-size: 3.75rem; margin-bottom: 1.75rem; color: #93c5fd; opacity: 0.95; }
.visual-title { font-size: clamp(2rem, 4vw, 2.5rem); font-weight: 800; margin-bottom: 1rem; color: #ffffff; line-height: 1.1; letter-spacing: var(--header-tracking); }
.visual-subtitle { font-size: 1rem; margin-bottom: 0rem; color: var(--text-on-dark-muted); line-height: 1.55; }

.feature-item {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    color: #cbd5e1;
}
.feature-item i { color: #93c5fd; margin-right: 0.75rem; }

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 3.5rem 2rem;
}

.login-card-enterprise {
    width: 100%;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
}

/* ── Stepper ─────────────────────────────────────────── */
.stepper-wrapper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 28px;
    padding: 0 20px;
}
.stepper-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}
.stepper-item::before {
    position: absolute;
    content: "";
    border-bottom: 2px solid var(--border);
    width: 100%;
    top: 15px; left: -50%;
    z-index: 2;
}
.stepper-item:first-child::before { content: none; }
.stepper-item.active::before,
.stepper-item.completed::before { border-color: var(--primary); }

.stepper-item .step-counter {
    position: relative;
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 30px; height: 30px;
    border-radius: 50% !important;
    background: #FFFFFF;
    border: 2px solid #C8C6C4;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
}
.stepper-item.active .step-counter {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.stepper-item.completed .step-counter {
    background: var(--success);
    color: white;
    border-color: var(--success);
}
.stepper-item .step-name { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stepper-item.active .step-name { color: var(--primary); font-weight: 600; }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #F1F1F1; }
::-webkit-scrollbar-thumb { background: #C8C6C4; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #8A8886; }

/* ── Utility ─────────────────────────────────────────── */

/* Global confirm stacks above nested modals / offcanvas backdrops */
#globalConfirmModal.modal {
    z-index: 109000;
}
code {
    background: #f1f5f9;
    color: var(--accent);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    border: 1px solid var(--border);
}

.border-radius-0 { border-radius: 0 !important; }
.shadow-enterprise { box-shadow: var(--shadow); }

/* Bootstrap overrides — align with design tokens */
.btn { border-radius: var(--radius-sm) !important; }
.alert { border-radius: var(--radius-md); border: 1px solid var(--border); }
.card { border-radius: var(--radius-md); border-color: var(--border); box-shadow: var(--shadow-xs); }
.dropdown-menu { border-radius: var(--radius-md); border-color: var(--border); box-shadow: var(--shadow); }
.list-group-item { border-radius: var(--radius-sm) !important; }
.nav-tabs .nav-link { border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; }
.input-group > * { border-radius: var(--radius-sm) !important; }

.toast.text-bg-primary {
    background: linear-gradient(180deg, #1e293b 0%, var(--primary) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-lg);
}

/* ── Facebook-Style Skeleton Shimmer Loader ─────────── */
@keyframes shimmer {
    0%   { background-position: -800px 0; }
    100% { background-position:  800px 0; }
}

.skeleton {
    background: #E8E8E8;
    background-image: linear-gradient(
        to right,
        #E8E8E8 0%,
        #F4F4F4 20%,
        #E8E8E8 40%,
        #E8E8E8 100%
    );
    background-repeat: no-repeat;
    background-size: 800px 100%;
    display: inline-block;
    border-radius: 0;
    animation: shimmer 1.4s linear infinite;
}

/* Skeleton primitives */
.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-line.short  { width: 45%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long   { width: 88%; }
.skeleton-line.full   { width: 100%; }

.skeleton-circle {
    border-radius: 50% !important;
    display: inline-block;
}

.skeleton-block {
    display: block;
    width: 100%;
}

/* Stat card skeleton */
.skeleton-stat {
    padding: 0;
}
.skeleton-stat .sk-label { height: 10px; width: 60%; margin-bottom: 14px; }
.skeleton-stat .sk-value { height: 38px; width: 50%; margin-bottom: 10px; }
.skeleton-stat .sk-note  { height: 10px; width: 75%; }

/* Table row skeleton */
.skeleton-row td .skeleton-line {
    margin-bottom: 0;
}

/* Card body skeleton */
.skeleton-card-body .sk-title  { height: 14px; width: 40%; margin-bottom: 18px; }
.skeleton-card-body .sk-row    { height: 11px; margin-bottom: 10px; }

/* Page-level overlay loader (top progress bar) */
#page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
    z-index: 9999;
    transition: width 0.3s ease;
}
#page-loader.active { animation: progress-bar 1.2s ease infinite; }

@keyframes progress-bar {
    0%   { width: 0%;   opacity: 1; }
    80%  { width: 90%;  opacity: 1; }
    100% { width: 100%; opacity: 0; }
}

/* ── Responsive Mobile Enhancements ───────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important; /* Slightly wider for mobile */
        transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
        box-shadow: 20px 0 50px rgba(0,0,0,0.3);
        visibility: visible !important;
        height: 100vh !important;
        top: 0 !important;
        z-index: 2000 !important;
    }
    .sidebar.show { transform: translateX(0); }
    
    /* Ensure no collapsed state on mobile */
    .sidebar.collapsed { width: 280px !important; }
    .sidebar.collapsed .sidebar-brand-title,
    .sidebar.collapsed .nav-text,
    .sidebar.collapsed .sidebar-user-info,
    .sidebar.collapsed .btn-link.text-danger { display: block !important; }
    
    .sidebar.collapsed .nav-link {
        justify-content: flex-start !important;
        width: auto !important;
        margin: 2px 12px !important;
        padding: 11px 16px !important;
    }
    
    .sidebar.collapsed .nav-link i {
        margin-right: 12px !important;
    }
    
    .sidebar.collapsed .sidebar-brand-bar {
        justify-content: space-between !important;
        padding: 1rem !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 20px 15px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0;
        width: 100vw; height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.show { display: block; }
    
    .fluent-card { padding: 16px; margin-bottom: 16px; }
    h1 { font-size: 1.5rem; }
    
    .login-visual { display: none; }
    .login-form-side { padding: 32px 20px; }
    
    /* Responsive Tables */
    .table-responsive {
        border: 0;
        margin-bottom: 0;
    }
    .enterprise-table thead { display: none; }
    .enterprise-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--border);
        background: #fff;
    }
    .enterprise-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
    }
    .enterprise-table td::before {
        content: attr(data-label);
        font-weight: 700;
        text-align: left;
        color: var(--text-muted);
        font-size: 11px;
        text-transform: uppercase;
    }
}

.sidebar-overlay { display: none; }

/* Premium patrol / checklist surfaces (tokens in main :root) */
/* Glassmorphic Operation Cards */
.qms-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.qms-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: #A8A8A8;
}

/* Custom Interactive Pass/Fail Toggle Buttons */
.btn-status {
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--text-main);
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
}

.btn-status:hover {
    background: #f8fafc;
    transform: translateY(-1px);
}

/* Active Glow States for Pass/Fail */
.qms-card[data-status="passed"] {
    border-color: var(--success);
    background: rgba(4, 120, 87, 0.04);
}
.qms-card[data-status="passed"] .btn-pass {
    background: var(--success);
    border-color: var(--success);
    color: #FFFFFF;
}

.qms-card[data-status="failed"] {
    border-color: var(--danger);
    background: rgba(185, 28, 28, 0.03);
}
.qms-card[data-status="failed"] .btn-fail {
    background: var(--danger);
    border-color: var(--danger);
    color: #FFFFFF;
}

/* Focus Highlights on inputs */
.qms-number-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

/* Custom Digital Sign-Off PIN dots */
.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50% !important;
    background: #E0E0E0;
    display: inline-block;
    transition: var(--transition-smooth);
}

.pin-dot.active {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Touch friendly PIN pad grid */
.pinpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 280px;
    margin: 0 auto;
}

.pin-btn {
    height: 56px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 8px !important;
    border: 1px solid #EDEBE9 !important;
    background: #FFFFFF;
    color: #323130;
    transition: var(--transition-smooth);
}

.pin-btn:hover {
    background: #F3F2F1;
    transform: scale(1.05);
}

.pin-btn:active {
    background: #EDEBE9;
}

/* Prevent sidebar flickering when loading page in collapsed state */
@media (min-width: 992px) {
    .sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed) !important;
        overflow: hidden !important;
    }
    .sidebar-collapsed .sidebar .sidebar-default-brand,
    .sidebar-collapsed .sidebar .sidebar-brand-title > .nav-text,
    .sidebar-collapsed .sidebar .nav-text,
    .sidebar-collapsed .sidebar .sidebar-user-info,
    .sidebar-collapsed .sidebar .btn-link.text-danger {
        display: none !important;
    }
    .sidebar-collapsed .sidebar .sidebar-brand-title {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
    }
    .sidebar-collapsed .sidebar .sidebar-company-logo {
        display: block !important;
    }
    .sidebar-collapsed .sidebar .sidebar-brand-bar {
        justify-content: center !important;
        padding: 12px 0 !important;
    }
    .sidebar-collapsed .sidebar .nav {
        padding-left: 0 !important;
        padding-right: 0 !important;
        align-items: center !important;
    }
    .sidebar-collapsed .sidebar .nav-link {
        justify-content: center !important;
        padding: 12px 0 !important;
        margin: 3px 6px !important;
        border-left: none !important;
        width: calc(var(--sidebar-collapsed) - 16px) !important;
    }
    .sidebar-collapsed .sidebar .nav-link i {
        margin-right: 0 !important;
        font-size: 18px !important;
        width: auto !important;
    }
    .sidebar-collapsed .sidebar .flex-shrink-0 {
        margin: 0 auto !important;
    }
    .sidebar-collapsed .sidebar .sidebar-footer {
        display: flex !important;
        justify-content: center !important;
        padding: 12px 0 !important;
    }
    .sidebar-collapsed .main-content {
        margin-left: var(--sidebar-collapsed) !important;
    }
}

