/* =========================================================
   BD Education Board Result Checker – Plugin Styles
   PECE-style design: Sora + Hind Siliguri, blue palette
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@400;500;600;700&family=Sora:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
.bdrc-wrapper {
    --bdrc-primary:    #1a56db;
    --bdrc-primary-dk: #1341b0;
    --bdrc-accent:     #0ea5e9;
    --bdrc-success:    #065f46;
    --bdrc-success-bg: #064e3b;
    --bdrc-danger:     #ef4444;
    --bdrc-danger-bg:  #7f1d1d;
    --bdrc-bg:         #f0f4ff;
    --bdrc-card:       #ffffff;
    --bdrc-border:     #dbe4f7;
    --bdrc-text:       #1e293b;
    --bdrc-muted:      #64748b;
    --bdrc-radius:     14px;
    --bdrc-shadow:     0 4px 24px rgba(26,86,219,.12);

    font-family: 'Sora', 'Hind Siliguri', sans-serif;
    color: var(--bdrc-text);
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

.bdrc-wrapper * { box-sizing: border-box; }

/* ── Page Title ─────────────────────────────────────────── */
.bdrc-main-title {
    text-align: center;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--bdrc-primary);
    margin: 0 0 .25rem;
    letter-spacing: -.5px;
}
.bdrc-main-title::after {
    content: '';
    display: block;
    width: 48px;
    height: 4px;
    background: var(--bdrc-primary);
    border-radius: 4px;
    margin: .5rem auto 1.6rem;
}

/* ── Form Card ──────────────────────────────────────────── */
.bdrc-form {
    background: var(--bdrc-card);
    border: 1.5px solid var(--bdrc-border);
    border-radius: var(--bdrc-radius);
    padding: 1.6rem 1.8rem;
    box-shadow: var(--bdrc-shadow);
    margin-bottom: 1.2rem;
}

.bdrc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.3rem;
}

@media (max-width: 580px) {
    .bdrc-grid  { grid-template-columns: 1fr; }
    .bdrc-form  { padding: 1.2rem 1rem 1.4rem; }
}

/* ── Form Fields ────────────────────────────────────────── */
.bdrc-field {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.bdrc-field label {
    font-weight: 700;
    font-size: .88rem;
    color: var(--bdrc-text);
}

.bdrc-req { color: var(--bdrc-danger); margin-left: 2px; }

.bdrc-field input,
.bdrc-field select {
    padding: .7rem 1rem;
    border: 1.5px solid var(--bdrc-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Sora', sans-serif;
    color: var(--bdrc-text);
    background: #f8faff;
    outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
}

.bdrc-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-color: #f8faff;
    padding-right: 2.5rem;
    cursor: pointer;
}

.bdrc-field input:focus,
.bdrc-field select:focus {
    border-color: var(--bdrc-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
    background: #fff;
}

.bdrc-field input::placeholder { color: var(--bdrc-muted); }

#bdrc-district-loading {
    display: block;
    font-size: .8rem;
    color: var(--bdrc-accent);
    margin-top: 2px;
}

/* ── Captcha Row ────────────────────────────────────────── */
.bdrc-captcha-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 1.2rem;
    padding: 1rem 1.1rem;
    background: var(--bdrc-bg);
    border: 1.5px solid var(--bdrc-border);
    border-radius: 8px;
}

.bdrc-captcha-image-wrap {
    flex: 0 0 auto;
    min-width: 150px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1.5px solid var(--bdrc-border);
    border-radius: 6px;
    overflow: hidden;
}

#bdrc-captcha-img  { max-height: 50px; width: auto; display: block; }
#bdrc-captcha-loading { font-size: .78rem; color: var(--bdrc-muted); padding: 0 8px; }

.bdrc-btn-sm {
    padding: .5rem .75rem !important;
    font-size: 1.1rem !important;
    height: 40px;
    align-self: flex-end;
    border-radius: 6px !important;
    min-width: 40px;
}

