/* =====================================================
   GLOBAL BASE
===================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.ms29-container {
    width: 100%;
    max-width: 100%;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #ffffff;
    color: #2f2f2f;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

/* Responsive padding for smaller screens */
@media (max-width: 768px) {
    .ms29-container {
        padding: 10px;
    }
}

.ms29-border {
    background: #ffffff;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
}

@media (max-width: 1300px) {
    .ms29-border {
        padding: 12px;
        border-radius: 6px;
    }
    
     body {
        overflow-x: auto !important;
    }

    .wrapper {
        width: 1600px !important;
    }
}

/* =====================================================
   HEADER - FIXED ALIGNMENT
===================================================== */
.ms29-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px;
    background: linear-gradient(135deg, #7b1e1e 0%, #5b4b8a 100%);
    border-radius: 10px;
    gap: 15px;
}

@media (max-width: 768px) {
    .ms29-header-wrapper {
        padding: 12px;
        gap: 10px;
    }
}

@media (max-width: 600px) {
    .ms29-header-wrapper {
        flex-direction: column;
        text-align: center;
    }
}

.ms29-logo-box {
    width: 70px;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .ms29-logo-box {
        width: 60px;
        min-width: 60px;
    }
}

.ms29-logo-img {
    max-width: 100%;
    height: auto;
    display: block;
    background: #ffffff;
    padding: 6px;
    border-radius: 6px;
}

