/* ==========================================================================
   IPS MIS - Bootstrap 5 theme
   Loaded after Bootstrap 5 and plugin CSS. Contains:
   1. Design tokens
   2. Base
   3. Layout (sidebar, topbar, page wrapper, footer)
   4. Components (cards, forms, buttons, tables, plugins)
   5. Bootstrap 4 / old template compatibility (kept so older pages still look right)
   ========================================================================== */

/* 1. Design tokens ------------------------------------------------------- */
:root {
    --mis-primary: #1d5fbf;
    --mis-primary-hover: #174e9e;
    --mis-primary-soft: #e8f0fb;
    --mis-sidebar: #0c1e33;
    --mis-sidebar-2: #10263f;
    --mis-sidebar-text: #aebdd0;
    --mis-bg: #f3f5f8;
    --mis-surface: #ffffff;
    --mis-border: #e3e8ef;
    --mis-text: #1b2533;
    --mis-muted: #667085;
    --mis-radius: 12px;
    --mis-radius-sm: 8px;
    --mis-sidebar-w: 260px;
    --mis-topbar-h: 64px;
    --mis-shadow: 0 1px 2px rgba(16, 24, 40, .05);

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --bs-body-font-size: .9rem;
    --bs-body-color: var(--mis-text);
    --bs-body-bg: var(--mis-bg);
    --bs-primary: #1d5fbf;
    --bs-primary-rgb: 29, 95, 191;
    --bs-link-color: #1d5fbf;
    --bs-link-color-rgb: 29, 95, 191;
    --bs-link-hover-color: #174e9e;
    --bs-link-hover-color-rgb: 23, 78, 158;
    --bs-border-color: #e3e8ef;
}

