:root {
    --primary: #1f7396;        /* Deep Teal */
    --primary-light: #e6f7f6;  /* Pastel cloud teal */
    --turquoise: #31b3ab;      /* Active brand turquoise */
    --cyan: #4cdbcf;           /* Glow accent cyan */
    --secondary: #F39C12;      /* Warm golden amber */
    --text-main: #2D3748;      /* High contrast charcoal */
    --text-muted: #5A6A85;     /* Slate gray secondary text */
    --border-color: #b3eae7;   /* Soft brand border */
    --bg-gradient: linear-gradient(135deg, #E8F8F7 0%, #D0F0EE 50%, #B8E8E5 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    gap: 30px;
}

.back-link {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: var(--primary);
    color: white;
    padding: 10px 18px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(31, 115, 150, 0.25);
    transition: all 0.3s ease;
}
.back-link:hover {
    background: var(--turquoise);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(49, 179, 171, 0.35);
}

.sample-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: #E53E3E;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: pulse 2s infinite;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(0.97); }
}

.a4-page {
    width: 210mm;
    min-height: 297mm;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 15px 45px rgba(0, 161, 154, 0.08);
    position: relative;
    padding: 18mm 15mm 12mm 15mm;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    margin: 0 auto;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
}

/* Watermark styles */
.a4-page {
    overflow: hidden; /* Keep watermarks within card boundary */
}

.a4-page::before {
    content: "";
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background-image: url('logo.png');
    background-repeat: repeat;
    background-position: 0 0;
    background-size: 150px auto;
    opacity: 0.038;
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: 99; /* Render above solid white bento backgrounds */
}

.a4-page::after {
    content: "";
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTAiIGhlaWdodD0iMTUwIj48dGV4dCB4PSIzMCIgeT0iODAiIGZpbGw9InJnYmEoMCwxMDIsMTAyLDAuMDQ1KSIgZm9udC1zaXplPSIxNCIgZm9udC1mYW1pbHk9InNhbnMtc2VyaWYiIGZvbnQtd2VpZ2h0PSI5MDAiIHRyYW5zZm9ybT0icm90YXRlKC0yMCwxMjUsNzUpIj5E4buuIExJ4buGVSBNSU5IIEhP4bqgPC90ZXh0Pjwvc3ZnPg==');
    background-repeat: repeat;
    background-position: 75px 50px; /* Checkerboard offset */
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: 99;
}

.bento {
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 161, 154, 0.02);
    page-break-inside: avoid;
    break-inside: avoid;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
}
.section-title i {
    color: white;
    background: var(--primary);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.75rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--turquoise);
    padding-bottom: 10px;
    flex-shrink: 0;
}
.logo {
    height: 40px;
    object-fit: contain;
}
.header-title {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.school-year {
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.8rem;
    border: 1px solid rgba(49, 179, 171, 0.2);
}

.profile-row {
    display: flex;
    flex-direction: row;
    gap: 18px;
}
.avatar-box {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.avatar {
    width: 120px;
    height: 160px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 6px 20px rgba(0, 161, 154, 0.08);
    border: 1.5px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-light), #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--turquoise);
}

.tracker-form {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-content: center;
}
.form-group {
    background: rgba(49, 179, 171, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    background: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 161, 154, 0.15);
}
.form-value.highlight {
    color: var(--primary);
    font-weight: 900;
    font-size: 1rem;
    border-color: var(--turquoise);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    min-height: 110px;
}

.score-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1.5px solid var(--border-color);
}
.score-table thead th {
    background: var(--primary);
    color: white;
    padding: 6px 4px;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-right: 1px solid rgba(255,255,255,0.15);
}
.score-table thead th:first-child { text-align: center; padding-left: 10px; }
.score-table thead th:last-child { border-right: none; }

