:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --ink: #1e293b;
    --muted: #64748b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-ink: #cbd5e1;
    --sidebar-active: #4f46e5;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand);
}
a { color: var(--brand); }

/* ============================================================
   AUTH / LOGIN
   ============================================================ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background: #0b1020;
}
/* animated aurora background */
.auth-body::before {
    content: "";
    position: absolute;
    inset: -20%;
    z-index: 0;
    background:
        radial-gradient(38% 45% at 18% 22%, rgba(99, 102, 241, .55), transparent 60%),
        radial-gradient(42% 50% at 82% 18%, rgba(139, 92, 246, .50), transparent 62%),
        radial-gradient(45% 55% at 25% 88%, rgba(56, 189, 248, .38), transparent 60%),
        radial-gradient(40% 50% at 88% 82%, rgba(217, 70, 239, .35), transparent 60%);
    filter: blur(20px);
    animation: auth-aurora 20s ease-in-out infinite alternate;
}
@keyframes auth-aurora {
    0%   { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
    50%  { transform: translate3d(2%, -2%, 0) scale(1.08) rotate(4deg); }
    100% { transform: translate3d(-2%, 2%, 0) scale(1.04) rotate(-3deg); }
}
/* fine noise/dot grid over the background */
.auth-body::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}

.auth-wrapper {
    width: 100%;
    max-width: 1000px;
    position: relative;
    z-index: 1;
}
.auth-card {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: #ffffff;
    border-radius: 26px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .35);
    box-shadow:
        0 40px 90px -30px rgba(2, 6, 23, .65),
        0 12px 40px -15px rgba(2, 6, 23, .45);
    animation: auth-card-in .75s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes auth-card-in {
    from { opacity: 0; transform: translateY(30px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- left visual panel ---------- */
.auth-visual {
    background: linear-gradient(155deg, #4338ca 0%, #6d28d9 48%, #7c3aed 100%);
    background-size: 200% 200%;
    animation: auth-visual-shift 14s ease infinite;
    color: #fff;
    padding: 54px 48px;
    position: relative;
    overflow: hidden;
    display: flex;
}
@keyframes auth-visual-shift {
    0%, 100% { background-position: 0% 0%; }
    50%      { background-position: 100% 100%; }
}
/* soft glow blobs kept in the corners, away from the text */
.auth-visual::before {
    content: "";
    position: absolute;
    width: 300px; height: 300px;
    border-radius: 50%;
    top: -130px; right: -110px;
    background: radial-gradient(circle, rgba(255, 255, 255, .30), transparent 68%);
    animation: auth-orb 11s ease-in-out infinite;
}
.auth-visual::after {
    content: "";
    position: absolute;
    width: 260px; height: 260px;
    border-radius: 50%;
    bottom: -120px; left: -90px;
    background: radial-gradient(circle, rgba(56, 189, 248, .28), transparent 70%);
    animation: auth-orb 13s ease-in-out infinite reverse;
}
@keyframes auth-orb {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(20px, 26px); }
}
.auth-visual-inner { position: relative; z-index: 1; align-self: center; width: 100%; }
.auth-visual h2 {
    font-weight: 800; font-size: 2.05rem; line-height: 1.18; margin: 30px 0 14px;
    letter-spacing: -.01em;
    animation: auth-rise .6s ease both .15s;
}
.auth-visual > .auth-visual-inner > p {
    color: rgba(255, 255, 255, .82); margin-bottom: 30px; max-width: 34ch;
    animation: auth-rise .6s ease both .25s;
}
.auth-points { list-style: none; padding: 0; margin: 0 0 34px; display: grid; gap: 14px; }
.auth-points li {
    display: flex; align-items: center; gap: 12px;
    color: rgba(255, 255, 255, .95); font-weight: 500;
    animation: auth-rise .5s ease both;
}
.auth-points li:nth-child(1) { animation-delay: .35s; }
.auth-points li:nth-child(2) { animation-delay: .44s; }
.auth-points li:nth-child(3) { animation-delay: .53s; }
.auth-point-ic {
    width: 30px; height: 30px; flex: none;
    border-radius: 9px;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .2);
    display: grid; place-items: center;
    font-size: .9rem; color: #e0e7ff;
}
@keyframes auth-rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-visual-foot {
    display: flex; gap: 26px;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, .16);
    animation: auth-rise .6s ease both .6s;
}
.auth-stat { display: flex; flex-direction: column; line-height: 1.2; }
.auth-stat strong { font-size: 1.35rem; font-weight: 800; }
.auth-stat span { font-size: .74rem; color: rgba(255, 255, 255, .7); }

.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.15rem; }
.auth-brand-mark {
    width: 44px; height: 44px; border-radius: 13px;
    background: rgba(255, 255, 255, .16);
    display: grid; place-items: center; font-size: 1.3rem;
    animation: auth-pulse 3s ease-in-out infinite;
    overflow: hidden;
}
@keyframes auth-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .35); }
    50%      { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); }
}
.auth-form-side .auth-brand-mark {
    background: var(--brand-soft); color: var(--brand);
    animation: none;
}

