@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Work+Sans:wght@400;600&display=swap');

:root {
    --bg: #fbf9f2;
    --card: #ffffff;
    --ink: #001e4e;
    --muted: #4a5875;
    --accent: #03318c;
    --accent-soft: #e8eefc;
    --highlight: #f7d070;
    --border: #d6dbe8;
    --error: #7d2e2e;
    --success: #2c5b3c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Work Sans", "Trebuchet MS", Arial, sans-serif;
    background: linear-gradient(160deg, #f5f7fc 0%, var(--bg) 40%, #fffdf7 100%);
    color: var(--ink);
}

body:not(.auth-page) {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3 {
    font-family: "Libre Baskerville", "Times New Roman", serif;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    background: var(--card);
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(28, 24, 18, 0.12);
    max-width: 360px;
    width: 100%;
    text-align: left;
}

.auth-logo {
    height: 28px;
    width: auto;
    margin-bottom: 16px;
}

.auth-card h1 {
    margin: 0 0 8px;
}

.auth-card p {
    margin: 0 0 24px;
    color: var(--muted);
}

label {
    display: block;
    margin: 16px 0 6px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

button {
    margin-top: 20px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

button:hover {
    opacity: 0.9;
}

.notice {
    padding: 12px 14px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
}

.notice.error {
    background: #fbeaea;
    color: var(--error);
}

.notice.success {
    background: #e9f7ef;
    color: var(--success);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand img {
    height: 28px;
    width: auto;
}

.brand strong {
    font-size: 18px;
}

.admin-header nav a {
    margin: 0 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
}

.admin-header nav a:hover {
    color: var(--accent);
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user a {
    color: var(--accent);
    text-decoration: none;
}

.admin-main {
    padding: 24px;
    flex: 1;
}

.card {
    background: var(--card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(28, 24, 18, 0.08);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.metric {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.metric strong {
    display: block;
    font-size: 28px;
}

.metric span {
    color: var(--muted);
    font-size: 14px;
}

.workflow {
    margin: 0;
    padding-left: 18px;
}

.workflow li {
    margin-bottom: 8px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 24px;
}

.panel {
    background: #f6f8fd;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.session-meta {
    display: flex;
    gap: 24px;
    margin: 20px 0;
}

.session-meta div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--muted);
}

.session-meta strong {
    color: var(--ink);
    font-size: 14px;
}

.inline-form {
    margin-bottom: 20px;
}

.inline-form button {
    width: auto;
}

.session-sizing {
    margin-bottom: 24px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 8px;
    font-size: 14px;
    color: var(--muted);
}

.checkbox input {
    width: auto;
}

.criteria-weight {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.criteria-weight input {
    width: 70px;
}

.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.group-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-card.is-bonus {
    border-style: dashed;
    background: #fffdf7;
}

.badge-bonus {
    background: #eaf6e4;
    color: #2e5b2a;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.group-name {
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 6px 8px;
    width: 65%;
}

.badge {
    background: var(--highlight);
    color: #4a3b12;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
}

.badge-ok {
    background: #edf3ff;
    color: #1f3766;
}

.badge-warn {
    background: #fdf0cf;
    color: #6a4f14;
}

.group-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
    border: 1px dashed transparent;
    border-radius: 10px;
    padding: 8px;
    background: #fbfaf7;
}

.group-list.is-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.student-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
    cursor: grab;
    font-size: 13px;
}

.student-chip:active {
    cursor: grabbing;
}

.student-chip.repeat-low {
    border-color: #f4c66a;
    background: #fff7df;
}

.student-chip.repeat-med {
    border-color: #f0a14a;
    background: #fff1e1;
}

.student-chip.repeat-high {
    border-color: #e0675b;
    background: #ffe9e7;
}

.chip-meta {
    color: var(--muted);
    font-size: 12px;
}

.group-meta {
    font-size: 12px;
    color: var(--muted);
}

.repeat-details {
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #f9fbff;
}

.repeat-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
}

.repeat-details ul {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.repeat-details li span {
    display: block;
    font-size: 13px;
    color: var(--ink);
    font-weight: 600;
}

.repeat-details li em {
    font-style: normal;
    color: var(--muted);
    font-size: 12px;
}

.session-list {
    display: grid;
    gap: 16px;
}

.session-nav-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 16px;
    display: grid;
    gap: 8px;
}

.session-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7f8fc;
    border: 1px solid var(--border);
}

.session-nav-item.active {
    background: #eef2ff;
    border-color: #c9d3ff;
    font-weight: 600;
}

.session-nav-meta {
    font-size: 12px;
    color: var(--muted);
}

.collapsible {
    margin-top: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 8px 16px 16px;
}

.collapsible summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
    font-size: 16px;
    padding: 10px 0;
}

.session-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.session-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.session-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.session-order {
    display: flex;
    gap: 4px;
}

.session-order button {
    width: auto;
    margin: 0;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
}

.session-order button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.session-card-header h3 {
    margin: 0 0 4px;
}

.session-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
}

.session-card-meta > span:not(.badge) {
    background: #f5f7fd;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
}

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

.publish-card {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.publish-card button {
    width: auto;
}

.embed-box {
    margin-top: 12px;
    padding: 12px;
    background: #f5f7fd;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 13px;
}

.embed-box code {
    display: block;
    margin: 8px 0 12px;
    padding: 8px;
    background: #fff;
    border-radius: 8px;
    border: 1px dashed var(--border);
    word-break: break-all;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

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

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

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
}

.link-button.danger {
    color: var(--error);
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
}

.icon-button:hover {
    background: #f5f7fd;
}

.icon-button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-bar button {
    width: auto;
    margin-top: 0;
}

.student-filter label {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.student-filter input,
.student-filter select {
    min-width: 140px;
}

.help {
    font-size: 12px;
    color: var(--muted);
}

.link {
    color: var(--accent);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.site-footer {
    margin-top: auto;
    padding: 16px 24px;
    border-radius: 0;
    background: #ffffff;
    border-top: 1px solid var(--border);
    border-left: none;
    border-right: none;
    border-bottom: none;
    color: var(--muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

@media (max-width: 720px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .admin-header nav a {
        margin-left: 0;
    }

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

    .session-meta {
        flex-direction: column;
    }
}
