:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #667085;
    --line: #e4e7ec;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --accent: #b45309;
    --danger: #b42318;
    --success: #027a48;
    --nav: #101828;
    --shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    direction: ltr;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3 {
    margin: 0;
}

h1 {
    font-size: clamp(26px, 3vw, 34px);
}

h2 {
    font-size: 19px;
}

.muted {
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0) 42%),
        #f5f7fa;
}

.login-box {
    width: min(470px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.login-brand {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
}

.login-logo-shell {
    display: grid;
    place-items: center;
    min-height: 92px;
    border: 1px solid #d9e3e1;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
    padding: 14px;
}

.login-logo {
    display: block;
    width: 100%;
    max-width: 108px;
    max-height: 66px;
    object-fit: contain;
}

.login-kicker {
    margin: 0 0 6px;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0;
}

.pwa-install-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    margin: 18px 0 4px;
    padding: 14px;
    border: 1px solid #b7ded8;
    border-radius: 8px;
    background: #effaf8;
}

.pwa-install-card strong {
    color: var(--brand-dark);
}

.pwa-install-card p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.pwa-install-button {
    min-width: 108px;
}

.pwa-install-fallback {
    grid-column: 1 / -1;
    display: grid;
    gap: 5px;
    color: #344054;
    font-size: 13px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 25px;
    font-weight: 700;
    margin-bottom: 18px;
}

.compact-mark {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
}

.form-field {
    margin-top: 16px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
}

input, select, textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cfd4dc;
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(15, 118, 110, 0.16);
    border-color: var(--brand);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    padding: 0 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    background: var(--brand);
    color: #fff;
    white-space: nowrap;
}

.btn:hover {
    background: var(--brand-dark);
}

