/* NSCT Portal – application styles (Bootstrap 5 base) */
:root {
    --brand: #0f6b4f; --brand-rgb: 15, 107, 79; --brand-dark: #0b533d;
    --ink: #17212b; --muted: #6b7785; --line: #e6eaee; --surface: #f4f6f8; --card: #ffffff;
    --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --sidebar-w: 264px;
    --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--ink); --bs-border-color: var(--line); --bs-border-radius: .6rem;
}
html[dir="rtl"] { --bs-body-font-family: "Noto Nastaliq Urdu", "Plus Jakarta Sans", system-ui, sans-serif; }
html[dir="rtl"] body { line-height: 2; }
body { font-family: var(--bs-body-font-family); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
h1, h2, h3, h4, h5, h6 { color: inherit; }
.btn { background-image: none; }
.fw-800 { font-weight: 800; }

/* Buttons & brand overrides */
.btn { font-weight: 600; border-radius: .6rem; }
.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-active-border-color: 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); --bs-btn-active-border-color: var(--brand); --bs-btn-disabled-color: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-soft { background: rgba(var(--brand-rgb), .1); color: var(--brand); border: 0; }
.btn-soft:hover { background: rgba(var(--brand-rgb), .18); color: var(--brand-dark); }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--ink); border: 0; background: transparent; }
.btn-icon:hover { background: var(--surface); }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.bg-brand-soft { background: rgba(var(--brand-rgb), .08) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--brand-rgb), .5); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .875rem; color: #3b4652; }
.page-link { color: var(--brand); }
.active > .page-link, .page-link.active { background-color: var(--brand); border-color: var(--brand); }
.nav-pills .nav-link.active { background: var(--brand); }
.nav-pills .nav-link { color: var(--ink); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); }
.progress-bar { background-color: var(--brand); }

/* Brand mark */
.brand-mark { width: 52px; height: 52px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem;
    color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); box-shadow: 0 6px 18px rgba(var(--brand-rgb), .35); }
.brand-mark.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 1.1rem; box-shadow: none; }
.brand-mark.light { background: rgba(255, 255, 255, .15); }
.brand-logo { height: 36px; width: auto; border-radius: 6px; }