/* 2. Base ---------------------------------------------------------------- */
body {
    background: var(--mis-bg);
    color: var(--mis-text);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3, h4, h5, h6 { color: #101828; font-weight: 600; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
hr { border-color: var(--mis-border); opacity: 1; }

/* 3. Layout -------------------------------------------------------------- */
.left-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--mis-sidebar-w);
    background: var(--mis-sidebar);
    z-index: 1045;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand {
    height: var(--mis-topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex-shrink: 0;
}
.sidebar-brand img { height: 34px; width: auto; }
.sidebar-brand span {
    color: #fff;
    font-weight: 600;
    font-size: .95rem;
    letter-spacing: .02em;
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 24px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 3px; }
.sidebar-label {
    color: #6f829a;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 14px 12px 6px;
}
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: var(--mis-radius-sm);
    color: var(--mis-sidebar-text);
    font-weight: 500;
    font-size: .88rem;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
}
.sidebar-link i:first-child { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-link:hover, .sidebar-link:focus-visible { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-link.active { background: var(--mis-primary); color: #fff; }
.sidebar-link.open { color: #fff; }
.sidebar-link .chev { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.sidebar-link[aria-expanded="true"] .chev { transform: rotate(90deg); }
.sidebar-sub { padding: 2px 0 6px !important; }
.sidebar-sub a {
    display: block;
    position: relative;
    padding: 7px 12px 7px 44px;
    color: #93a4ba;
    font-size: .84rem;
    border-radius: 6px;
}
.sidebar-sub a::before {
    content: "";
    position: absolute;
    left: 21px;
    top: 50%;
    width: 5px;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 50%;
    background: currentColor;
    opacity: .5;
}
.sidebar-sub a:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.sidebar-sub a.active { color: #fff; font-weight: 600; }
.sidebar-sub a.active::before { background: #5fa0ff; opacity: 1; }

.topbar {
    position: fixed;
    top: 0;
    left: var(--mis-sidebar-w);
    right: 0;
    height: var(--mis-topbar-h);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--mis-border);
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
}
.topbar .sidebar-toggle {
    display: none;
    border: 0;
    background: none;
    font-size: 1.4rem;
    color: var(--mis-text);
    padding: 4px 6px;
    border-radius: 6px;
}
.topbar .sidebar-toggle:hover { background: var(--mis-bg); }
.topbar-title { font-weight: 600; color: var(--mis-muted); font-size: .9rem; }
.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: none;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    color: var(--mis-text);
}
.topbar-user:hover, .topbar-user[aria-expanded="true"] { background: var(--mis-bg); }
.topbar-user img, .avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--mis-primary-soft);
}
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--mis-primary);
    font-weight: 600;
}
.topbar-user .who { text-align: left; line-height: 1.15; }
.topbar-user .who strong { display: block; font-size: .85rem; font-weight: 600; }
.topbar-user .who small { color: var(--mis-muted); font-size: .72rem; }
.topbar .dropdown-menu {
    border: 1px solid var(--mis-border);
    border-radius: var(--mis-radius-sm);
    box-shadow: 0 12px 24px -6px rgba(16, 24, 40, .15);
    padding: 6px;
    min-width: 200px;
}
.topbar .dropdown-item { border-radius: 6px; padding: 8px 10px; font-size: .88rem; }
.topbar .dropdown-item i { width: 18px; margin-right: 6px; }

.page-wrapper {
    margin-left: var(--mis-sidebar-w);
    padding-top: var(--mis-topbar-h);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.page-wrapper > .container-fluid { padding: 24px 28px; flex: 1; }
.footer {
    padding: 14px 28px;
    color: var(--mis-muted);
    font-size: .8rem;
    border-top: 1px solid var(--mis-border);
    background: var(--mis-surface);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 30, 51, .45);
    z-index: 1040;
}

@media (max-width: 991.98px) {
    .left-sidebar { transform: translateX(-100%); }
    body.sidebar-open .left-sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .topbar { left: 0; padding: 0 16px; }
    .topbar .sidebar-toggle { display: inline-flex; }
    .page-wrapper { margin-left: 0; }
    .page-wrapper > .container-fluid { padding: 16px; }
    .topbar-user .who { display: none; }
}

/* Loading overlay (shown by loader() / endLoader() in main.js) */
.preloader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(243, 245, 248, .7);
}
.preloader .loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.preloader .loader__figure {
    width: 42px;
    height: 42px;
    margin: 0 auto 10px;
    border: 3px solid var(--mis-primary-soft);
    border-top-color: var(--mis-primary);
    border-radius: 50%;
    animation: mis-spin .8s linear infinite;
}
.preloader .loader__label { color: var(--mis-muted); font-size: .85rem; margin: 0; }
@keyframes mis-spin { to { transform: rotate(360deg); } }

/* 4. Components ---------------------------------------------------------- */
/* Page title + breadcrumb */
.page-titles { margin-bottom: 20px; }
.page-titles h3, .page-titles .text-themecolor { font-size: 1.35rem; margin-bottom: 4px; color: #101828; }
.breadcrumb { margin: 0; font-size: .8rem; --bs-breadcrumb-divider-color: #98a2b3; }
.breadcrumb-item a { color: var(--mis-muted); }
.breadcrumb-item a:hover { color: var(--mis-primary); }
.breadcrumb-item.active { color: #98a2b3; }

/* Cards */
.card {
    border: 1px solid var(--mis-border);
    border-radius: var(--mis-radius);
    box-shadow: var(--mis-shadow);
    margin-bottom: 24px;
    --bs-card-cap-bg: #fafbfc;
}
.card-body { padding: 24px; }
.card-header { padding: 14px 24px; font-weight: 600; }
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.card-subtitle { color: var(--mis-muted); font-size: .84rem; margin-top: 0; margin-bottom: 16px; display: block; }
.card .card-title + hr, .form-body > hr { margin: 12px 0 20px; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label, .control-label, .form-group > label {
    display: inline-block;
    font-weight: 500;
    font-size: .84rem;
    color: #344054;
    margin-bottom: .35rem;
}
.form-control, .form-select {
    border-radius: var(--mis-radius-sm);
    border-color: #d0d5dd;
    font-size: .9rem;
    padding: .5rem .75rem;
    min-height: 40px;
}
.form-select { padding-right: 2.25rem; }
textarea.form-control { min-height: auto; }
.form-control:focus, .form-select:focus {
    border-color: #7aa7e6;
    box-shadow: 0 0 0 .2rem rgba(29, 95, 191, .15);
}
.form-control::placeholder { color: #98a2b3; }
.form-check-input:checked { background-color: var(--mis-primary); border-color: var(--mis-primary); }
.form-actions {
    border-top: 1px solid var(--mis-border);
    padding-top: 18px;
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Buttons */
.btn { border-radius: var(--mis-radius-sm); font-weight: 500; font-size: .88rem; padding: .5rem 1rem; }
.btn-sm { font-size: .8rem; padding: .3rem .65rem; }
.btn-lg { font-size: 1rem; padding: .7rem 1.25rem; }
.btn-primary, .btn-info {
    --bs-btn-bg: var(--mis-primary);
    --bs-btn-border-color: var(--mis-primary);
    --bs-btn-hover-bg: var(--mis-primary-hover);
    --bs-btn-hover-border-color: var(--mis-primary-hover);
    --bs-btn-active-bg: var(--mis-primary-hover);
    --bs-btn-active-border-color: var(--mis-primary-hover);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
}
.btn-success {
    --bs-btn-bg: #16874d;
    --bs-btn-border-color: #16874d;
    --bs-btn-hover-bg: #117040;
    --bs-btn-hover-border-color: #117040;
    --bs-btn-active-bg: #117040;
}
.btn-inverse, .btn-dark {
    --bs-btn-color: #fff;
    --bs-btn-bg: #475467;
    --bs-btn-border-color: #475467;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #344054;
    --bs-btn-hover-border-color: #344054;
    --bs-btn-active-bg: #344054;
    --bs-btn-active-color: #fff;
}
.btn-default, .btn-secondary {
    --bs-btn-color: #344054;
    --bs-btn-bg: #fff;
    --bs-btn-border-color: #d0d5dd;
    --bs-btn-hover-color: #101828;
    --bs-btn-hover-bg: #f9fafb;
    --bs-btn-hover-border-color: #c1c7d0;
    --bs-btn-active-bg: #f2f4f7;
    --bs-btn-active-color: #101828;
}
.btn-rounded { border-radius: 999px; }
.btn-circle { border-radius: 50%; width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* Tables */
.table { --bs-table-striped-bg: #f9fafb; --bs-table-hover-bg: #f2f6fc; font-size: .86rem; vertical-align: middle; }
.table > thead > tr > th {
    background: #f6f8fa;
    color: #475467;
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
    border-bottom-width: 1px;
}
.table-bordered > :not(caption) > * > * { border-color: var(--mis-border); }
.table-responsive { border-radius: var(--mis-radius-sm); }

/* DataTables (Bootstrap 5 integration) */
div.dataTables_wrapper div.dataTables_filter input { border-radius: var(--mis-radius-sm); margin-left: 8px; min-height: 36px; }
div.dataTables_wrapper div.dataTables_length select { border-radius: var(--mis-radius-sm); }
div.dataTables_wrapper div.dataTables_info { color: var(--mis-muted); font-size: .82rem; }
.dt-buttons { margin-bottom: 12px; }
.dt-buttons .btn { font-size: .8rem; padding: .35rem .75rem; }
div.dataTables_wrapper div.dataTables_paginate ul.pagination { margin-top: 10px; }
.page-link { font-size: .82rem; color: var(--mis-primary); }
.active > .page-link, .page-link.active { background-color: var(--mis-primary); border-color: var(--mis-primary); }

/* Select2 with Bootstrap 5 theme */
.select2-container { width: 100% !important; }
.select2-container--bootstrap-5 .select2-selection { border-radius: var(--mis-radius-sm); border-color: #d0d5dd; min-height: 40px; font-size: .9rem; }
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: #7aa7e6; box-shadow: 0 0 0 .2rem rgba(29, 95, 191, .15); }
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered .select2-selection__choice {
    background: var(--mis-primary-soft);
    border-color: #c9dbf5;
    color: #174e9e;
    border-radius: 6px;
}

/* Summernote (replaces the old wysihtml5 editor) */
.note-editor.note-frame { border-radius: var(--mis-radius-sm); border-color: #d0d5dd; }
.note-editor .note-toolbar { background: #f9fafb; border-radius: var(--mis-radius-sm) var(--mis-radius-sm) 0 0; }

/* Material date picker: use brand colour */
.dtp > .dtp-content > .dtp-date-view > header.dtp-header { background: var(--mis-primary-hover) !important; }
.dtp div.dtp-date, .dtp div.dtp-time { background: var(--mis-primary) !important; }
.dtp table.dtp-picker-days tr > td > a.selected, .dtp .p10 > a { background: var(--mis-primary) !important; color: #fff !important; }
.dtp div.dtp-actual-year { color: rgba(255, 255, 255, .8); }
.dtp .dtp-buttons .btn { font-size: .8rem; }

/* Magnific popup panels */
.mfp-content > .mfp-hide, .mfp-content > div[id^="popup"] {
    border-radius: var(--mis-radius);
    background: #fff !important;
    box-shadow: 0 20px 40px -12px rgba(16, 24, 40, .3);
}

/* Badges, progress, modal */
.badge { font-weight: 600; border-radius: 6px; }
.progress { border-radius: 999px; background: #eef1f5; }
.modal-content { border: 0; border-radius: var(--mis-radius); }
.modal-header, .modal-footer { border-color: var(--mis-border); }

/* Login page */
.auth-page { min-height: 100vh; display: flex; background: var(--mis-bg); }
.auth-brand {
    flex: 1 1 50%;
    background:
        radial-gradient(1200px 500px at -10% 110%, rgba(29, 95, 191, .55), transparent 60%),
        radial-gradient(800px 400px at 120% -10%, rgba(95, 160, 255, .25), transparent 60%),
        var(--mis-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 56px;
}
.auth-brand img { height: 56px; width: auto; align-self: flex-start; }
.auth-brand h1 { color: #fff; font-size: 2.1rem; font-weight: 700; line-height: 1.2; margin-bottom: 12px; }
.auth-brand p { color: #b8c6d8; font-size: 1rem; max-width: 420px; margin: 0; }
.auth-brand small { color: #7f93ab; }
.auth-form { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--mis-muted); font-size: .95rem; margin-bottom: 28px; }
.auth-card .form-control { min-height: 46px; }
.auth-card .input-group-text { background: #fff; border-color: #d0d5dd; color: #98a2b3; border-radius: var(--mis-radius-sm); }
.auth-card .input-group .form-control { border-left: 0; }
.auth-mobile-logo { display: none; }
@media (max-width: 991.98px) {
    .auth-brand { display: none; }
    .auth-mobile-logo { display: block; background: var(--mis-sidebar); border-radius: 12px; padding: 14px 18px; margin-bottom: 28px; width: max-content; }
    .auth-mobile-logo img { height: 40px; }
}

/* Error pages */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.error-page .code { font-size: 6rem; font-weight: 700; color: var(--mis-primary); line-height: 1; }

/* 5. Bootstrap 4 / template compatibility ---------------------------------
   Older pages still use these class names. They are mapped here so the pages
   render correctly under Bootstrap 5 without rewriting every template. */
.text-themecolor { color: var(--mis-primary); }
.box-title { font-weight: 600; }
.no-block { display: flex; }
.align-slef-center { align-self: center; }
.txt-bold { font-weight: 600; }
.pull-right { float: right; }
.pull-left { float: left; }
.custom-select { /* fallback in case a leftover select was missed */
    display: block; width: 100%; padding: .5rem 2.25rem .5rem .75rem; font-size: .9rem;
    border: 1px solid #d0d5dd; border-radius: var(--mis-radius-sm); background-color: #fff; min-height: 40px;
}
@media (min-width: 1600px) {
    .col-xlg-3 { flex: 0 0 auto; width: 25%; }
    .col-xlg-4 { flex: 0 0 auto; width: 33.3333%; }
    .col-xlg-6 { flex: 0 0 auto; width: 50%; }
    .col-xlg-12 { flex: 0 0 auto; width: 100%; }
}
.b-l { border-left: 1px solid var(--mis-border); }
.b-r { border-right: 1px solid var(--mis-border); }
.b-t { border-top: 1px solid var(--mis-border); }
.b-b { border-bottom: 1px solid var(--mis-border); }
.b-0 { border: 0 !important; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-light { font-weight: 300; }

/* Template spacing helpers (m-t-20, p-l-10, ...) */
.m-0{margin:0px!important}.p-0{padding:0px!important}
.m-t-0{margin-top:0px!important}.p-t-0{padding-top:0px!important}
.m-b-0{margin-bottom:0px!important}.p-b-0{padding-bottom:0px!important}
.m-l-0{margin-left:0px!important}.p-l-0{padding-left:0px!important}
.m-r-0{margin-right:0px!important}.p-r-0{padding-right:0px!important}
.m-5{margin:5px!important}.p-5{padding:5px!important}
.m-t-5{margin-top:5px!important}.p-t-5{padding-top:5px!important}
.m-b-5{margin-bottom:5px!important}.p-b-5{padding-bottom:5px!important}
.m-l-5{margin-left:5px!important}.p-l-5{padding-left:5px!important}
.m-r-5{margin-right:5px!important}.p-r-5{padding-right:5px!important}
.m-10{margin:10px!important}.p-10{padding:10px!important}
.m-t-10{margin-top:10px!important}.p-t-10{padding-top:10px!important}
.m-b-10{margin-bottom:10px!important}.p-b-10{padding-bottom:10px!important}
.m-l-10{margin-left:10px!important}.p-l-10{padding-left:10px!important}
.m-r-10{margin-right:10px!important}.p-r-10{padding-right:10px!important}
.m-15{margin:15px!important}.p-15{padding:15px!important}
.m-t-15{margin-top:15px!important}.p-t-15{padding-top:15px!important}
.m-b-15{margin-bottom:15px!important}.p-b-15{padding-bottom:15px!important}
.m-l-15{margin-left:15px!important}.p-l-15{padding-left:15px!important}
.m-r-15{margin-right:15px!important}.p-r-15{padding-right:15px!important}
.m-20{margin:20px!important}.p-20{padding:20px!important}
.m-t-20{margin-top:20px!important}.p-t-20{padding-top:20px!important}
.m-b-20{margin-bottom:20px!important}.p-b-20{padding-bottom:20px!important}
.m-l-20{margin-left:20px!important}.p-l-20{padding-left:20px!important}
.m-r-20{margin-right:20px!important}.p-r-20{padding-right:20px!important}
.m-25{margin:25px!important}.p-25{padding:25px!important}
.m-t-25{margin-top:25px!important}.p-t-25{padding-top:25px!important}
.m-b-25{margin-bottom:25px!important}.p-b-25{padding-bottom:25px!important}
.m-l-25{margin-left:25px!important}.p-l-25{padding-left:25px!important}
.m-r-25{margin-right:25px!important}.p-r-25{padding-right:25px!important}
.m-30{margin:30px!important}.p-30{padding:30px!important}
.m-t-30{margin-top:30px!important}.p-t-30{padding-top:30px!important}
.m-b-30{margin-bottom:30px!important}.p-b-30{padding-bottom:30px!important}
.m-l-30{margin-left:30px!important}.p-l-30{padding-left:30px!important}
.m-r-30{margin-right:30px!important}.p-r-30{padding-right:30px!important}
.m-40{margin:40px!important}.p-40{padding:40px!important}
.m-t-40{margin-top:40px!important}.p-t-40{padding-top:40px!important}
.m-b-40{margin-bottom:40px!important}.p-b-40{padding-bottom:40px!important}
.m-l-40{margin-left:40px!important}.p-l-40{padding-left:40px!important}
.m-r-40{margin-right:40px!important}.p-r-40{padding-right:40px!important}
.m-50{margin:50px!important}.p-50{padding:50px!important}
.m-t-50{margin-top:50px!important}.p-t-50{padding-top:50px!important}
.m-b-50{margin-bottom:50px!important}.p-b-50{padding-bottom:50px!important}
.m-l-50{margin-left:50px!important}.p-l-50{padding-left:50px!important}
.m-r-50{margin-right:50px!important}.p-r-50{padding-right:50px!important}

/* Dashboard stat cards */
.stat-card { color: inherit; margin-bottom: 0; transition: border-color .15s, box-shadow .15s; }
a.stat-card:hover { border-color: #c9dbf5; box-shadow: 0 4px 12px -4px rgba(16, 24, 40, .12); color: inherit; }
.stat-card .card-body { padding: 18px 20px; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-icon.text-bg-success { background: #e7f6ee !important; color: #16874d !important; }
.stat-icon.text-bg-info { background: #e6f4fb !important; color: #0b7fab !important; }
.stat-icon.text-bg-primary { background: var(--mis-primary-soft) !important; color: var(--mis-primary) !important; }
.stat-icon.text-bg-danger { background: #fdecec !important; color: #c0362c !important; }
.stat-icon.text-bg-warning { background: #fff5e0 !important; color: #b76e00 !important; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: #101828; }
.stat-label { color: var(--mis-muted); font-size: .84rem; }

/* Project pages */
.detail-list dt { color: var(--mis-muted); font-weight: 500; font-size: .84rem; }
.detail-list dd { margin-bottom: .6rem; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mis-muted); margin-bottom: .5rem; }
.prose { font-size: .92rem; line-height: 1.65; overflow-wrap: anywhere; }
.prose p:last-child { margin-bottom: 0; }
.prose img { max-width: 100%; height: auto; }
.review-box { border: 1px solid var(--mis-border); border-radius: var(--mis-radius-sm); padding: 14px; background: #fcfcfd; }
.dt-buttons.btn-group { flex-wrap: wrap; }

/* Administration */
.role-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--mis-border); border-radius: var(--mis-radius-sm); cursor: pointer; }
.role-option:hover { border-color: #c9dbf5; background: #fbfcfe; }
.role-option:has(input:checked) { border-color: var(--mis-primary); background: var(--mis-primary-soft); }
.rights-matrix { max-height: 75vh; }
.rights-matrix thead th { position: sticky; top: 0; background: #f6f8fa; z-index: 2; font-size: .76rem; min-width: 96px; }
.rights-matrix .sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 260px; }
.rights-matrix thead .sticky-col { z-index: 3; background: #f6f8fa; }
.rights-matrix tr.table-light .sticky-col { background: #f8f9fa; }
.rights-matrix .form-check-input { width: 1.25em; height: 1.25em; }

/* Project form */
.repeater { display: grid; gap: 10px; justify-items: start; }
.repeater-rows { display: grid; gap: 10px; width: 100%; }
.repeater-row { padding: 10px 12px; border: 1px solid var(--mis-border); border-radius: var(--mis-radius-sm); background: #fbfcfd; margin: 0; }
.repeater-row.has-error { border-color: #d92d20; background: #fef3f2; }
.repeater-row .form-label { margin-bottom: .2rem; }
.form-savebar {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; gap: 8px; padding: 12px 16px; margin: 0 -4px 12px;
    background: rgba(255, 255, 255, .95); border: 1px solid var(--mis-border); border-radius: var(--mis-radius);
    box-shadow: 0 -4px 16px -8px rgba(16, 24, 40, .15);
}
.form-control[readonly] { background-color: #f2f4f7; color: #475467; cursor: not-allowed; }

/* ---------- Project reports ---------- */
.report-table th, .report-table td { white-space: nowrap; font-size: .875rem; }
.report-table tbody th { white-space: normal; min-width: 220px; }
.report-table a { text-decoration: none; font-weight: 600; }
.report-nav .nav-link { padding: .25rem .6rem; }
.chart-box { position: relative; height: 360px; }
.chart-box-wide { height: 420px; }

/* ---------- Project calendar ---------- */
.mis-calendar { --fc-border-color: var(--mis-border); --fc-today-bg-color: var(--mis-primary-soft); --fc-button-bg-color: var(--mis-primary);
    --fc-button-border-color: var(--mis-primary); --fc-button-hover-bg-color: var(--mis-primary-hover); --fc-button-active-bg-color: var(--mis-primary-hover); }
.mis-calendar .fc-toolbar-title { font-size: 1.25rem; }
.mis-calendar .fc-event { cursor: pointer; border: 0; padding: 1px 4px; font-size: .78rem; }
.mis-calendar .fc-daygrid-event-dot { display: none; }
.cal-output, .mis-calendar .fc-event.cal-output { background: #1e88e5; color: #fff; }
.cal-event, .mis-calendar .fc-event.cal-event { background: #43a047; color: #fff; }
.cal-done, .mis-calendar .fc-event.cal-done { background: #98a2b3; color: #fff; text-decoration: line-through; }
.mis-calendar .fc-event .fc-event-title, .mis-calendar .fc-event .fc-event-time { color: inherit; }
.cal-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.report-table .report-pct td { background: #f8fafc; color: var(--mis-muted); padding-top: .35rem; padding-bottom: .35rem; }

/* ---------- Events ---------- */
.checklist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem 1.5rem; }
@media print {
    .sidebar, .topbar, .page-titles .breadcrumb, .btn, .footer { display: none !important; }
    .page-wrapper { margin: 0 !important; padding: 0 !important; }
    .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ---------- Contact labels ---------- */
.label-sheet { display: none; }
@media print {
    body:has(.label-sheet:not(:empty)) * { visibility: hidden; }
    body:has(.label-sheet:not(:empty)) .label-sheet,
    body:has(.label-sheet:not(:empty)) .label-sheet * { visibility: visible; }
    .label-sheet:not(:empty) {
        display: grid; grid-template-columns: repeat(var(--label-cols, 3), 1fr); gap: 4mm 6mm;
        position: absolute; left: 0; top: 0; width: 100%; color: #000;
    }
    .label-item { break-inside: avoid; padding: 3mm 2mm; min-height: 30mm; font-size: 10pt; line-height: 1.3; }
    .label-name { font-weight: 700; font-size: 11pt; }
    .label-role { font-weight: 600; }
    @page { margin: 12mm; }
}

/* ---------- Contact portal ---------- */
.portal-body { background: var(--mis-bg); min-height: 100vh; }
.portal-top { background: #fff; border-bottom: 1px solid var(--mis-border); }
.portal-narrow { max-width: 460px; margin: 3rem auto; }
.portal-photo { width: 140px; height: 160px; object-fit: cover; border-radius: 10px; background: #e9edf3; }

/* Notification bell --------------------------------------------------------- */
.topbar-icon {
    position: relative;
    border: 0;
    background: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--mis-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.topbar-icon:hover, .topbar-icon[aria-expanded="true"] { background: var(--mis-bg); }
.notif-count {
    position: absolute;
    top: 3px;
    right: 1px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #dc3545;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.topbar .notif-menu { width: 380px; max-width: calc(100vw - 24px); overflow: hidden; }
.notif-head, .notif-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    font-size: .85rem;
}
.notif-head { border-bottom: 1px solid var(--mis-border); }
.notif-foot { border-top: 1px solid var(--mis-border); justify-content: space-between; }
.notif-items { max-height: 420px; overflow-y: auto; }
.notif-item {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    color: var(--mis-text);
    text-decoration: none;
    border-bottom: 1px solid var(--mis-border);
    font-size: .85rem;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--mis-bg); color: var(--mis-text); }
.notif-item > i { font-size: 1.1rem; margin-top: 1px; }
.notif-text { min-width: 0; display: flex; flex-direction: column; }
.notif-text strong { font-weight: 600; }
.notif-text span { color: var(--mis-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-text small { color: var(--mis-muted); font-size: .72rem; }
.notif-item.unread, .notif-list .unread { background: var(--mis-primary-soft); }
.notif-item.unread strong::after, .notif-list .unread strong::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--mis-primary);
    vertical-align: middle;
}
.min-w-0 { min-width: 0; }
@media (max-width: 575.98px) {
    .topbar .notif-bell { position: static; }
    .topbar .notif-menu { width: calc(100vw - 16px); }
}

/* Contact merge */
.merge-table td { min-width: 170px; }
.merge-table .btn-check + .btn { white-space: normal; font-weight: 400; }

/* Test-site bar (config app.banner) */
.env-banner {
    background: #ffe08a;
    color: #5c4400;
    border: 1px solid #f0c040;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
}
.auth-card .env-banner { display: block; max-width: none; white-space: normal; margin-bottom: 16px; }
