/* ==========================================================================
   assets/portal.css
   The ONE stylesheet for the whole portal. Link it from every page with:
     <link rel="stylesheet" href="/assets/portal.css?v=<?= (int)@filemtime($_SERVER['DOCUMENT_ROOT'] . '/assets/portal.css') ?>">
   (the ?v= part makes browsers pick up changes straight away)

   Fonts: Roboto Thin (headings) + Nunito Sans (text) load via the @import
   below. If a page already links Google Fonts in <head>, you can remove the
   @import and add these families to that link instead (slightly faster).

   Layout of this file:
     1. Theme variables (colours shared by every page; change the brand colour here)
     2. Shared bits (icon circle)
     3. 2FA page   (<body class="auth-page">)
     4. Login page (<body class="login-page">)
     5. Sidebar: Menu / Apps / Settings tabs and the app grid   (core/header.php)
     6. "View as" menu in the top bar                             (core/header.php)
     7. Staging badge under the logo                              (core/header.php)
     8. App shell: sidebar, top bar, notifications, tables, forms  (core/header.php)
     9. Manage users page + "Reassign assets" pop-up               (admin.php)
    10. My Profile: full-screen ID card pop-up                     (profile.php)
    11. Document viewer: full-screen compliance document page      (profile.php?view_doc=)
    12. My Profile details table                                   (profile.php)
    13. Email health widget                                        (core/email_log.php)
    14. Firearms Medical case page                                 (systems/firearms_medical.php)
   Page styles are scoped under a class on <body> (e.g. .auth-page) so moving a
   page's CSS in here can never change how other pages look.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700&family=Roboto:wght@100;300&display=swap');


/* ==========================================================================
   1. THEME VARIABLES
   If header.php / other pages define these same variables, remove those copies
   once this file is linked there, so there is only one place to edit.
   ========================================================================== */
:root {
    --bg-base: #ffffff;          /* page background */
    --bg-surface: #ffffff;       /* cards */
    --bg-input: #f7f9fc;         /* form fields */
    --bg-hover: #eef3f9;
    --primary: #004F94;
    --primary-hover: #003b6f;
    --primary-soft: rgba(0, 79, 148, 0.12);   /* focus rings, active tabs */
    --text-main: #1f2933;
    --text-muted: #6b7280;
    --border-color: #e3e8ef;

    /* "View as" (admin impersonation) accent: kept separate from the brand
       blue so it's obvious when you're viewing as someone else */
    --viewas: #7c3aed;
    --viewas-soft: #f3eefe;
    --viewas-soft-hover: #e7dcfd;

    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Nunito Sans', sans-serif;

    --radius-card: 16px;
    --radius-field: 10px;
    --radius-pill: 999px;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-pop: 0 14px 34px rgba(0, 0, 0, 0.12);
    --shadow-icon: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);

    /* App shell (section 8) */
    --bg-active: rgba(0, 79, 148, 0.08);      /* active nav item, action buttons */
    --bg-subtle: #f7f9fc;                     /* table headers, dropdown headers */
    --danger: #c62828;

    --status-success: #1e7b4f;
    --status-success-bg: #e8f6ef;
    --status-warning: #b45309;
    --status-warning-bg: #fff4e5;
    --status-danger: #c62828;
    --status-danger-bg: #fdecec;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --topbar-height: 64px;
}


/* ==========================================================================
   2. SHARED BITS
   .icon-circle: put this class on any icon (<i class="... icon-circle">) to
   get the white circle. Icons inside .input-wrapper get it automatically.
   ========================================================================== */
.icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background-color: #FFFFFF;
    padding: 0;                     /* even padding so the glyph sits dead centre */
    border-radius: 30px 30px 30px 30px;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    color: var(--primary);
    line-height: 1;
}
.icon-circle::before { line-height: 1; display: block; }


/* ==========================================================================
   3. 2FA PAGE  (<body class="auth-page">)
   Used by: 2fa.php
   ========================================================================== */
:where(.auth-page) * { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-body); }

.auth-page {
    background-color: var(--bg-base); color: var(--text-main);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; overflow: hidden; padding: 20px;
}

.auth-page .auth-container { width: 100%; max-width: 420px; position: relative; }
.auth-page .auth-card {
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-card); padding: 40px; box-shadow: var(--shadow-card);
    text-align: center;
}
.auth-page .auth-logo { margin-bottom: 32px; }
.auth-page .auth-logo img { max-height: 52px; }

.auth-page .auth-header h2 {
    font-family: var(--font-heading); font-weight: 100;
    font-size: 1.9rem; letter-spacing: 0.3px; margin-bottom: 8px; color: var(--text-main);
}
.auth-page .auth-header p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 24px; }

.auth-page .alert-error {
    color: #c62828; background-color: #fdecec; padding: 10px 14px;
    border-radius: var(--radius-field); font-size: 0.875rem; margin-bottom: 20px;
    border: 1px solid #f5c2c2;
}

/* 2FA: QR code + manual key */
.auth-page .qr-wrapper {
    background: #ffffff; padding: 16px; border-radius: 12px;
    display: inline-block; margin-bottom: 16px;
    border: 1px solid var(--border-color); box-shadow: var(--shadow-icon);
}
.auth-page .qr-wrapper img { display: block; border-radius: 4px; }
.auth-page .qr-fallback { display: none; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 12px; }

.auth-page .secret-key {
    font-family: monospace; letter-spacing: 2px; color: var(--primary);
    font-size: 1.1rem; margin-bottom: 24px; font-weight: 600;
}
.auth-page .app-link { margin: -12px 0 20px; }
.auth-page .app-link a { color: var(--primary); font-size: 0.875rem; font-weight: 600; }

