/* SchoolMS styles — sits on top of Bootstrap 5.3 */
:root {
    --sms-primary: #1d4ed8;
    --sms-primary-rgb: 29, 78, 216;
    --sms-sidebar: #0f1b2d;
    --sms-sidebar-2: #16263d;
    --sms-sidebar-text: #aab6c8;
    --sms-accent: #14b8a6;
    --sms-bg: #f3f5f9;
    --sms-border: #e3e8ef;
    --sidebar-w: 256px;
    --bs-primary: var(--sms-primary);
    --bs-primary-rgb: var(--sms-primary-rgb);
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .925rem;
    --bs-body-color: #1f2937;
    --bs-border-color: var(--sms-border);
}
body { background: var(--sms-bg); }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: var(--sms-primary); --bs-btn-border-color: var(--sms-primary); --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; --bs-btn-active-bg: #1e3a8a; }
.btn-outline-primary { --bs-btn-color: var(--sms-primary); --bs-btn-border-color: var(--sms-primary); --bs-btn-hover-bg: var(--sms-primary); --bs-btn-hover-border-color: var(--sms-primary); }
.text-primary { color: var(--sms-primary) !important; }
.bg-primary { background-color: var(--sms-primary) !important; }

/* ---------- layout ---------- */
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
    background: linear-gradient(180deg, var(--sms-sidebar), var(--sms-sidebar-2));
    color: var(--sms-sidebar-text); display: flex; flex-direction: column; transition: transform .2s ease;
}
.app-brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.06); color: #fff; }
.app-brand img { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; }
.app-brand .brand-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--sms-accent); color: #fff; font-size: 1.25rem; flex-shrink: 0; }
.app-brand .brand-name { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.app-brand .brand-sub { font-size: .72rem; color: var(--sms-sidebar-text); }
.app-nav { overflow-y: auto; flex: 1; padding: .6rem .6rem 2rem; scrollbar-width: thin; }
.app-nav .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7a90; padding: 1rem .75rem .35rem; }
.app-nav .nav-link { color: var(--sms-sidebar-text); border-radius: 8px; padding: .5rem .75rem; display: flex; align-items: center; gap: .65rem; font-size: .9rem; }
.app-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.app-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.app-nav .nav-link.active { background: rgba(20,184,166,.16); color: #fff; box-shadow: inset 3px 0 0 var(--sms-accent); }
.app-nav .nav-link .chev { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.app-nav .nav-link[aria-expanded="true"] .chev { transform: rotate(90deg); }
.app-nav .sub .nav-link { padding: .38rem .75rem .38rem 2.6rem; font-size: .85rem; }
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--sms-border); height: 60px; display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; }
.app-content { padding: 1.5rem; flex: 1; }
.app-footer { padding: .9rem 1.5rem; font-size: .78rem; color: #8a94a6; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,27,45,.45); z-index: 1035; }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
}

