* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, "Segoe UI", sans-serif;
    color: #1a1a1a;
    background: linear-gradient(135deg, #e8f6fc 0%, #f5f8fb 50%, #fff4ee 100%);
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #e8f6fc 0%, #f5f8fb 50%, #fff4ee 100%);
}

.login-card {
    background: #fff;
    border: 3px double #0f9ed5;
    border-radius: 10px;
    padding: 32px 40px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 8px 28px rgba(15, 158, 213, 0.2);
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 1rem;
    margin-bottom: 2px;
    line-height: 1.4;
    color: #156082;
    font-weight: 800;
}

.login-header .college-sub {
    font-size: 0.9rem;
    color: #156082;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 0.85rem;
    color: #333;
    font-weight: 600;
}

.login-header .subtitle {
    margin-top: 12px;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(90deg, #0f9ed5 0%, #0b769f 100%);
    display: inline-block;
    padding: 6px 16px;
    border-radius: 4px;
}

.login-form {
    margin-top: 28px;
    text-align: left;
}

.login-form label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: #156082;
}

.login-form input {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    border: 2px solid #60caf3;
    border-radius: 6px;
    font-family: inherit;
    text-transform: uppercase;
    background: #f7fcff;
}

.login-form button {
    width: 100%;
    margin-top: 16px;
    padding: 11px;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(90deg, #0f9ed5 0%, #0b769f 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}

.login-form button:hover {
    background: linear-gradient(90deg, #0b769f 0%, #156082 100%);
}

.login-note {
    margin-top: 20px;
    font-size: 0.8rem;
    color: #555;
}

.login-note a {
    color: #0b769f;
    font-weight: 600;
    text-decoration: none;
}

.login-note a:hover {
    text-decoration: underline;
}

.error-msg {
    background: #fde8e8;
    color: #b00020;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* Marks memo page */
.memo-page {
    padding: 24px 16px;
}

.memo-actions {
    max-width: 860px;
    margin: 0 auto 16px;
    display: flex;
    gap: 12px;
}

.memo-actions button,
.btn-back {
    padding: 8px 16px;
    font-size: 0.9rem;
    border: 1px solid #0f9ed5;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: #0b769f;
    font-family: inherit;
    font-weight: 600;
}

.memo-actions button {
    background: #0f9ed5;
    color: #fff;
}

.memo-actions button:hover {
    background: #0b769f;
}

.memo-sheet.certificate {
    max-width: 860px;
    margin: 0 auto;
    background: #fff;
    padding: 0;
    border: none;
    box-shadow: 0 8px 32px rgba(15, 158, 213, 0.18);
    border-radius: 4px;
    overflow: hidden;
}

.certificate-frame {
    padding: 24px 36px 32px;
    border: 4px double #0f9ed5;
    margin: 8px;
    background:
        linear-gradient(180deg, rgba(202, 237, 251, 0.35) 0%, rgba(255, 255, 255, 0) 120px),
        #fff;
}

.memo-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid #60caf3;
}

.memo-logo {
    width: 105px;
    height: 105px;
    object-fit: contain;
    flex-shrink: 0;
}

.memo-title-block {
    flex: 1;
    text-align: center;
    padding-top: 2px;
}

.memo-title-block h1 {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 0;
    color: #156082;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.memo-title-block .college-sub {
    font-size: 1rem;
    font-weight: 800;
    color: #156082;
    margin-bottom: 4px;
}

.memo-title-block p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #333;
    font-weight: 600;
}

.memo-title-block h2 {
    display: inline-block;
    font-size: 1rem;
    font-weight: 800;
    margin: 10px 0 6px;
    padding: 6px 18px;
    color: #fff;
    background: linear-gradient(90deg, #0f9ed5 0%, #0b769f 100%);
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.exam-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #0b769f;
}

.student-info {
    margin: 16px auto 18px;
    max-width: 620px;
    font-size: 0.95rem;
    line-height: 2;
    text-align: center;
    background: #eaf7fd;
    border: 1px solid #60caf3;
    border-radius: 6px;
    padding: 10px 16px;
}

.student-info p {
    display: flex;
    justify-content: center;
    gap: 0;
}

.student-info .info-label {
    display: inline-block;
    min-width: 140px;
    text-align: right;
    font-weight: 700;
    color: #156082;
}

.student-info .info-colon {
    display: inline-block;
    min-width: 16px;
    text-align: left;
    font-weight: 700;
    color: #156082;
}

.student-info .info-value {
    font-weight: 600;
    color: #1a1a1a;
}

.marks-block {
    background: #caedfb;
    border: 2px solid #60caf3;
    border-radius: 8px;
    padding: 12px;
    margin: 0 auto 18px;
    max-width: 620px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.grade-block {
    background: #fff8f4;
    border: 2px solid #f1a983;
    border-radius: 8px;
    padding: 10px;
    margin: 0 auto 18px;
    max-width: 680px;
}

.marks-table,
.sgpa-table,
.grade-scale {
    border-collapse: collapse;
    margin: 0 auto;
    font-size: 0.88rem;
    width: 100%;
}

.marks-table {
    margin-bottom: 10px;
}

.sgpa-table {
    max-width: 320px;
}

.marks-table th,
.marks-table td,
.sgpa-table th,
.sgpa-table td,
.grade-scale th,
.grade-scale td {
    border: 1px solid #60caf3;
    padding: 5px 8px;
    text-align: center;
}

.marks-table thead th {
    background: linear-gradient(180deg, #0f9ed5 0%, #0b769f 100%);
    color: #fff;
    font-weight: 700;
    border-color: #0b769f;
}

.marks-table tbody tr:nth-child(odd) td {
    background: #eaf7fd;
}

.marks-table tbody tr:nth-child(even) td {
    background: #fff;
}

.marks-table .sub-code {
    text-align: left;
    padding-left: 12px;
    font-weight: 700;
    color: #0b769f;
}

.marks-table .total-row td {
    background: #b8e6fa !important;
    font-weight: 700;
    color: #156082;
    border-top: 2px double #0f9ed5;
}

.sgpa-table th,
.sgpa-table td {
    border-color: #0f9ed5;
}

.sgpa-table th {
    width: 50%;
    background: linear-gradient(180deg, #0f9ed5 0%, #0b769f 100%);
    color: #fff;
    font-weight: 700;
}

.sgpa-table td {
    font-weight: 800;
    font-size: 1rem;
    color: #156082;
    background: #fff;
}

.grade-scale th,
.grade-scale td {
    border-color: #f1a983;
}

.grade-scale tr:first-child th {
    background: linear-gradient(180deg, #e97132 0%, #c75d24 100%);
    color: #fff;
    text-align: left;
    padding-left: 8px;
    white-space: nowrap;
}

.grade-scale tr:nth-child(2) th {
    background: #fae2d5;
    color: #8a3d14;
    text-align: left;
    padding-left: 8px;
    font-weight: 700;
}

.grade-scale tr:nth-child(3) th {
    background: #fff0e8;
    color: #8a3d14;
    text-align: left;
    padding-left: 8px;
    font-weight: 700;
}

.grade-scale tr:first-child td {
    background: #fff8f4;
    font-weight: 600;
}

.grade-scale tr:nth-child(2) td,
.grade-scale tr:nth-child(3) td {
    background: #fff;
    font-weight: 600;
}

.memo-notes {
    font-size: 0.82rem;
    line-height: 1.65;
    margin-bottom: 16px;
    border: 1px solid #d0d0d0;
    border-left: 4px solid #e97132;
    background: #fafafa;
    padding: 12px 14px;
    border-radius: 4px;
}

.memo-notes p {
    margin-bottom: 8px;
}

.memo-notes p:last-child {
    margin-bottom: 0;
}

.memo-notes strong {
    color: #c00000;
}

.sgpa-formula {
    font-size: 0.82rem;
    line-height: 1.6;
    margin-bottom: 16px;
    color: #333;
}

.formula-block {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.formula-block strong {
    color: #0b769f;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.fraction .numerator {
    border-bottom: 1px solid #0b769f;
    padding: 0 8px 3px;
    font-size: 0.78rem;
}

.fraction .denominator {
    padding-top: 3px;
    font-size: 0.78rem;
}

.disclaimer {
    font-size: 0.82rem;
    line-height: 1.6;
    text-align: justify;
    color: #c00000;
    border-top: 1px dashed #f1a983;
    padding-top: 12px;
}

.disclaimer strong {
    color: #a00000;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 8mm;
    }

    html,
    body {
        background: #fff !important;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .no-print {
        display: none !important;
    }

    .memo-page {
        padding: 0;
        margin: 0;
    }

    .memo-sheet.certificate {
        box-shadow: none;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    .certificate-frame {
        margin: 0;
        padding: 7mm 9mm 6mm;
        border-width: 2.5px;
        border-radius: 0;
        page-break-inside: avoid;
        min-height: 75vh;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    .memo-header {
        gap: 10px;
        margin-bottom: 10px;
        padding-bottom: 8px;
        flex-shrink: 0;
    }

    .memo-logo {
        width: 72px;
        height: 72px;
    }

    .memo-title-block h1 {
        font-size: 13pt;
        line-height: 1.2;
    }

    .memo-title-block .college-sub {
        font-size: 11pt;
        margin-bottom: 2px;
    }

    .memo-title-block p {
        font-size: 9.5pt;
        line-height: 1.3;
    }

    .memo-title-block h2 {
        font-size: 11pt;
        margin: 6px 0 5px;
        padding: 5px 14px;
    }

    .exam-title {
        font-size: 9.5pt;
        line-height: 1.3;
    }

    .student-info {
        margin: 8px auto 10px;
        padding: 8px 12px;
        font-size: 9.5pt;
        line-height: 1.55;
        max-width: 100%;
        flex-shrink: 0;
    }

    .student-info .info-label {
        min-width: 115px;
    }

    .marks-block {
        padding: 8px;
        margin: 0 auto 10px;
        max-width: 100%;
        border-radius: 4px;
        page-break-inside: avoid;
        flex-shrink: 0;
    }

    .grade-block {
        padding: 7px;
        margin: 0 auto 10px;
        max-width: 100%;
        border-radius: 4px;
        page-break-inside: avoid;
        flex-shrink: 0;
    }

    .marks-table,
    .sgpa-table,
    .grade-scale {
        font-size: 9pt;
    }

    .marks-table th,
    .marks-table td,
    .sgpa-table th,
    .sgpa-table td,
    .grade-scale th,
    .grade-scale td {
        padding: 3px 5px;
        line-height: 1.25;
    }

    .marks-table .sub-code {
        padding-left: 8px;
        font-size: 9pt;
    }

    .marks-table {
        margin-bottom: 8px;
    }

    .sgpa-table td {
        font-size: 11pt;
    }

    .memo-notes {
        font-size: 8.5pt;
        line-height: 1.4;
        margin-bottom: 8px;
        padding: 8px 10px;
        flex-shrink: 0;
    }

    .memo-notes p {
        margin-bottom: 5px;
    }

    .sgpa-formula {
        font-size: 8.5pt;
        line-height: 1.35;
        margin-bottom: 8px;
        flex-shrink: 0;
    }

    .formula-block {
        margin-top: 4px;
        gap: 6px;
    }

    .fraction .numerator,
    .fraction .denominator {
        font-size: 7.5pt;
        padding: 0 6px 2px;
    }

    .disclaimer {
        font-size: 8.5pt;
        line-height: 1.35;
        padding-top: 8px;
        margin-bottom: 0;
        margin-top: auto;
        flex-shrink: 0;
    }

    .marks-block,
    .grade-block,
    .student-info,
    .marks-table thead th,
    .marks-table tbody tr:nth-child(odd) td,
    .marks-table .total-row td,
    .sgpa-table th,
    .grade-scale tr:first-child th,
    .grade-scale tr:nth-child(2) th,
    .grade-scale tr:nth-child(3) th,
    .memo-title-block h2 {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* M.Pharm — fewer rows, scale up to fill ~75%+ of page */
    .mpharm-memo .certificate-frame {
        min-height: 75vh;
        padding: 8mm 10mm 7mm;
        justify-content: space-between;
    }

    .mpharm-memo .memo-logo {
        width: 88px;
        height: 88px;
    }

    .mpharm-memo .memo-title-block h1 {
        font-size: 14pt;
    }

    .mpharm-memo .memo-title-block h2 {
        font-size: 12pt;
        padding: 6px 16px;
    }

    .mpharm-memo .student-info {
        font-size: 10.5pt;
        line-height: 1.65;
        padding: 10px 14px;
        margin: 10px auto 12px;
    }

    .mpharm-memo .marks-block {
        padding: 10px;
        margin-bottom: 12px;
    }

    .mpharm-memo .marks-table,
    .mpharm-memo .sgpa-table,
    .mpharm-memo .grade-scale {
        font-size: 10pt;
    }

    .mpharm-memo .marks-table th,
    .mpharm-memo .marks-table td {
        padding: 5px 7px;
    }

    .mpharm-memo .sgpa-table td {
        font-size: 12pt;
    }

    .mpharm-memo .grade-block {
        padding: 9px;
        margin-bottom: 12px;
    }

    .mpharm-memo .memo-notes {
        font-size: 9pt;
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    .mpharm-memo .sgpa-formula {
        font-size: 9pt;
        margin-bottom: 10px;
    }

    .mpharm-memo .disclaimer {
        font-size: 9pt;
        padding-top: 10px;
    }

    /* B.Pharm biology: 12 subject rows */
    .subjects-many .certificate-frame {
        min-height: 76vh;
        padding: 6mm 8mm 5mm;
    }

    .subjects-many .memo-logo {
        width: 64px;
        height: 64px;
    }

    .subjects-many .marks-table,
    .subjects-many .sgpa-table,
    .subjects-many .grade-scale {
        font-size: 8pt;
    }

    .subjects-many .marks-table th,
    .subjects-many .marks-table td {
        padding: 2px 4px;
    }

    .subjects-many .memo-title-block h1 {
        font-size: 12pt;
    }

    .subjects-many .student-info {
        font-size: 9pt;
        line-height: 1.45;
        padding: 6px 10px;
    }

    .subjects-many .memo-notes,
    .subjects-many .sgpa-formula,
    .subjects-many .disclaimer {
        font-size: 8pt;
    }
}

@media (max-width: 600px) {
    .certificate-frame {
        padding: 16px 12px;
        margin: 4px;
    }

    .memo-header {
        flex-direction: column;
        align-items: center;
    }

    .memo-logo {
        width: 85px;
        height: 85px;
    }

    .student-info p {
        flex-wrap: wrap;
        justify-content: flex-start;
        padding-left: 4px;
    }

    .marks-block,
    .grade-block {
        padding: 8px;
    }

    .grade-scale {
        font-size: 0.72rem;
    }
}