.auth-page .form-group { margin-bottom: 24px; }

.auth-page .code-input {
    width: 100%; background-color: var(--bg-input); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 16px; border-radius: var(--radius-field);
    font-size: 1.5rem; outline: none; transition: all 0.2s;
    text-align: center; letter-spacing: 8px; font-weight: 600;
}
.auth-page .code-input:focus { background-color: #ffffff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-page .code-input::placeholder { color: #c7ced8; letter-spacing: 8px; }

.auth-page .btn-primary {
    background-color: var(--primary); color: #ffffff; border: none;
    width: 100%; padding: 14px 24px; border-radius: var(--radius-pill); font-weight: 700;
    font-size: 0.95rem; cursor: pointer; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-page .btn-primary:hover { background-color: var(--primary-hover); }

@media (max-width: 480px) {
    .auth-page .auth-card { padding: 32px 24px; border: none; box-shadow: none; }
    .auth-page { padding: 10px; align-items: flex-start; padding-top: 10vh; }
}


/* ==========================================================================
   4. LOGIN PAGE  (<body class="login-page">)
   Used by: login.php (sign in + forgot password)
   ========================================================================== */
:where(.login-page) * { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-body); }

.login-page {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    padding: 20px;
}

/* Container & card */
.login-page .auth-container { width: 100%; max-width: 420px; position: relative; }
.login-page .auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 40px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}
.login-page .auth-logo { text-align: center; margin-bottom: 32px; }
.login-page .auth-logo img { max-height: 52px; }

/* View states (sign in <-> forgot password) */
.login-page .auth-view { display: none; opacity: 0; transform: translateX(20px); transition: all 0.3s ease; }
.login-page .auth-view.active { display: block; opacity: 1; transform: translateX(0); }
.login-page .auth-view.slide-left { transform: translateX(-20px); }

/* Typography */
.login-page .auth-header { text-align: center; margin-bottom: 32px; }
.login-page .auth-header h2 {
    font-family: var(--font-heading);
    font-weight: 100;
    font-size: 2rem;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    color: var(--text-main);
}
.login-page .auth-header p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.login-page .alert-error {
    background: #fdecec;
    color: #c62828;
    border: 1px solid #f5c2c2;
    padding: 12px;
    border-radius: var(--radius-field);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}
.login-page .alert-success {
    background: #e8f6ef;
    color: #1e7b4f;
    border: 1px solid #bfe5d1;
    padding: 12px;
    border-radius: var(--radius-field);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

/* Form elements */
.login-page .form-group { margin-bottom: 20px; position: relative; }
.login-page .form-group label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.login-page .input-wrapper { position: relative; }

/* Icon inside the field, on the white circle */
.login-page .input-wrapper i {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #FFFFFF;
    padding: 0;                     /* even padding so the glyph sits dead centre */
    border-radius: 30px 30px 30px 30px;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1;
    text-align: center;
    transition: color 0.2s;
    pointer-events: none;
}
.login-page .input-wrapper i::before { line-height: 1; display: block; }
.login-page .form-control {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 13px 16px 13px 50px; /* extra left padding for the icon circle */
    border-radius: var(--radius-field);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.login-page .form-control::placeholder { color: #9aa3af; }
.login-page .form-control:focus { background-color: #ffffff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-page .form-control:focus + i,
.login-page .input-wrapper:focus-within i { color: var(--primary); }

/* Links & buttons */
.login-page .auth-options { display: flex; justify-content: flex-end; margin-bottom: 24px; margin-top: -8px; }
.login-page .text-link { color: var(--primary); text-decoration: none; font-size: 0.875rem; font-weight: 600; transition: color 0.2s; cursor: pointer; }
.login-page .text-link:hover { color: var(--primary-hover); text-decoration: underline; }

.login-page .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 24px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}
.login-page .btn-primary { background-color: var(--primary); color: #ffffff; margin-bottom: 16px; }
.login-page .btn-primary:hover { background-color: var(--primary-hover); }
.login-page .btn-secondary { background-color: transparent; color: var(--primary); border: 1px solid var(--primary); }
.login-page .btn-secondary:hover { background-color: var(--bg-hover); color: var(--primary-hover); }

/* Phones */
@media (max-width: 480px) {
    .login-page .auth-card { padding: 32px 24px; border: none; box-shadow: none; }
    .login-page { padding: 10px; align-items: flex-start; padding-top: 10vh; }
}


/* ==========================================================================
   5. SIDEBAR TABS + APP GRID  (core/header.php)
   ========================================================================== */
.sb-tabs {
    display: flex; gap: 6px; padding: 12px; position: sticky; top: 0; z-index: 5;
    background: var(--bg-surface); border-bottom: 1px solid var(--border-color);
}
.sb-tab {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 8px; border: 1px solid transparent; border-radius: var(--radius-pill);
    background: transparent; color: var(--text-muted);
    font: 700 0.8rem var(--font-body); cursor: pointer; transition: .15s;
}
.sb-tab:hover { color: var(--primary); background: var(--bg-hover); }
.sb-tab.active { background: var(--primary); border-color: var(--primary); color: #ffffff; }
.sb-tab.sb-tab-icon { flex: 0 0 42px; }
.sb-pane { display: none; }
.sb-pane.active { display: block; }

.app-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.app-tile {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 16px 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-card);
    background: var(--bg-surface); color: var(--text-main); text-decoration: none; text-align: center;
    transition: .15s; min-width: 0;
}
.app-tile:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-card); }

/* App icon sits on the white circle */
.app-tile-icon {
    width: 54px; height: 54px; border-radius: 50%; background: #FFFFFF;
    box-shadow: var(--shadow-icon);
    display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.app-tile-icon img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.app-tile-icon i { font-size: 1.4rem; color: var(--primary); line-height: 1; }
.app-tile-icon i::before { line-height: 1; display: block; }
.app-tile-title {
    font-family: var(--font-body); font-size: 0.8rem; font-weight: 700; line-height: 1.25; max-width: 100%;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.sb-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: 0.875rem; }


/* ==========================================================================
   6. "VIEW AS" MENU  (core/header.php; admins only)
   ========================================================================== */
body.viewing-as .topbar { box-shadow: inset 0 -3px 0 var(--viewas); }
.va-wrap { position: relative; }
.va-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px;
    border-radius: var(--radius-pill); border: 1px solid var(--border-color);
    background: var(--bg-surface); color: var(--text-main);
    font: 700 0.85rem var(--font-body); cursor: pointer; white-space: nowrap; transition: .15s;
}
.va-btn:hover { border-color: var(--primary); color: var(--primary); }
.va-btn.on { background: var(--viewas-soft); border-color: var(--viewas); color: var(--viewas); }

.va-pop {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    width: 290px; max-width: calc(100vw - 30px);
    background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-card);
    box-shadow: var(--shadow-pop); z-index: 9000; overflow: hidden;
}
.va-pop.open { display: block; }
.va-head {
    padding: 12px 14px; border-bottom: 1px solid var(--border-color);
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700;
}
.va-search {
    width: calc(100% - 20px); margin: 10px; padding: 9px 14px; border-radius: var(--radius-pill);
    border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-main);
    font-family: var(--font-body); font-size: 0.875rem; outline: none; transition: .15s;
}
.va-search:focus { background: #ffffff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.va-list { max-height: 300px; overflow-y: auto; }
.va-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
    padding: 10px 14px; background: none; border: none; border-top: 1px solid var(--border-color);
    color: var(--text-main); font-family: var(--font-body); font-size: 0.9rem; text-align: left; cursor: pointer;
}
.va-item:hover { background: var(--bg-hover); }
.va-item.current { color: var(--viewas); font-weight: 700; }
.va-item small { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: .3px; }
.va-return {
    display: flex; width: 100%; align-items: center; gap: 8px; padding: 11px 14px;
    background: var(--viewas-soft); border: none; border-bottom: 1px solid var(--border-color);
    color: var(--viewas); font: 700 0.85rem var(--font-body); cursor: pointer;
}
.va-return:hover { background: var(--viewas-soft-hover); }

