:root {
    --page: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --text: #182230;
    --muted: #667085;
    --border: #d9e0e7;
    --primary: #155eef;
    --primary-hover: #004eeb;
    --accent: #087e68;
    --accent-soft: #e9f7f3;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --success: #067647;
    --success-soft: #ecfdf3;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    color: var(--text);
    background: var(--page);
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
input,
select,
textarea {
    transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(21, 94, 239, .2);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.site-shell {
    width: min(100%, 940px);
    margin: 0 auto;
}

.topbar {
    display: flex;
    min-height: 70px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}

.brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 800;
    text-decoration: none;
}

.brand img {
    width: 68px;
    height: 44px;
    object-fit: contain;
}

.teacher-link,
.secondary-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #344054;
    background: var(--surface);
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.teacher-link:hover,
.secondary-button:hover {
    border-color: #aab5c0;
    background: var(--surface-soft);
}

.correction-panel {
    margin-top: 20px;
}

.auth-view {
    width: min(100%, 460px);
    margin: 64px auto 0;
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .08);
}

.eyebrow,
.panel-kicker {
    margin: 0 0 7px;
    color: var(--accent);
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    color: var(--text);
    letter-spacing: 0;
}

h1 {
    margin: 0;
    font-size: 1.85rem;
    line-height: 1.2;
}

h2 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.3;
}

.login-form,
.correction-form {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.login-form label,
.correction-form label {
    margin-top: 6px;
    color: #344054;
    font-size: .86rem;
    font-weight: 700;
}

.login-form input,
.correction-form input,
.correction-form select,
.correction-form textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #b8c2cc;
    border-radius: 6px;
    color: var(--text);
    background: var(--surface);
}

.correction-form textarea {
    min-height: 96px;
    resize: vertical;
}

.login-form input:hover,
.correction-form input:hover,
.correction-form select:hover,
.correction-form textarea:hover {
    border-color: #8795a4;
}

.login-form input:focus,
.correction-form input:focus,
.correction-form select:focus,
.correction-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 94, 239, .12);
    outline: none;
}

.login-form button,
.correction-form > button,
.import-panel > button {
    min-height: 44px;
    margin-top: 8px;
    padding: 10px 16px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #ffffff;
    background: var(--primary);
    font-weight: 800;
    cursor: pointer;
}

.login-form button:hover,
.correction-form > button:hover,
.import-panel > button:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.login-form .link-button {
    min-height: 36px;
    margin-top: 2px;
    padding: 7px 10px;
    border: 0;
    color: var(--primary);
    background: transparent;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
}

.login-form .link-button:hover {
    color: var(--primary-hover);
    background: #f0f5ff;
}

button:disabled {
    cursor: wait;
    opacity: .55;
}

.admin-heading,
.history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.admin-heading {
    padding: 6px 2px 14px;
}

.manual-panel,
.import-panel,
.history-panel {
    margin-top: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}

.import-panel {
    border-top: 4px solid var(--accent);
}

.import-panel dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.import-panel dl div {
    padding: 14px;
    border: 1px solid #cce8e1;
    border-radius: 6px;
    background: var(--accent-soft);
}

.import-panel dt {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.import-panel dd {
    margin: 4px 0 0;
    color: #075e54;
    font-size: 1.1rem;
    font-weight: 800;
}

.import-entries {
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.import-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 54px;
    gap: 12px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.import-entry:nth-child(even) {
    background: var(--surface-soft);
}

.import-entry:last-child {
    border-bottom: 0;
}

.import-entry strong {
    color: var(--accent);
    text-align: right;
}

.delta-control {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 10px;
}

.quick-values {
    display: grid;
    grid-template-columns: repeat(6, minmax(42px, 1fr));
    gap: 6px;
}

.quick-values button {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #344054;
    background: var(--surface-soft);
    font-weight: 800;
    cursor: pointer;
}

.quick-values button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f5ff;
}

.zero-team-button {
    justify-self: start;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid #f5b7b1;
    border-radius: 6px;
    color: var(--danger);
    background: var(--danger-soft);
    font-weight: 800;
    cursor: pointer;
}

.zero-team-button:hover {
    border-color: var(--danger);
    background: #fee4e2;
}

.point-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 4px 0;
}