.btn,
a,
summary,
button {
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.btn-light {
    background: #eef7f6;
    color: var(--brand-dark);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #912018;
}

.alert {
    margin-top: 16px;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #fecdca;
    color: var(--danger);
    background: #fff1f0;
}

.notice {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #abefc6;
    color: var(--success);
    background: #ecfdf3;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
    background: var(--nav);
    color: #fff;
    padding: 22px;
}

.student-mini {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.avatar {
    width: 58px;
    height: 58px;
    border-radius: 8px;
    object-fit: cover;
    background: #d0d5dd;
    flex: 0 0 auto;
}

.avatar-large {
    width: 96px;
    height: 96px;
}

.table-avatar {
    width: 42px;
    height: 42px;
}

.nav {
    display: grid;
    gap: 8px;
    margin-top: 22px;
}

.nav a, .logout-button {
    display: flex;
    align-items: center;
    min-height: 42px;
    border-radius: 6px;
    padding: 0 12px;
    color: #e4e7ec;
    background: transparent;
    border: 0;
    width: 100%;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.nav a:hover, .logout-button:hover, .nav .active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.main {
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-gap {
    margin-top: 16px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
    padding: 18px;
}

.metric {
    font-size: 28px;
    font-weight: 800;
    margin-top: 8px;
}

.final-result-card {
    border-color: #0f766e;
    background: #ecfdf3;
    box-shadow: 0 16px 36px rgba(2, 122, 72, 0.14);
}

.final-result-card .muted {
    color: #05603a;
    font-weight: 800;
}

.final-result-card .metric {
    color: #034737;
    font-size: 34px;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.table-wrap {
    overflow-x: auto;
}

.table-scrollbar {
    overflow-x: auto;
    overflow-y: hidden;
    height: 16px;
    margin-bottom: 8px;
}

.table-scrollbar > div {
    height: 1px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.mini-table {
    min-width: 520px;
    margin-top: 8px;
    font-size: 13px;
}

.mini-table th,
.mini-table td {
    padding: 8px;
    vertical-align: top;
}

.history-old-value {
    background: #fff4e5;
    color: #8a4b00;
    font-weight: 700;
}

.history-new-value {
    background: #e8f7ef;
    color: #05603a;
    font-weight: 800;
}

.history-revert-form {
    margin-top: 10px;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #344054;
    font-size: 14px;
    background: #f9fafb;
}

.subnote-cell {
    padding-left: 34px;
    color: #475467;
    border-left: 3px solid #d0d5dd;
}

.result-final-row td {
    background: #dffbea;
    border-top: 3px solid #039855;
    border-bottom: 3px solid #039855;
}

.result-final-cell {
    font-weight: 900;
    color: #05603a;
    border-left: 8px solid var(--success);
    font-size: 17px;
}

.result-final-score strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    min-height: 34px;
    border-radius: 6px;
    background: #027a48;
    color: #fff;
    font-size: 18px;
}

.result-parent-cell {
    padding-left: 28px;
    font-weight: 700;
    color: #101828;
    border-left: 3px solid var(--brand);
}

.result-child-cell {
    padding-left: 54px;
    color: #344054;
    border-left: 3px solid #98a2b3;
}

.result-grandchild-cell {
    padding-left: 82px;
    color: #667085;
    border-left: 3px solid #d0d5dd;
}

.result-s4-cell {
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
}

.badge-success {
    color: var(--success);
    background: #ecfdf3;
}

.badge-danger {
    color: var(--danger);
    background: #fff1f0;
}

.badge-warning {
    color: var(--accent);
    background: #fffaeb;
}

.profile-head {
    display: flex;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}

.profile-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.profile-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fcfcfd;
    min-width: 0;
    overflow-wrap: anywhere;
}

.profile-item strong {
    display: block;
    margin-bottom: 5px;
}

.narrow-form {
    max-width: 520px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.form-span {
    grid-column: 1 / -1;
}

.action-card {
    display: block;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.action-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 118, 110, 0.38);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
    background: #fbfefd;
}

.action-card p {
    margin-bottom: 0;
}

.choice-summary {
    cursor: pointer;
    font-size: 18px;
    font-weight: 800;
    border-radius: 6px;
    padding: 4px 6px;
    margin: -4px -6px;
}

.choice-summary:hover {
    background: #eef7f6;
    color: var(--brand-dark);
}

details.card[open] .choice-summary {
    margin-bottom: 12px;
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.actions-cell form {
    margin: 0;
}

.publication-table td:first-child {
    font-weight: 800;
}

.publication-table .publication-year-0 td {
    background: #eef6ff;
    border-bottom-color: #d6e4ff;
}

.publication-table .publication-year-1 td {
    background: #edfdf5;
    border-bottom-color: #c7f0dd;
}

.publication-table .publication-year-0 td:first-child {
    box-shadow: inset 6px 0 0 #2f80ed;
}

.publication-table .publication-year-1 td:first-child {
    box-shadow: inset 6px 0 0 #0f766e;
}

.publication-table .publication-year-start td {
    border-top: 3px solid #98a2b3;
}

td a:hover,
.settings-admin-link:hover {
    color: var(--brand-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
}

tr:hover td {
    background-color: #fffdf5;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.checkbox-line input {
    width: 18px;
    height: 18px;
}

.list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.list-heading form {
    margin: 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 16px;
}

@media (max-width: 1100px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 16px;
    }

    .student-mini {
        padding-bottom: 14px;
    }

    .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        margin-top: 14px;
    }

    .nav a, .logout-button {
        min-height: 40px;
        justify-content: center;
        text-align: center;
        padding: 0 8px;
        font-size: 14px;
    }

    .main {
        padding: 18px;
    }

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

    .grid-3, .grid-2, .toolbar, .profile-list, .form-grid {
        grid-template-columns: 1fr;
    }

    .form-span {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .login-page {
        padding: 14px;
        align-items: start;
    }

    .login-box {
        padding: 20px;
        margin-top: 24px;
    }

    .login-brand {
        grid-template-columns: 1fr;
        gap: 14px;
        text-align: center;
    }

    .login-logo-shell {
        width: 132px;
        min-height: 88px;
        margin: 0 auto;
    }

    .pwa-install-card {
        grid-template-columns: 1fr;
    }

    .pwa-install-button {
        width: 100%;
    }

    .grid-4 {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 14px;
    }

    .card {
        padding: 14px;
    }

    .metric {
        font-size: 24px;
    }

    .profile-head {
        align-items: flex-start;
    }

    table {
        min-width: 760px;
    }
}