/* ---------- right form panel ---------- */
.auth-form-side {
    padding: 54px 48px;
    display: flex; flex-direction: column; justify-content: center;
    animation: auth-card-in .75s cubic-bezier(.16, 1, .3, 1) both .12s;
}
.auth-form-head h1 { font-weight: 800; font-size: 1.75rem; margin-bottom: 6px; letter-spacing: -.01em; }
.auth-form-side .form-label { font-weight: 600; font-size: .82rem; color: var(--ink); margin-bottom: .35rem; }

.auth-form-side .input-group {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.auth-form-side .input-group-text {
    background: transparent; border: 0; color: var(--muted);
    padding-left: 1rem;
    transition: color .18s ease;
}
.auth-form-side .form-control {
    border: 0;
    padding: .78rem .9rem;
    background: transparent;
}
.auth-form-side .form-control:focus,
.auth-form-side .form-select:focus { box-shadow: none; }
.auth-form-side #toggle-password {
    border: 0; background: transparent; color: var(--muted);
}
.auth-form-side #toggle-password:hover { color: var(--brand); }
.auth-form-side .input-group:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .14);
}
.auth-form-side .input-group:focus-within .input-group-text { color: var(--brand); }

.auth-form-side .form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.auth-form-side #login-submit {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    padding: .85rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    background: linear-gradient(135deg, #4f46e5, #7c3aed 60%, #9333ea);
    background-size: 160% 160%;
    border: 0;
    box-shadow: 0 10px 24px -10px rgba(79, 70, 229, .55);
    transition: transform .18s ease, box-shadow .18s ease, background-position .4s ease;
}
.auth-form-side #login-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    background-position: 100% 100%;
    box-shadow: 0 18px 34px -10px rgba(79, 70, 229, .65);
}
.auth-form-side #login-submit:active:not(:disabled) { transform: translateY(0); }
.auth-form-side #login-submit::after {
    content: "";
    position: absolute;
    top: 0; left: -130%;
    width: 55%; height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .4), transparent);
    transform: skewX(-18deg);
    transition: left .55s ease;
}
.auth-form-side #login-submit:hover:not(:disabled)::after { left: 140%; }

.auth-form-side .alert-success {
    border: 0;
    background: #ecfdf5;
    color: #047857;
    border-radius: 10px;
}
.auth-form-side .alert-danger {
    border: 0;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 10px;
}

@media (max-width: 991.98px) {
    .auth-card { grid-template-columns: 1fr; max-width: 440px; margin: 0 auto; }
    .auth-visual { display: none; }
    .auth-form-side { padding: 40px 28px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-body::before,
    .auth-card,
    .auth-visual,
    .auth-visual::before,
    .auth-visual::after,
    .auth-visual h2,
    .auth-visual-inner > p,
    .auth-points li,
    .auth-visual-foot,
    .auth-brand-mark,
    .auth-form-side {
        animation: none !important;
    }
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-body { background: var(--bg); }
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 264px;
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 16px;
    font-weight: 700; color: #fff; font-size: 1.02rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--brand); display: grid; place-items: center; font-size: 1.1rem; color: #fff;
    overflow: hidden; flex-shrink: 0;
}
.sidebar-brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; }
.auth-brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }

/* company logo preview in the form */
.company-logo-box {
    display: grid; place-items: center;
    height: 90px; border: 1px dashed #c7d2fe; border-radius: 10px;
    background: #f8faff; overflow: hidden;
}
.company-logo-box img { max-height: 78px; max-width: 100%; object-fit: contain; }
.sidebar-close { color: #fff; margin-left: auto; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.sidebar-heading {
    text-transform: uppercase;
    font-size: .66rem; letter-spacing: .08em;
    color: #64748b; font-weight: 700;
    margin: 8px 10px 3px;
}
.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-nav > .sidebar-menu + .sidebar-menu {
    margin-top: 3px;
    padding-top: 3px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px; border-radius: 9px;
    color: var(--sidebar-ink); text-decoration: none;
    font-size: .875rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar-menu a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-menu a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-menu a i:first-child { font-size: 1rem; width: 18px; text-align: center; }

.has-submenu .submenu-caret { margin-left: auto; transition: transform .2s; font-size: .78rem; }
.has-submenu.open .submenu-caret { transform: rotate(180deg); }
.submenu {
    list-style: none; margin: 1px 0 0; padding: 0 0 0 10px;
    max-height: 0; overflow: hidden; transition: max-height .25s ease;
}
.has-submenu.open .submenu { max-height: 400px; }
.submenu a { font-size: .84rem; padding: 5px 10px; }
.submenu a i { font-size: 1rem; }

.sidebar-footer { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user-meta { overflow: hidden; }
.sidebar-user-meta strong { display: block; color: #fff; font-size: .85rem; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar-user-meta small { color: #64748b; font-size: .74rem; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: .85rem;
    flex-shrink: 0;
}

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.5);
    z-index: 1039; opacity: 0; visibility: hidden; transition: opacity .2s;
}
.app-shell.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* Main column */
.app-main {
    flex: 1;
    margin-left: 264px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.app-header {
    height: 64px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 1020;
}
.app-header-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.header-icon-btn {
    border: 1px solid var(--border); background: #fff;
    width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center; font-size: 1.1rem;
}
.header-user-btn {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--border); background: #fff;
    padding: 5px 12px 5px 6px; border-radius: 999px; font-weight: 600; font-size: .9rem;
}