.score-table thead th.group-hk1 { background: var(--primary); }
.score-table thead th.group-hk2 { background: var(--turquoise); }
.score-table thead th.group-cn { background: #27AE60; }

.score-table tbody tr { transition: background 0.15s; }
.score-table tbody tr:nth-child(even) { background: rgba(49, 179, 171, 0.02); }
.score-table tbody tr:hover { background: var(--primary-light); }
.score-table td {
    padding: 6px 6px;
    border-top: 1px solid rgba(0, 161, 154, 0.12);
    text-align: center;
    font-weight: 600;
    color: var(--text-main);
}
.score-table td:first-child {
    text-align: left;
    font-weight: 800;
    color: var(--text-main);
    padding-left: 10px;
}

.score-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.75rem;
    min-width: 28px;
}
.score-badge.qual-t { background: #27AE60; color: white; }
.score-badge.qual-h { background: #1f7396; color: white; }
.score-badge.qual-d { background: var(--secondary); color: white; }
.score-badge.qual-c { background: #E74C3C; color: white; }
.score-badge.empty, .sb.e {
    background: #EDF2F7;
    color: #A0AEC0;
    font-weight: 600;
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    min-width: 28px;
}

.sb {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.75rem;
    min-width: 28px;
}
.sb.hi {
    background: rgba(49, 179, 171, 0.12);
    color: var(--primary);
}
.sb.lo {
    background: #FEE2E2;
    color: #E53E3E;
}

.orientation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.orientation-item {
    background: rgba(49, 179, 171, 0.02);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--border-color);
    border-left: 5px solid var(--secondary);
    font-size: 0.85rem;
}
.orientation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    color: var(--primary);
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.orientation-content {
    line-height: 1.45;
    font-weight: 500;
    color: var(--text-main);
}

.achievement-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.achievement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #FFFBEB;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(243, 156, 18, 0.2);
    border-left: 5px solid var(--secondary);
    font-size: 0.85rem;
}
.achievement-icon {
    color: var(--secondary);
    font-size: 1.2rem;
}
.achievement-info {
    display: flex;
    flex-direction: column;
}
.achievement-title {
    font-weight: 800;
    color: var(--text-main);
}
.achievement-medal {
    font-weight: 700;
    color: #D35400;
}

.radar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    flex: 1;
}
.mini-radar-box {
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 161, 154, 0.02);
}
.mini-radar-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 14px;
    border-radius: 20px;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-align: center;
    border: 1px solid rgba(49, 179, 171, 0.15);
}
.mini-radar-wrapper {
    position: relative;
    width: 100%;
    height: 230px;
}

@media screen and (max-width: 768px) {
    body { padding: 10px; padding-top: 70px; background: white; }
    .a4-page { width: 100%; min-height: auto; padding: 10px; box-shadow: none; border-bottom: 2px dashed #ccc; margin-bottom: 20px; border-radius: 0; }
    .header { flex-direction: column; text-align: center; gap: 10px; }
    .profile-row { flex-direction: column; align-items: center; }
    .tracker-form { grid-template-columns: 1fr; }
    .radar-grid { grid-template-columns: 1fr; }
    .bento { padding: 10px; }
    .header-title { font-size: 1.1rem; }
    
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 5px;
        position: relative;
    }
    .score-table {
        font-size: 0.68rem;
        min-width: 580px;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        overflow: visible !important;
    }
    
    /* Anchoring / Sticky first column for mobile tables */
    .table-responsive .score-table thead tr:first-child th:first-child {
        position: -webkit-sticky;
        position: sticky;
        left: 0;
        background: var(--primary) !important;
        z-index: 10;
        box-shadow: 2px 0 5px rgba(0,0,0,0.12);
        border-right: 1px solid rgba(255,255,255,0.15) !important;
        min-width: 110px !important;
        white-space: normal !important;
    }
    .table-responsive .score-table tbody td:first-child {
        position: -webkit-sticky;
        position: sticky;
        left: 0;
        background: #ffffff !important;
        z-index: 5;
        font-weight: 700;
        box-shadow: 2px 0 5px rgba(0,0,0,0.06);
        border-right: 1px solid var(--border-color) !important;
        min-width: 110px !important;
        white-space: normal !important;
        text-align: left !important;
    }
    .table-responsive .score-table tbody tr:nth-child(even) td:first-child {
        background: #fcfdfd !important;
    }
    .table-responsive .score-table tbody tr:hover td:first-child {
        background: var(--primary-light) !important;
    }
}

@media print {
    body { background: white; padding: 0; }
    .a4-page { box-shadow: none; margin: 0; padding: 18mm 15mm 12mm 15mm; width: 100%; min-height: auto; page-break-after: always; border: none; border-radius: 0; }
    .back-link, .sample-badge { display: none; }
}

/* Content & Design Protection Rules */
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none;
}
