/* ==========================================================================
   PylotOps Knowledge Base — design system
   Primary / secondary colours come from the Theme table (set in _Layout via JS):
     --primary-color, --secondary-color
   Everything else (dark/light shades, gradients, shadows) is derived from them.
   ========================================================================== */

:root {
    /* ---- Theme colours (fallbacks; _Layout overrides these from the DB) ---- */
   --theme-primary: #303f5e;
    --theme-secondary: #4c95be;
    --primary-color: var(--theme-primary);
    --secondary-color: var(--theme-secondary);
    /* ---- Derived from primary ---- */
    --primary-dark: color-mix(in srgb, var(--primary-color) 75%, #000);
    --primary-darker: color-mix(in srgb, var(--primary-color) 50%, #000);
    /* ---- Derived from secondary ---- */
    --secondary-dark: color-mix(in srgb, var(--secondary-color) 80%, #000);
    --secondary-soft: color-mix(in srgb, var(--secondary-color) 85%, #fff);
    --secondary-bright: color-mix(in srgb, var(--secondary-color) 75%, #fff);
    --secondary-lighter: color-mix(in srgb, var(--secondary-color) 60%, #fff);
    --secondary-light: color-mix(in srgb, var(--secondary-color) 12%, #fff);
    /* ---- Neutrals ---- */
    --bg: #f2f4f8;
    --surface: #ffffff;
    --border: #e4e8ef;
    --text: #263042;
    --muted: #6b7686;
    /* ---- Status colours (fixed, not themed) ---- */
    --success: #1f9d55;
    --success-bg: #e7f7ee;
    --danger: #d6455a;
    --danger-bg: #fceaec;
    --warning: #c98a1b;
    --warning-bg: #fdf3e0;
    /* ---- Shape / shadow / layout ---- */
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 10px color-mix(in srgb, var(--primary-color) 10%, transparent);
    --shadow-md: 0 10px 30px color-mix(in srgb, var(--primary-color) 20%, transparent);
    --sidebar-width: 264px;
    --topbar-height: 64px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    /*background: var(--bg);*/
    color: var(--text);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.95rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--primary-color);
}

a {
    color: var(--secondary-dark);
}

    a:hover {
        color: var(--primary-color);
    }

/* ---------------------------------------------------------------------- */
/* App shell                                                               */
/* ---------------------------------------------------------------------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 36, 0.45);
    z-index: 1030;
}

body.sidebar-open .sidebar-overlay {
    display: block;
}

/* ---------------------------------------------------------------------- */
/* Sidebar                                                                 */
/* ---------------------------------------------------------------------- */

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: radial-gradient(120% 45% at 0% 0%, color-mix(in srgb, var(--secondary-color) 25%, transparent) 0%, transparent 60%), linear-gradient(180deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #dfe6f2;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    box-shadow: 4px 0 24px color-mix(in srgb, var(--primary-darker) 35%, transparent);
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: var(--topbar-height);
}

    .sidebar-brand img {
        max-width: 100%;
        filter: brightness(0) invert(1);
    }

/* ---- Nav container: scroll chalta hai, scrollbar nazar nahi aati ---- */
.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0; /* flex child ko scroll karne ke liye */
    padding: 1rem 0.75rem;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* purana Edge / IE */
}

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

.sidebar-section-label {
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: rgba(223, 230, 242, 0.45);
    padding: 0.5rem 0.85rem;
    margin-top: 0.75rem;
}

/* ---- Links ---- */
.sidebar-nav .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    color: rgba(223, 230, 242, 0.82);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

    .sidebar-nav .nav-link i {
        width: 1.25rem;
        text-align: center;
        font-size: 0.95rem;
        color: rgba(223, 230, 242, 0.6);
        transition: color 0.15s ease;
    }

    .sidebar-nav .nav-link:hover {
        background: rgba(255, 255, 255, 0.07);
        color: #ffffff;
        text-decoration: none;
        transform: translateX(2px);
    }

        .sidebar-nav .nav-link:hover i {
            color: #ffffff;
        }

    /* Active link */
    .sidebar-nav .nav-link.active {
        background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-soft) 100%);
        color: #ffffff;
        box-shadow: 0 6px 16px color-mix(in srgb, var(--secondary-color) 35%, transparent);
        transform: none;
    }

        .sidebar-nav .nav-link.active i {
            color: #ffffff;
        }

/* ---- Group (Knowledge Records) ---- */
.sidebar .nav-link .fa-chevron-down {
    margin-left: auto;
    width: auto;
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}

.sidebar-nav .nav-link[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg);
}

/* Group khula ho aur uska koi child active ho: parent halka, child nazar aaye */
.sidebar-nav .nav-link[data-toggle="collapse"][aria-expanded="true"].active {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

/* ---- Sub menu ---- */
.sidebar-nav .collapse,
.sidebar-nav .collapsing {
    margin: 0.15rem 0 0.5rem 1.55rem;
    padding-left: 0.6rem;
    border-left: 1px solid rgba(255, 255, 255, 0.14);
}

    /* pl-5 ko override: text ab wrap nahi hota */
    .sidebar-nav .collapse .nav-link,
    .sidebar-nav .collapsing .nav-link {
        padding: 0.5rem 0.7rem !important;
        font-size: 0.84rem;
        font-weight: 400;
        gap: 0.65rem;
    }

        .sidebar-nav .collapse .nav-link i,
        .sidebar-nav .collapsing .nav-link i {
            font-size: 0.82rem;
        }

        .sidebar-nav .collapse .nav-link.active,
        .sidebar-nav .collapsing .nav-link.active {
            background: color-mix(in srgb, var(--secondary-color) 25%, transparent);
            color: #ffffff;
            font-weight: 600;
            box-shadow: none;
        }
            /* active child ke liye connector line par chhota indicator */
            .sidebar-nav .collapse .nav-link.active::before,
            .sidebar-nav .collapsing .nav-link.active::before {
                content: "";
                position: absolute;
                left: calc(-0.6rem - 2px);
                top: 22%;
                bottom: 22%;
                width: 3px;
                border-radius: 3px;
                background: var(--secondary-bright);
            }

            .sidebar-nav .collapse .nav-link.active i {
                color: var(--secondary-lighter);
            }

/* ---- Footer ---- */
.sidebar-footer {
    padding: 0.75rem 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

    .sidebar-footer a {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.5rem 0.85rem;
        border-radius: 10px;
        color: rgba(223, 230, 242, 0.7);
        font-size: 0.82rem;
        transition: background-color 0.15s ease, color 0.15s ease;
    }

        .sidebar-footer a:hover {
            background: rgba(255, 255, 255, 0.07);
            color: #ffffff;
            text-decoration: none;
        }

/* ---------------------------------------------------------------------- */
/* Main area / topbar                                                      */
/* ---------------------------------------------------------------------- */

.main-area {
    flex: 1 1 auto;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0; /* let wide tables scroll inside .table-scroll instead of widening the page */
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-size: 1.15rem;
    padding: 0.25rem 0.5rem;
}

.topbar-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary-color);
    flex: 1 1 auto;
}

.topbar-actions {
    display: flex;
    align-items: center;
}

    .topbar-actions .navbar-nav {
        flex-direction: row;
        align-items: center;
        gap: 0.25rem;
    }

    /* ---- Topbar user menu ---- */
    .topbar-actions .nav-link {
        color: var(--primary-color) !important;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

        .topbar-actions .nav-link:hover {
            color: var(--secondary-dark) !important;
        }

        .topbar-actions .nav-link .fa-circle-user {
            color: var(--secondary-color);
            font-size: 1.25rem;
        }

        .topbar-actions .nav-link img.avatar {
            border: 2px solid var(--secondary-light);
        }

    /* ---- Dropdown ---- */
    .topbar-actions .dropdown-menu {
        margin-top: 0;
        padding: 0.35rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-md);
    }

    .topbar-actions .dropdown-item {
        display: flex;
        align-items: center;
        color: var(--text);
        font-weight: 500;
        border-radius: 6px;
    }

        .topbar-actions .dropdown-item i {
            color: var(--muted);
        }

        .topbar-actions .dropdown-item:hover,
        .topbar-actions .dropdown-item:focus {
            background: var(--secondary-light);
            color: var(--primary-color);
        }

            .topbar-actions .dropdown-item:hover i {
                color: var(--secondary-color);
            }

        .topbar-actions .dropdown-item:active {
            background: var(--secondary-color);
            color: #fff;
        }

            .topbar-actions .dropdown-item:active i {
                color: #fff;
            }
.content {
    flex: 1 1 auto;
    padding: 1.75rem;
}

.app-footer {
    padding: 1rem 1.75rem;
    color: var(--muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------- */
/* Page header                                                            */
/* ---------------------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

    .page-header h1 {
        font-size: 1.4rem;
        margin: 0;
    }

    .page-header .page-subtitle {
        color: var(--muted);
        font-size: 0.85rem;
        margin-top: 0.25rem;
    }

/* ---------------------------------------------------------------------- */
/* Cards                                                                   */
/* ---------------------------------------------------------------------- */

.card {
    /*border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 50vh;*/
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--primary-color);
    border-top-left-radius: var(--radius) !important;
    border-top-right-radius: var(--radius) !important;
}

.card-footer {
    background: #fafbfd;
    border-top: 1px solid var(--border);
    border-bottom-left-radius: var(--radius) !important;
    border-bottom-right-radius: var(--radius) !important;
    padding: 1rem 1.25rem;
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

    .btn-primary:hover, .btn-primary:focus {
        background-color: var(--secondary-dark);
        border-color: var(--secondary-dark);
    }

.btn-outline-secondary {
    color: var(--primary-color);
    border-color: transparent;
    background-color: transparent;
}

    .btn-outline-secondary:hover,
    .btn-outline-secondary:focus {
        color: var(--primary-color);
        background-color: transparent;
        border-color: transparent;
        box-shadow: none;
    }

.btn-outline-secondary {
    border-color: transparent;
}

.btn-outline-danger {
    color: var(--danger);
    border-color: transparent;
    background-color: transparent;
}

    .btn-outline-danger:hover,
    .btn-outline-danger:focus {
        color: var(--danger);
        background-color: transparent;
        border-color: transparent;
        box-shadow: none;
    }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus, .custom-select:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--secondary-color) 25%, transparent);
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

.form-control, .custom-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
}

    .form-control:focus, .custom-select:focus {
        border-color: var(--secondary-color);
    }

.control-label, label {
    font-weight: 500;
    color: var(--text);
    font-size: 0.85rem;
}

.form-text.text-muted, small.form-text {
    font-size: 0.78rem;
}

/* ---------------------------------------------------------------------- */
/* Password field: show/hide toggle + live requirements checklist         */
/* ---------------------------------------------------------------------- */

.password-field-wrap {
    position: relative;
}

.password-toggle-btn {
    border-color: var(--border);
    color: var(--muted);
    background: var(--surface);
}

    .password-toggle-btn:hover, .password-toggle-btn:focus {
        color: var(--text);
        background: var(--surface);
    }

.password-requirements-hint {
    font-size: 0.78rem;
    color: var(--success);
    margin-top: 0.35rem;
    display: block;
}

.password-requirements-popover {
    display: none;
    position: absolute;
    top: 0;
    left: calc(100% + 12px);
    width: 260px;
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 0.85rem 1rem;
}

    .password-requirements-popover.show {
        display: block;
    }

.password-requirements-title {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.password-requirements-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

    .password-requirements-list li {
        font-size: 0.8rem;
        color: var(--danger);
        margin-bottom: 0.4rem;
    }

        .password-requirements-list li:last-child {
            margin-bottom: 0;
        }

        .password-requirements-list li.is-met {
            color: var(--success);
        }

@media (max-width: 991.98px) {
    .password-requirements-popover {
        left: 0;
        top: calc(100% + 6px);
        width: 100%;
    }
}

/* ---------------------------------------------------------------------- */
/* Section tabs (e.g. Engineering Standards Index)                        */
/* ---------------------------------------------------------------------- */

.section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

    .section-tabs .nav-link {
        padding: 0.45rem 1.1rem;
        color: var(--muted);
        font-weight: 500;
        background-color: var(--surface);
        border: 1px solid var(--border);
        border-radius: 999px;
        text-decoration: none;
        transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }

        .section-tabs .nav-link:hover {
            color: var(--primary-color);
            background-color: var(--secondary-light);
            border-color: var(--secondary-light);
        }

        .section-tabs .nav-link.active {
            color: #fff;
            background-color: var(--secondary-dark);
            border-color: var(--secondary-dark);
            font-weight: 600;
        }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */

.table {
    margin-bottom: 0;
    table-layout: fixed;
    width: 100%;
}

    .table thead th {
        text-transform: none;
        font-size: 0.72rem;
        letter-spacing: 0.05em;
        color: var(--muted);
        border-top: none;
        border-bottom: 1px solid var(--border);
        background: #fafbfd;
        font-weight: 600;
    }

    .table td {
        vertical-align: middle;
        border-color: var(--border);
    }

.table-hover tbody tr:hover {
    background-color: var(--secondary-light);
}

/* Wrap any table in .table-scroll: body scrolls after 420px, header stays fixed. */
.table-scroll {
    max-height: 420px;
    overflow: auto;
    position: relative;
    width: 100%;
}

    .table-scroll > .table {
        border-collapse: separate;
        border-spacing: 0;
    }

        .table-scroll > .table > thead th {
            position: sticky;
            top: 0;
            z-index: 2;
        }

        .table-scroll > .table td {
            overflow-wrap: break-word;
        }

        /* Reserve room for the action buttons; otherwise they spill past the header's right edge. */
        .table-scroll > .table th.table-actions {
            width: 110px;
        }

/* Below desktop, keep columns readable and let the wrapper scroll sideways instead of squashing them. */
@media (max-width: 991.98px) {
    .table-scroll > .table {
        table-layout: auto;
        min-width: 760px;
    }

    .table-scroll > .table-sm {
        min-width: 600px;
    }

    .table-scroll > .table > thead th {
        white-space: nowrap;
    }
}

@media (max-width: 575.98px) {
    .table-scroll {
        max-height: 360px;
    }

        .table-scroll > .table > :not(caption) > * > * {
            padding: 0.5rem 0.6rem;
        }

        .table-scroll > .table td {
            font-size: 0.85rem;
        }
}

.table-actions {
    white-space: nowrap;
    justify-content: center;
    align-items: center;
    gap: 1px;
}

    .table-actions .btn {
        width: 26px;
        height: 26px;
        min-width: 26px;
        padding: 0.3rem 0.1rem;
        margin: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.8rem;
    }

.fw-medium {
    font-weight: 500;
}

/* Bootstrap 4 has no gap utilities (added in v5) — used for flex button groups. */
.gap-2 {
    gap: 0.5rem;
}

.hidden-col {
    display: none;
}

.version-edit-btn {
    width: auto !important;
    height: auto !important;
    border-radius: .375rem !important;
    padding: .25rem .5rem !important;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

/* ---------------------------------------------------------------------- */
/* Badges / status pills                                                  */
/* ---------------------------------------------------------------------- */

.badge {
    font-weight: 500;
    padding: 0.35em 0.7em;
    border-radius: 999px;
    font-size: 0.75rem;
}

.badge-status-active {
    background: var(--success-bg);
    color: var(--success);
}

.badge-status-inactive {
    background: #eef0f4;
    color: var(--muted);
}

.badge-status-review {
    background: var(--warning-bg);
    color: var(--warning);
}

    .badge-status-active::before, .badge-status-inactive::before, .badge-status-review::before {
        content: "";
        display: inline-block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
        margin-right: 0.4em;
    }

/* ---------------------------------------------------------------------- */
/* Avatars                                                                 */
/* ---------------------------------------------------------------------- */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--secondary-light);
    color: var(--primary-color);
    overflow: hidden;
    flex-shrink: 0;
}

img.avatar {
    object-fit: cover;
}

.avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 0.8rem;
}