/* iPhones zoom the page when you tap a box with text smaller than 16px, so keep the search box at 16px on touch screens */
@media (max-width: 768px), (pointer: coarse) { .va-search { font-size: 16px; } }

/* MOBILE: the View as dropdown moves out of the crowded top bar into its own full-width strip at the very top (the script in header.php does the moving) */
.va-mobile-bar { display: none; }
@media (max-width: 768px) {
    .va-mobile-bar.has { display: block; position: relative; z-index: 1100; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); padding: 8px 12px; }
    body.viewing-as .va-mobile-bar.has { background: var(--viewas-soft); border-bottom-color: var(--viewas); }
    .va-mobile-bar .va-wrap { width: 100%; }
    .va-mobile-bar .va-btn { width: 100%; height: 42px; }
    .va-mobile-bar .va-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
    .va-mobile-bar .va-pop { left: 0; right: 0; width: auto; max-width: none; }
    .va-mobile-bar .va-list { max-height: 50vh; }
}


/* ==========================================================================
   7. STAGING BADGE  (core/header.php shows it under the logo on the staging site only)
   A small pill so nobody mistakes the staging site for the live system. The top bar is not changed.
   ========================================================================== */
.env-tag {
    display: block; margin: 8px auto 0; width: fit-content;
    background: #f97316; color: #fff;
    font: 700 11px/1 var(--font-body); letter-spacing: 1.5px; text-transform: uppercase;
    padding: 5px 12px; border-radius: var(--radius-pill);
}


/* ==========================================================================
   8. APP SHELL  (core/header.php: sidebar, top bar, notifications, page
      header, filters, tables, status pills, row actions, form cards)
   This replaces the <style> block that used to sit inside header.php, so
   delete that block once this file is linked there.

   The general rules (body, *, .btn, .form-control, .form-group) are wrapped
   in :where(body:not(.login-page):not(.auth-page)) so they never touch the
   login / 2FA pages, which have their own versions above. :where() adds no
   specificity, so these behave exactly like the plain selectors did.
   ========================================================================== */