/* ---------- components ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head .sub { color: #6b7280; font-size: .85rem; }
.card { border-color: var(--sms-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom-color: var(--sms-border); font-weight: 600; padding: .85rem 1.1rem; border-radius: 12px 12px 0 0 !important; }
.table { --bs-table-hover-bg: #f7f9fc; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; background: #f8fafc; white-space: nowrap; }
.table-card { margin: 0; }
.table-card td, .table-card th { vertical-align: middle; }
.badge-status { font-weight: 600; font-size: .72rem; }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: 8px; }
.stat-card { padding: 1.1rem 1.2rem; display: flex; flex-direction: row; gap: 1rem; align-items: center; }
.stat-card .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-card .label { color: #6b7280; font-size: .8rem; }
.icon-blue { background: #e0ebff; color: #1d4ed8; } .icon-teal { background: #d7f5f0; color: #0f8a7c; }
.icon-amber { background: #fff1d6; color: #b45309; } .icon-red { background: #fde2e2; color: #b91c1c; }
.icon-violet { background: #ece6ff; color: #6d28d9; } .icon-slate { background: #e8edf3; color: #334155; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #e0ebff; color: #1d4ed8; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.6rem; border-radius: 16px; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #8a94a6; }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.filter-bar > * { min-width: 150px; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; min-width: 150px; }
.filter-bar .input-group .form-control { min-width: 80px; }
.nav-tabs .nav-link { color: #4b5563; }
.nav-tabs .nav-link.active { color: var(--sms-primary); font-weight: 600; }
.info-list dt { font-weight: 500; color: #6b7280; font-size: .8rem; }
.info-list dd { margin-bottom: .7rem; }
.search-results { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--sms-border); border-radius: 10px; box-shadow: 0 10px 30px rgba(15,27,45,.12); max-height: 320px; overflow-y: auto; }
.search-results .item { padding: .55rem .8rem; cursor: pointer; display: flex; gap: .6rem; align-items: center; border-bottom: 1px solid #f1f4f8; }
.search-results .item:hover, .search-results .item.active { background: #f3f7ff; }
.att-radio .btn { min-width: 40px; }
.marks-input { width: 90px; text-align: center; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--sms-border); padding: .75rem 1rem; z-index: 5; }
.toast-container { z-index: 2000; }
.cursor-pointer { cursor: pointer; }
.small-muted { font-size: .8rem; color: #6b7280; }
.text-money { font-variant-numeric: tabular-nums; }

/* ---------- auth ---------- */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, #dbe7ff, transparent), radial-gradient(900px 500px at 110% 110%, #d5f5ef, transparent), #f3f5f9; min-height: 100vh; }
.auth-card { max-width: 420px; width: 100%; border: 0; border-radius: 16px; box-shadow: 0 20px 50px rgba(15,27,45,.12); }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--sms-primary); color: #fff; font-size: 2rem; }
.auth-logo img { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; background: #fff; }

/* ---------- print ---------- */
.print-page { background: #fff; max-width: 210mm; margin: 0 auto; padding: 12mm; }
.print-toolbar { position: sticky; top: 0; background: #0f1b2d; color: #fff; padding: .6rem 1rem; display: flex; gap: .5rem; align-items: center; z-index: 10; }
.doc-header { display: flex; align-items: center; gap: 14px; border-bottom: 3px double #222; padding-bottom: 8px; margin-bottom: 10px; }
.doc-header img { width: 80px; height: 80px; object-fit: contain; }
.doc-header .school { flex: 1; text-align: center; }
.doc-header .school h2 { margin: 0; font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.doc-header .school div { font-size: 12px; }
.doc-title { text-align: center; font-weight: 700; text-transform: uppercase; background: #eef2f7; padding: 4px; font-size: 14px; margin: 6px 0 10px; letter-spacing: .05em; }
.report-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.report-table th, .report-table td { border: 1px solid #444; padding: 3px 6px; }
.report-table th { background: #eef2f7; text-align: center; }
.page-break { page-break-after: always; break-after: page; }
@media print {
    @page { size: A4; margin: 10mm; }
    body { background: #fff !important; }
    .no-print, .print-toolbar { display: none !important; }
    .print-page { padding: 0; max-width: none; }
}

@media (max-width: 575.98px) {
    .stat-card { padding: .8rem; gap: .6rem; }
    .stat-card .icon { width: 36px; height: 36px; font-size: 1.1rem; }
    .stat-card .value { font-size: 1.05rem; overflow-wrap: anywhere; }
    .page-head h1 { font-size: 1.2rem; }
}

/* ================= Parent / student portal (mobile-first) ================= */
.portal-body { background: #f4f6fa; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
.portal-wrap { max-width: 760px; margin: 0 auto; padding-left: 14px; padding-right: 14px; }
.portal-top { background: #1d4ed8; color: #fff; position: sticky; top: 0; z-index: 1030; padding: 10px 0; box-shadow: 0 2px 10px rgba(15,27,45,.15); }
.portal-brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: .5rem; font-weight: 700; min-width: 0; }
.portal-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-brand img { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; }
.portal-brand i { font-size: 1.4rem; }
.portal-icon-btn, .portal-child-btn { color: #fff; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); }
.portal-icon-btn:hover, .portal-child-btn:hover, .portal-child-btn.show { color: #fff; background: rgba(255,255,255,.18); }
.portal-icon-btn i { font-size: 1.1rem; }
.portal-dot { position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; background: #f43f5e; border-radius: 50%; border: 2px solid #1d4ed8; }
.portal-main { padding-top: 14px; padding-bottom: 14px; }
.portal-tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: #fff; border-top: 1px solid #e3e8ef; display: flex; padding-bottom: env(safe-area-inset-bottom); }
.portal-tabs a { flex: 1; text-align: center; padding: 7px 0 6px; color: #64748b; text-decoration: none; font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.portal-tabs a i { font-size: 1.25rem; }
.portal-tabs a.active { color: #1d4ed8; font-weight: 600; }
.portal-menu .list-group-item { padding: .85rem 1.1rem; display: flex; align-items: center; gap: .75rem; }
.portal-menu .list-group-item i { font-size: 1.1rem; color: #1d4ed8; width: 1.3rem; }
.portal-body .card { border: 0; border-radius: 14px; box-shadow: 0 1px 3px rgba(15,27,45,.07); }
.portal-h { font-size: 1.15rem; font-weight: 700; margin: 4px 0 12px; }
.child-card { display: flex; align-items: center; gap: 12px; }
.child-card .avatar-lg { width: 56px; height: 56px; }
.tile { display: block; background: #fff; border-radius: 14px; padding: 12px; text-decoration: none; color: inherit; box-shadow: 0 1px 3px rgba(15,27,45,.07); height: 100%; }
.tile .t-label { font-size: .75rem; color: #64748b; }
.tile .t-value { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.tile i { font-size: 1.1rem; }
.portal-list .list-group-item { padding: .8rem 1rem; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.chat .bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(15,27,45,.08); white-space: pre-wrap; word-wrap: break-word; }
.chat .bubble.me { align-self: flex-end; background: #dbe7ff; }
.chat .meta { font-size: .7rem; color: #64748b; margin-top: 2px; }
.tt-day { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.tt-day .btn { white-space: nowrap; }
.result-row { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid #f1f4f8; }
.result-row:last-child { border-bottom: 0; }
.grade-pill { min-width: 42px; text-align: center; font-weight: 700; border-radius: 8px; padding: 2px 8px; background: #eef2ff; color: #1d4ed8; }
@media (min-width: 992px) { .portal-body { padding-bottom: 20px; } .portal-tabs { position: sticky; max-width: 760px; margin: 0 auto 0; border: 0; border-radius: 14px; box-shadow: 0 1px 3px rgba(15,27,45,.07); bottom: 12px; } }
