
:root {
    --navy:        #0f2340;
    --navy-mid:    #1a3a5c;
    --navy-light:  #234876;
    --teal:        #19a89a;
    --teal-light:  #21c9b8;
    --gold:        #d4a017;
    --gold-light:  #f0c040;
    --bg:          #f4f6fb;
    --surface:     #ffffff;
    --surface-2:   #f8fafd;
    --border:      #dde4ef;
    --text:        #1e2d42;
    --text-muted:  #6b7a96;
    --error:       #d93025;
    --error-bg:    #fef2f1;
    --success:     #1a8a4a;
    --success-bg:  #f0faf5;
    --warn:        #c97a00;
    --warn-bg:     #fffbf0;

    --gpa-high:    #1a8a4a;
    --gpa-mid:     #c97a00;
    --gpa-low:     #d93025;

    --grade-a:     #1a6b3a;
    --grade-a-bg:  #e6f5ec;
    --grade-b:     #1a5fa8;
    --grade-b-bg:  #e5f0fb;
    --grade-c:     #a06800;
    --grade-c-bg:  #fff8e0;
    --grade-d:     #8b3a00;
    --grade-d-bg:  #fff1e6;
    --grade-f:     #c0001a;
    --grade-f-bg:  #ffe9ec;

    --radius:      10px;
    --radius-sm:   6px;
    --shadow:      0 2px 12px rgba(15,35,64,.09);
    --shadow-md:   0 4px 24px rgba(15,35,64,.13);
    --font-body:   'DM Sans', system-ui, sans-serif;
    --font-display:'Playfair Display', Georgia, serif;
    --header-h:    64px;
    --transition:  0.2s ease;
}


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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-light); text-decoration: underline; }

img { max-width: 100%; display: block; }


.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: calc(var(--header-h) + 28px) 18px 48px;
}


.site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--navy);
    box-shadow: 0 2px 16px rgba(0,0,0,.25);
    z-index: 1000;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding-top: 0;
    padding-bottom: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .02em;
}
.header-brand:hover { color: var(--teal-light); text-decoration: none; }

.brand-icon-sm { font-size: 1.5rem; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link {
    color: rgba(255,255,255,.8);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
}
.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    text-decoration: none;
}
.nav-link.active { background: var(--teal); color: #fff; }

.nav-divider {
    width: 1px; height: 24px;
    background: rgba(255,255,255,.2);
    margin: 0 8px;
}

.nav-user {
    font-size: .88rem;
    color: rgba(255,255,255,.7);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 10px;
}


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 22px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.3;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}
.btn-primary:hover { background: var(--teal-light); border-color: var(--teal-light); color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--navy-mid);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--surface-2); color: var(--navy); border-color: var(--navy-light); }

.btn-full { width: 100%; }
.btn-sm   { padding: 5px 14px; font-size: .82rem; }

/*  Cards  */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 22px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.card-header h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--navy);
    font-weight: 600;
}

.card-body { padding: 22px; }

.mt-4 { margin-top: 28px; }


.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 180px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 18px;
}

label {
    font-weight: 600;
    font-size: .88rem;
    color: var(--navy-mid);
}
label small {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    font-family: var(--font-body);
    font-size: .93rem;
    color: var(--text);
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(25,168,154,.15);
}
input.input-error, select.input-error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(217,48,37,.1);
}
input.input-ok, select.input-ok {
    border-color: var(--success);
}

.field-error {
    font-size: .8rem;
    color: var(--error);
    display: none;
}

.req { color: var(--error); margin-left: 2px; }

.input-eye-wrapper {
    position: relative;
    display: flex;
}
.input-eye-wrapper input { padding-right: 40px; }

.eye-btn {
    position: absolute; right: 0; top: 0; bottom: 0;
    background: none;
    border: none;
    padding: 0 12px;
    cursor: pointer;
    font-size: 1rem;
    opacity: .6;
    transition: opacity var(--transition);
}
.eye-btn:hover { opacity: 1; }