.point-preview span {
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: .8rem;
    font-weight: 700;
}

.point-preview strong {
    display: block;
    margin-top: 2px;
    color: var(--text);
    font-size: 1.15rem;
}

.form-message {
    min-height: 22px;
    margin: 12px 0 0;
    color: var(--danger);
    font-size: .87rem;
    font-weight: 700;
}

.form-message:not(:empty) {
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--danger-soft);
}

.form-message.success {
    color: var(--success);
    background: var(--success-soft);
}

.booking-dialog {
    width: min(calc(100% - 28px), 560px);
    max-height: calc(100vh - 28px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 24px 60px rgba(16, 24, 40, .22);
}

.booking-dialog::backdrop {
    background: rgba(24, 34, 48, .54);
}

.booking-form {
    display: grid;
    gap: 10px;
    padding: 26px;
}

.booking-form label {
    margin-top: 5px;
    color: #344054;
    font-size: .86rem;
    font-weight: 700;
}

.booking-form input,
.booking-form textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #b8c2cc;
    border-radius: 6px;
    color: var(--text);
    background: var(--surface);
}

.booking-form textarea {
    min-height: 84px;
    resize: vertical;
}

.booking-form input:focus,
.booking-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 94, 239, .12);
    outline: none;
}

.booking-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 4px;
}

.booking-summary div {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-soft);
}

.booking-summary dt {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
}

.booking-summary dd {
    margin: 3px 0 0;
    font-size: 1rem;
    font-weight: 800;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.dialog-actions > button {
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 6px;
    font-weight: 800;
    cursor: pointer;
}

.dialog-actions > button[type="submit"] {
    border: 1px solid var(--primary);
    color: #ffffff;
    background: var(--primary);
}

.dialog-actions > button[type="submit"]:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.history-list {
    margin-top: 16px;
    overflow: hidden;
    border-top: 1px solid var(--border);
}

.history-header,
.history-entry {
    display: grid;
    grid-template-columns: 82px 58px minmax(90px, 1fr) 58px 62px minmax(140px, 2fr);
    gap: 10px;
    align-items: start;
}

.history-header {
    padding: 9px 4px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.history-entry {
    padding: 13px 4px;
    border-bottom: 1px solid var(--border);
    font-size: .84rem;
}

.history-entry strong {
    color: var(--primary);
}

.history-initials {
    font-weight: 800;
}

@media (max-width: 680px) {
    body {
        padding: 10px;
    }

    .topbar {
        min-height: 62px;
        padding: 9px 11px;
    }

    .brand {
        gap: 8px;
        font-size: .84rem;
    }

    .brand img {
        width: 52px;
        height: 36px;
    }

    .teacher-link,
    .secondary-button {
        min-height: 38px;
        padding: 8px 10px;
        font-size: .78rem;
    }

    .auth-view {
        margin-top: 28px;
        padding: 22px 18px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .manual-panel,
    .import-panel,
    .history-panel {
        padding: 17px 14px;
    }

    .delta-control {
        grid-template-columns: 1fr;
    }

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

    .import-panel dl,
    .point-preview {
        grid-template-columns: 1fr 1fr;
    }

    .import-entry {
        grid-template-columns: minmax(0, 1fr) 42px;
        gap: 7px;
        padding: 10px 8px;
        font-size: .76rem;
    }

    .booking-form {
        padding: 20px 16px;
    }

    .history-header {
        display: none;
    }

    .history-entry {
        grid-template-columns: 76px 56px minmax(80px, 1fr) 48px;
        gap: 8px;
    }

    .history-entry .history-initials {
        grid-column: 1;
        grid-row: 2;
    }

    .history-entry span:last-child {
        grid-column: 2 / -1;
        grid-row: 2;
        color: var(--muted);
    }
}

@media (max-width: 430px) {
    .brand span {
        display: none;
    }

    .admin-heading,
    .history-heading {
        align-items: flex-start;
    }

    .import-panel dl,
    .point-preview,
    .booking-summary {
        grid-template-columns: 1fr;
    }

    .dialog-actions {
        flex-direction: column-reverse;
    }

    .dialog-actions > button {
        width: 100%;
    }
}