:where(body:not(.login-page):not(.auth-page)) * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body:where(:not(.login-page):not(.auth-page)) {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Buttons & Inputs --- */
:where(body:not(.login-page):not(.auth-page)) .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}
:where(body:not(.login-page):not(.auth-page)) .btn-primary { background-color: var(--primary); color: #ffffff; }
:where(body:not(.login-page):not(.auth-page)) .btn-primary:hover { background-color: var(--primary-hover); }
:where(body:not(.login-page):not(.auth-page)) .btn-secondary { background-color: transparent; color: var(--primary); border: 1px solid var(--primary); }
:where(body:not(.login-page):not(.auth-page)) .btn-secondary:hover { background-color: var(--bg-hover); color: var(--primary-hover); }

:where(body:not(.login-page):not(.auth-page)) .form-control {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 11px 14px;
    border-radius: var(--radius-field);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    width: 100%;
}
:where(body:not(.login-page):not(.auth-page)) .form-control::placeholder { color: #9aa3af; }
:where(body:not(.login-page):not(.auth-page)) .form-control:focus {
    background-color: #ffffff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

/* --- Sidebar Navigation --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
}

.brand-logo { max-width: 100%; max-height: 44px; transition: opacity 0.2s ease; }

.sidebar-nav { flex: 1; padding: 24px 16px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.nav-section {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin: 20px 0 10px 12px;
    letter-spacing: 1px;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}
.nav-section:first-child { margin-top: 0; }

.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-pill);
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

/* Nav icons sit on the white circle */
.nav-item i {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #FFFFFF;
    border-radius: 30px;
    box-shadow: var(--shadow-icon);
    font-size: 0.9rem;
    line-height: 1;
    margin-right: 12px;
    color: var(--text-muted);
    transition: color 0.2s, margin 0.2s;
}
.nav-item i::before { line-height: 1; display: block; }
.nav-item img { margin-right: 12px; }

.nav-item span { transition: opacity 0.2s ease; }
.nav-item:hover { background-color: var(--bg-hover); color: var(--primary); }
.nav-item:hover i { color: var(--primary); }
.nav-item.active { background-color: var(--bg-active); color: var(--primary); }
.nav-item.active i { color: var(--primary); }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border-color); }

.logout-btn-sidebar, .logout-btn-sidebar i { color: var(--danger); }

/* --- Quick Links Grid --- */
.quick-links-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 12px 12px 12px; }

.quick-link-tile {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 14px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.quick-link-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); border-color: var(--primary); }
.quick-link-tile img { width: 32px; height: 32px; object-fit: contain; }
.quick-link-tile span {
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

/* Collapsed sidebar: quick links */
body.sidebar-collapsed .quick-links-grid { grid-template-columns: 1fr; padding: 0 12px; }
body.sidebar-collapsed .quick-link-tile span { display: none; }
body.sidebar-collapsed .quick-link-tile { padding: 10px; }

/* --- Desktop Collapsed State --- */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}
body.sidebar-collapsed .brand-logo { opacity: 0; }
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .nav-item span { opacity: 0; pointer-events: none; display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 8px 0; }
body.sidebar-collapsed .nav-item i { margin-right: 0; }

/* --- Main Content Wrapper --- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* --- Top Bar --- */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 990;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

/* Menu + bell buttons are white icon circles too */
.menu-toggle,
.notification-btn {
    background: #FFFFFF;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    box-shadow: var(--shadow-icon);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    position: relative;
    transition: color 0.2s, box-shadow 0.2s;
}
.menu-toggle:hover,
.notification-btn:hover,
.notification-btn.active { color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-icon); }

.mobile-logo { max-height: 34px; display: none; }

.topbar-right { display: flex; align-items: center; gap: 20px; }

/* --- Notifications --- */
.notification-wrapper { position: relative; }
.notification-badge {
    position: absolute; top: -3px; right: -3px;
    background-color: var(--primary); color: #ffffff;
    font-size: 0.62rem; font-weight: 700; height: 17px; min-width: 17px; padding: 0 4px;
    border-radius: var(--radius-pill); border: 2px solid #ffffff;
    display: flex; align-items: center; justify-content: center;
}
.notifications-dropdown {
    position: absolute; top: 120%; right: 0; width: 340px;
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-card); box-shadow: var(--shadow-pop);
    display: flex; flex-direction: column; overflow: hidden;
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s; z-index: 1000;
}
.notifications-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; background-color: var(--bg-subtle); border-bottom: 1px solid var(--border-color);
}
.notif-header h4 { font-size: 0.95rem; font-weight: 700; }
.notif-header a { color: var(--primary); text-decoration: none; font-size: 0.8rem; font-weight: 600; }
.notif-body { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; background-color: var(--bg-surface); }
.notif-body::-webkit-scrollbar { width: 4px; }
.notif-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.notif-item {
    display: flex; gap: 16px; padding: 16px 20px;
    background-color: var(--bg-surface); border-bottom: 1px solid var(--border-color);
    text-decoration: none; color: var(--text-main); transition: background 0.2s;
}
.notif-item:hover { background-color: var(--bg-hover); }
.notif-item.unread { box-shadow: inset 4px 0 0 var(--primary); background-color: var(--bg-active); }
.notif-icon-circle {
    width: 36px; height: 36px; border-radius: 50%; background-color: #FFFFFF; box-shadow: var(--shadow-icon);
    display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0; line-height: 1;
}
.notif-content { display: flex; flex-direction: column; gap: 4px; }
.notif-title { font-size: 0.85rem; font-weight: 700; line-height: 1.4; }
.notif-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.notif-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }
.notif-footer { padding: 14px; text-align: center; background-color: var(--bg-surface); }
.notif-footer a { color: var(--primary); text-decoration: none; font-size: 0.85rem; font-weight: 700; transition: color 0.2s; }
.notif-footer a:hover { color: var(--primary-hover); }

.topbar-divider { height: 24px; width: 1px; background-color: var(--border-color); }

/* --- Content Area & Views --- */
.content-body { padding: 32px; flex: 1; }
.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Page Header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}
.header-text h2 {
    font-family: var(--font-heading);
    font-weight: 100;
    font-size: 2.2rem;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    color: var(--text-main);
}
.header-text p { color: var(--text-muted); font-size: 0.95rem; }

