:root {
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --indigo-50: #eef2ff;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;
    --indigo-800: #3730a3;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --ink: #0f172a;
    --navy: #1e3a8a;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --green-600: #16a34a;
    --green-700: #15803d;
    --red-400: #f87171;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --yellow-400: #facc15;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, "Segoe UI", sans-serif;
    color: var(--ink);
    background: #f4f6fb;
    overflow-x: hidden;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    max-width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 14px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    background: #fff;
}

.font-display,
h1, h2, h3 {
    font-family: Outfit, Inter, sans-serif;
    word-wrap: break-word;
}

a { color: var(--blue-600); text-decoration: none; }

.site-header {
    background: #1e3a8a;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.12);
    color: #fff;
    text-align: center;
    padding: 22px 16px;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(1.25rem, 2.4vw, 1.65rem);
    font-weight: 700;
    letter-spacing: 0.06em;
}

.header-sub {
    margin: 0;
    color: #bfdbfe;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.header-rule {
    width: 48px;
    height: 2px;
    background: #93c5fd;
    margin: 10px auto 0;
    border-radius: 99px;
}

.admin-link-wrap {
    width: min(1152px, calc(100% - 32px));
    margin: 12px auto 0;
    display: flex;
    justify-content: flex-end;
}

.admin-link {
    color: var(--slate-500);
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.admin-link:hover { color: var(--blue-600); }

.wrap {
    width: min(1152px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.page-title {
    text-align: center;
    margin-bottom: 24px;
}

.page-title h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2.5vw, 1.7rem);
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0;
}

.page-title p {
    margin: 8px 0 0;
    color: var(--slate-600);
    font-size: 0.95rem;
    font-weight: 500;
}

.field-label {
    display: block;
    font-family: Inter, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--slate-700);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.card-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0;
}

.muted {
    margin: 4px 0 0;
    color: var(--slate-600);
    font-size: 0.875rem;
    font-weight: 500;
}

.total-pill {
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: none;
}

input::placeholder,
input::-webkit-input-placeholder,
input::-moz-placeholder {
    color: #64748b !important;
    opacity: 1 !important;
    font-weight: 500 !important;
    text-transform: none !important;
}

select:invalid,
.row-competition:invalid {
    color: #64748b;
    font-weight: 500;
}

.student-table thead th {
    background: #1e3a8a;
    color: #fff !important;
    text-align: left;
    padding: 12px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 0;
    white-space: nowrap;
}

.student-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    color: var(--ink);
}

.sr-no {
    color: var(--navy);
    font-weight: 800;
    text-align: center;
    width: 64px;
}

.summary-head h3 {
    margin: 0;
    color: var(--ink);
    font-weight: 700;
    font-size: 1.05rem;
}
.summary-head p {
    margin: 4px 0 0;
    color: var(--slate-600);
    font-size: 0.875rem;
    font-weight: 500;
}

.summary-table th {
    background: #312e81;
    color: #fff;
    text-align: left;
    padding: 14px 16px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.summary-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    color: var(--ink);
    font-weight: 600;
}

.summary-table .name { font-weight: 800; color: var(--navy); }

.summary-foot {
    padding: 12px 24px;
    background: var(--indigo-50);
    text-align: right;
    color: #312e81;
    font-weight: 800;
    font-size: 0.95rem;
}

.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-pad { padding: 24px; }

.req { color: var(--red-500); }