/* Password strength */
.pw-strength-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 6px 0 2px;
    overflow: hidden;
}
.pw-strength-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width .3s, background .3s;
}
.pw-weak   { background: var(--error); }
.pw-fair   { background: #e67e22; }
.pw-good   { background: var(--warn); }
.pw-strong { background: #27ae60; }
.pw-great  { background: var(--gpa-high); }
.pw-strength-label {
    font-size: .78rem;
    color: var(--text-muted);
    min-height: 1.2em;
}

/* Grade preview */
.grade-preview {
    background: var(--navy);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: .9rem;
    margin-bottom: 20px;
    border-left: 4px solid var(--teal);
}
.preview-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--teal-light);
    margin-bottom: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.form-card .card-body { padding: 28px; }

/*  Auth Pages  */
.auth-page {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, var(--navy-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-wrapper {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.auth-brand {
    text-align: center;
    padding: 30px 0 24px;
}
.brand-icon { font-size: 3rem; margin-bottom: 8px; }
.brand-name {
    font-family: var(--font-display);
    font-size: 2rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: .04em;
}
.brand-tagline {
    color: rgba(255,255,255,.6);
    font-size: .9rem;
    margin-top: 4px;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 34px 38px 28px;
    width: 100%;
}
.auth-card h2 {
    font-family: var(--font-display);
    font-size: 1.45rem;
    color: var(--navy);
    margin-bottom: 22px;
    font-weight: 700;
}
.auth-card .form-group { margin-bottom: 16px; }

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: .88rem;
    color: var(--text-muted);
}

/*  Alerts  */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    margin-bottom: 18px;
    font-size: .9rem;
    font-weight: 500;
}
.alert-error   { background: var(--error-bg);   border-color: var(--error);   color: var(--error);   }
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-info    { background: #e8f4fd; border-color: #1a8ab8; color: #1a5a7a; }

/*  Page Header  */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 24px;
}
.page-header h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--navy);
    font-weight: 700;
}
.text-muted { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }

/*  Stats Grid (Dashboard)  */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    text-align: center;
}
.stat-card.stat-gpa {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}
.stat-card.stat-gpa .stat-label { color: rgba(255,255,255,.65); }
.stat-card.stat-gpa .stat-sub   { color: rgba(255,255,255,.55); }

.stat-label {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.1;
}
.stat-card.stat-gpa .stat-value { color: var(--gold-light); }
.stat-sub {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/*  GPA Color Classes  */
.gpa-high { color: var(--gpa-high) !important; }
.gpa-mid  { color: var(--gpa-mid)  !important; }
.gpa-low  { color: var(--gpa-low)  !important; }

/*  Quick Links  */
.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.quick-link-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--navy);
    font-weight: 600;
    font-size: .9rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}
.quick-link-card:hover {
    border-color: var(--teal);
    background: var(--teal);
    color: #fff;
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.ql-icon { font-size: 1.6rem; }

/*  Tables  */
.grade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.grade-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}
.grade-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.grade-table tr:last-child td { border-bottom: none; }
.grade-table tbody tr:hover { background: var(--surface-2); }

.sem-gpa-row {
    text-align: right;
    background: var(--surface-2);
    font-size: .88rem;
    color: var(--text-muted);
    padding: 10px 14px !important;
}

.tfoot-totals td {
    background: var(--navy);
    color: #fff;
    font-size: .88rem;
    border-bottom: none !important;
    padding: 12px 14px !important;
}

.ref-table th, .ref-table td {
    text-align: center;
    min-width: 50px;
}

/* Grade Pills */
.grade-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
}
.grade-a { color: var(--grade-a); background: var(--grade-a-bg); }
.grade-b { color: var(--grade-b); background: var(--grade-b-bg); }
.grade-c { color: var(--grade-c); background: var(--grade-c-bg); }
.grade-d { color: var(--grade-d); background: var(--grade-d-bg); }
.grade-f { color: var(--grade-f); background: var(--grade-f-bg); }

/*  Badge  */
.badge {
    display: inline-block;
    background: var(--navy);
    color: #fff;
    border-radius: 999px;
    padding: 3px 12px;
    font-size: .78rem;
    font-weight: 600;
}

/*  Summary Banner (View Grades)  */
.summary-banner {
    background: var(--navy);
    border-radius: var(--radius);
    padding: 20px 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-md);
}
.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 110px;
}
.summary-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(255,255,255,.55);
    font-weight: 600;
}
.summary-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--gold-light);
    font-weight: 700;
    line-height: 1.1;
}
.summary-standing {
    font-size: 1rem !important;
    color: rgba(255,255,255,.8) !important;
    font-family: var(--font-body) !important;
    font-weight: 600 !important;
    text-align: center;
}

