:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --line: #d6ddea;
    --text: #243447;
    --muted: #748396;
    --accent: #2f6ee5;
    --accent-soft: #e7efff;
    --submit-bg: #e7f5ee;
    --submit-text: #1e7b4a;
    --missing-bg: #fdeeee;
    --missing-text: #c84545;
    --score-bg: #eef3ff;
    --score-border: #c7d6ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
}

body.modal-open {
    overflow: hidden;
}

.page {
    width: 100%;
    padding: 20px;
}

.toolbar,
.table-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    padding: 18px 20px;
    margin-bottom: 16px;
}

h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.toolbar p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.toolbar-actions {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}

.date-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

input,
button {
    font: inherit;
}

input[type="date"] {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}

.range-switch {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.range-btn,
.refresh-btn {
    border: 0;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

.range-btn {
    padding: 10px 14px;
    border-right: 1px solid var(--line);
}

.range-btn:last-child {
    border-right: 0;
}

.range-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}

.refresh-btn {
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
}

.table-panel {
    padding: 16px;
}

.table-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
}

.legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid var(--line);
}

.ok-box {
    background: var(--submit-bg);
}

.miss-box {
    background: var(--missing-bg);
}

.score-box {
    background: var(--score-bg);
    border-color: var(--score-border);
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    text-align: center;
    padding: 0;
}

thead th {
    position: sticky;
    top: 0;
    background: #f8fbff;
    z-index: 3;
    height: 72px;
    font-size: 18px;
}

th.name-col {
    min-width: 220px;
    left: 0;
    z-index: 4;
}

.date-col {
    min-width: 116px;
}

.lobster-cell {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
    min-width: 220px;
    text-align: left;
    padding: 16px 18px;
}

.lobster-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.lobster-owner {
    margin-top: 6px;
    color: #4f6278;
    font-size: 14px;
}

.lobster-code {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.matrix-cell {
    height: 92px;
    transition: background-color 0.18s ease;
    position: relative;
}

.matrix-cell.clickable {
    cursor: pointer;
}

.matrix-cell.clickable:hover {
    box-shadow: inset 0 0 0 2px rgba(47, 110, 229, 0.18);
}

.submitted-bg {
    background: var(--submit-bg);
}

.missing-bg {
    background: var(--missing-bg);
}

.cell-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 8px 18px;
}

.count-number {
    min-width: 30px;
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
}

.submitted-bg .count-number {
    color: var(--submit-text);
}

.missing-bg .count-number {
    color: var(--missing-text);
}

.score-bar {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: 10px;
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 2px;
}

.score-bar.disabled {
    opacity: 0.45;
}

.score-block {
    height: 100%;
    background: #e8edf5;
    border: 1px solid #d4dbe8;
}

.score-block.active {
    background: #5f88e8;
    border-color: #4f79db;
}

.detail-modal.hidden {
    display: none;
}

.detail-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
}

.detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 31, 53, 0.32);
}

.detail-panel {
    position: relative;
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    margin: 24px auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(28, 43, 68, 0.18);
    padding: 20px;
}

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

.detail-header h2 {
    margin: 0 0 6px;
    font-size: 24px;
}

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

.detail-close-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
}

.detail-content {
    display: grid;
    gap: 12px;
}

.detail-card {
    border: 1px solid var(--line);
    background: #f9fbff;
    border-radius: 14px;
    padding: 16px;
}

.detail-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

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

.detail-score {
    color: var(--accent);
    font-weight: 700;
}

.detail-time {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.detail-block + .detail-block {
    margin-top: 12px;
}

.detail-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.detail-text {
    margin: 0;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
}

.detail-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: #fbfcff;
}

.empty-cell {
    color: var(--muted);
    padding: 24px 0;
}

@media (max-width: 980px) {
    .toolbar,
    .toolbar-actions,
    .table-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .date-col {
        min-width: 100px;
    }

    .matrix-cell {
        height: 84px;
    }

    .count-number {
        font-size: 28px;
    }

    .detail-panel {
        width: calc(100vw - 20px);
        margin: 10px auto;
        max-height: calc(100vh - 20px);
        padding: 16px;
    }
}