/* --- Filters --- */
.filters-container {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-card);
    align-items: center;
}
.filter-item { flex: 1; min-width: 150px; }
.mobile-filter-trigger { display: none; }
.close-filters { display: none; }

/* --- Table --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    background-color: var(--bg-surface);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}
.data-table { width: 100%; border-collapse: collapse; min-width: 800px; /* forces horizontal scroll on small screens */ }
.data-table th, .data-table td { padding: 16px 24px; text-align: left; border-bottom: 1px solid var(--border-color); }
.data-table th {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    font-weight: 700;
    background-color: var(--bg-subtle);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background-color: var(--bg-hover); }

/* Cell formatting */
.cell-main-text { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; display: block; }
.cell-sub-text { font-size: 0.8rem; color: var(--text-muted); }

/* --- Status Pills --- */
.status-pill {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pill-success { background-color: var(--status-success-bg); color: var(--status-success); }
.pill-warning { background-color: var(--status-warning-bg); color: var(--status-warning); }
.pill-danger  { background-color: var(--status-danger-bg);  color: var(--status-danger); }

/* --- Row Actions Dropdown --- */
.actions-cell { position: relative; width: 60px; text-align: center !important; }
.actions-trigger {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s;
}
.actions-trigger:hover, .actions-trigger.active { background-color: #FFFFFF; box-shadow: var(--shadow-icon); color: var(--primary); }

.actions-menu {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-pop);
    width: 170px;
    display: none;
    z-index: 100;
    text-align: left;
    overflow: hidden;
}
.actions-menu.show { display: block; }
.actions-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}
.actions-menu a:hover { background-color: var(--bg-hover); color: var(--primary); }
.actions-menu a.text-danger { color: var(--danger); }
.actions-menu a.text-danger:hover { background-color: var(--status-danger-bg); color: var(--danger); }

/* --- Form View --- */
.form-card {
    background-color: var(--bg-surface);
    padding: 32px;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }

:where(body:not(.login-page):not(.auth-page)) .form-group { display: flex; flex-direction: column; gap: 8px; }
:where(body:not(.login-page):not(.auth-page)) .form-group label { font-size: 0.85rem; font-weight: 700; color: var(--text-main); }
.form-group.full-width { grid-column: 1 / -1; }

.form-actions { display: flex; gap: 16px; padding-top: 24px; border-top: 1px solid var(--border-color); }

/* --- Mobile Overlays --- */
.sidebar-overlay, .filter-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(15, 23, 42, 0.35); z-index: 998;
    display: none; opacity: 0; transition: opacity 0.3s ease;
}

/* --- Responsive --- */
@media (max-width: 992px) {
    /* Sidebar */
    body.sidebar-collapsed .sidebar { width: var(--sidebar-width); }
    body.sidebar-collapsed .brand-logo { opacity: 1; }
    body.sidebar-collapsed .nav-section, body.sidebar-collapsed .nav-item span { display: block; opacity: 1; pointer-events: auto; }
    body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 8px 12px; }
    body.sidebar-collapsed .nav-item i { margin-right: 12px; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; width: 100% !important; }
    .mobile-logo { display: block; }
    .logout-btn-top, .topbar-divider { display: none; }
    .sidebar-overlay.active { display: block; opacity: 1; }
    .notifications-dropdown { position: fixed; top: var(--topbar-height); right: 16px; left: 16px; width: auto; }

    /* Views */
    .page-header { flex-direction: column; align-items: stretch; gap: 20px; }
    .page-header .btn { width: 100%; }
    .header-text h2 { font-size: 1.9rem; }
    .form-grid { grid-template-columns: 1fr; }
    .content-body { padding: 16px; }

    /* Mobile filter modal */
    .mobile-filter-trigger { display: flex; width: 100%; margin-bottom: 16px; }
    .filters-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        width: 90%;
        max-width: 400px;
        background-color: var(--bg-surface);
        flex-direction: column;
        z-index: 1000;
        padding: 24px;
        box-shadow: var(--shadow-pop);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        border: 1px solid var(--border-color);
    }
    .filters-container.show { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
    .filter-item { width: 100%; }
    .close-filters { display: block; width: 100%; margin-top: 16px; }
    .filter-overlay.active { display: block; opacity: 1; }
}

/* iPhones zoom when tapping a field with text under 16px */
@media (max-width: 768px), (pointer: coarse) {
    :where(body:not(.login-page):not(.auth-page)) .form-control { font-size: 16px; }
}


/* ==========================================================================
   9. MANAGE USERS PAGE  (admin.php)
   The generic names (.data-table, .table-responsive, .role-tag, .edit-layout)
   are scoped under .admin-page (a class on the page's two main views) because
   other pages use the same names with different looks.
   ========================================================================== */
.admin-page .action-btn-hover:hover { background-color: var(--bg-hover) !important; }
.admin-page .action-btn-hover-primary:hover { background-color: var(--bg-hover) !important; color: var(--primary) !important; }
.admin-page .action-btn-hover-danger:hover { background-color: var(--status-danger-bg) !important; color: var(--danger) !important; }
.admin-page .role-tag {
    display: inline-block; background: var(--bg-active); color: var(--primary);
    font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill);
    margin-right: 4px; margin-top: 4px;
}

/* Responsive layout */
.admin-page .edit-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.admin-page .table-responsive {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color); border-radius: var(--radius-card);
    background: var(--bg-surface); box-shadow: var(--shadow-card);
}
.admin-page .data-table { width: 100%; min-width: 800px; border-collapse: collapse; }