#school_name,
.row-name,
.row-std {
    text-transform: uppercase;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input.is-invalid,
select.is-invalid {
    border-color: var(--red-400);
    background: #fef2f2;
}

.field-error {
    color: var(--red-500);
    font-size: 0.75rem;
    margin: 6px 0 0;
}

.card-head {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.student-table,
.summary-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.student-table tbody tr:hover { background: rgba(239, 246, 255, 0.45); }

.student-table input,
.student-table select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
}

.icon-btn {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover { background: #fee2e2; color: #991b1b; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.card-foot {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.btn {
    border: 0;
    border-radius: 8px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-blue {
    background: #1d4ed8;
    color: #fff;
    box-shadow: none;
}

.btn-blue:hover { background: #1e40af; }

.btn-green {
    background: #15803d;
    color: #fff;
    font-family: Inter, sans-serif;
    font-weight: 700;
    font-size: 1rem;
    padding: 14px 28px;
    border-radius: 8px;
    box-shadow: none;
}

.btn-green:hover { background: #166534; }

.submit-wrap {
    display: flex;
    justify-content: center;
    padding-bottom: 32px;
}

.summary-head {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: var(--indigo-50);
}

.summary-table tbody tr:nth-child(even) { background: #f8fafc; }

.alert {
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 0.875rem;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-error ul { margin: 8px 0 0; padding-left: 18px; }

.hidden { display: none !important; }

.mobile-rows { display: none; padding: 16px; }

.mobile-card {
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 16px;
    background: #f8fafc;
    margin-bottom: 16px;
}

.mobile-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mobile-card-head span {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mobile-card .stack { display: grid; gap: 8px; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: grid;
    place-items: center;
    z-index: 50;
    padding: 16px;
}

.modal {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.25);
    max-width: 28rem;
    width: 100%;
    padding: 32px;
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    border-radius: 999px;
    background: #dcfce7;
    color: var(--green-600);
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
}

.modal h3 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 800;
}

.success-box {
    background: #f0fdf4;
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
    text-align: left;
}

.success-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.success-row span { color: var(--slate-500); }
.success-row strong { color: var(--slate-800); }
.count-lg { color: var(--green-700); font-size: 1.125rem; }

.modal p { color: var(--slate-500); font-size: 0.875rem; }
.btn-block { width: 100%; justify-content: center; }

@media (max-width: 1024px) {
    .wrap { width: min(1152px, calc(100% - 24px)); padding: 20px 0 40px; }
    .header-sub { letter-spacing: 0.12em; }
    .btn-green { padding: 14px 28px; font-size: 1.05rem; }
}

@media (max-width: 767px) {
    .site-header { padding: 20px 12px; }
    .brand-row { flex-wrap: wrap; gap: 8px; }
    .site-header h1 { font-size: 1.25rem; letter-spacing: 0.02em; }
    .header-sub { font-size: 0.78rem; letter-spacing: 0.08em; }
    .wrap { width: calc(100% - 16px); padding: 16px 0 32px; }
    .page-title h2 { font-size: 1.25rem; }
    .card-pad, .card-head, .card-foot, .summary-head, .summary-foot { padding: 14px; }
    .desktop-table { display: none; }
    .mobile-rows { display: block; padding: 12px; }
    .student-table { min-width: 0; }
    .btn, .btn-blue { width: 100%; justify-content: center; min-height: 44px; }
    .submit-wrap { padding: 0 0 24px; }
    .btn-green { width: 100%; justify-content: center; padding: 16px; font-size: 1rem; }
    .success-row { flex-direction: column; gap: 4px; }
    .modal { padding: 24px 16px; border-radius: 18px; }

    .summary-table {
        min-width: 0;
        width: 100%;
    }
    .summary-table thead { display: none; }
    .summary-table, .summary-table tbody, .summary-table tr, .summary-table td {
        display: block;
    }
    .summary-table tr {
        border: 1px solid var(--slate-200);
        border-radius: 12px;
        margin: 10px;
        padding: 8px 10px;
        background: #fff;
    }
    .summary-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 4px;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
    }
    .summary-table td:last-child { border-bottom: 0; }
    .summary-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--slate-500);
        text-align: left;
        flex-shrink: 0;
    }
    .summary-foot { text-align: center; }
}

@media (max-width: 479px) {
    .total-pill { width: 100%; text-align: center; }
    .brand-mark { width: 32px; height: 32px; }
}