/* Cards & stats */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; font-weight: 700; }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.stat-card { padding: 1.1rem 1.25rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.stat-icon { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; }
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.tone-brand { background: rgba(var(--brand-rgb), .1); color: var(--brand); }
.tone-blue { background: #e8f1ff; color: #2563eb; }
.tone-amber { background: #fff4e0; color: #d97706; }
.tone-red { background: #fde8e8; color: #dc2626; }
.tone-violet { background: #f1eaff; color: #7c3aed; }
.tone-teal { background: #e0f7f5; color: #0d9488; }
.tone-slate { background: #eef1f4; color: #475569; }
.badge-soft-success { background: #dcf5e7; color: #15803d; }
.badge-soft-warning { background: #fff2d6; color: #b45309; }
.badge-soft-danger { background: #fde4e4; color: #b91c1c; }
.badge-soft-secondary { background: #eef1f4; color: #475569; }
.badge-soft-info { background: #e0f2fe; color: #0369a1; }
.badge-soft-primary { background: rgba(var(--brand-rgb), .12); color: var(--brand); }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; background: #fafbfc; white-space: nowrap; }
.table-hover tbody tr:hover > * { background: rgba(var(--brand-rgb), .03); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; color: #c3ccd5; }
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--brand-rgb), .12); color: var(--brand); font-weight: 700; }
.section-title { font-weight: 800; letter-spacing: -.01em; }
.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.4rem; font-weight: 800; margin: 0; }
.filter-bar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; margin-bottom: 1rem; }
.meter { height: 8px; border-radius: 99px; background: #edf0f3; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.kv dt { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.kv dd { margin-bottom: .8rem; font-weight: 600; }

/* App shell */
.app-body { background: var(--surface); min-height: 100vh; }
.app-sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
@media (min-width: 992px) {
    .app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1030; }
    html[dir="rtl"] .app-sidebar { inset: 0 0 0 auto; border-right: 0; border-left: 1px solid var(--line); }
    .app-main { margin-left: var(--sidebar-w); }
    html[dir="rtl"] .app-main { margin-left: 0; margin-right: var(--sidebar-w); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); min-height: 66px; }
.brand-text { color: var(--ink); font-weight: 800; line-height: 1.1; font-size: .98rem; }
.brand-text small { display: block; font-weight: 600; color: var(--muted); font-size: .7rem; }
.sidebar-nav { padding: .75rem .7rem; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-group { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #98a3ae; padding: .75rem .75rem .3rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; padding: .45rem .75rem; border-radius: 10px; color: #3d4955; font-weight: 600; font-size: .9rem; margin-bottom: 2px; }
.sidebar-nav .nav-link i { font-size: 1.05rem; color: #8592a0; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--surface); color: var(--ink); }
.sidebar-nav .nav-link.active { background: rgba(var(--brand-rgb), .1); color: var(--brand); }
.sidebar-nav .nav-link.active i { color: var(--brand); }
.sidebar-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.app-topbar { position: sticky; top: 0; z-index: 1020; height: 66px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: .5rem; padding: 0 1rem; }
.topbar-title { font-weight: 700; font-size: 1.02rem; }
.user-btn { border: 0; padding: .25rem .4rem; border-radius: 12px; }
.user-btn:hover { background: var(--surface); }
.notif-dot { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; border-radius: 9px; background: #dc2626; color: #fff; font-size: .65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif-menu { width: 320px; max-width: 92vw; }
.notif-item { white-space: normal; border-bottom: 1px solid var(--line); padding: .6rem 1rem; }
.notif-item.unread { background: rgba(var(--brand-rgb), .05); border-left: 3px solid var(--brand); }
.app-content { padding: 1.5rem; max-width: 1440px; }
.app-footer { padding: 1rem 1.5rem 1.5rem; }
@media (max-width: 575px) { .app-content { padding: 1rem; } }

/* Public site */
.public-body { background: #fff; }
.public-nav { background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.public-nav .nav-link { font-weight: 600; color: #3d4955; font-size: .92rem; }
.public-nav .nav-link.active, .public-nav .nav-link:hover { color: var(--brand); }
.hero { position: relative; overflow: hidden; background: radial-gradient(1200px 500px at 85% -10%, rgba(255, 255, 255, .14), transparent 60%), linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; padding: 5rem 0 6rem; }
.hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, transparent, #000 40%, transparent); pointer-events: none; }
.hero h1 { font-weight: 800; letter-spacing: -.02em; }
.hero .lead { color: rgba(255, 255, 255, .85); }
.hero-card { background: #fff; color: var(--ink); border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .18); padding: 1.4rem; position: relative; z-index: 1; }
.hero-card .q-opt { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem; margin-bottom: .5rem; font-size: .9rem; }
.hero-card .q-opt.correct { border-color: #16a34a; background: #effaf3; }
.stat-strip { margin-top: -3rem; position: relative; z-index: 2; }
.stat-strip .card { border: 0; }
.feature-icon { width: 54px; height: 54px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: rgba(var(--brand-rgb), .1); color: var(--brand); }
.subject-tile { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; height: 100%; color: var(--ink); background: #fff; transition: .15s; }
.subject-tile:hover { border-color: rgba(var(--brand-rgb), .45); box-shadow: var(--shadow); transform: translateY(-2px); color: var(--ink); }
.subject-tile .ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(var(--brand-rgb), .1); color: var(--brand); font-size: 1.25rem; }
.step-num { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.section { padding: 4.5rem 0; }
.section-alt { background: var(--surface); }
.page-banner { background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; padding: 3rem 0; }
.page-banner h1 { font-weight: 800; margin: 0; }
.prose { font-size: 1.02rem; line-height: 1.8; color: #2c3742; }
.cta-band { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; border-radius: 22px; padding: 3rem; }
.public-footer { background: #0f1720; color: #9aa6b2; }
.public-footer a { color: #c6cfd8; }
.public-footer a:hover { color: #fff; }

/* Auth */
.auth-body { background: var(--surface); }
.auth-wrap { min-height: 100vh; display: flex; }
.auth-side { width: 44%; background: radial-gradient(900px 400px at 0% 0%, rgba(255, 255, 255, .12), transparent 60%), linear-gradient(160deg, var(--brand), var(--brand-dark)); padding: 3rem; flex-direction: column; justify-content: space-between; }
.auth-points li { color: rgba(255, 255, 255, .9); padding: .35rem 0; font-size: 1.02rem; }
.auth-points i { margin-right: .5rem; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 480px; }
.auth-card.wide { max-width: 720px; }

/* Installer */
.install-body { background: var(--surface); }
.install-card { border-radius: 18px; }
.install-steps { display: flex; justify-content: space-between; gap: .25rem; overflow-x: auto; padding-bottom: .25rem; }
.install-step { display: flex; flex-direction: column; align-items: center; gap: .3rem; min-width: 80px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.install-step .dot { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #cfd6dd; display: flex; align-items: center; justify-content: center; background: #fff; font-weight: 700; }
.install-step.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.install-step.current .dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .15); }
.install-step.current { color: var(--ink); }

/* Question content */
.q-text { font-size: 1.08rem; line-height: 1.7; }
.q-text code, .opt-text code { background: #f3f4f6; padding: .1rem .35rem; border-radius: 5px; color: #b42318; font-size: .92em; }
.code-block { background: #0f1720; color: #e5e9ee; padding: .9rem 1rem; border-radius: 10px; font-size: .88rem; margin: .6rem 0; overflow-x: auto; }
.code-block code { color: inherit; background: none; padding: 0; }
.q-table { width: auto; margin: .5rem 0; }
.q-image { max-width: 100%; max-height: 320px; border-radius: 10px; border: 1px solid var(--line); margin: .5rem 0; }
.answer-opt { display: flex; gap: .75rem; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin-bottom: .6rem; cursor: pointer; transition: .12s; background: #fff; }
.answer-opt:hover { border-color: rgba(var(--brand-rgb), .45); background: rgba(var(--brand-rgb), .02); }
.answer-opt input { margin-top: .3rem; }
.answer-opt.selected { border-color: var(--brand); background: rgba(var(--brand-rgb), .06); }
.answer-opt .opt-label { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; color: #495562; }
.answer-opt.selected .opt-label { background: var(--brand); color: #fff; }
.review-opt { border: 1.5px solid var(--line); border-radius: 10px; padding: .55rem .85rem; margin-bottom: .45rem; display: flex; gap: .6rem; align-items: flex-start; }
.review-opt.correct { border-color: #16a34a; background: #effaf3; }
.review-opt.wrong { border-color: #dc2626; background: #fef2f2; }
.explanation { background: #f6f8fb; border-left: 4px solid var(--brand); border-radius: 8px; padding: .8rem 1rem; }

/* Test interface */
.test-body { background: var(--surface); min-height: 100vh; }
.test-top { position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--line); height: 64px; display: flex; align-items: center; padding: 0 1rem; gap: 1rem; }
.timer-pill { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem; padding: .4rem .9rem; border-radius: 99px; background: rgba(var(--brand-rgb), .1); color: var(--brand); display: flex; align-items: center; gap: .4rem; }
.timer-pill.warn { background: #fff4e0; color: #b45309; }
.timer-pill.danger { background: #fde8e8; color: #b91c1c; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.test-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; padding: 1.25rem; max-width: 1280px; margin: 0 auto; }
@media (max-width: 991px) { .test-layout { grid-template-columns: 1fr; padding: .75rem; } .palette-col { display: none; } }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: .45rem; }
.palette button { height: 40px; border-radius: 10px; border: 1.5px solid #d5dbe1; background: #fff; font-weight: 700; font-size: .85rem; color: #4a5561; position: relative; }
.palette button.answered { background: #16a34a; border-color: #16a34a; color: #fff; }
.palette button.marked { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.palette button.answered.marked::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; }
.palette button.current { outline: 3px solid rgba(var(--brand-rgb), .35); outline-offset: 1px; border-color: var(--brand); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; color: var(--muted); margin-right: .7rem; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; border: 1.5px solid #d5dbe1; }
.sync-state { font-size: .78rem; }
.offline-banner { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 1100; }

/* Charts */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* Misc */
.leader-rank { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; background: var(--surface); }
.leader-rank.r1 { background: #fde68a; color: #92400e; } .leader-rank.r2 { background: #e5e7eb; color: #374151; } .leader-rank.r3 { background: #fed7aa; color: #9a3412; }
.badge-tile { border: 1px dashed var(--line); border-radius: 12px; padding: .9rem; text-align: center; height: 100%; }
.badge-tile.earned { border-style: solid; border-color: rgba(var(--brand-rgb), .4); background: rgba(var(--brand-rgb), .04); }
.badge-tile i { font-size: 1.8rem; }
.badge-tile:not(.earned) i, .badge-tile:not(.earned) .fw-semibold { opacity: .45; }
.mode-card { display: block; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 1.1rem; height: 100%; color: var(--ink); transition: .15s; }
.mode-card:hover { border-color: rgba(var(--brand-rgb), .5); box-shadow: var(--shadow); color: var(--ink); transform: translateY(-2px); }
.mode-card .ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(var(--brand-rgb), .1); color: var(--brand); font-size: 1.3rem; margin-bottom: .7rem; }
.result-ring { width: 150px; height: 150px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto;
    background: conic-gradient(var(--ring-color, var(--brand)) calc(var(--p) * 1%), #edf0f3 0); }
.result-ring > div { width: 118px; height: 118px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.certificate-preview { border: 8px double rgba(var(--brand-rgb), .5); border-radius: 12px; padding: 2rem; text-align: center; background: #fffdf7; }
@media print { .app-sidebar, .app-topbar, .app-footer, .no-print { display: none !important; } .app-main { margin: 0 !important; } }