.avatar-lg {
    width: 96px;
    height: 96px;
    font-size: 2.2rem;
    border: 3px solid var(--surface);
    box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------------- */
/* Photo upload control                                                    */
/* ---------------------------------------------------------------------- */

.photo-upload {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.photo-upload-fields {
    flex: 1 1 auto;
}

/* ---------------------------------------------------------------------- */
/* Alerts                                                                  */
/* ---------------------------------------------------------------------- */

.alert {
    border: none;
    border-left: 4px solid transparent;
    border-radius: var(--radius-sm);
}

.alert-success {
    background: var(--success-bg);
    color: #146c3a;
    border-left-color: var(--success);
}

.alert-danger {
    background: var(--danger-bg);
    color: #9c2a3a;
    border-left-color: var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    color: #8a600f;
    border-left-color: var(--warning);
}

/* ---------------------------------------------------------------------- */
/* Detail / definition list panels                                        */
/* ---------------------------------------------------------------------- */

.detail-grid {
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr;
    row-gap: 0.9rem;
    column-gap: 1rem;
    margin: 0;
}

    .detail-grid dt {
        color: var(--muted);
        font-weight: 500;
        font-size: 0.82rem;
    }

    .detail-grid dd {
        margin: 0;
        color: var(--text);
    }

/* ---------------------------------------------------------------------- */
/* Dashboard                                                               */
/* ---------------------------------------------------------------------- */

.hero-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-dark) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.75rem;
    position: relative;
    overflow: hidden;
}

    .hero-banner::after {
        content: "";
        position: absolute;
        top: -60px;
        right: -60px;
        width: 220px;
        height: 220px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
    }

.hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.hero-banner h1 {
    color: #fff;
    margin-bottom: 0.4rem;
    text-transform: capitalize;
}

.hero-banner p {
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0;
    position: relative;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.dashboard-stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    opacity: 0;
    animation: dashboard-card-in 0.4s ease forwards;
}

    .dashboard-stat-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-md);
        text-decoration: none;
        color: var(--text);
        border-color: var(--secondary-color);
    }

        .dashboard-stat-card:hover .dashboard-stat-arrow {
            opacity: 1;
            transform: translateX(0);
        }

        .dashboard-stat-card:hover .dashboard-stat-icon {
            transform: scale(1.08);
        }

.dashboard-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.dashboard-stat-icon--0 {
    background: var(--secondary-light);
    color: var(--secondary-dark);
}

.dashboard-stat-icon--1 {
    background: var(--success-bg);
    color: var(--success);
}

.dashboard-stat-icon--2 {
    background: var(--warning-bg);
    color: var(--warning);
}

.dashboard-stat-icon--3 {
    background: var(--danger-bg);
    color: var(--danger);
}

.dashboard-stat-body {
    flex: 1 1 auto;
    min-width: 0;
}

.dashboard-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.dashboard-stat-label {
    color: var(--muted);
    font-size: 0.82rem;
}

