:root {
    --bg: #f5f7f8;
    --surface: #ffffff;
    --text: #14201c;
    --muted: #68756f;
    --line: #dce4e0;
    --primary: #0b8f6f;
    --primary-dark: #06745a;
    --primary-soft: #e9f7f2;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 10px 28px rgba(20, 32, 28, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    max-width: 1300px;
    margin: 0 auto;
    min-height: 64px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    white-space: nowrap;
}

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

.brand__mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

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

.nav a,
.userbar a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
}

.nav a.is-active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 700;
}

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

.page {
    max-width: 1300px;
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.auth-shell {
    min-height: calc(100vh - 130px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 520px;
    padding: 30px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-card h1,
.page-heading h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.25;
}

.auth-card p,
.page-heading p {
    margin: 8px 0 0;
    color: var(--muted);
}

.auth-card__intro {
    margin-bottom: 24px;
}

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

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    margin-bottom: 18px;
}

.panel--table {
    padding: 0;
    overflow: hidden;
}

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

.section-title h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
}

.section-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.manual-panel {
    display: grid;
    gap: 18px;
}

.manual-section {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.manual-section:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.manual-section h2 {
    margin: 0 0 10px;
    font-size: 18px;
    line-height: 1.35;
}

.manual-section p,
.manual-section li {
    color: var(--text);
    line-height: 1.8;
}

.manual-section p {
    margin: 0 0 8px;
}

.manual-section ol,
.manual-section ul {
    margin: 0;
    padding-left: 22px;
}

.form,
.filters {
    display: grid;
    gap: 16px;
}

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

.filters {
    grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
    align-items: end;
}

.filters--admin {
    grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
}

.field {
    display: grid;
    gap: 7px;
}

.field--full {
    grid-column: 1 / -1;
}

.field span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cfd9d4;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(11, 143, 111, 0.14);
    border-color: var(--primary);
}

input[readonly] {
    background: #f1f5f3;
    color: var(--muted);
}

.btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
}

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

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

.btn--ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}

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

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

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

.btn--danger:hover {
    background: #8f1f16;
}

.btn--block {
    width: 100%;
}

.btn--sm {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 13px;
}

.form-actions,
.filter-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.outline-history {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.outline-history-trigger {
    margin-left: 10px;
    box-shadow: 0 8px 18px rgba(13, 148, 136, 0.18);
}

.outline-history__message {
    color: var(--muted);
    font-size: 14px;
}

.outline-history__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
}

.outline-history__item span {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.copy-outline-button {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    line-height: inherit;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.copy-outline-button:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.view-outline-button {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    line-height: inherit;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.view-outline-button:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.outline-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.outline-modal.is-open {
    display: flex;
}

.outline-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 32, 28, 0.45);
}

.outline-modal__panel {
    position: relative;
    z-index: 1;
    width: min(720px, calc(100vw - 32px));
    max-height: min(76vh, 680px);
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.outline-modal__header,
.outline-modal__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.outline-modal__actions {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.outline-modal__header h2 {
    margin: 0;
    font-size: 18px;
}

.outline-modal__close {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
}

.outline-modal__body {
    padding: 16px;
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.7;
}

.inline-form {
    margin: 0;
}

.inline-form--stack {
    display: grid;
    gap: 6px;
    min-width: 132px;
    margin-bottom: 8px;
}

.inline-form--stack:last-child {
    margin-bottom: 0;
}

.inline-form--stack input,
.inline-form--stack select {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 116px;
    white-space: nowrap;
}

.table-actions .inline-form {
    display: inline-flex;
    flex: 0 0 auto;
}

.table-actions .btn {
    width: auto;
    flex: 0 0 auto;
}

.filter-actions {
    padding-bottom: 1px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
}

.alert--success {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-color: #bfe9dc;
}

.alert--error {
    background: #fff1f0;
    color: var(--danger);
    border-color: #ffd3cf;
}

.alert--info {
    background: #eff6ff;
    color: #1d4e89;
    border-color: #c8ddff;
}

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

.record-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.record-card__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.record-card__head strong,
.record-card__head span {
    display: block;
}

.record-card__head span {
    color: var(--muted);
}

.status-dot {
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark) !important;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex !important;
    align-items: center;
    white-space: nowrap;
}

.status-dot--warning {
    margin-top: 6px;
    background: #fff4df;
    color: var(--warning) !important;
}

.status-dot--void {
    background: #f1f3f2;
    color: var(--muted) !important;
}

.row-warning {
    background: #fffaf0;
}

.record-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 12px;
}

.record-meta div {
    min-width: 0;
}

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

.record-meta dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
}

