:root {
    --sim-primary: #1d9b57;
    --sim-primary-dark: #087443;
    --sim-primary-soft: #e8f8ee;
    --sim-accent: #f59e0b;
    --sim-accent-dark: #d97706;
    --sim-navy: #123c2a;
    --sim-page: #f2f8f4;
    --sim-border: #dcebe2;
    --sim-muted: #617368;
    --sim-sidebar-width: 270px;
    --bs-primary: #1d9b57;
    --bs-primary-rgb: 29, 155, 87;
    --bs-link-color: #087443;
    --bs-link-hover-color: #065f36;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: clip; }
body { font-family: Inter, "Segoe UI", Arial, sans-serif; background: var(--sim-page); color: #173226; }
.app-shell { min-height: 100vh; }
.min-w-0 { min-width: 0!important; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1030;
    display: flex; width: var(--sim-sidebar-width); height: 100vh; flex-direction: column;
    color: #def5e6; background: linear-gradient(180deg, #0d5f3b, #073c29); overflow: hidden;
    transition: transform .25s ease;
}
.brand { display: flex; min-height: 86px; padding: 12px 16px; align-items: center; gap: 11px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { display: grid; width: 52px; height: 52px; flex: 0 0 52px; place-items: center; overflow: hidden; border: 2px solid rgba(255,255,255,.75); border-radius: 50%; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); text-decoration: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { color: #fff; text-decoration: none; }
.brand-name strong, .brand strong { display: block; font-size: 1rem; line-height: 1.15; color: #fff; }
.brand-name small, .brand small { display: block; margin-top: 2px; color: #c4ecd2; font-size: .72rem; line-height: 1.15; }
.brand-vendor { display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; color: #fde047; font-size: .65rem; font-weight: 600; line-height: 1.2; text-decoration: none; transition: all .2s ease; opacity: .92; }
.brand-vendor:hover { color: #ffffff; text-decoration: underline; opacity: 1; }
.sidebar-menu { flex: 1 1 auto; padding: 12px 0 18px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.sidebar-menu::-webkit-scrollbar { display: none; }
.sidebar-home { margin-bottom: 6px; padding: 0 10px; }
.sidebar .nav-link { display: flex; margin: 2px 0; padding: 10px 13px; align-items: center; gap: 11px; color: #c5e6d1; border-radius: 9px; font-size: .91rem; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(245,158,11,.24); }
.sidebar .nav-link i { width: 20px; flex: 0 0 20px; text-align: center; font-size: 1rem; }
.sidebar-accordion .accordion-item { border: 0; background: transparent; }
.sidebar-accordion .accordion-button { min-height: 45px; padding: 10px 16px; gap: 11px; color: #acd8bc; background: transparent; box-shadow: none; font-size: .77rem; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.sidebar-accordion .accordion-button:hover, .sidebar-accordion .accordion-button:not(.collapsed) { color: #fff; background: rgba(255,255,255,.045); }
.sidebar-accordion .accordion-button i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-accordion .accordion-button::after { width: .85rem; height: .85rem; margin-left: auto; filter: brightness(0) invert(1); opacity: .6; background-size: .85rem; }
.sidebar-subnav { margin: 2px 10px 8px; padding: 4px; border-radius: 10px; background: rgba(2,39,24,.32); }
.sidebar-subnav .nav-link { padding: 8px 11px; font-size: .86rem; }
.sidebar-subnav--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sidebar-subnav--grid .nav-link { min-width: 0; padding: 7px 6px; gap: 5px; font-size: .72rem; line-height: 1.2; }
.sidebar-subnav--grid .nav-link i { width: 15px; flex-basis: 15px; font-size: .82rem; }
.sidebar-subnav--grid .nav-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.main-panel { min-width: 0; min-height: 100vh; margin-left: var(--sim-sidebar-width); transition: margin-left .25s ease; position: relative; }
.topbar { position: -webkit-sticky; position: sticky; top: 0; z-index: 1020; display: flex; min-height: 76px; padding: 12px 28px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--sim-border); background: rgba(255,255,255,.98); backdrop-filter: blur(10px); box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.topbar-heading, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-heading { min-width: 0; gap: 14px; }
.topbar-school { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-school-logo { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border-radius: 50%; background: #fff; border: 2px solid #e2e8f0; box-shadow: 0 2px 8px rgba(0,0,0,.06); overflow: hidden; }
.topbar-school-logo img { width: 100%; height: 100%; object-fit: cover; }
.topbar-school-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.topbar-school-text .school-name { font-size: 1.05rem; font-weight: 750; color: #1e293b; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-school-text .badge-branch { font-size: .68rem; font-weight: 700; background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; letter-spacing: .5px; }
.topbar-school-text .school-tagline { font-size: .72rem; color: #64748b; font-weight: 500; margin-top: 1px; }
.content-header { margin-bottom: 1.5rem; }
.content-header .page-title { font-size: 1.45rem; font-weight: 750; color: #0f172a; letter-spacing: -0.01em; margin-bottom: .25rem; }
.topbar-actions { flex: 0 0 auto; }
.header-help-button {
    display: grid; width: 44px; height: 44px; flex: 0 0 44px; padding: 0; place-items: center;
    color: #fff; border: 0; border-radius: 12px; background: var(--sim-primary);
    box-shadow: 0 6px 14px rgba(29,155,87,.22); font-size: 1.25rem; transition: transform .16s, background .16s;
}
.header-help-button:hover, .header-help-button:focus-visible { color: #fff; background: var(--sim-primary-dark); transform: translateY(-1px); }
.header-help-button:focus-visible { outline: 3px solid rgba(245,158,11,.35); outline-offset: 2px; }
.header-clock {
    display: flex; min-height: 44px; padding: 7px 13px; align-items: center; gap: 10px;
    color: #fff; border-radius: 12px; background: linear-gradient(135deg, var(--sim-primary-dark), var(--sim-primary));
    box-shadow: 0 6px 14px rgba(8,116,67,.18); white-space: nowrap;
}
.header-clock > i { color: #ffd27a; font-size: 1.05rem; }
.header-clock time { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.header-clock strong { padding-left: 8px; border-left: 1px solid rgba(255,255,255,.3); font-size: .92rem; letter-spacing: .025em; font-variant-numeric: tabular-nums; }
.user-avatar { width: 34px; height: 34px; place-items: center; }
.user-menu-button { min-height: 44px; }
.content-wrap { min-height: calc(100vh - 132px); padding: 28px; }
.page-title { font-size: 1.5rem; font-weight: 750; }
.breadcrumb { margin-bottom: 0; font-size: .84rem; }
.card { min-width: 0; border: 1px solid var(--sim-border); border-radius: 14px; box-shadow: 0 5px 18px rgba(18,60,42,.055); }
.card-header { padding: 18px 20px; border-bottom-color: var(--sim-border); background: #fff; }
.card-body { padding: 20px; }
.stat-card { overflow: hidden; }
.stat-icon { display: grid; width: 48px; height: 48px; place-items: center; color: var(--sim-primary); border-radius: 13px; background: var(--sim-primary-soft); font-size: 1.25rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; }
.text-muted { color: var(--sim-muted)!important; }
.table-responsive { max-width: 100%; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #c5cfdd transparent; }
.table > :not(caption) > * > * { padding: .85rem .9rem; border-bottom-color: var(--sim-border); }
.table thead th { color: #667085; background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table tbody tr:last-child > * { border-bottom-width: 0; }
.form-label { font-weight: 650; }
.form-control, .form-select { min-height: 42px; border-color: #d9e0ea; border-radius: 9px; }
.form-control:focus, .form-select:focus { border-color: #65c789; box-shadow: 0 0 0 .2rem rgba(29,155,87,.14); }
.required::after { content: " *"; color: #dc3545; }
.empty-state { padding: 48px 20px; color: var(--sim-muted); text-align: center; }
.empty-state i { display: block; margin-bottom: 12px; font-size: 2.2rem; }
.alert { border: 0; border-radius: 11px; box-shadow: 0 5px 16px rgba(15,31,61,.06); }
.badge { font-weight: 650; }
.btn { border-radius: 8px; }
.modal-content { border: 0; border-radius: 15px; box-shadow: 0 18px 55px rgba(15,31,61,.18); }
.context-help-modal .modal-dialog { max-width: 620px; }
.context-help-header { color: #fff; border: 0; background: linear-gradient(135deg, var(--sim-primary-dark), var(--sim-primary)); }
.context-help-header small { color: #c9f0d8; font-size: .68rem; font-weight: 800; letter-spacing: .09em; }
.context-help-mark { display: grid; width: 42px; height: 42px; place-items: center; color: var(--sim-primary-dark); border-radius: 12px; background: #fff; font-size: 1.2rem; }
.context-help-description { color: var(--sim-muted); line-height: 1.65; }
.context-help-subtitle { display: flex; margin: 22px 0 14px; align-items: center; gap: 8px; color: var(--sim-primary-dark); font-size: .93rem; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.context-help-steps { display: grid; margin: 0; padding: 0; gap: 10px; counter-reset: help-step; list-style: none; }
.context-help-steps li { display: grid; grid-template-columns: 32px 1fr; align-items: start; gap: 11px; line-height: 1.55; counter-increment: help-step; }
.context-help-steps li::before { display: grid; width: 30px; height: 30px; place-items: center; color: #fff; border-radius: 50%; background: var(--sim-primary); content: counter(help-step); font-size: .78rem; font-weight: 800; }
.context-help-steps li span { padding-top: 3px; }
.context-help-tips { margin-top: 20px; padding: 14px 16px; color: #7a4a00; border: 1px solid #fbd38d; border-radius: 12px; background: #fff8e8; font-size: .88rem; }
.context-help-tips strong { display: block; margin-bottom: 6px; color: var(--sim-accent-dark); }
.context-help-tips ul { padding-left: 19px; }
.pagination .page-link { color: var(--sim-primary); border-color: var(--sim-border); }
.pagination .active > .page-link { color: #fff; background: var(--sim-primary); border-color: var(--sim-primary); }
.btn-primary {
    --bs-btn-bg: var(--sim-primary); --bs-btn-border-color: var(--sim-primary);
    --bs-btn-hover-bg: var(--sim-primary-dark); --bs-btn-hover-border-color: var(--sim-primary-dark);
    --bs-btn-active-bg: #06643a; --bs-btn-active-border-color: #06643a;
    --bs-btn-disabled-bg: var(--sim-primary); --bs-btn-disabled-border-color: var(--sim-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--sim-primary-dark); --bs-btn-border-color: var(--sim-primary);
    --bs-btn-hover-bg: var(--sim-primary); --bs-btn-hover-border-color: var(--sim-primary);
    --bs-btn-active-bg: var(--sim-primary-dark); --bs-btn-active-border-color: var(--sim-primary-dark);
}
.text-primary { color: var(--sim-primary-dark)!important; }
.bg-primary { background-color: var(--sim-primary)!important; }
.bg-primary-subtle { background-color: var(--sim-primary-soft)!important; }
.border-primary { border-color: var(--sim-primary)!important; }
.badge.text-bg-primary, .progress-bar { background-color: var(--sim-primary)!important; }
.dropdown-item:active { background-color: var(--sim-primary); }
.form-check-input:checked { border-color: var(--sim-primary); background-color: var(--sim-primary); }
.accent-orange { color: var(--sim-accent-dark)!important; }
.dt-container { padding: 14px 16px; }
.dt-container .dt-layout-row:last-child { margin-bottom: 0; }
.dt-container .dt-search input, .dt-container .dt-length select { border: 1px solid #d9e0ea; border-radius: 8px; }
.sidebar-toggle {
    display: inline-flex; width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
    align-items: center; justify-content: center; color: var(--sim-primary-dark);
    border: 1px solid var(--sim-border); border-radius: 11px; background: #fff;
    box-shadow: 0 4px 12px rgba(18,60,42,.06);
}
.sidebar-toggle:hover, .sidebar-toggle:focus-visible { color: #fff; border-color: var(--sim-primary); background: var(--sim-primary); }
.sidebar-toggle:focus-visible { outline: 3px solid rgba(245,158,11,.3); outline-offset: 2px; }
.sidebar-toggle i { font-size: 1.55rem; line-height: 1; }
.mobile-backdrop { display: none; }
.footer { padding: 18px 28px; color: #7a8699; font-size: .84rem; }

.page-loader { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; visibility: hidden; background: rgba(15,23,42,.38); opacity: 0; transition: opacity .16s, visibility .16s; backdrop-filter: blur(2px); }
.page-loader.show { visibility: visible; opacity: 1; }
.page-loader-box { display: grid; min-width: 190px; padding: 24px; justify-items: center; gap: 8px; border-radius: 15px; background: #fff; box-shadow: 0 18px 45px rgba(15,31,61,.25); }
.page-loader-box small { color: var(--sim-muted); }

@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .main-panel { margin-left: 0; }
}
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: none; }
    .main-panel { width: 100vw; max-width: 100vw; margin-left: 0; overflow-x: clip; }
    .topbar, .content-wrap, .footer { width: 100%; max-width: 100vw; }
    .mobile-backdrop.show { position: fixed; inset: 0; z-index: 1025; display: block; background: rgba(15,23,42,.5); }
    .content-wrap { padding: 20px; }
    .topbar { padding: 12px 18px; }
    .header-clock time { display: block; line-height: 1.25; }
    .header-clock strong { display: block; padding: 0; border: 0; }
}
@media (max-width: 575.98px) {
    .page-title { overflow: hidden; font-size: 1.08rem; text-overflow: ellipsis; white-space: nowrap; }
    .content-wrap { padding: 14px; }
    .card-body { padding: 16px; }
    .card-header { padding: 15px 16px; }
    .hide-mobile { display: none!important; }
    .topbar-heading { min-width: 0; flex: 1 1 auto; gap: 8px; overflow: hidden; }
    .topbar-school-logo { width: 34px; height: 34px; flex-basis: 34px; }
    .topbar-school-text .school-name { font-size: .88rem; }
    .topbar-school-text .badge-branch { font-size: .6rem; padding: 1px 5px; }
    .topbar-school-text .school-tagline { display: none; }
    .topbar-actions { gap: 4px; }
    .sidebar-toggle { width: 34px; height: 36px; padding: 0; align-items: center; justify-content: center; }
    .header-help-button { width: 36px; height: 36px; flex-basis: 36px; border-radius: 9px; }
    .header-clock { min-width: 64px; min-height: 36px; padding: 4px 7px; justify-content: center; gap: 0; border-radius: 9px; }
    .header-clock > i, #headerDatePart { display: none; }
    .header-clock strong { font-size: .76rem; }
    .user-menu-button { min-height: 36px; padding: 2px; }
    .user-avatar { width: 32px; height: 32px; }
    .user-menu-button > .bi-chevron-down { display: none; }
    .card-body.p-0 { max-width: 100%; overflow-x: auto; }
    .card-body.p-0 > .table { min-width: 560px; }
    .nav-pills { max-width: 100%; flex-wrap: nowrap!important; overflow-x: auto; scrollbar-width: thin; }
    .nav-pills .nav-link { flex: 0 0 auto; white-space: nowrap; }
    .footer { flex-direction: column; align-items: flex-start; gap: 4px; }
    .context-help-modal .modal-dialog { margin: .75rem; }
    .context-help-modal .modal-body { padding: 1.1rem!important; }
    .footer { padding: 14px; }
    .dt-container { padding: 12px; }
    .dt-container .dt-layout-row { gap: 8px; }
}

/* Metric Cards Global Styling */
.metric-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 0;
    box-shadow: 0 4px 14px rgba(18, 60, 42, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.metric-card:hover {
    box-shadow: 0 6px 18px rgba(18, 60, 42, 0.1);
}
.metric-card .metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.metric-card strong {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: #1a2e1f;
}
.metric-card small {
    display: block;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 3px;
}
.metric-blue .metric-icon, .metric-icon.metric-blue { color: #0284c7; background: #e0f2fe; }
.metric-green .metric-icon, .metric-icon.metric-green { color: #16a34a; background: #dcfce7; }
.metric-orange .metric-icon, .metric-icon.metric-orange { color: #ea580c; background: #ffedd5; }
.metric-red .metric-icon, .metric-icon.metric-red { color: #dc2626; background: #fee2e2; }
.metric-purple .metric-icon, .metric-icon.metric-purple { color: #7c3aed; background: #ede9fe; }

@media print {
    .sidebar, .topbar, .footer, .mobile-backdrop, .page-loader, .no-print { display: none!important; }
    .main-panel { margin: 0; }
    .content-wrap { padding: 0; }
    .card { border: 0; box-shadow: none; }
}
