/* =====================================================
   style.css - ระบบลงทะเบียนสอบภาษาอังกฤษ
   ===================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

:root {
    --brand-blue-900: #1e3a8a;
    --brand-blue-700: #2563eb;
    --brand-pink-600: #db2777;
    --brand-pink-500: #ec4899;
    --bg-soft: #f8f5ff;
    --bg-soft-2: #fdf2f8;
    --text-main: #2d3748;
    --text-muted: #64748b;
}

body {
    font-family: 'Sarabun', 'Tahoma', sans-serif;
    font-size: 16px;
    background:
        radial-gradient(1200px 500px at 12% -20%, #dbeafe 0%, rgba(219, 234, 254, 0) 70%),
        radial-gradient(900px 420px at 88% -10%, #fbcfe8 0%, rgba(251, 207, 232, 0) 68%),
        linear-gradient(180deg, var(--bg-soft) 0%, var(--bg-soft-2) 100%);
    color: var(--text-main);
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--brand-blue-900) 0%, var(--brand-blue-700) 55%, var(--brand-pink-600) 100%);
    color: white;
    padding: 0;
    box-shadow: 0 6px 18px rgba(30, 58, 138, 0.28);
}
.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}
.header-icon { font-size: 2rem; }
.header h1 { font-size: 1.4rem; font-weight: 700; }
.header p { font-size: 0.85rem; opacity: 0.85; }

/* Container */
.container { max-width: 900px; margin: 30px auto; padding: 0 20px; }
.container-sm { max-width: 580px; margin: 40px auto; padding: 0 20px; }
.app-shell { padding-bottom: 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.portal-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 20px 16px 24px;
}
.portal-sidebar {
    width: 250px;
    background: #ffffff;
    border: 1px solid #dbe3f0;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    position: sticky;
    top: 18px;
}
.portal-main {
    flex: 1;
    min-width: 0;
}
.portal-sidebar-head {
    padding: 4px 4px 10px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 10px;
}
.portal-sidebar-title {
    font-size: 1rem;
    color: #1e3a8a;
    font-weight: 800;
}
.portal-user {
    margin-top: 5px;
    color: #475569;
    font-size: 0.86rem;
}
.portal-nav {
    display: grid;
    gap: 8px;
}
.portal-nav-btn,
.portal-nav-link {
    border: 1px solid #dbe3f0;
    background: #f8fafc;
    color: #1e293b;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}
.portal-nav-btn:hover,
.portal-nav-link:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}
.portal-nav-btn.active {
    background: linear-gradient(135deg, var(--brand-blue-700), var(--brand-pink-600));
    color: #fff;
    border-color: transparent;
}
.portal-nav-link.danger {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}
.public-nav-toggle {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 12px;
    z-index: 1200;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    background: #1e3a8a;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.public-sidebar-overlay {
    display: none;
}
body.public-sidebar-open {
    overflow: hidden;
}
body.public-sidebar-open .public-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 1090;
}