.app-content {
    padding: 24px;
    flex: 1;
    background-color: #eef1fb;
    background-image:
        radial-gradient(rgba(30, 27, 75, .045) 1px, transparent 1px),
        radial-gradient(820px 460px at 100% -10%, rgba(124, 58, 237, .26), transparent 60%),
        radial-gradient(760px 420px at -8% 0%, rgba(79, 70, 229, .24), transparent 58%),
        radial-gradient(700px 520px at 50% 130%, rgba(56, 189, 248, .20), transparent 62%),
        radial-gradient(520px 380px at 88% 58%, rgba(236, 72, 153, .11), transparent 60%),
        linear-gradient(180deg, #eef1fb 0%, #eaf0fb 45%, #f2f0fb 100%);
    background-size: 24px 24px, auto, auto, auto, auto, auto;
    background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
    background-attachment: scroll, fixed, fixed, fixed, fixed, fixed;
}
.app-footer {
    padding: 14px 24px; border-top: 1px solid var(--border);
    color: var(--muted); font-size: .82rem; background: var(--card);
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
}

/* ============================================================
   CONTENT PIECES
   ============================================================ */
.page-header, .page-welcome {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-header h2, .page-welcome h2 { font-weight: 800; font-size: 1.4rem; }

.content-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.content-card .card-header { background: #fff; border-bottom: 1px solid var(--border); padding: 11px 16px; }
.content-card .card-footer { background: #fff; border-top: 1px solid var(--border); padding: 9px 16px; }

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    display: flex; align-items: center; gap: 16px;
    height: 100%;
}
.stat-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0;
}
.stat-label { display: block; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat-primary .stat-icon { background: #eef2ff; color: #4f46e5; }
.stat-success .stat-icon { background: #dcfce7; color: #16a34a; }
.stat-warning .stat-icon { background: #fef9c3; color: #ca8a04; }
.stat-info .stat-icon { background: #cffafe; color: #0891b2; }

/* Page hero banner */
.page-hero {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(115deg, #4338ca 0%, #4f46e5 45%, #7c3aed 100%);
    box-shadow: 0 8px 20px -10px rgba(79, 70, 229, .45);
    position: relative;
    overflow: hidden;
}
.page-hero::after {
    content: "";
    position: absolute; right: -40px; top: -60px;
    width: 180px; height: 180px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.16), transparent 70%);
}
.page-hero-text { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.page-hero h2 { font-weight: 800; font-size: 1.15rem; margin: 0; }
.page-hero p { color: rgba(255,255,255,.85); font-size: .82rem; }
.page-hero-icon {
    width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
    background: rgba(255,255,255,.16);
    display: grid; place-items: center; font-size: 1.15rem;
}
.btn-hero {
    position: relative; z-index: 1;
    font-weight: 700; color: var(--brand) !important;
    border: none; box-shadow: 0 3px 10px rgba(15, 23, 42, .16);
    padding: 6px 14px;
}
.btn-hero:hover { background: #fff; transform: translateY(-1px); }

/* Filter bar */
.filter-bar {
    background: linear-gradient(120deg, #eef2ff 0%, #f5f3ff 55%, #faf5ff 100%);
    border-bottom: 1px solid #e2e5f5 !important;
    padding: 12px 16px;
}
.filter-bar .form-control,
.filter-bar .form-select,
.filter-bar .input-group-text {
    border-color: #d9def0;
}
.filter-bar .input-group-text { background: #fff; color: var(--brand); }
#branch-count {
    display: inline-block;
    background: #fff;
    border: 1px solid #dbe0ff;
    color: var(--brand);
    font-weight: 700;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: .78rem;
}

/* Branch table — compact rows (overrides Bootstrap .table cell padding) */
.branch-table > :not(caption) > * > *,
.branch-table td,
.branch-table th {
    padding: 4px 12px !important;
}
.branch-table thead th {
    background: #eef2ff;
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    color: #4338ca; font-weight: 800;
    white-space: nowrap;
    border-bottom: 2px solid #dbe0ff;
    padding-top: 6px !important; padding-bottom: 6px !important;
}
.branch-table tbody td { font-size: .84rem; line-height: 1.25; }
.branch-table tbody td > div { margin: 0; }
.branch-table tbody td .small,
.branch-table tbody td small { font-size: .75rem; line-height: 1.15; }
.branch-table tbody td .fw-semibold { line-height: 1.25; }
.branch-table tbody td .badge { padding: .26em .5em; font-size: .72rem; }
.branch-table tbody tr { transition: background .12s; }
.branch-table tbody tr:hover { background: #f7f8ff; }

.btn-icon { width: 27px; height: 27px; padding: 0; display: inline-grid; place-items: center; font-size: .8rem; line-height: 1; }
.branch-table tbody td .btn-sm { --bs-btn-padding-y: 2px; --bs-btn-padding-x: 4px; }

.branch-avatar {
    width: 52px; height: 52px; border-radius: 14px;
    background: var(--brand-soft); color: var(--brand);
    display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
}
.detail-list dt { font-weight: 600; color: var(--muted); padding: 5px 0; font-size: .86rem; }
.detail-list dd { padding: 5px 0; margin: 0; font-size: .9rem; border-bottom: 1px dashed var(--border); }

.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.is-invalid ~ .invalid-feedback { display: block; }

.swal2-styled.swal2-confirm { background-color: var(--brand) !important; }

/* ===== Delete confirmation dialog ===== */
.del-popup { border-radius: 16px !important; overflow: hidden; }
.del-body { padding: 26px 24px 6px; text-align: center; }
.del-icon {
    width: 62px; height: 62px; margin: 0 auto 14px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    display: grid; place-items: center;
    font-size: 1.6rem;
    box-shadow: 0 0 0 8px #fef2f2;
}
.del-title { font-weight: 800; color: #1e293b; margin: 0 0 6px; font-size: 1.15rem; }
.del-text { color: #64748b; font-size: .9rem; margin: 0 0 8px; }
.del-chip {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 14px;
}
.del-note {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: .78rem;
    border-radius: 8px;
    padding: 8px 10px;
    margin: 0;
}
.del-actions { gap: 8px; padding: 16px 24px 22px !important; }
.del-actions .btn { font-weight: 600; }

/* ============================================================
   APP MODAL (invoice-style)
   ============================================================ */
.app-modal .modal-content {
    border: none;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35);
}

/* Our modals wrap header/body/footer inside a <form>, so the <form> must
   carry the scrollable-modal column layout — otherwise .modal-body never
   gets a height limit and a tall modal overflows the viewport. */
.app-modal .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.app-modal .modal-body { overflow-y: auto; }

.app-modal-header {
    background: linear-gradient(100deg, #1e40af 0%, #2563eb 55%, #3b82f6 100%);
    color: #fff;
    border-bottom: none;
    padding: 16px 22px;
}
.app-modal-header .modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
}
.app-modal-header .btn-close {
    opacity: .9;
}

.app-modal-header { padding: 12px 18px; }
.app-modal-header .modal-title { font-size: .98rem; }

.app-modal-body {
    background: #f1f5f9;
    padding: 16px;
}

.app-modal-footer {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 10px 16px;
}

/* Light-blue information panel */
.form-panel {
    background: #eef4ff;
    border: 1px solid #dbe6ff;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}
.form-panel-title {
    color: #2563eb;
    font-weight: 700;
    font-size: .76rem;
    letter-spacing: .05em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

/* Dark section header (like "BILLABLE ITEMS") */
.form-section {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}
.form-section:last-child { margin-bottom: 0; }
.form-section-head {
    background: #1e293b;
    color: #fff;
    padding: 9px 14px;
    font-weight: 700;
    font-size: .76rem;
    letter-spacing: .05em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.form-section-body {
    background: #fff;
    padding: 14px;
}

.app-modal-body .form-label {
    font-weight: 600;
    font-size: .78rem;
    color: #334155;
    margin-bottom: 3px;
}
.app-modal-body .req { color: #dc2626; }
.app-modal-body .form-control,
.app-modal-body .form-select { background: #fff; }
.app-modal-body .invalid-feedback { font-size: .75rem; }

@media (max-width: 575.98px) {
    .app-modal-body, .app-modal-header, .app-modal-footer { padding-left: 12px; padding-right: 12px; }
}

/* ============================================================
   STUDENT MODULE
   ============================================================ */
#student-count {
    display: inline-block;
    background: #fff;
    border: 1px solid #dbe0ff;
    color: var(--brand);
    font-weight: 700;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: .78rem;
}
.student-thumb {
    width: 32px; height: 32px; border-radius: 9px;
    object-fit: cover; flex-shrink: 0;
    border: 1px solid var(--border);
}
.student-thumb-fallback {
    display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand);
    font-weight: 800;
}
.student-form .form-section { margin-bottom: 14px; }
.student-form .form-label { font-weight: 600; font-size: .8rem; color: #334155; margin-bottom: 3px; }
.student-form .req { color: #dc2626; }

.student-photo-preview {
    width: 100%; aspect-ratio: 1 / 1; max-height: 220px;
    border: 1px dashed #c7d2fe; border-radius: 12px;
    background: #f8faff;
    display: grid; place-items: center;
    overflow: hidden;
    color: #a5b4fc; font-size: 3rem;
}
.student-photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.student-view-photo {
    width: 130px; height: 130px; border-radius: 16px;
    object-fit: cover;
    display: inline-grid; place-items: center;
    font-size: 2.4rem;
    border: 1px solid var(--border);
}

/* ---- Student detail (view) page ---- */
.student-hero {
    background: linear-gradient(115deg, #4338ca 0%, #6d28d9 45%, #9333ea 100%);
}

.student-profile-card { overflow: hidden; }
.student-profile-banner {
    height: 60px;
    background: linear-gradient(120deg, #6366f1, #8b5cf6 55%, #a855f7);
}
.student-profile-photo {
    width: 124px; height: 124px;
    margin: -62px auto 0;
    border-radius: 24px;
    border: 4px solid #fff;
    background: var(--brand-soft);
    box-shadow: 0 12px 26px -10px rgba(49, 46, 129, .5);
    overflow: hidden;
    display: grid; place-items: center;
    position: relative;
}
.student-profile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.student-profile-photo .student-thumb-fallback {
    width: 100%; height: 100%; font-size: 2.8rem; border-radius: 0;
}

.student-quick-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin-top: 6px;
}
.student-quick-row > div {
    background: #f5f6ff;
    border: 1px solid #e6e8fb;
    border-radius: 10px;
    padding: 8px 10px;
    min-width: 0;
}
.student-quick-label {
    display: block; font-size: .68rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); font-weight: 700;
}
.student-quick-value {
    display: block; font-weight: 700; font-size: .9rem; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.student-block {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
    background: #fff;
}
.student-block-head {
    padding: 11px 16px;
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #fff;
}
.student-block-head i { margin-right: 6px; }

/* collapsible section (EMI schedule) */
.collapsible-block .student-block-head { cursor: pointer; user-select: none; }
.collapsible-block .student-block-head:hover { filter: brightness(1.05); }
.collapsible-block .block-caret {
    display: inline-block; transition: transform .2s ease; font-size: .85rem; margin-right: 4px;
}
.collapsible-block.is-open .block-caret { transform: rotate(90deg); }

.student-block-indigo { background: linear-gradient(100deg, #4f46e5, #6366f1); }
.student-block-teal   { background: linear-gradient(100deg, #0d9488, #14b8a6); }
.student-block-amber  { background: linear-gradient(100deg, #d97706, #f59e0b); }

.student-block-body { padding: 8px 16px 14px; }
.student-block-body-indigo { background: linear-gradient(180deg, #f4f5ff, #fbfbff); }
.student-block-body-teal   { background: linear-gradient(180deg, #eefbf9, #fbfefe); }
.student-block-body-amber  { background: linear-gradient(180deg, #fff8ee, #fffdf9); }

.student-block-body .detail-list dt {
    color: #475569; font-weight: 600; padding: 9px 0;
}
.student-block-body .detail-list dd {
    color: #0f172a; font-weight: 500; padding: 9px 0; margin: 0;
    border-bottom: 1px dashed rgba(100, 116, 139, .25);
}
.student-block-body .detail-list dd:last-of-type { border-bottom: 0; }

/* ---- Student form (create / edit) page ---- */
.student-form .form-section-body { background: #fbfbff; }
.student-form .form-panel { background: linear-gradient(160deg, #eef4ff, #f5f0ff); }

/* ---- Fee collection ---- */
.fee-summary-list dt { font-weight: 600; color: #475569; padding: 6px 0; font-size: .9rem; }
.fee-summary-list dd { padding: 6px 0; margin: 0; font-size: .95rem; }
#sum-due.text-danger { color: #dc2626 !important; }
#sum-due.text-success { color: #16a34a !important; }
.student-form #f-amount_paid.is-warning {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .18);
}
#fee-history .table td { padding: 4px 6px; border-color: #eef1f6; }

/* ---- Installment plan ---- */
#s-installment-panel .form-section-head { background: #0f766e; }
.inst-table .inst-due { max-width: 150px; }

/* ---- EMI schedule (student view) ---- */
.emi-stat {
    background: #fff; border: 1px solid #f1e3c6; border-radius: 10px;
    padding: 8px 10px; height: 100%;
}
.emi-stat span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.emi-stat strong { display: block; font-size: 1rem; }
.emi-audit li { padding: 3px 0; border-bottom: 1px dashed #e2e8f0; }
.emi-audit li:last-child { border-bottom: 0; }

/* ---- Fee status report ---- */
.fs-totals { background: #f8fafc; }
.fs-total { text-align: center; }
.fs-total span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.fs-total strong { font-size: 1rem; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-hero {
    display: flex; flex-wrap: wrap; gap: 14px;
    align-items: center; justify-content: space-between;
    padding: 18px 20px; margin-bottom: 16px;
    border-radius: 16px; color: #fff;
    background: linear-gradient(115deg, #4338ca 0%, #6d28d9 48%, #9333ea 100%);
    box-shadow: 0 14px 30px -14px rgba(79, 70, 229, .5);
}
.dash-hero-text h2 { font-weight: 800; font-size: 1.35rem; }
.dash-hero-text p { color: rgba(255, 255, 255, .82); font-size: .85rem; }
.dash-wave { display: inline-block; animation: dash-wave 2.2s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes dash-wave { 0%,60%,100% { transform: rotate(0); } 15% { transform: rotate(16deg); } 30% { transform: rotate(-8deg); } 45% { transform: rotate(12deg); } }

.dash-branch-filter { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .14); padding: 6px 10px; border-radius: 10px; }
.dash-branch-filter label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.dash-branch-filter select { min-width: 190px; border: 0; }

#dashboard.dash-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }

/* KPI cards */
.dash-kpi {
    position: relative; overflow: hidden;
    border: 1px solid #dce0f2;
    border-radius: 14px; padding: 16px 16px 14px;
    box-shadow: 0 10px 24px -14px rgba(30, 27, 75, .3);
    height: 100%;
    display: flex; flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}
.dash-kpi::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.dash-kpi:hover { transform: translateY(-3px); box-shadow: 0 18px 34px -14px rgba(30, 27, 75, .38); }
.dash-kpi-ic {
    width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center; font-size: 1.15rem; margin-bottom: 10px;
}
.dash-kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); }
.dash-kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.15; color: var(--ink); }
.dash-kpi-sub { font-size: .72rem; color: var(--muted); }
.dash-kpi::after {
    content: ""; position: absolute; right: -22px; bottom: -22px;
    width: 78px; height: 78px; border-radius: 50%; opacity: .12;
}
.kpi-indigo { background: linear-gradient(160deg, #fbfbff 20%, #dfe3fb); border-color: #c9cff2; } .kpi-indigo .dash-kpi-ic { background: #dbe0ff; color: #4f46e5; } .kpi-indigo::after { background: #4f46e5; } .kpi-indigo::before { background: #4f46e5; }
.kpi-violet { background: linear-gradient(160deg, #fdfbff 20%, #eddffb); border-color: #ddc9f2; } .kpi-violet .dash-kpi-ic { background: #ebdcff; color: #7c3aed; } .kpi-violet::after { background: #7c3aed; } .kpi-violet::before { background: #7c3aed; }
.kpi-cyan   { background: linear-gradient(160deg, #fafeff 20%, #d0f1f8); border-color: #b6e6ef; } .kpi-cyan .dash-kpi-ic { background: #c2eff7; color: #0891b2; } .kpi-cyan::after { background: #0891b2; } .kpi-cyan::before { background: #0891b2; }
.kpi-green  { background: linear-gradient(160deg, #fafffb 20%, #d2f4df); border-color: #b6e8c7; } .kpi-green .dash-kpi-ic { background: #c4f0d3; color: #16a34a; } .kpi-green::after { background: #16a34a; } .kpi-green::before { background: #16a34a; }
.kpi-red    { background: linear-gradient(160deg, #fffbfb 20%, #fbdcdc); border-color: #f4c4c4; } .kpi-red .dash-kpi-ic { background: #fbd0d0; color: #dc2626; } .kpi-red::after { background: #dc2626; } .kpi-red::before { background: #dc2626; }
.kpi-amber  { background: linear-gradient(160deg, #fffdf6 20%, #fbeec2); border-color: #f2df9e; } .kpi-amber .dash-kpi-ic { background: #fbe9a8; color: #ca8a04; } .kpi-amber::after { background: #f59e0b; } .kpi-amber::before { background: #f59e0b; }

.dash-card {
    border-radius: 14px;
    border: 1.5px solid #c3c9e8;
    box-shadow: 0 12px 28px -16px rgba(30, 27, 75, .32), inset 0 0 0 1px rgba(255, 255, 255, .6);
    background: linear-gradient(180deg, #fbfbff 0%, #eef0fb 100%);
}
.dash-card .card-header {
    background: linear-gradient(180deg, #eef0fd, #e6e9fa);
    border-bottom: 1px solid #d7dbf0;
    padding: 12px 16px;
}
.dash-card-title { font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: #334155; margin-bottom: 12px; }

/* circular ring */
.dash-ring {
    --val: 0; --track: #e5e7eb;
    width: 132px; height: 132px; border-radius: 50%;
    margin: 6px auto 12px; position: relative;
    display: grid; place-items: center;
    background: conic-gradient(var(--ring-c) calc(var(--val) * 1%), var(--track) 0);
    transition: background .4s ease;
}
.dash-ring::before {
    content: ""; position: absolute;
    width: 100px; height: 100px; border-radius: 50%; background: #fff;
    box-shadow: inset 0 0 0 1px #f1f5f9;
}
.dash-ring span { position: relative; z-index: 1; font-weight: 800; font-size: 1.4rem; color: var(--ink); }
.ring-green { --ring-c: #16a34a; }
.ring-amber { --ring-c: #f59e0b; }

.dash-card .table { background: transparent; }
.dash-card .table tbody tr { transition: background .12s; }
.dash-card .table tbody tr:hover { background: rgba(79, 70, 229, .06); }
.dash-card .table > :not(caption) > * > * { background: transparent; padding: 7px 12px; }
.dash-card .table td { font-size: .875rem; }

.dash-mini-list { list-style: none; margin: 0; padding: 0; }
.dash-mini-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .9rem;
}
.dash-mini-list li:last-child { border-bottom: 0; }
.dash-mini-list strong { font-weight: 800; }

.dash-chart-wrap { position: relative; height: 260px; }
.dash-chart-wrap.sm { height: 200px; }

/* Quick report tiles */
.dash-report-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}
.dash-report-tile {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-align: center; text-decoration: none;
    padding: 16px 10px; border-radius: 12px;
    border: 1.5px solid #c3c9e8; color: #334155;
    font-weight: 600; font-size: .82rem;
    box-shadow: 0 8px 18px -12px rgba(30, 27, 75, .3), inset 0 0 0 1px rgba(255, 255, 255, .55);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.dash-report-tile::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.rt-indigo { background: linear-gradient(165deg, #fbfbff, #dfe3fb); border-color: #aab4ea; } .rt-indigo::before { background: #4f46e5; }
.rt-violet { background: linear-gradient(165deg, #fdfbff, #ecddfb); border-color: #cdb2ea; } .rt-violet::before { background: #7c3aed; }
.rt-cyan   { background: linear-gradient(165deg, #fafeff, #cfeff6); border-color: #95d6e2; } .rt-cyan::before { background: #0891b2; }
.rt-green  { background: linear-gradient(165deg, #fafffb, #d0f2de); border-color: #95d9ac; } .rt-green::before { background: #16a34a; }
.rt-red    { background: linear-gradient(165deg, #fffbfb, #fbd7d7); border-color: #eeaaaa; } .rt-red::before { background: #dc2626; }
.rt-amber  { background: linear-gradient(165deg, #fffdf6, #fbeaba); border-color: #e9cd7c; } .rt-amber::before { background: #f59e0b; }
.dash-report-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 26px -14px rgba(30, 27, 75, .4);
    color: #0f172a;
}
.dash-report-tile .rt-ic {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.2rem;
}
.rt-indigo .rt-ic { background: #eef2ff; color: #4f46e5; } .rt-indigo:hover { border-color: #c7d2fe; }
.rt-violet .rt-ic { background: #f3e8ff; color: #7c3aed; } .rt-violet:hover { border-color: #ddd6fe; }
.rt-cyan   .rt-ic { background: #cffafe; color: #0891b2; } .rt-cyan:hover { border-color: #a5f3fc; }
.rt-green  .rt-ic { background: #dcfce7; color: #16a34a; } .rt-green:hover { border-color: #bbf7d0; }
.rt-red    .rt-ic { background: #fee2e2; color: #dc2626; } .rt-red:hover { border-color: #fecaca; }
.rt-amber  .rt-ic { background: #fef9c3; color: #ca8a04; } .rt-amber:hover { border-color: #fde68a; }

@media (max-width: 991.98px) { .dash-report-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 575.98px) { .dash-report-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 991.98px) {
    .dash-chart-wrap { height: 230px; }
}

/* ---- Reports ---- */
.report-summary { background: #f8fafc; display: flex; flex-wrap: wrap; gap: 6px; }
.rp-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #fff; border: 1px solid var(--border); border-radius: 999px;
    padding: 3px 10px; font-size: .78rem; color: #475569;
}
.rp-chip strong { color: #0f172a; }
.report-print-head { padding: 12px 16px; }
.report-print-head h3 { margin: 0; font-weight: 800; }

@media print {
    .app-sidebar, .app-header, .app-footer, .sidebar-backdrop, .d-print-none { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; }
    .content-card { border: none; box-shadow: none; }
    .report-summary { display: flex !important; }
    body { background: #fff !important; }
}
.inst-table { background: #fff; }
.inst-table thead th {
    background: #ecfdf5; color: #047857; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .04em; font-weight: 800;
}
.inst-table tfoot th { background: #f8fafc; font-size: .9rem; }
.inst-table .inst-amount { max-width: 200px; }
.inst-table .btn-icon { width: 28px; height: 28px; }
#s-inst-total.text-success { color: #16a34a !important; }
#s-inst-total.text-danger { color: #dc2626 !important; }

/* ============================================================
   ATTENDANCE MODULE
   ============================================================ */
#attendance-records .student-block-head,
#attendance-module .student-block-head { border-radius: 0; }

.att-switch { display: flex; align-items: center; gap: 10px; padding-left: 2.6em; }
.att-switch .form-check-input {
    width: 2.1em; height: 1.15em; cursor: pointer;
    margin-left: -2.6em;
}
.att-switch .form-check-input:checked {
    background-color: #16a34a;
    border-color: #16a34a;
}
.att-switch .form-check-input:not(:checked) {
    background-color: #fca5a5;
    border-color: #fca5a5;
}
.att-switch .att-state { font-weight: 600; font-size: .85rem; min-width: 54px; }

#rec-count {
    display: inline-block; background: #fff; border: 1px solid #dbe0ff;
    color: var(--brand); font-weight: 700; padding: 4px 11px;
    border-radius: 999px; font-size: .78rem;
}

/* ============================================================
   ATTENDANCE REGISTER (monthly grid)
   ============================================================ */
.reg-legend {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 10px 16px; font-size: .8rem; color: #475569;
    background: #f8fafc; border-bottom: 1px solid var(--border);
}
.reg-badge {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; border-radius: 6px;
    font-size: .72rem; font-weight: 800; color: #fff;
}
.reg-badge.reg-p { background: #16a34a; }
.reg-badge.reg-a { background: #dc2626; }
.reg-badge.reg-blank { background: #e2e8f0; color: #64748b; }
.reg-badge.reg-sun-badge { background: #6d28d9; }

.reg-scroll { overflow: auto; max-height: calc(100vh - 260px); }
.reg-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: .8rem;
    width: max-content;
    min-width: 100%;
}
.reg-table th, .reg-table td {
    border-right: 1px solid #e8ebf3;
    border-bottom: 1px solid #e8ebf3;
    padding: 6px 8px;
    background: #fff;
    text-align: center;
    white-space: nowrap;
}
.reg-table thead th {
    position: sticky; top: 0; z-index: 3;
    background: #1e293b; color: #fff;
    font-size: .68rem; letter-spacing: .03em; font-weight: 700;
    vertical-align: middle;
}
.reg-table thead th.reg-day { padding: 4px 6px; line-height: 1.15; }
.reg-daynum { display: block; font-size: .8rem; font-weight: 800; }
.reg-dayname { display: block; font-size: .6rem; opacity: .75; }

/* sticky left columns */
.reg-sticky { position: sticky; z-index: 2; }
.reg-col-sr { left: 0; width: 42px; min-width: 42px; }
.reg-col-name { left: 42px; width: 220px; min-width: 220px; text-align: left; }
.reg-col-cb { left: 262px; width: 170px; min-width: 170px; text-align: left; }
.reg-table thead .reg-sticky { z-index: 4; }
.reg-table tbody .reg-sticky { background: #fff; box-shadow: 1px 0 0 #e8ebf3; }
.reg-table tbody tr:hover .reg-sticky { background: #f7f8ff; }
.reg-table tbody tr:hover td { background: #f7f8ff; }

.reg-day.reg-sun, .reg-cell.reg-sun { background: #f5f3ff; }
.reg-table thead th.reg-sun { background: #4c1d95; }
.reg-day.reg-today { background: #4f46e5; }

.reg-cell { cursor: pointer; min-width: 34px; font-weight: 800; user-select: none; transition: background .12s; }
.reg-cell .reg-mark { pointer-events: none; }
.reg-cell.is-p { background: #dcfce7; color: #15803d; }
.reg-cell.is-a { background: #fee2e2; color: #b91c1c; }
.reg-cell.is-dirty { outline: 2px solid #f59e0b; outline-offset: -2px; }
.reg-cell.reg-future { cursor: not-allowed; background: #fafafa; color: #cbd5e1; }
.reg-cell:not(.reg-future):hover { background: #eef2ff; }

@media (max-width: 767.98px) {
    .reg-col-name { width: 150px; min-width: 150px; }
    .reg-col-cb { left: 192px; width: 120px; min-width: 120px; }
    .reg-scroll { max-height: calc(100vh - 320px); }
}

@media print {
    .app-sidebar, .app-header, .app-footer, .sidebar-backdrop,
    .filter-bar, .page-hero, .reg-legend { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .content-card { border: none; box-shadow: none; }
    .reg-scroll { overflow: visible; max-height: none; }
    .reg-table { font-size: 8pt; }
    .reg-table thead th { background: #ddd !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .reg-cell.is-p, .reg-cell.is-a, .reg-cell.reg-sun { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================================
   Role & Permission matrix
   ============================================================ */
.perm-matrix { font-size: .875rem; }
.perm-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .5rem;
    padding: .65rem .85rem; margin-bottom: .75rem;
    background: #f3f4ff; border: 1.5px solid #c3c9e8; border-radius: .6rem;
}
.perm-table { border: 1px solid #e5e7f2; }
.perm-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: #eef1fb; color: #33306b;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
    white-space: nowrap;
}
.perm-table .perm-menu-col { min-width: 200px; }
.perm-table .perm-act-col { width: 84px; }
.perm-table tbody tr.perm-group-row {
    background: #f7f8ff;
}
.perm-table tbody tr.perm-group-row td { border-top: 2px solid #d7dbf3; }
.perm-table tbody tr.perm-menu-row:hover { background: #fafbff; }
.perm-table td, .perm-table th { vertical-align: middle; }
.perm-na { color: #cbd5e1; }
.perm-matrix .form-check-input { cursor: pointer; }
.perm-matrix .form-check-input:indeterminate {
    background-color: #6366f1; border-color: #6366f1;
}

@media (max-width: 575.98px) {
    .perm-table .perm-menu-col { min-width: 150px; }
    .perm-table .perm-act-col { width: 64px; }
}