.dashboard-stat-arrow {
    color: var(--secondary-color);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

@keyframes dashboard-card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-progress-track {
    display: flex;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef0f4;
    margin-bottom: 1rem;
}

.dashboard-progress-segment {
    height: 100%;
    transition: width 0.6s ease;
    min-width: 0;
}

.dashboard-progress-segment--draft {
    background: var(--muted);
}

.dashboard-progress-segment--submitted {
    background: var(--secondary-color);
}

.dashboard-progress-segment--in-review {
    background: var(--warning);
}

.dashboard-progress-segment--approved {
    background: var(--primary-color);
}

.dashboard-progress-segment--published {
    background: var(--success);
}

.dashboard-progress-segment--archived {
    background: var(--border);
}

.dashboard-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.dashboard-status-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.dashboard-status-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.dashboard-status-pct {
    font-size: 0.78rem;
    color: var(--muted);
}

/* ---------------------------------------------------------------------- */
/* Permission matrix (Permissions screen)                                 */
/* ---------------------------------------------------------------------- */

.custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.permission-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.permission-role-select {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
}

    .permission-role-select select {
        width: auto;
        min-width: 220px;
    }

.permission-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.permission-stat-card {
    border-radius: var(--radius);
    padding: 1.1rem 1.35rem;
    background: linear-gradient(135deg, var(--primary-darker), var(--primary-color));
    color: #fff;
    box-shadow: var(--shadow-md);
}

.permission-stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 0.4rem;
}