.record-card p {
    margin: 0;
    color: #35413d;
}

.table-summary {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}

.table-summary strong {
    color: var(--text);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
    padding: 12px 16px 16px;
    background: #fbfcfc;
    border-top: 1px solid var(--line);
}

.pagination__summary {
    color: var(--muted);
    font-size: 14px;
    margin-right: auto;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

.data-table--accounts {
    min-width: 920px;
}





.data-table th,
.data-table td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.data-table th {
    background: #f8faf9;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.data-table td {
    overflow-wrap: anywhere;
}

.data-table td.table-cell--outline {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table--admin-home th,
.data-table--admin-home td {
    white-space: nowrap;
}

.data-table--admin-home .table-cell--outline {
    width: 260px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table--teacher-records th,
.data-table--teacher-records td {
    white-space: nowrap;
}

.data-table--teacher-records .table-cell--outline {
    width: 280px;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state,
.empty-cell {
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 8px;
}

.empty-cell {
    border: 0;
}

.check-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf9;
}

.check-item {
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.check-item input {
    width: 18px;
    min-height: 18px;
    flex: 0 0 18px;
}

.check-item span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.teacher-permission-groups {
    display: grid;
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf9;
}

.teacher-permission-group {
    display: grid;
    gap: 8px;
}

.teacher-permission-group__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-dark);
}

.teacher-permission-group__items {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

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

@media (max-width: 900px) {
    .topbar__inner {
        min-height: auto;
        padding: 12px 16px;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px 12px;
    }

    .brand {
        flex: 1 1 auto;
        min-width: 0;
        max-width: calc(100% - 112px);
        font-size: 17px;
    }

    .brand span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand__mark {
        flex: 0 0 32px;
    }

    .nav {
        order: 3;
        width: 100%;
        flex: 0 0 100%;
        overflow-x: auto;
        padding-top: 4px;
        gap: 8px;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav a {
        min-height: 38px;
        flex: 0 0 auto;
        padding: 0 14px;
        white-space: nowrap;
        writing-mode: horizontal-tb;
    }

    .userbar {
        flex: 0 0 auto;
        margin-left: auto;
        gap: 8px;
        white-space: nowrap;
    }

    .userbar span {
        max-width: 58px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .userbar a {
        padding: 0 8px;
        white-space: nowrap;
    }

    .page {
        padding: 20px 14px 36px;
    }

    .page-heading {
        display: grid;
    }

    .section-title {
        display: grid;
    }

    .form--grid,
    .filters,
    .filters--admin,
    .records-grid,
    .check-list,
    .teacher-permission-group__items {
        grid-template-columns: 1fr;
    }

    .panel,
    .auth-card {
        padding: 18px;
    }

    .record-meta {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .btn {
        width: 100%;
    }

    .form-actions,
    .filter-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .table-actions .btn {
        width: auto;
    }
}

@media (max-width: 420px) {
    .topbar__inner {
        padding: 10px 12px;
        gap: 8px 10px;
    }

    .brand {
        font-size: 16px;
        gap: 8px;
        max-width: calc(100% - 98px);
    }

    .brand__mark {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .nav a {
        min-height: 36px;
        padding: 0 12px;
    }

    .userbar {
        font-size: 13px;
    }

    .userbar span {
        max-width: 46px;
    }
}