/* Card */
.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 26px rgba(30, 58, 138, 0.08);
    margin-bottom: 24px;
    border: 1px solid #e8eaf7;
}
.card-header {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
    margin-bottom: 22px;
}
.card-header h2 {
    font-size: 1.25rem;
    color: var(--brand-blue-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Home Hero */
.home-hero-card {
    border: 1px solid #c7d2fe;
    background:
        radial-gradient(500px 220px at 90% -10%, rgba(219, 39, 119, 0.10), rgba(219, 39, 119, 0)),
        radial-gradient(560px 240px at 12% -20%, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0)),
        #ffffff;
}
.home-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.home-hero-head h2 {
    font-size: 1.38rem;
    color: var(--brand-blue-900);
    margin-bottom: 6px;
}
.home-hero-head p {
    color: #475569;
    font-size: 0.92rem;
}
.home-hero-grid {
    display: grid;
    grid-template-columns: 1.35fr 0.9fr;
    gap: 14px;
    align-items: start;
}
.hero-submit-btn {
    font-weight: 800;
    letter-spacing: 0.2px;
}
.home-hero-side .info-box {
    margin-bottom: 12px;
}
.home-quick-actions {
    display: grid;
    gap: 8px;
}
.home-quick-actions .btn {
    width: 100%;
}
.home-secondary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.home-secondary-grid .card {
    margin-bottom: 0;
}

/* Steps Badge */
.step-badge {
    display: inline-flex;
    align-items: center;
    background: #fce7f3;
    border: 1px solid #f9a8d4;
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.82rem;
    color: var(--brand-pink-600);
    font-weight: 600;
    margin-bottom: 14px;
}

/* Info Box */
.info-box {
    background: #eff6ff;
    border-left: 4px solid var(--brand-blue-700);
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.info-box.warning { background: #fffbeb; border-color: #f6ad55; }
.info-box.success { background: #f0fff4; border-color: #48bb78; }
.info-box.danger  { background: #fff5f5; border-color: #fc8181; }

/* Timeline */
.timeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.timeline-item {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}
.timeline-item .label { font-size: 0.78rem; color: #718096; margin-bottom: 4px; }
.timeline-item .value { font-size: 1rem; font-weight: 700; color: #1a365d; }
.timeline-item.active { border-color: #3182ce; background: #ebf8ff; }
.timeline-item.active .value { color: var(--brand-blue-700); }

/* Form */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: #4a5568;
}
.form-group label span.req { color: #e53e3e; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: white;
}
.form-control:focus { outline: none; border-color: var(--brand-blue-700); box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.form-control:disabled { background: #f7fafc; cursor: not-allowed; }

/* Radio Center Selection */
.center-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.center-card {
    border: 2.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.center-card:hover { border-color: #3182ce; background: #ebf8ff; }
.center-card input[type="radio"] { position: absolute; opacity: 0; }
.center-card.selected { border-color: #3182ce; background: #ebf8ff; }
.center-card .center-name { font-weight: 700; font-size: 1rem; color: var(--brand-blue-900); }
.center-card .center-loc { font-size: 0.82rem; color: #718096; margin-top: 4px; }
.center-card .center-seats { font-size: 0.8rem; margin-top: 6px; color: #48bb78; font-weight: 600; }
.center-card .center-seats.low { color: #e53e3e; }
.center-card .check-icon { position: absolute; top: 10px; right: 10px; color: #3182ce; display: none; font-size: 1.2rem; }
.center-card.selected .check-icon { display: block; }

.result-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.result-popup-card {
    width: min(560px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 18px 42px rgba(2, 6, 23, 0.28);
    padding: 20px 20px 16px;
    position: relative;
}
.result-popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}
.result-popup-close:hover { color: #334155; }
.result-popup-head {
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--brand-blue-900);
    margin-bottom: 10px;
}
.popup-actions {
    display: flex;
    gap: 10px;
}

.install-app-btn {
    position: fixed;
    right: 14px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
    z-index: 90;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-pink-600), var(--brand-blue-700));
    color: #fff;
    font-weight: 700;
    font-size: 0.83rem;
    padding: 10px 14px;
    box-shadow: 0 10px 24px rgba(30, 58, 138, 0.33);
}

.bottom-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 9px 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
    background: rgba(255,255,255,0.96);
    border-top: 1px solid #dbe3f0;
    box-shadow: 0 -10px 26px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(8px);
}

.tabbar-item {
    border: 1px solid #d8e0f0;
    background: #f8fafc;
    color: #334155;
    border-radius: 13px;
    padding: 9px 6px 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.tabbar-item .tab-icon {
    font-size: 0.98rem;
    line-height: 1.2;
}
.tabbar-item .tab-label {
    font-size: 0.76rem;
    font-weight: 700;
}
.tabbar-item.active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-blue-700), var(--brand-pink-600));
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.26);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 11px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}
.btn-primary { background: linear-gradient(135deg, var(--brand-blue-700), var(--brand-pink-600)); color: white; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-success { background: #38a169; color: white; }
.btn-success:hover { background: #276749; }
.btn-danger { background: #e53e3e; color: white; }
.btn-danger:hover { background: #c53030; }
.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-secondary:hover { background: #cbd5e0; }
.btn-outline { background: transparent; border: 2px solid var(--brand-blue-700); color: var(--brand-blue-700); }
.btn-outline:hover { background: var(--brand-blue-700); color: white; }
.btn-lg { padding: 14px 36px; font-size: 1.1rem; }
.btn-sm { padding: 6px 16px; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; }
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.2);
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
}
.badge-pending  { background: #fefcbf; color: #b7791f; }
.badge-confirmed { background: #c6f6d5; color: #276749; }
.badge-cancelled { background: #fed7d7; color: #c53030; }
.badge-active { background: #c6f6d5; color: #276749; }
.badge-closed { background: #e2e8f0; color: #718096; }
.badge-draft  { background: #fefcbf; color: #b7791f; }
.badge-passed { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #b91c1c; }

/* Student Info Display */
.student-info { background: #f7fafc; border-radius: 8px; padding: 18px; margin-bottom: 20px; }
.student-info .name { font-size: 1.2rem; font-weight: 700; color: #1a365d; }
.student-info .meta { font-size: 0.88rem; color: #718096; margin-top: 4px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table th { background: linear-gradient(135deg, var(--brand-blue-900), var(--brand-blue-700)); color: white; padding: 10px 12px; text-align: left; white-space: nowrap; }
table td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
table tr:hover td { background: #f7fafc; }
table .actions { white-space: nowrap; }

/* Alert/Flash */
.alert {
    padding: 13px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    font-weight: 500;
}
.alert-success { background: #c6f6d5; color: #276749; border: 1px solid #9ae6b4; }
.alert-danger   { background: #fed7d7; color: #c53030; border: 1px solid #fc8181; }
.alert-info     { background: #bee3f8; color: #2b6cb0; border: 1px solid #90cdf4; }
.alert-warning  { background: #fefcbf; color: #b7791f; border: 1px solid #f6e05e; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 10px; padding: 18px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.stat-card .num { font-size: 2rem; font-weight: 800; color: var(--brand-blue-700); }
.stat-card .lbl { font-size: 0.82rem; color: #718096; margin-top: 2px; }

/* Admin Sidebar */
.admin-layout { display: flex; min-height: 100vh; }
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 12px;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 12px;
    z-index: 1200;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    background: #1a365d;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(15,23,42,0.25);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 1090;
}
body.sidebar-open .sidebar-overlay { display: block; }
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1e3a8a 0%, #1d4ed8 50%, #be185d 100%);
    color: white;
    flex-shrink: 0;
    padding: 0;
}
.sidebar-logo { padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo h2 { font-size: 0.95rem; font-weight: 700; line-height: 1.4; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: #63b3ed;
}
.sidebar nav .nav-section {
    padding: 14px 20px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
}
.admin-main { flex: 1; padding: 28px; background: transparent; overflow-y: auto; }
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.admin-topbar h1 { font-size: 1.4rem; color: var(--brand-blue-900); }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 18px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.88rem;
    text-decoration: none;
    color: #4a5568;
}
.pagination .current { background: var(--brand-blue-700); color: white; border-color: var(--brand-blue-700); }

.site-footer {
    margin-top: 12px;
    margin-bottom: 6px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.site-footer strong {
    color: var(--brand-pink-600);
}
.site-footer a {
    color: var(--brand-blue-700);
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
}

/* Student Profile */
.profile-page {
    max-width: 1120px;
}
.profile-hero-card {
    padding: 20px 22px;
    margin-bottom: 18px;
}
.profile-hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.profile-name {
    font-size: 1.22rem;
    font-weight: 800;
    color: var(--brand-blue-900);
}
.profile-meta {
    margin-top: 6px;
    color: #475569;
    font-size: 0.9rem;
}
.profile-layout-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 16px;
}
.profile-card {
    margin-bottom: 0;
}
.profile-inline-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Confirm Page */
.confirm-page {
    max-width: 1120px;
}
.confirm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.85fr);
    gap: 16px;
    align-items: start;
}
.confirm-main .card,
.confirm-side .card {
    margin-bottom: 0;
}
.confirm-hero-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}
.confirm-hero-title {
    font-size: 1.08rem;
    font-weight: 800;
    color: #1e3a8a;
}
.confirm-hero-sub {
    color: #64748b;
    font-size: 0.88rem;
    margin-top: 4px;
}
.confirm-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.confirm-info-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
}
.confirm-info-item .label {
    font-size: 0.76rem;
    color: #64748b;
    margin-bottom: 4px;
}
.confirm-info-item .value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}
.confirm-actions {
    display: flex;
    gap: 10px;
}
.confirm-actions .btn-success {
    flex: 1;
}
.confirm-checklist {
    margin: 0 0 14px;
    padding-left: 18px;
    color: #334155;
}
.confirm-checklist li {
    margin-bottom: 7px;
    line-height: 1.45;
}

/* Result Page */
.result-page {
    max-width: 980px;
}
.result-hero-card {
    border: 1px solid #c7d2fe;
    background:
        radial-gradient(540px 240px at 96% -18%, rgba(30, 64, 175, 0.18), rgba(30, 64, 175, 0)),
        radial-gradient(500px 230px at 8% -20%, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0)),
        #ffffff;
    position: relative;
    overflow: hidden;
}
.result-hero-card::before {
    content: '';
    position: absolute;
    left: -70px;
    top: -70px;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.20), rgba(59, 130, 246, 0));
    pointer-events: none;
}
.result-hero-card::after {
    content: '';
    position: absolute;
    right: -60px;
    bottom: -70px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, rgba(56, 189, 248, 0.24), rgba(56, 189, 248, 0));
    pointer-events: none;
}
.result-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.result-hero-title {
    font-size: 1.24rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: 0.2px;
}
.result-hero-sub {
    margin-top: 4px;
    color: #334155;
    font-size: 0.87rem;
}
.result-hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.result-tag {
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
}
.result-tag.alt {
    color: #92400e;
    border-color: #fcd34d;
    background: #fffbeb;
}
.result-filter-form {
    margin-bottom: 14px;
}
.result-compact-grid {
    display: grid;
    grid-template-columns: minmax(190px, 0.55fr) minmax(0, 1fr);
    gap: 15px;
    align-items: stretch;
}
.result-score-panel {
    border-radius: 16px;
    padding: 16px 14px 14px;
    background: linear-gradient(152deg, #1e3a8a, #1d4ed8);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.34);
    animation: resultCardIn 420ms ease-out;
    position: relative;
    overflow: hidden;
}
.result-score-panel.failed {
    background: linear-gradient(154deg, #7f1d1d, #dc2626);
    box-shadow: 0 18px 36px rgba(220, 38, 38, 0.30);
}
.result-score-panel::after {
    content: '';
    position: absolute;
    right: -38px;
    top: -54px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle at 55% 55%, rgba(255,255,255,0.25), rgba(255,255,255,0));
    pointer-events: none;
}
@keyframes resultCardIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.result-score-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.result-score-label {
    font-size: 0.8rem;
    opacity: 0.85;
}
.result-score-icon {
    font-size: 1.3rem;
    line-height: 1;
}
.result-ring {
    --result-percent: 0;
    width: 150px;
    height: 150px;
    margin: 10px auto 8px;
    border-radius: 50%;
    position: relative;
    display: grid;
    place-items: center;
    background: conic-gradient(#facc15 calc(var(--result-percent) * 1%), rgba(255, 255, 255, 0.24) 0);
}
.result-ring.failed {
    background: conic-gradient(#fb7185 calc(var(--result-percent) * 1%), rgba(255, 255, 255, 0.24) 0);
}
.result-ring::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.30);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.result-ring-inner {
    position: relative;
    text-align: center;
    z-index: 1;
}
.result-score-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}
.result-ring-max {
    margin-top: 4px;
    font-size: 0.74rem;
    letter-spacing: 0.3px;
    opacity: 0.92;
}
.result-score-pass {
    margin-top: 2px;
    font-size: 0.8rem;
    opacity: 0.9;
    text-align: center;
}
.result-meter-wrap {
    margin-top: 12px;
}
.result-meter {
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    position: relative;
    overflow: hidden;
}
.result-meter-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, #facc15, #f59e0b);
}
.result-meter-fill.failed {
    background: linear-gradient(90deg, #fb7185, #ef4444);
}
.result-meter-threshold {
    position: absolute;
    top: -3px;
    width: 2px;
    bottom: -3px;
    background: rgba(15, 23, 42, 0.88);
}
.result-meter-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 0.72rem;
    opacity: 0.92;
}
.result-diff {
    margin-top: 10px;
    font-size: 0.84rem;
    color: rgba(255,255,255,0.95);
}
.result-diff strong {
    font-size: 0.94rem;
}
.result-status-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.result-status-chip {
    width: fit-content;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.84rem;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.38);
    background: rgba(255,255,255,0.14);
}
.result-status-chip.failed {
    background: rgba(127, 29, 29, 0.32);
}
.result-status-sub {
    font-size: 0.76rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 999px;
    padding: 4px 10px;
}
.result-detail-panel {
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    padding: 13px;
    background: linear-gradient(180deg, #f8fafc, #eef2ff);
}
.result-detail-panel .student-info {
    border: 1px solid #dbeafe;
    background: linear-gradient(180deg, #ffffff, #f1f5f9);
}
.result-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.result-mini-item {
    border: 1px solid #dbeafe;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    padding: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.result-mini-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(30, 64, 175, 0.10);
}
.result-mini-item span {
    display: block;
    color: #64748b;
    font-size: 0.76rem;
    margin-bottom: 4px;
}
.result-mini-item strong {
    color: #0f172a;
    font-size: 0.92rem;
}

.sidebar-credit {
    margin-top: 14px;
    padding: 10px 20px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    font-size: 0.74rem;
    line-height: 1.5;
    color: rgba(255,255,255,0.78);
}
.sidebar-credit strong {
    color: #fbcfe8;
}
.pagination a:hover { background: #f7fafc; }

/* Universal RWD helpers for legacy inline layouts */
@media (max-width: 768px) {
    .card [style*="display:grid"][style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .card [style*="display:flex"][style*="gap"] {
        flex-wrap: wrap !important;
    }
    .card [style*="display:flex"][style*="gap"] > .btn,
    .card [style*="display:flex"][style*="gap"] > a.btn,
    .card [style*="display:flex"][style*="gap"] > button.btn {
        width: 100%;
        flex: 1 1 100%;
    }

    .table-wrap {
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
    }
    table {
        min-width: 560px;
    }
    table th, table td {
        padding: 8px 9px;
        font-size: 0.84rem;
    }
}

/* Print */
@media print {
    .sidebar, .admin-topbar .btn, .no-print { display: none; }
    .admin-main { padding: 0; }
    table th { background: #444 !important; -webkit-print-color-adjust: exact; }
}

/* Responsive */
@media (max-width: 1024px) {
    .public-nav-toggle { display: inline-flex; align-items: center; gap: 6px; }
    .portal-layout {
        padding: 70px 10px 18px;
        display: block;
    }
    .portal-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 270px;
        max-width: 88vw;
        border-radius: 0;
        z-index: 1100;
        transform: translateX(-105%);
        transition: transform 0.24s ease;
        overflow-y: auto;
        box-shadow: 16px 0 30px rgba(2, 6, 23, 0.3);
    }
    body.public-sidebar-open .portal-sidebar {
        transform: translateX(0);
    }
    .portal-main .container-sm {
        max-width: 100%;
        margin: 0;
        padding: 0 8px;
    }

    .mobile-nav-toggle { display: inline-flex; align-items: center; gap: 6px; }
    body.sidebar-open { overflow: hidden; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 1100;
        transform: translateX(-105%);
        -webkit-transform: translateX(-105%);
        transition: transform 0.24s ease;
        -webkit-transition: -webkit-transform 0.24s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 16px 0 30px rgba(2, 6, 23, 0.3);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
        -webkit-transform: translateX(0);
    }
    .admin-main {
        width: 100%;
        min-width: 0;
        padding: 74px 16px 16px;
    }
    .admin-topbar {
        gap: 10px;
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .admin-topbar h1 { font-size: 1.2rem; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
    .home-hero-grid,
    .home-secondary-grid {
        grid-template-columns: 1fr;
    }
    .result-compact-grid {
        grid-template-columns: 1fr;
    }
    .profile-layout-grid,
    .confirm-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .portal-layout {
        padding-top: 66px;
    }
    .container, .container-sm {
        margin-top: 16px;
    }
    .center-cards { grid-template-columns: 1fr; }
    .timeline { grid-template-columns: 1fr; }
    .app-shell { padding-bottom: 24px; }
    .popup-actions { flex-direction: column; }
    .card { padding: 20px; }
    .container, .container-sm { padding: 0 14px; }
    .profile-inline-fields,
    .confirm-info-grid,
    .result-mini-grid {
        grid-template-columns: 1fr;
    }
    .profile-hero-top,
    .confirm-hero-head,
    .result-hero-head {
        flex-direction: column;
    }
    .home-hero-head {
        flex-direction: column;
    }
}
