: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: 1180px;
    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: 1180px;
    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);
}

.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;
}

.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;
}

.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);
}

.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--teacher-records {
    min-width: 1120px;
}

.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;
}

.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 {
        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;
    }
}
