:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #172026;
    --muted: #66727a;
    --line: #d9e0e4;
    --primary: #1f6f5b;
    --primary-dark: #174f42;
    --warn: #9a6200;
    --danger: #a73838;
    --success: #267a4d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 700;
    color: var(--text);
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

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

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 64px;
}

.auth-panel,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.auth-panel {
    width: min(440px, 100%);
    margin: 64px auto;
}

h1,
h2 {
    margin: 0 0 16px;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.section-head p,
.muted {
    color: var(--muted);
    margin: 0 0 12px;
}

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

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

.compact-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

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

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    padding: 0 16px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover,
.button-link:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

button.secondary {
    background: #eef2f3;
    color: var(--text);
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-range input {
    min-width: 150px;
}

.flash-list {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    border-radius: 8px;
    padding: 12px 14px;
    background: #eef6f3;
    color: var(--primary-dark);
    border: 1px solid #c8e2d9;
}

.flash.error {
    background: #fff0f0;
    color: var(--danger);
    border-color: #f0c7c7;
}

.rule-strip,
.stats-row,
.score-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.rule-strip span,
.rule-strip strong,
.stat,
.score-grid div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

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

.stat span,
.score-grid span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat strong,
.score-grid strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
}

.panel + .panel,
.panel + .stats-row,
.stats-row + .panel {
    margin-top: 20px;
}

.item-list {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.work-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.work-item.readonly {
    display: block;
}

.item-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.work-item p {
    margin: 0 0 10px;
}

.work-item small {
    color: var(--muted);
}

.completion-form {
    display: grid;
    gap: 10px;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.checkline input {
    width: auto;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 9px;
    background: #e9f3ef;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
}

.tag.warn {
    background: #fff3d8;
    color: var(--warn);
}

.tag.danger {
    background: #ffe7e7;
    color: var(--danger);
}

.tag.success {
    background: #e7f6ed;
    color: var(--success);
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

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

.actions {
    display: flex;
    gap: 8px;
}

.message-box {
    min-height: 180px;
    font-family: Consolas, "Microsoft YaHei", monospace;
}

.note {
    padding: 12px;
    background: #f7f9fa;
    border-radius: 6px;
}

@media (max-width: 820px) {
    .topbar,
    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar nav,
    .inline-form {
        flex-wrap: wrap;
    }

    .grid-form,
    .review-form,
    .compact-form,
    .rule-strip,
    .stats-row,
    .score-grid,
    .work-item {
        grid-template-columns: 1fr;
    }
}