@media (max-width: 1024px) {
    .admin-page .edit-layout { grid-template-columns: 1fr; }
    .admin-page .data-table { min-width: 600px; }
}

/* Messages */
.admin-page .alert {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px; margin-bottom: 24px;
    border-radius: 12px; font-size: 0.9rem; font-weight: 600; border: 1px solid transparent;
}
.admin-page .alert-success { background: var(--status-success-bg); color: var(--status-success); border-color: #bfe5d1; }
.admin-page .alert-error   { background: var(--status-danger-bg);  color: var(--status-danger);  border-color: #f5c2c2; }

/* User table */
.admin-page .text-muted { color: var(--text-muted); }
.admin-page .contact-line { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--text-muted); }
.admin-page .contact-line i { font-size: 0.7rem; margin-right: 4px; }
.admin-page .role-tag-admin { background: var(--primary); color: #ffffff; }
.admin-page .empty-row td { text-align: center; color: var(--text-muted); padding: 40px 24px; }

/* Buttons inside the row actions menu (forms) look like the menu links */
.admin-page .actions-menu form { margin: 0; }
.admin-page .actions-menu-btn {
    display: block; width: 100%; padding: 10px 16px; text-align: left;
    background: none; border: none; cursor: pointer;
    color: var(--text-main); font: 600 0.85rem var(--font-body);
    transition: background 0.2s, color 0.2s;
}
.admin-page .actions-menu-btn:hover { background-color: var(--bg-hover); color: var(--primary); }
.admin-page .actions-menu-btn.text-danger { color: var(--danger); }
.admin-page .actions-menu-btn.text-danger:hover { background-color: var(--status-danger-bg); color: var(--danger); }
.admin-page .actions-menu a i,
.admin-page .actions-menu-btn i { margin-right: 6px; color: inherit; }

/* Add / edit form */
.admin-page .form-narrow { max-width: 880px; }
.admin-page .section-title {
    font-family: var(--font-heading); font-weight: 300; font-size: 1.4rem; color: var(--text-main);
    margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
}
.admin-page .form-section { margin-top: 8px; margin-bottom: 8px; }
.admin-page .section-help { color: var(--text-muted); font-size: 0.875rem; margin: -8px 0 16px; }
.admin-page .system-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.admin-page .system-card { background: var(--bg-subtle); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px; }
.admin-page .system-card label { display: block; margin-bottom: 8px; font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.admin-page .system-card .form-control { background: #ffffff; }

/* "Reassign assets" pop-up (class names start with ra-, so they cannot clash with other pages) */
.ra-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 9999;
    display: none; justify-content: center; align-items: flex-start; padding: 20px;
    backdrop-filter: blur(4px); overflow-y: auto;
}
.ra-box {
    background: var(--bg-surface); width: 100%; max-width: 720px;
    border-radius: var(--radius-card); border: 1px solid var(--border-color);
    overflow: hidden; box-shadow: var(--shadow-pop); margin: 5vh auto;
}
.ra-box input[type="checkbox"], .ra-box input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }
.ra-head {
    padding: 18px 24px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center; background: var(--bg-surface);
}
.ra-head h3 { margin: 0; color: var(--text-main); font-family: var(--font-heading); font-weight: 300; font-size: 1.4rem; }
.ra-close {
    background: #FFFFFF; border: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1;
    width: 34px; height: 34px; border-radius: 50%; box-shadow: var(--shadow-icon);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: color 0.2s;
}
.ra-close:hover { color: var(--primary); }
.ra-body { padding: 20px 24px; max-height: 60vh; overflow-y: auto; }
.ra-foot { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; gap: 10px; background: var(--bg-subtle); }

.ra-filter { background: var(--bg-subtle); border: 1px solid var(--border-color); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.ra-filter-title {
    font-size: 0.72rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ra-filter-title a { color: var(--primary); cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 600; margin-left: 10px; }
.ra-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ra-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
    border: 1px solid var(--border-color); border-radius: var(--radius-pill);
    font-size: 0.85rem; font-weight: 600; color: var(--text-main); cursor: pointer; background: #ffffff; transition: .15s;
}
.ra-chip:hover { border-color: var(--primary); color: var(--primary); }

.ra-all {
    display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-main);
    padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border-color); cursor: pointer;
}
.ra-group { margin-bottom: 20px; }
.ra-group[hidden] { display: none !important; }
.ra-group-head {
    display: flex; align-items: center; gap: 8px; color: var(--primary);
    font-size: 0.8rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 8px; cursor: pointer;
}
.ra-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 6px;
    cursor: pointer; background: #ffffff; transition: background 0.15s, border-color 0.15s;
}
.ra-item:hover { background: var(--bg-hover); border-color: #cfd8e3; }
.ra-item-off { opacity: 0.55; cursor: not-allowed; }
.ra-item-off:hover { background: #ffffff; border-color: var(--border-color); }
.ra-item .ra-main { flex: 1; min-width: 0; }
.ra-item .ra-main strong { color: var(--text-main); display: block; font-weight: 700; }
.ra-item .ra-main small { color: var(--text-muted); }

/* Type icon on the white circle */
.ra-type {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
    background: #FFFFFF; box-shadow: var(--shadow-icon); color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-size: 0.85rem;
}
.ra-type::before { line-height: 1; display: block; }

.ra-status { font-size: 0.72rem; font-weight: 700; white-space: nowrap; padding: 4px 10px; border-radius: var(--radius-pill); }
.ra-ok   { color: var(--status-success); background: var(--status-success-bg); }
.ra-warn { color: var(--status-warning); background: var(--status-warning-bg); }
.ra-bad  { color: var(--status-danger);  background: var(--status-danger-bg); }


/* ==========================================================================
   10. MY PROFILE PAGE  (profile.php)
   The full-screen ID card pop-up. These names are unique to this page.
   ========================================================================== */
.id-card-trigger {
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.id-card-trigger:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-card);
}

#idCardFullscreenOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: #ffffff;
    z-index: 999999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.id-card-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-pill);
    font: 700 0.95rem var(--font-body);
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: background 0.2s;
}
.id-card-close-btn:hover { background: var(--primary-hover); }