/*  GPA Visual Bar  */
.gpa-visual-bar {
    margin-bottom: 24px;
    padding: 0 2px;
}
.gpa-bar-track {
    height: 12px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}
.gpa-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 1s ease;
}
.gpa-bar-fill.gpa-high { background: linear-gradient(90deg, #1a8a4a, #27c76a); }
.gpa-bar-fill.gpa-mid  { background: linear-gradient(90deg, #c97a00, #f0a030); }
.gpa-bar-fill.gpa-low  { background: linear-gradient(90deg, #d93025, #ff5c52); }

.gpa-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--text-muted);
    padding: 0 1px;
}

/*  Semester Cards  */
.semester-card .card-header { align-items: center; }
.sem-header-info { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sem-header-info h3 { font-size: 1.1rem; }
.sem-meta { display: flex; gap: 10px; align-items: center; }
.sem-credits {
    font-size: .8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2px 10px;
    border-radius: 999px;
    color: var(--text-muted);
}

.sem-gpa-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--navy);
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    min-width: 90px;
}
.sem-gpa-badge.gpa-high { background: var(--gpa-high); }
.sem-gpa-badge.gpa-mid  { background: var(--gpa-mid);  }
.sem-gpa-badge.gpa-low  { background: var(--gpa-low);  }

.gpa-label-sm {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255,255,255,.75);
}
.gpa-val-sm {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: #fff;
    font-weight: 700;
    line-height: 1.1;
}

/*  Filter Card  */
.filter-card { margin-bottom: 22px; }
.filter-toggle-header { cursor: pointer; }
.filter-toggle-header:hover { background: var(--border); }
.toggle-icon { font-size: .85rem; color: var(--text-muted); }

.filter-row { align-items: flex-end; }
.filter-to-label {
    display: flex;
    align-items: flex-end;
    padding-bottom: 10px;
    font-weight: 700;
    color: var(--text-muted);
}
.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding-bottom: 1px;
}

/*  Empty State  */
.empty-state {
    text-align: center;
    padding: 60px 30px;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    margin: 16px 0;
}
.empty-icon  { font-size: 3rem; margin-bottom: 14px; }
.empty-state h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--navy);
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/*  Print Styles  */
@media print {
    .site-header, .page-header .btn, .filter-card,
    .quick-links, .btn, nav, .nav-toggle { display: none !important; }
    .container { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    body { background: #fff; }
}

/*  Responsive  */
@media (max-width: 768px) {
    :root { --header-h: 60px; }

    /* Mobile nav */
    .nav-toggle { display: block; }
    .site-nav {
        position: fixed;
        top: var(--header-h); left: 0; right: 0;
        background: var(--navy-mid);
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
        gap: 8px;
        display: none;
        box-shadow: var(--shadow-md);
    }
    .site-nav.nav-open { display: flex; }
    .nav-link { text-align: center; padding: 10px; }
    .nav-divider { display: none; }
    .nav-user { text-align: center; }
    .btn-sm { width: 100%; text-align: center; justify-content: center; }

    .auth-card { padding: 24px 22px; }
    .form-row  { flex-direction: column; }
    .filter-row { flex-direction: column; }
    .filter-to-label { padding-bottom: 0; }
    .filter-actions { flex-direction: column; }
    .filter-actions .btn { width: 100%; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .summary-banner { padding: 16px; gap: 14px; }
    .summary-value  { font-size: 1.4rem; }

    .grade-table th, .grade-table td {
        padding: 8px 10px;
        font-size: .83rem;
    }

    .sem-header-info { gap: 8px; }
    .sem-gpa-badge { padding: 6px 12px; }

    .card-body { padding: 16px; }
    .form-card .card-body { padding: 18px; }

    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 20px 16px; }
    .summary-item { min-width: 80px; }

    /* Scroll wide tables on small screens */
    .card-body { overflow-x: auto; }
    .grade-table { min-width: 500px; }
    .ref-table { min-width: 680px; }
}