.ms29-institution-info {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.ms29-institution-name {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .ms29-institution-name {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .ms29-institution-name {
        font-size: 14px;
    }
}

.ms29-branch-code,
.ms29-branch-address,
.ms29-branch-contact {
    font-size: 11px;
    color: #e5e7eb;
    line-height: 1.4;
    margin: 2px 0;
}

@media (max-width: 480px) {
    .ms29-branch-code,
    .ms29-branch-address,
    .ms29-branch-contact {
        font-size: 10px;
    }
}

/* =====================================================
   REPORT TITLE - FIXED ALIGNMENT
===================================================== */
.ms29-report-header {
    margin: 20px 0;
    padding: 14px;
    background: #ffffff;
    border-left: 5px solid #7b1e1e;
    border-right: 5px solid #5b4b8a;
    text-align: center;
}

@media (max-width: 768px) {
    .ms29-report-header {
        margin: 15px 0;
        padding: 10px;
        border-left-width: 3px;
        border-right-width: 3px;
    }
}

.ms29-report-title {
    font-size: 17px;
    font-weight: 700;
    color: #7b1e1e;
    line-height: 1.3;
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .ms29-report-title {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .ms29-report-title {
        font-size: 13px;
    }
}

.ms29-academic-year {
    font-size: 12px;
    color: #5b4b8a;
    font-weight: 600;
    line-height: 1.3;
}

@media (max-width: 480px) {
    .ms29-academic-year {
        font-size: 11px;
    }
}

/* =====================================================
   STUDENT INFO - FIXED ALIGNMENT
===================================================== */
.ms29-student-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: stretch;
}

@media (max-width: 768px) {
    .ms29-student-wrapper {
        gap: 10px;
        margin-bottom: 15px;
    }
}

.ms29-student-box {
    flex: 1;
    min-width: 280px;
}

@media (max-width: 768px) {
    .ms29-student-box {
        min-width: 100%;
        flex: 1 1 100%;
    }
}

.ms29-student-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ms29-student-table td {
    border: 1px solid #d1d5db;
    padding: 8px;
    font-size: 11px;
    word-wrap: break-word;
    vertical-align: middle;
    text-align: left;
}

@media (max-width: 768px) {
    .ms29-student-table td {
        padding: 6px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .ms29-student-table td {
        padding: 5px;
        font-size: 9px;
    }
}

.ms29-student-table td:first-child {
    background: #f3f4f6;
    font-weight: 600;
    width: 35%;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .ms29-student-table td:first-child {
        width: 40%;
    }
}

/* =====================================================
   PAGE & SECTION HEADERS - FIXED ALIGNMENT
===================================================== */
.ms29-page {
    margin-top: 24px;
    page-break-after: always;
}

@media (max-width: 768px) {
    .ms29-page {
        margin-top: 18px;
    }
}

.ms29-page-title,
.ms29-section-title,
.ms29-intel-title,
.ms29-subhead {
    padding: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(90deg, #7b1e1e 0%, #5b4b8a 100%);
    border-radius: 6px;
    margin: 12px 0;
    text-align: left;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .ms29-page-title,
    .ms29-section-title,
    .ms29-intel-title,
    .ms29-subhead {
        padding: 8px;
        font-size: 12px;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .ms29-page-title,
    .ms29-section-title,
    .ms29-intel-title,
    .ms29-subhead {
        font-size: 11px;
        padding: 6px;
    }
}

/* =====================================================
   TABLE BASE - PERFECT ALIGNMENT LOCKED
===================================================== */
.ms29-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 14px;
}

.ms29-marks-table,
.ms29-term1-table,
.ms29-rounded-table,
.ms29-skill-table,
.ms29-health-table,
.ms29-attendance-table,
.ms29-support-table,
.ms29-assessment-table,
.ms29-competition-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-bottom: 14px;
    background: #ffffff;
    border-spacing: 0;
}

/* Force column alignment */
.ms29-marks-table,
.ms29-term1-table,
.ms29-rounded-table,
.ms29-skill-table,
.ms29-health-table,
.ms29-attendance-table {
    border: 1px solid #d1d5db;
}

.ms29-marks-table th,
.ms29-term1-table th,
.ms29-rounded-table th,
.ms29-skill-table th,
.ms29-health-table th,
.ms29-attendance-table th {
    background: #7b1e1e;
    color: #ffffff;
    font-size: 10px;
    padding: 8px;
    text-align: left;
    vertical-align: middle;
    font-weight: 600;
    border: 1px solid #5a1515;
    line-height: 1.3;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .ms29-marks-table th,
    .ms29-term1-table th,
    .ms29-rounded-table th,
    .ms29-skill-table th,
    .ms29-health-table th,
    .ms29-attendance-table th {
        font-size: 9px;
        padding: 6px 4px;
    }
}

@media (max-width: 480px) {
    .ms29-marks-table th,
    .ms29-term1-table th,
    .ms29-rounded-table th,
    .ms29-skill-table th,
    .ms29-health-table th,
    .ms29-attendance-table th {
        font-size: 8px;
        padding: 5px 3px;
    }
}

.ms29-marks-table td,
.ms29-term1-table td,
.ms29-rounded-table td,
.ms29-skill-table td,
.ms29-health-table td,
.ms29-attendance-table td,
.ms29-support-table td,
.ms29-assessment-table td {
    border: 1px solid #d1d5db;
    padding: 6px;
    font-size: 14px;
    text-align: left;
    vertical-align: middle;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .ms29-marks-table td,
    .ms29-term1-table td,
    .ms29-rounded-table td,
    .ms29-skill-table td,
    .ms29-health-table td,
    .ms29-attendance-table td,
    .ms29-support-table td,
    .ms29-assessment-table td {
        font-size: 9px;
        padding: 5px 4px;
    }
}

@media (max-width: 480px) {
    .ms29-marks-table td,
    .ms29-term1-table td,
    .ms29-rounded-table td,
    .ms29-skill-table td,
    .ms29-health-table td,
    .ms29-attendance-table td,
    .ms29-support-table td,
    .ms29-assessment-table td {
        font-size: 8px;
        padding: 4px 3px;
    }
}

.ms29-marks-table tr:nth-child(even),
.ms29-term1-table tr:nth-child(even),
.ms29-rounded-table tr:nth-child(even),
.ms29-skill-table tr:nth-child(even) {
    background: #f9fafb;
}

/* =====================================================
   INPUTS & TEXTAREA - PERFECT ALIGNMENT
===================================================== */
input,
textarea,
.ms29-level-select {
    width: 100%;
    height: 32px;
    line-height: 20px;
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    font-size: 11px;
    border-radius: 4px;
    background: #ffffff;
    color: #111827;
    box-sizing: border-box;
    vertical-align: middle;
    display: block;
}

@media (max-width: 768px) {
    input,
    textarea,
    .ms29-level-select {
        height: 36px;
        font-size: 12px;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    input,
    textarea,
    .ms29-level-select {
        height: 40px;
        font-size: 14px;
        padding: 10px 12px;
    }
}

textarea {
    height: auto;
    line-height: 1.4;
    padding: 8px;
    min-height: 60px;
    resize: vertical;
}

@media (max-width: 768px) {
    textarea {
        padding: 10px;
        min-height: 70px;
    }
}

input:focus,
textarea:focus,
.ms29-level-select:focus {
    outline: none;
    border-color: #5b4b8a;
    box-shadow: 0 0 0 3px rgba(91, 75, 138, 0.1);
}

/* =====================================================
   SPECIAL BLOCKS - FIXED ALIGNMENT
===================================================== */
.ms29-support-legend {
    font-size: 12px;
    color: #374151;
    margin-bottom: 12px;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .ms29-support-legend {
        font-size: 11px;
    }
}

.ms29-remarks-box {
    padding: 14px;
    background: #ffffff;
    border-left: 4px solid #7b1e1e;
}

@media (max-width: 768px) {
    .ms29-remarks-box {
        padding: 10px;
        border-left-width: 3px;
    }
}

.ms29-promotion-box {
    margin-top: 14px;
    padding: 10px;
    background: #f9fafb;
    border-left: 4px solid #5b4b8a;
    font-weight: 600;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .ms29-promotion-box {
        padding: 8px;
        border-left-width: 3px;
        font-size: 11px;
    }
}

/* =====================================================
   FORM ACTIONS - FIXED ALIGNMENT
===================================================== */
.ms29-form-actions {
    text-align: center;
    margin: 30px 0;
}

@media (max-width: 768px) {
    .ms29-form-actions {
        margin: 20px 0;
    }
}

.ms29-submit-btn {
    background: #7b1e1e;
    color: #ffffff;
    border: none;
    padding: 12px 36px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .ms29-submit-btn {
        padding: 14px 40px;
        font-size: 15px;
        width: auto;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .ms29-submit-btn {
        padding: 16px 24px;
        font-size: 16px;
        width: 100%;
        display: block;
    }
}

.ms29-submit-btn:hover {
    background: #5b4b8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.ms29-submit-btn:active {
    transform: translateY(0);
}

.ms29-message {
    display: none;
    margin-top: 16px;
    padding: 14px;
    font-weight: 600;
    border-radius: 6px;
    text-align: center;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .ms29-message {
        padding: 12px;
        font-size: 13px;
    }
}

.ms29-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #10b981;
}

.ms29-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* =====================================================
   TERM ORDER
===================================================== */
.ms29-term-wrapper {
    display: flex;
    flex-direction: column;
}

.term-1 { order: 1; }
.term-2 { order: 2; }

/* =====================================================
   ACCORDION - PERFECT ALIGNMENT WITH ARROW
===================================================== */
.accordion-item {
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    margin-bottom: 14px;
    overflow: hidden;
}

@media (max-width: 768px) {
    .accordion-item {
        margin-bottom: 10px;
    }
}

.accordion-header {
    width: 100%;
    padding: 14px 50px 14px 16px;
    font-size: 16px;
    background: linear-gradient(135deg, #283593, #1e88e5);
    color: #fff;
    border: none;
    text-align: left;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    display: block;
    line-height: 1.4;
    font-weight: 600;
}

@media (max-width: 768px) {
    .accordion-header {
        padding: 12px 45px 12px 14px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .accordion-header {
        padding: 12px 40px 12px 12px;
        font-size: 14px;
    }
}

.accordion-header:hover {
    background: linear-gradient(135deg, #1e88e5, #283593);
}

.accordion-header:active {
    transform: scale(0.99);
}

/* Arrow indicator - FIXED POSITION */
.accordion-header::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    margin-top: -4px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .accordion-header::after {
        right: 14px;
        margin-top: -3.5px;
        border-left-width: 7px;
        border-right-width: 7px;
        border-top-width: 7px;
    }
}

@media (max-width: 480px) {
    .accordion-header::after {
        right: 12px;
        margin-top: -3px;
        border-left-width: 6px;
        border-right-width: 6px;
        border-top-width: 6px;
    }
}

/* Rotate arrow when active */
.accordion-item.active .accordion-header::after {
    transform: rotate(180deg);
}

.accordion-body {
    display: none;
    padding: 16px;
    background: #ffffff;
}

@media (max-width: 768px) {
    .accordion-body {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .accordion-body {
        padding: 10px;
    }
}

.accordion-item.active .accordion-body {
    display: block;
    animation: slideDown 0.3s ease;
}

/* Slide down animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   PRINT SAFE
===================================================== */
@media print {
    .ms29-form-actions,
    .accordion-header::after {
        display: none !important;
    }

    .accordion-body {
        display: block !important;
    }

    .accordion-item {
        page-break-inside: avoid;
    }

    * {
        font-size: 10pt !important;
        /*color: #000 !important;*/
    }

    input,
    textarea,
    select {
        border: 1px solid #000 !important;
    }
}

/* =====================================================
   SCROLLBAR STYLING
===================================================== */
.ms29-table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.ms29-table-wrapper::-webkit-scrollbar-thumb {
    background: #7b1e1e;
    border-radius: 4px;
}

.ms29-table-wrapper::-webkit-scrollbar-track {
    background: #f3f4f6;
}

/* Firefox scrollbar */
.ms29-table-wrapper {
    scrollbar-width: thin;
    scrollbar-color: #7b1e1e #f3f4f6;
}




.ms29-marks-table td input,
.ms29-term1-table td input,
.ms29-rounded-table td input,
.ms29-skill-table td input,
.ms29-health-table td input,
.ms29-attendance-table td input,
.ms29-assessment-table td input {
    width: 100%;
    min-width: 0;
    text-align: center;
    padding: 2px;
    box-sizing: border-box;
    font-size: 12px;
}

/* ===== Attendance: clean, non-stuck, non-overlapping ===== */

.ms29-attendance-sticky {
    position: sticky;
    top: 20px;                 /* distance from top while scrolling */
    z-index: 10;

    margin: 30px 0;
    padding: 15px;

    background: #fff;
    border: 2px solid #333;
    border-radius: 8px;
}

/* Make sure accordion does not clip it */
.accordion-body {
    overflow: visible;
}

/* =====================================================
   LATE ADMISSION (LT) – CLEAN & EASY TOGGLE (ALL TERMS)
===================================================== */

/* LT label container */
label:has(.lt-toggle),
label:has(.lt-toggle-t1) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    margin-right: 12px;
    border-radius: 18px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    color: #374151;
    transition: all 0.25s ease;
}

/* Hide native checkbox look */
.lt-toggle,
.lt-toggle-t1 {
    appearance: none;
    -webkit-appearance: none;
    width: 34px;
    height: 18px;
    background: #d1d5db;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background 0.25s ease;
}

/* Toggle knob */
.lt-toggle::after,
.lt-toggle-t1::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* Checked (LT ON) */
.lt-toggle:checked,
.lt-toggle-t1:checked {
    background: #7b1e1e;
}

.lt-toggle:checked::after,
.lt-toggle-t1:checked::after {
    transform: translateX(16px);
}

/* Active label highlight */
label:has(.lt-toggle:checked),
label:has(.lt-toggle-t1:checked) {
    background: #fff1f2;
    border-color: #7b1e1e;
    color: #7b1e1e;
}

/* Mobile friendly */
@media (max-width: 768px) {
    label:has(.lt-toggle),
    label:has(.lt-toggle-t1) {
        font-size: 11px;
        padding: 5px 12px;
    }
}

/* =====================================================
   LT ROW & CELL STYLE (UNCHANGED LOGIC)
===================================================== */

.lt-row td,
.lt-row-t1 td {
    background: #f3f4f6 !important;
    color: #6b7280;
    font-weight: 600;
    text-align: center;
}

.lt-mark,
.lt-mark-t1 {
    background: #e5e7eb !important;
    color: #374151 !important;
    font-weight: 700;
    text-align: center !important;
}

/* =====================================================
   PRINT SAFE
===================================================== */
@media print {
    .lt-toggle,
    .lt-toggle-t1 {
        display: none !important;
    }
}