.bdrc-captcha-field { flex: 1 1 160px; }
.bdrc-captcha-field input { letter-spacing: 2px; font-weight: 600; }

/* ── Buttons ────────────────────────────────────────────── */
.bdrc-actions {
    display: flex;
    gap: .7rem;
    margin-top: 1.2rem;
    flex-wrap: wrap;
}

.bdrc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1.4rem;
    border: none;
    border-radius: 8px;
    font-family: 'Sora', sans-serif;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}

.bdrc-btn-primary               { background: var(--bdrc-primary); color: #fff; }
.bdrc-btn-primary:hover         { background: var(--bdrc-primary-dk); }
.bdrc-btn-primary:active        { transform: scale(.97); }
.bdrc-btn-primary:disabled      { opacity: .55; cursor: not-allowed; }

.bdrc-btn-secondary             { background: transparent; color: var(--bdrc-primary); border: 1.5px solid var(--bdrc-primary); }
.bdrc-btn-secondary:hover       { background: var(--bdrc-bg); }
.bdrc-btn-secondary:active      { transform: scale(.97); }

/* Spinner */
.bdrc-spinner {
    width: 16px; height: 16px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bdrc-spin .7s linear infinite;
}
@keyframes bdrc-spin { to { transform: rotate(360deg); } }

/* ── Message bar ────────────────────────────────────────── */
.bdrc-message {
    margin-top: .75rem;
    padding: .65rem 1rem;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}
.bdrc-message.bdrc-msg-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--bdrc-danger); }
.bdrc-message.bdrc-msg-info  { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ── Result Card wrapper ────────────────────────────────── */
.bdrc-result-card {
    animation: bdrc-fadein .4s ease;
}
@keyframes bdrc-fadein {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bdrc-card {
    background: var(--bdrc-card);
    border: 1.5px solid var(--bdrc-border);
    border-radius: var(--bdrc-radius);
    box-shadow: var(--bdrc-shadow);
    overflow: hidden;
}

/* ── Result Card Header ─────────────────────────────────── */
.bdrc-card-header {
    background: var(--bdrc-primary);
    color: #fff;
    padding: 1.3rem 1.5rem 1.1rem;
    position: relative;
    overflow: hidden;
}

/* Top row: org name + exam meta */
.bdrc-card-header-top {
    text-align: center;
    margin-bottom: 0;
    padding-bottom: 0;
}
.bdrc-org {
    font-size: .78rem;
    opacity: .8;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: .2rem;
}
.bdrc-exam-meta {
    font-family: 'Hind Siliguri', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    opacity: .9;
}

/* Bottom row: name/roll left — GPA/badge right */
.bdrc-card-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
}
.bdrc-header-left  { display: flex; flex-direction: column; gap: .15rem; }
.bdrc-header-right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }

.bdrc-student-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.01em;
    line-height: 1.2;
}
.bdrc-student-roll {
    font-size: .8rem;
    opacity: .75;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.bdrc-result-badge {
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    background: rgba(255,255,255,.18);
    padding: .3rem .9rem;
    border-radius: 999px;
    border: 1.5px solid rgba(255,255,255,.28);
}
.bdrc-gpa-badge {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.02em;
}
.bdrc-gpa-label {
    font-size: .7rem;
    opacity: .65;
    text-transform: uppercase;
    letter-spacing: .08em;
    text-align: right;
}

/* ── Card Body ──────────────────────────────────────────── */
.bdrc-card-body { background: var(--bdrc-card); }

/* ── Marksheet title ────────────────────────────────────── */
.bdrc-marksheet-title {
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bdrc-primary);
    padding: 1rem 1.5rem .4rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* ── Info Grid (2-column) ───────────────────────────────── */
.bdrc-info-grid {
    padding: .6rem 1.5rem .8rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem 1.5rem;
    border-bottom: 1.5px solid var(--bdrc-border);
}

@media (max-width: 480px) {
    .bdrc-info-grid { grid-template-columns: 1fr; }
}

.bdrc-info-item {
    display: flex;
    flex-direction: column;
    padding: .38rem 0;
    border-bottom: 1px solid #f1f5fd;
}
.bdrc-info-key {
    font-size: .7rem;
    color: var(--bdrc-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    margin-bottom: .12rem;
}
.bdrc-info-val {
    font-family: 'Hind Siliguri', sans-serif;
    font-size: 1rem;
    color: var(--bdrc-text);
    font-weight: 600;
}

/* ── Result / GPA row ───────────────────────────────────── */
.bdrc-result-row {
    background: var(--bdrc-bg);
    margin: .8rem 1.5rem;
    border-radius: 10px;
    padding: .8rem 1.2rem;
}
.bdrc-result-row-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.bdrc-gpa-display {
    text-align: center;
}
.bdrc-gpa-num {
    display: block;
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--bdrc-primary);
    line-height: 1;
}
.bdrc-gpa-unit {
    font-size: .7rem;
    color: var(--bdrc-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: .2rem;
    display: block;
}
.bdrc-status-pill {
    font-size: 1.05rem;
    font-weight: 700;
    padding: .45rem 1.2rem;
    border-radius: 999px;
}
.bdrc-status-passed { background: #d1fae5; color: #065f46; }
.bdrc-status-failed { background: #fee2e2; color: #991b1b; }

/* ── Subject Grades ─────────────────────────────────────── */
.bdrc-grades-section {
    padding: .8rem 1.5rem .5rem;
}
.bdrc-section-title {
    font-size: .8rem;
    font-weight: 700;
    color: var(--bdrc-muted);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.bdrc-section-title::after {
    content: '';
    flex: 1;
    height: 1.5px;
    background: var(--bdrc-border);
}

/* Grade table */
.bdrc-grades-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 1.5px solid var(--bdrc-border);
}
.bdrc-grades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    min-width: 260px;
}
.bdrc-grades-table thead tr {
    background: var(--bdrc-primary);
    color: #fff;
}
.bdrc-grades-table thead th {
    padding: .6rem 1rem;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: left;
    white-space: nowrap;
}
.bdrc-grades-table tbody tr {
    border-bottom: 1px solid var(--bdrc-border);
    transition: background .12s;
}
.bdrc-grades-table tbody tr:last-child { border-bottom: none; }
.bdrc-grades-table tbody tr:nth-child(even) { background: #f8faff; }
.bdrc-grades-table tbody tr:hover { background: #eef3ff; }
.bdrc-grades-table td {
    padding: .55rem 1rem;
    vertical-align: middle;
}
.bdrc-gt-code {
    font-size: .75rem;
    color: var(--bdrc-muted);
    white-space: nowrap;
    width: 70px;
}
.bdrc-gt-subj { word-break: break-word; }
.bdrc-gt-grade {
    white-space: nowrap;
    width: 72px;
    text-align: center;
}
.bdrc-grade-badge {
    display: inline-block;
    padding: .2rem .7rem;
    border-radius: 99px;
    font-weight: 800;
    font-size: .85rem;
    border: 1.5px solid transparent;
}

/* Grade colours — applied to .bdrc-grade-badge spans */
.bdrc-grade-aplus  { color: #0369a1; border-color: #0ea5e9; background: #e0f2fe; }
.bdrc-grade-a      { color: #065f46; border-color: #10b981; background: #d1fae5; }
.bdrc-grade-aminus { color: #3a5c05; border-color: #65a30d; background: #ecfccb; }
.bdrc-grade-b      { color: #1e40af; border-color: #3b82f6; background: #dbeafe; }
.bdrc-grade-c      { color: #92400e; border-color: #f59e0b; background: #fef3c7; }
.bdrc-grade-d      { color: #7c2d12; border-color: #ea580c; background: #ffedd5; }
.bdrc-grade-f      { color: #7f1d1d; border-color: #ef4444; background: #fee2e2; }

/* ── Disclaimer ─────────────────────────────────────────── */
.bdrc-disclaimer {
    margin: 0;
    padding: .9rem 1.5rem;
    background: #fffbeb;
    border-top: 1.5px solid #fde68a;
    font-size: .78rem;
    color: #92400e;
    display: flex;
    align-items: flex-start;
    gap: .4rem;
}
.bdrc-disclaimer::before { content: '⚠'; flex-shrink: 0; margin-top: 1px; }

/* ── Result actions (Print / New Search) ────────────────── */
.bdrc-result-actions {
    display: flex;
    justify-content: flex-end;
    gap: .7rem;
    padding: .8rem 1.5rem 1.2rem;
    border-top: 1px solid var(--bdrc-border);
}

/* ── Institution / District ─────────────────────────────── */

/* School info card */
.bdrc-school-card {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    margin: 1.1rem 1.2rem .2rem;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 12px;
    padding: .9rem 1rem;
}
.bdrc-school-icon-wrap {
    flex-shrink: 0;
    width: 46px; height: 46px;
    background: var(--bdrc-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.bdrc-school-details { flex: 1; min-width: 0; }
.bdrc-school-name {
    font-size: .95rem;
    font-weight: 700;
    color: var(--bdrc-text);
    line-height: 1.3;
    margin-bottom: .45rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}
.bdrc-eiin-badge {
    display: inline-block;
    font-size: .68rem;
    font-weight: 700;
    background: var(--bdrc-primary);
    color: #fff;
    padding: .15rem .55rem;
    border-radius: 999px;
    letter-spacing: .04em;
    white-space: nowrap;
}
.bdrc-school-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .75rem;
}
.bdrc-school-meta-item {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    font-size: .75rem;
    color: var(--bdrc-muted);
    font-weight: 500;
}
.bdrc-school-meta-item svg { flex-shrink: 0; }

/* Stats section */
.bdrc-stats-section {
    padding: 1rem 1.2rem .4rem;
}
.bdrc-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: .6rem;
}
.bdrc-stat-card {
    border-radius: 12px;
    padding: .75rem .6rem .65rem;
    text-align: center;
    border: 1.5px solid transparent;
    transition: transform .15s, box-shadow .15s;
    min-width: 0;
    word-break: keep-all;
    overflow-wrap: normal;
    hyphens: none;
}
.bdrc-stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.bdrc-stat-icon { margin-bottom: .35rem; opacity: .75; }
.bdrc-stat-val {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .2rem;
}
.bdrc-stat-lbl {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .75;
    word-break: keep-all;
    overflow-wrap: normal;
    hyphens: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stat card colour themes */
.bdrc-stat-blue   { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.bdrc-stat-indigo { background: #e0e7ff; border-color: #a5b4fc; color: #3730a3; }
.bdrc-stat-green  { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.bdrc-stat-teal   { background: #ccfbf1; border-color: #5eead4; color: #0f766e; }
.bdrc-stat-gold   { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

/* Group section */
.bdrc-group-section { padding: .8rem 1.2rem 1rem; }

.bdrc-group-cards { display: flex; flex-direction: column; gap: .65rem; }

.bdrc-group-card {
    background: #f8faff;
    border: 1.5px solid var(--bdrc-border);
    border-radius: 10px;
    padding: .85rem 1rem;
    transition: border-color .2s;
}
.bdrc-group-card:hover { border-color: var(--bdrc-primary); }

.bdrc-group-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}
.bdrc-group-name {
    font-size: .88rem;
    font-weight: 700;
    color: var(--bdrc-text);
}
.bdrc-group-pct {
    font-size: .9rem;
    font-weight: 800;
    color: var(--bdrc-primary);
}

/* Pass rate progress bar */
.bdrc-group-bar-wrap {
    height: 6px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: .6rem;
}
.bdrc-group-bar {
    height: 100%;
    background: var(--bdrc-primary);
    border-radius: 99px;
    transition: width .4s ease;
}

/* Group mini stats row */
.bdrc-group-stats {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.bdrc-gs {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 999px;
}
.bdrc-gs-pass  { background: #d1fae5; color: #065f46; }
.bdrc-gs-fail  { background: #fee2e2; color: #991b1b; }
.bdrc-gs-gpa5  { background: #fef3c7; color: #92400e; }

/* Fallback raw HTML table styles */
.bdrc-html-result { padding: 1.4rem; overflow-x: auto; }
.bdrc-html-result table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: .88rem !important;
    font-family: 'Hind Siliguri', 'Sora', sans-serif !important;
    background: var(--bdrc-card) !important;
}
.bdrc-html-result table th,
.bdrc-html-result table td {
    padding: .6rem .9rem !important;
    border: 1px solid var(--bdrc-border) !important;
    text-align: left !important;
    vertical-align: middle !important;
    color: var(--bdrc-text) !important;
}
.bdrc-html-result table thead th,
.bdrc-html-result table tr:first-child td,
.bdrc-html-result table tr:first-child th {
    background: var(--bdrc-primary) !important;
    color: #fff !important;
    font-weight: 600 !important;
    font-size: .78rem !important;
    text-transform: uppercase !important;
    letter-spacing: .06em !important;
    white-space: nowrap;
}
.bdrc-html-result table tbody tr:nth-child(even) td { background: #f8faff !important; }
.bdrc-html-result table tbody tr:hover td           { background: var(--bdrc-bg) !important; }

.bdrc-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bdrc-table-scroll::-webkit-scrollbar       { height: 5px; }
.bdrc-table-scroll::-webkit-scrollbar-track { background: #f8faff; }
.bdrc-table-scroll::-webkit-scrollbar-thumb { background: var(--bdrc-border); border-radius: 99px; }

/* ── Mobile tweaks for institution card ─────────────────── */
@media (max-width: 480px) {
    .bdrc-school-card      { margin: .8rem .8rem .2rem; padding: .75rem .85rem; }
    .bdrc-school-icon-wrap { width: 40px; height: 40px; border-radius: 8px; }
    .bdrc-school-icon-wrap svg { width: 22px; height: 22px; }
    .bdrc-school-name      { font-size: .88rem; }
    .bdrc-stats-section    { padding: .8rem .8rem .4rem; }
    .bdrc-stats-grid       { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .45rem; }
    .bdrc-stat-val         { font-size: 1.2rem; }
    .bdrc-group-section    { padding: .6rem .8rem .8rem; }
    .bdrc-group-card       { padding: .75rem .85rem; }
}

/* PDF button icon alignment */
.bdrc-btn svg { vertical-align: middle; margin-right: .35rem; margin-top: -2px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .bdrc-main-title       { font-size: 1.35rem; }
    .bdrc-student-name     { font-size: 1.1rem; }
    .bdrc-gpa-badge        { font-size: 1.25rem; }
    .bdrc-info-grid        { padding: .5rem 1rem .6rem; }
    .bdrc-grades-section   { padding: .7rem 1rem .4rem; }
    .bdrc-result-actions   { padding: .7rem 1rem 1rem; }
    .bdrc-disclaimer       { padding: .8rem 1rem; }
    .bdrc-marksheet-title  { padding: .8rem 1rem .3rem; }
    .bdrc-result-row       { margin: .6rem 1rem; }
    .bdrc-card-header      { padding: 1.1rem 1rem; }
    .bdrc-grades-table-wrap { border-radius: 6px; }
    .bdrc-grades-table thead th,
    .bdrc-grades-table td  { padding: .45rem .75rem; font-size: .8rem; }
    .bdrc-gt-code          { display: none; }
    .bdrc-html-result      { padding: .75rem; }
}

/* ── Print styles ───────────────────────────────────────── */
@media print {
    /* Hide every element by default using visibility (avoids display:none ancestor trap) */
    * { visibility: hidden !important; }

    /* Make the result card and ALL its descendants visible */
    #bdrc-printable,
    #bdrc-printable * { visibility: visible !important; }

    /* Position card at top-left of print canvas */
    #bdrc-printable {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* Hide action buttons */
    .bdrc-no-print,
    .bdrc-no-print * { visibility: hidden !important; display: none !important; }

    /* Strip all backgrounds for a clean white PDF */
    * {
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
    }

    /* Keep grade badge text colours readable with just a border */
    .bdrc-grade-badge { border: 1.5px solid currentColor !important; }

    /* Restore code column that was hidden on mobile */
    .bdrc-gt-code { display: table-cell !important; }

    /* Table header text visible without coloured background */
    .bdrc-grades-table thead th { color: #111 !important; font-weight: 700 !important; }
}

/* ================================================================
   District Result Styles
   ================================================================ */

/* District header - mirrors bdrc-school-card styling */
.bdrc-district-header {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin: 1rem 1.2rem .6rem;
    background: #f0f4ff;
    border: 1px solid var(--bdrc-border);
    border-left: 4px solid var(--bdrc-primary);
    border-radius: var(--bdrc-radius-sm);
    padding: .9rem 1.1rem;
}

.bdrc-district-icon-wrap {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--bdrc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.bdrc-district-info { flex: 1; min-width: 0; }

.bdrc-district-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bdrc-text);
    line-height: 1.3;
    letter-spacing: -.01em;
}

.bdrc-district-count {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-top: .3rem;
    font-size: .8rem;
    color: var(--bdrc-text-muted);
    font-weight: 500;
}

/* Container for all institution blocks */
.bdrc-district-institutions {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: .4rem 0 0;
}

/* Each institution block */
.bdrc-dist-inst-block {
    border-top: 1px solid var(--bdrc-border);
    padding: .8rem 1.2rem 1rem;
}

.bdrc-dist-inst-block:first-child { border-top: none; }

/* Institution header row inside district */
.bdrc-dist-inst-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .65rem;
}

.bdrc-dist-inst-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bdrc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: .85;
}

.bdrc-dist-inst-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .45rem;
    min-width: 0;
}

.bdrc-dist-inst-name {
    font-size: .88rem;
    font-weight: 700;
    color: var(--bdrc-text);
    letter-spacing: -.01em;
    line-height: 1.35;
}

/* Compact stats grid for district institution rows */
.bdrc-dist-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-bottom: .65rem;
}

.bdrc-stat-sm.bdrc-stat-card {
    flex: 1 1 70px;
    min-width: 70px;
    padding: .45rem .5rem;
}

.bdrc-stat-sm .bdrc-stat-val { font-size: 1rem; }
.bdrc-stat-sm .bdrc-stat-lbl { font-size: .65rem; }
.bdrc-stat-sm .bdrc-stat-icon { display: none; }

/* Group cards inside district - inherit existing .bdrc-group-cards */
.bdrc-dist-group-cards {
    margin-top: .1rem;
}

/* Responsive */
@media (max-width: 600px) {
    .bdrc-district-header {
        margin: .8rem .8rem .4rem;
        padding: .75rem .85rem;
    }
    .bdrc-dist-inst-block {
        padding: .65rem .8rem .85rem;
    }
    .bdrc-district-name { font-size: .95rem; }
    .bdrc-dist-inst-name { font-size: .82rem; }
}

/* ============================================================
   DISTRICT RESULT TABLE  (table-based design)
   ============================================================ */

/* Wrapper */
.bdrc-district-table-wrap {
    margin: .8rem 0 0;
    border-radius: var(--bdrc-radius-sm);
    overflow: hidden;
    border: 1.5px solid var(--bdrc-border);
}

/* ── Summary grid (replaces flat bar) ── */
.bdrc-dist-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    background: #f0f4ff;
    border-bottom: 1.5px solid var(--bdrc-border);
}
.bdrc-dist-sgrid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem .75rem .9rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    border-right: 1px solid var(--bdrc-border);
    gap: .2rem;
}
.bdrc-dist-sgrid-item:last-child { border-right: none; }

.bdrc-dist-sgrid-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-bottom: .25rem;
}
.bdrc-dist-sgrid-val {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.02em;
}
.bdrc-dist-sgrid-lbl {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bdrc-text-muted);
    white-space: nowrap;
}

/* Per-item colours */
.bdrc-sgrid-schools .bdrc-dist-sgrid-icon { background: #eff6ff; color: #2563eb; }
.bdrc-sgrid-schools .bdrc-dist-sgrid-val  { color: #2563eb; }

.bdrc-sgrid-pass .bdrc-dist-sgrid-icon { background: #f0fdf4; color: #16a34a; }
.bdrc-sgrid-pass .bdrc-dist-sgrid-val  { color: #16a34a; }

.bdrc-sgrid-fail .bdrc-dist-sgrid-icon { background: #fef2f2; color: #dc2626; }
.bdrc-sgrid-fail .bdrc-dist-sgrid-val  { color: #dc2626; }

.bdrc-sgrid-gpa5 .bdrc-dist-sgrid-icon { background: #fffbeb; color: #d97706; }
.bdrc-sgrid-gpa5 .bdrc-dist-sgrid-val  { color: #d97706; }

.bdrc-sgrid-pct .bdrc-dist-sgrid-icon { background: #f5f3ff; color: #7c3aed; }
.bdrc-sgrid-pct .bdrc-dist-sgrid-val  { color: #7c3aed; }

/* ── Modern search bar ── */
.bdrc-dist-search-wrap {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--bdrc-border);
}
.bdrc-dist-search-inner {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}
.bdrc-dist-filter-input {
    width: 100%;
    border: 1.5px solid var(--bdrc-border);
    border-radius: 10px;
    padding: .62rem 2.6rem .62rem .9rem;
    font-size: .85rem;
    outline: none;
    color: var(--bdrc-text);
    background: #f7f9ff;
    transition: border-color .2s, background .2s, box-shadow .2s;
    line-height: 1.4;
}
.bdrc-dist-filter-input::placeholder { color: #aab4cc; }
.bdrc-dist-filter-input:focus {
    border-color: var(--bdrc-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, .1);
}
.bdrc-dist-search-clear {
    position: absolute;
    right: .7rem;
    top: 50%;
    transform: translateY(-50%);
    background: #e8eeff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--bdrc-text-muted);
    transition: background .15s, color .15s, opacity .2s;
    padding: 0;
    line-height: 1;
}
.bdrc-dist-search-clear:hover {
    background: #d1d5f0;
    color: var(--bdrc-text);
}
.bdrc-dist-search-meta {
    font-size: .76rem;
    color: var(--bdrc-primary);
    font-weight: 600;
    white-space: nowrap;
    background: #eef2ff;
    padding: .3rem .65rem;
    border-radius: 99px;
    letter-spacing: .01em;
}

/* Scroll container */
.bdrc-dist-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 72vh;
    overflow-y: auto;
}
.bdrc-dist-table-scroll::-webkit-scrollbar { width: 5px; height: 5px; }
.bdrc-dist-table-scroll::-webkit-scrollbar-track { background: #f0f4ff; }
.bdrc-dist-table-scroll::-webkit-scrollbar-thumb { background: var(--bdrc-border); border-radius: 99px; }

/* Main district table */
.bdrc-dist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .83rem;
    background: #fff;
}

/* Sticky header */
.bdrc-dist-table thead tr {
    position: sticky;
    top: 0;
    z-index: 2;
}
.bdrc-dist-table thead th {
    background: var(--bdrc-primary);
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .7rem 1rem;
    border: none;
    white-space: nowrap;
    text-align: left;
}
.bdrc-dist-table thead th.bdrc-dt-num { text-align: center; }

/* Row styles */
.bdrc-dist-table tbody tr { border-bottom: 1px solid #e8eeff; }
.bdrc-dist-table tbody tr:last-child { border-bottom: none; }
.bdrc-dist-table tbody tr:hover td { background: #f0f5ff !important; }

/* Alternating institution shading */
.bdrc-dist-table tbody tr.bdrc-dt-row:nth-of-type(odd) td.bdrc-dt-sl,
.bdrc-dist-table tbody tr.bdrc-dt-row:nth-of-type(odd) td.bdrc-dt-inst {
    background: #f4f7ff;
}

/* Cell padding — comfortable */
.bdrc-dist-table td {
    padding: .65rem 1rem;
    vertical-align: middle;
    color: var(--bdrc-text);
}
.bdrc-dt-sl {
    width: 40px;
    text-align: center;
    font-size: .73rem;
    color: var(--bdrc-text-muted);
    font-weight: 600;
    background: #f0f4ff;
    border-right: 1px solid #e0e7ff;
    padding: .65rem .6rem;
}
.bdrc-dt-inst {
    min-width: 200px;
    max-width: 300px;
    background: #f8faff;
    border-right: 1px solid #e8eeff;
}
.bdrc-dt-inst-name {
    font-weight: 700;
    font-size: .81rem;
    color: var(--bdrc-text);
    line-height: 1.4;
}
.bdrc-dt-inst-eiin {
    font-size: .71rem;
    color: var(--bdrc-text-muted);
    margin-top: .15rem;
}
.bdrc-dt-group { white-space: nowrap; padding-left: 1rem; padding-right: 1rem; }
.bdrc-dt-num {
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    padding: .65rem .85rem;
}

/* Group badges */
.bdrc-dt-group-badge {
    display: inline-block;
    padding: .25rem .6rem;
    border-radius: 4px;
    font-size: .71rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.bdrc-dt-group-science          { background: #dbeafe; color: #1d4ed8; }
.bdrc-dt-group-humanities       { background: #d1fae5; color: #065f46; }
.bdrc-dt-group-business-studies { background: #fef3c7; color: #92400e; }
.bdrc-dt-group-badge:not([class*="bdrc-dt-group-s"]):not([class*="bdrc-dt-group-h"]):not([class*="bdrc-dt-group-b"]) {
    background: #f1f5f9; color: #475569;
}

/* Column value colours */
.bdrc-dt-pass { color: #059669; font-weight: 700; }
.bdrc-dt-fail { color: #dc2626; font-weight: 700; }
.bdrc-dt-gpa5 { color: #d97706; font-weight: 700; }

/* Pass% badge */
.bdrc-dt-pct-badge {
    display: inline-block;
    padding: .22rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}
.bdrc-pct-high { background: #dcfce7; color: #15803d; }
.bdrc-pct-mid  { background: #fef9c3; color: #854d0e; }
.bdrc-pct-low  { background: #fee2e2; color: #b91c1c; }

/* No-results message */
.bdrc-dist-no-results {
    padding: 1.8rem;
    text-align: center;
    color: var(--bdrc-text-muted);
    font-size: .85rem;
    background: #f8faff;
    border-top: 1px solid var(--bdrc-border);
}

/* Responsive — auto-fit handles column collapsing; just tune padding on small screens */
@media (max-width: 640px) {
    .bdrc-dist-sgrid-item { padding: .75rem .5rem .7rem; }
    .bdrc-dist-sgrid-val  { font-size: 1rem; }
    .bdrc-dist-sgrid-lbl  { font-size: .65rem; }

    .bdrc-dist-table thead th { font-size: .67rem; padding: .65rem .7rem; }
    .bdrc-dist-table td       { padding: .6rem .7rem; font-size: .78rem; }
    .bdrc-dt-num              { padding: .6rem .6rem; }
    .bdrc-dt-inst { min-width: 150px; }
    .bdrc-dt-inst-name { font-size: .76rem; }
}

@media print {
    .bdrc-dist-table-scroll { max-height: none; overflow: visible; }
    .bdrc-dist-search-wrap, .bdrc-dist-filter-input { display: none; }
}