#idCardScaleWrapper {
    width: 95%;
    max-width: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ignore the card's own 320px max-width, fill the wrapper, and strip its 5% padding */
#idCardScaleWrapper > div {
    pointer-events: none;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
}
#idCardScaleWrapper > div > div {
    width: 100% !important;
    max-width: 100% !important;
}


/* ==========================================================================
   11. DOCUMENT VIEWER  (profile.php?view_doc=...  full-screen page for a compliance document)
   It is its own page (no sidebar), so it links this stylesheet itself.
   Scoped under .doc-viewer (class on its <body>) because .top-bar etc. are common names.
   A light grey backdrop so white documents still stand out from the page.
   ========================================================================== */
.doc-viewer {
    margin: 0; padding: 0;
    background-color: var(--bg-subtle); color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
.doc-viewer .top-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 14px 20px; background-color: #ffffff;
    border-bottom: 1px solid var(--border-color); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    z-index: 10;
}
.doc-viewer .top-bar h2 {
    margin: 0; font-family: var(--font-heading); font-weight: 300; font-size: 1.35rem;
    color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-viewer .btn-close {
    display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
    padding: 9px 18px; border-radius: var(--radius-pill);
    background: transparent; color: var(--primary); border: 1px solid var(--primary);
    text-decoration: none; font: 700 0.9rem var(--font-body);
    transition: background 0.2s, color 0.2s;
}
.doc-viewer .btn-close:hover { background: var(--primary); color: #ffffff; }
.doc-viewer .viewer-container {
    flex: 1; display: flex; justify-content: center; align-items: center;
    background-color: var(--bg-subtle); overflow: auto; padding: 24px;
}
.doc-viewer .viewer-container img {
    max-width: 100%; max-height: 100%; object-fit: contain;
    background: #ffffff; border-radius: 12px; box-shadow: var(--shadow-card);
}
.doc-viewer .viewer-container iframe {
    width: 100%; height: 100%; border: 1px solid var(--border-color);
    border-radius: 12px; background: #ffffff; box-shadow: var(--shadow-card);
}

@media (max-width: 600px) {
    .doc-viewer .top-bar { padding: 12px 14px; }
    .doc-viewer .top-bar h2 { font-size: 1.1rem; }
    .doc-viewer .viewer-container { padding: 12px; }
    .id-card-close-btn { top: 12px; right: 12px; padding: 9px 18px; }
}


/* ==========================================================================
   12. MY PROFILE DETAILS TABLE  (profile.php)
   Scoped under .profile-page (class on the page's view) so it can't affect other pages.
   ========================================================================== */
.profile-page .profile-card { max-width: 760px; }
.profile-page .profile-table { width: 100%; border-collapse: collapse; }
.profile-page .profile-table th,
.profile-page .profile-table td { padding: 16px 24px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border-color); }
.profile-page .profile-table tr:last-child th,
.profile-page .profile-table tr:last-child td { border-bottom: none; }
.profile-page .profile-table th {
    width: 38%; background: var(--bg-subtle);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
}
.profile-page .profile-table td { font-size: 0.95rem; font-weight: 600; color: var(--text-main); }
.profile-page .text-muted { color: var(--text-muted); font-weight: 400; }
.profile-page .role-tag {
    display: inline-block; background: var(--bg-active); color: var(--primary);
    font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: var(--radius-pill);
    margin: 2px 4px 2px 0;
}
.profile-page .role-tag-admin { background: var(--primary); color: #ffffff; }
.profile-page .profile-note { margin-top: 14px; font-size: 0.85rem; color: var(--text-muted); }
.profile-page .profile-empty {
    max-width: 760px; padding: 30px; text-align: center; border-radius: var(--radius-card);
    border: 1px dashed var(--border-color); color: var(--text-muted); background: var(--bg-surface);
}

@media (max-width: 600px) {
    .profile-page .profile-table th,
    .profile-page .profile-table td { display: block; width: 100%; padding: 10px 16px; }
    .profile-page .profile-table th { border-bottom: none; padding-bottom: 4px; }
    .profile-page .profile-table td { padding-top: 6px; }
}


/* ==========================================================================
   13. EMAIL HEALTH WIDGET  (core/email_log.php -> el_health_widget(), shown in the System Security widget)
   ========================================================================== */
.el-health-ok {
    display: flex; align-items: center; gap: 12px; padding: 10px 0;
}
.el-health-ok i {
    width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; line-height: 1;
    background: #FFFFFF; box-shadow: var(--shadow-icon); color: var(--status-success);
}
.el-health-ok i::before { line-height: 1; display: block; }
.el-health-ok span { color: var(--text-muted); font-size: 0.9rem; font-weight: 600; }

.el-health-bad {
    padding: 12px 14px; border: 1px solid #f5c2c2; border-left: 4px solid var(--status-danger);
    background: var(--status-danger-bg); border-radius: 12px;
}
.el-health-title { color: var(--status-danger); font-weight: 700; font-size: 0.95rem; }
.el-health-item { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; line-height: 1.45; }
.el-health-item strong { color: var(--text-main); font-weight: 700; }
.el-health-time { opacity: .75; }
.el-health-err { color: var(--status-danger); font-weight: 600; }
.el-health-link {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
    padding: 6px 14px; border-radius: var(--radius-pill);
    background: #ffffff; border: 1px solid var(--status-danger); color: var(--status-danger);
    font-size: 0.8rem; font-weight: 700; text-decoration: none; transition: background 0.2s, color 0.2s;
}
.el-health-link:hover { background: var(--status-danger); color: #ffffff; }


/* ==========================================================================
   14. FIREARMS MEDICAL CASE PAGE  (systems/firearms_medical.php)
   Scoped under .fa-page (class on the page's view).
   ========================================================================== */
.fa-page .alert {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px; margin-bottom: 20px;
    border-radius: 12px; font-size: 0.9rem; font-weight: 600; border: 1px solid transparent;
}
.fa-page .alert-success { background: var(--status-success-bg); color: var(--status-success); border-color: #bfe5d1; }
.fa-page .alert-error   { background: var(--status-danger-bg);  color: var(--status-danger);  border-color: #f5c2c2; }
.fa-page .alert-warning { background: var(--status-warning-bg); color: var(--status-warning); border-color: #fcd9a8; }

.fa-page .pill-info    { background-color: var(--bg-active); color: var(--primary); }
.fa-page .pill-neutral { background-color: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border-color); }

.fa-page .header-text p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fa-page .fa-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.fa-page .fa-actions form { margin: 0; }

.fa-page .fa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; align-items: start; }
.fa-page .fa-grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.fa-page .fa-card { padding: 24px; }
.fa-page .fa-wide { margin-bottom: 20px; }
.fa-page .fa-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fa-page .fa-card-head form { margin: 0; }

.fa-page .fa-section-title {
    font-family: var(--font-heading); font-weight: 300; font-size: 1.3rem; color: var(--text-main);
    margin: 0 0 14px 0; padding-bottom: 10px; border-bottom: 1px solid var(--border-color);
}
.fa-page .fa-card .fa-section-title:not(:first-child) { margin-top: 22px; }
.fa-page .fa-card-head .fa-section-title { border-bottom: none; padding-bottom: 0; margin-bottom: 10px; }

.fa-page .fa-dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 10px 14px; margin: 0; }
.fa-page .fa-dl dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted); padding-top: 2px; }
.fa-page .fa-dl dd { margin: 0; font-weight: 600; color: var(--text-main); word-break: break-word; }
.fa-page .fa-dl dd a { color: var(--primary); text-decoration: none; }
.fa-page .fa-dl-inline { grid-template-columns: max-content 1fr; margin-bottom: 16px; }

.fa-page .fa-muted { color: var(--text-muted); font-weight: 400; }
.fa-page .fa-note { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 16px 0; line-height: 1.5; }
.fa-page .fa-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; color: var(--text-muted); word-break: break-all; }