.permission-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.permission-quick-apply {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.permission-quick-apply-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    margin-right: 0.25rem;
}

.permission-pill {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

    .permission-pill:hover {
        color: #fff;
        background: var(--secondary-color);
        border-color: var(--secondary-color);
    }

.permission-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.permission-module-card {
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    align-self: start;
}

.permission-module-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.92rem;
}

.permission-module-body {
    padding: 0.6rem 1rem;
}

.permission-resource-row {
    padding: 0.5rem 0;
}

.permission-resource-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

    .permission-resource-main .custom-control {
        min-height: unset;
    }

    .permission-resource-main .custom-control-label {
        font-size: 0.88rem;
        color: var(--text);
        cursor: pointer;
    }

.permission-access-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.permission-action-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.65rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
}

.permission-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

    .permission-chip input {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

    .permission-chip i {
        font-size: 0.72rem;
    }

    .permission-chip.is-checked {
        background: var(--secondary-light);
        border-color: var(--secondary-color);
        color: var(--secondary-dark);
    }

.permission-chip-create.is-checked {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.permission-chip-edit.is-checked {
    background: var(--warning-bg);
    border-color: var(--warning);
    color: var(--warning);
}

.permission-chip-delete.is-checked {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.section-tabs i {
    margin-right: 6px !important;
}

/* ---------------------------------------------------------------------- */
/* Empty state                                                            */
/* ---------------------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

    .empty-state i {
        font-size: 2.5rem;
        color: var(--border);
        margin-bottom: 0.75rem;
    }

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-md);
    }

    .main-area {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }
}

@media (max-width: 575.98px) {
    .content {
        padding: 1.1rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        row-gap: 0.3rem;
    }

        .detail-grid dd {
            margin-bottom: 0.6rem;
        }
}

/* chevron */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
}

    .custom-select-wrapper .custom-select {
        appearance: none !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        background-image: none !important;
        padding-right: 35px;
        cursor: pointer;
    }

    .custom-select-wrapper .select-chevron {
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        font-size: 11px;
        color: #777;
    }

/* ----------------------------------------------------- */
/* Pagination                                             */
/* ----------------------------------------------------- */

.pagination {
    gap: 0.35rem;
}

    .pagination .page-link {
        color: var(--primary-color);
        background: #fff;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        min-width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 500;
        transition: all .2s ease;
    }

        .pagination .page-link:hover {
            background: var(--primary-color);
            color: #fff;
            border-color: var(--primary-color);
        }

    .pagination .page-item.active .page-link {
        background: var(--primary-color);
        border-color: var(--primary-color);
        color: #fff;
        box-shadow: 0 4px 12px color-mix(in srgb, var(--primary-color) 25%, transparent);
    }

    .pagination .page-link:focus {
        box-shadow: none;
    }

    .pagination .page-item.disabled .page-link {
        color: #adb5bd;
        background-color: #f8f9fa;
        border-color: #dee2e6;
        cursor: not-allowed;
        pointer-events: none;
        opacity: 0.7;
    }

        .pagination .page-item.disabled .page-link:hover {
            color: #adb5bd;
            background-color: #f8f9fa;
            border-color: #dee2e6;
        }

.custom-select {
    background-image: none !important;
    appearance: auto !important;
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
}

/* Version change comparison (Record Versions → Edit) */
.change-comparison .comparison-value {
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-added {
    background: var(--success-bg);
    color: var(--success);
    border-radius: 3px;
}

.diff-removed {
    background: var(--danger-bg);
    color: var(--danger);
    text-decoration: line-through;
    border-radius: 3px;
}

.badge-diff-removed {
    background: var(--danger-bg);
    color: var(--danger);
}
.profile-color {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .profile-color input[type="color"] {
        width: 56px;
        height: 38px;
        padding: 2px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        cursor: pointer;
    }

        .profile-color input[type="color"]:disabled {
            cursor: not-allowed;
            opacity: 0.6;
        }

    .profile-color code {
        color: var(--muted);
        font-size: 0.85rem;
    }