.fa-page .fa-table-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 12px; }
.fa-page .fa-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.fa-page .fa-table th, .fa-page .fa-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-color); font-size: 0.88rem; }
.fa-page .fa-table th { background: var(--bg-subtle); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted); }
.fa-page .fa-table tr:last-child td { border-bottom: none; }

.fa-page .fa-timeline { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.fa-page .fa-timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border-color); margin-left: 6px; }
.fa-page .fa-timeline li::before {
    content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%;
    background: #ffffff; border: 2px solid var(--primary);
}
.fa-page .fa-timeline li:last-child { padding-bottom: 0; }
.fa-page .fa-ev-when { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }
.fa-page .fa-ev-what { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text-main); line-height: 1.4; }
.fa-page .fa-ev-deposit_paid::before, .fa-page .fa-ev-balance_paid::before { border-color: var(--status-success); background: var(--status-success); }
.fa-page .fa-ev-email_failed::before, .fa-page .fa-ev-duplicate_payment::before, .fa-page .fa-ev-payment_mismatch::before, .fa-page .fa-ev-deleted::before { border-color: var(--status-danger); background: var(--status-danger); }

.fa-page .fa-edit { max-width: 980px; }
.fa-page .fa-edit .fa-section-title { margin-top: 26px; }
.fa-page .fa-edit .fa-section-title:first-of-type { margin-top: 0; }
.fa-page .fa-field-error { color: var(--status-danger); font-size: 0.8rem; font-weight: 600; }
.fa-page .fa-other[hidden] { display: none; }
.fa-page .fa-other .form-grid { margin-bottom: 0; }

.fa-page .fa-find { max-width: 520px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.fa-page .fa-find .form-group { width: 100%; }

.fa-page form.fa-card .form-group { margin-bottom: 14px; }
.fa-page .fa-btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.fa-page .fa-danger { border-color: #f5c2c2; }
.fa-page .fa-danger .fa-section-title { color: var(--status-danger); }
.fa-page .fa-inline { display: flex; gap: 12px; flex-wrap: wrap; }
.fa-page .fa-inline .form-control { flex: 1; min-width: 220px; }
.fa-page .fa-btn-danger { background: var(--status-danger); color: #ffffff; }
.fa-page .fa-btn-danger:hover { background: #a61f1f; }

@media (max-width: 600px) {
    .fa-page .fa-grid, .fa-page .fa-grid-2 { grid-template-columns: 1fr; }
    .fa-page .fa-dl { grid-template-columns: 1fr; gap: 2px; }
    .fa-page .fa-dl dd { margin-bottom: 10px; }
}
