/* ============================================================
   地区日报工作台 · 设计系统 v3
   扁平、克制：白底、细边框、小圆角、单一深青绿主色。
   数据色：蓝 = 普教，橙 = 竞赛，石板灰 = 地区，红 = 未知 / 错误。
   不使用渐变、发光阴影和装饰色块。
   ============================================================ */

:root {
    --bg: #ffffff;
    --subtle: #f7f8fa;
    --line: #e4e7ec;
    --line-strong: #cfd4dc;
    --ink: #1b1f24;
    --ink-soft: #3d444d;
    --muted: #667085;
    --faint: #98a2b3;

    --primary: #0f766e;
    --primary-dark: #0b5c56;
    --primary-soft: #e8f4f2;
    --primary-line: #b7dcd7;

    --edu: #1d4ed8;
    --edu-soft: #eaf0fd;
    --contest: #c2570c;
    --contest-soft: #fdf0e4;
    --region: #475467;
    --region-soft: #f0f2f5;
    --danger: #c0362c;
    --danger-soft: #fdeeed;

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
    --font-sans: "Noto Sans SC", -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

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

button,
input,
textarea {
    font: inherit;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.hidden {
    display: none !important;
}

/* ---------- 应用外壳：侧边栏 + 内容 ---------- */

.page-shell {
    width: min(1120px, calc(100% - 48px));
    margin: 0 auto;
    padding-bottom: 72px;
}

.app {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    min-height: 100vh;
}

.app .page-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 32px clamp(24px, 3.5vw, 64px) 72px;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100vh;
    padding: 20px 12px;
    border-right: 1px solid var(--line);
    background: var(--subtle);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 8px 20px;
    font-size: 16px;
    font-weight: 700;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.side-nav {
    display: grid;
    gap: 2px;
    flex: 1;
    align-content: start;
}

.side-title {
    margin: 18px 12px 4px;
    color: var(--faint);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--ink-soft);
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}

.side-link svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--muted);
}

.side-link:hover {
    background: #eceff3;
    color: var(--ink);
}

.side-link.active {
    background: #fff;
    color: var(--primary-dark);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--primary), 0 0 0 1px var(--line);
}

.side-link.active svg {
    color: var(--primary);
}

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: 0 0 0 1px var(--line);
}

.avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
}

.side-user-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    font-weight: 500;
}

.side-logout {
    padding: 4px 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.side-logout:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.page-content {
    display: grid;
    gap: 20px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.page-head h1 {
    font-size: 26px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
    word-break: break-all;
}

.page-head .status-note {
    margin-top: 6px;
}

.page-head .page-sub {
    margin-top: 4px;
    color: var(--muted);
}

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

/* ---------- 卡片 ---------- */

.panel {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    font-size: 16px;
    font-weight: 700;
}

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

.empty-panel {
    padding: 48px 24px;
    text-align: center;
}

.empty-panel h2 {
    font-size: 18px;
}

.empty-panel p {
    margin: 8px auto 0;
    max-width: 420px;
    color: var(--muted);
}

.empty-panel .button-row {
    justify-content: center;
}

/* ---------- 按钮 ---------- */

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

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

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

.btn-secondary {
    color: var(--ink);
    border-color: var(--line-strong);
    background: #fff;
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--ink);
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--ink);
    background: var(--subtle);
}

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

.btn-danger:hover:not(:disabled) {
    background: #a22c23;
}

.btn-small {
    min-height: 30px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-large {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
}

.btn:focus-visible,
.tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- 状态提示 ---------- */

.status-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.status-note.success {
    color: var(--primary);
}

.status-note.error {
    color: var(--danger);
}

.status-note.dirty {
    color: var(--contest);
    font-weight: 600;
}

/* ---------- 表单 ---------- */

input[type="text"],
input[type="password"],
input[type="search"] {
    width: 100%;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--ink);
    transition: border-color 0.12s, box-shadow 0.12s;
}

input::placeholder,
textarea::placeholder {
    color: var(--faint);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

textarea.test-address {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--ink);
    resize: vertical;
}

.mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 14px;
}

.text-link {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
}

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

.link-btn {
    padding: 0;
    border: none;
    background: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

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

/* ---------- 数据指标卡 ---------- */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metric-card {
    padding: 18px 22px 20px;
    border: 1px solid var(--line);
    border-top: 3px solid var(--ink);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.metric-card span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.metric-card strong {
    display: block;
    font-size: 44px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.metric-card:nth-child(1) {
    border-top-color: var(--edu);
}

.metric-card:nth-child(1) strong {
    color: var(--edu);
}

.metric-card:nth-child(2) {
    border-top-color: var(--contest);
}

.metric-card:nth-child(2) strong {
    color: var(--contest);
}

.metric-card:nth-child(3) {
    border-top-color: var(--region);
}

.metric-card:nth-child(3) strong {
    color: var(--ink);
}

.chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.chip b {
    font-size: 15px;
}

.chip.edu {
    color: var(--edu);
    background: var(--edu-soft);
}

.chip.contest {
    color: var(--contest);
    background: var(--contest-soft);
}

.chip.region {
    color: var(--region);
    background: var(--region-soft);
}

.file-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
}

/* ---------- 工作台（首页） ---------- */

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
    gap: 20px;
    align-items: start;
}

.side-stack {
    display: grid;
    gap: 20px;
}

.recent-list {
    display: grid;
    gap: 2px;
}

.recent-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    margin: 0 -12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    transition: background 0.12s;
}

.recent-item:hover {
    background: var(--subtle);
}

.recent-main {
    display: grid;
    min-width: 0;
}

.recent-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-main small {
    color: var(--muted);
}

.empty-inline {
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: 8px 0;
    color: var(--muted);
}

.quick-card {
    display: grid;
    gap: 10px;
}

.quick-card .panel-header {
    margin-bottom: 4px;
}

.quick-card .btn {
    justify-self: start;
    margin-top: 4px;
}

.rules-count {
    color: var(--ink-soft);
}

.rules-count b {
    font-size: 26px;
    color: var(--primary);
}

.how-to {
    margin: 0;
    padding-left: 20px;
    color: var(--ink-soft);
    line-height: 2;
}

.how-to a {
    color: var(--primary);
    font-weight: 600;
}

/* ---------- 数据处理页 ---------- */

.stepper {
    display: flex;
    align-items: center;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
}

.stepper-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--faint);
    font-weight: 600;
}

.stepper-item:not(:last-child)::after {
    content: "";
    width: 48px;
    height: 1px;
    margin: 0 14px;
    background: var(--line-strong);
}

.stepper-item b {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px var(--line-strong);
    font-size: 13px;
}

.stepper-item.active {
    color: var(--ink);
}

.stepper-item.active b {
    background: var(--primary);
    box-shadow: none;
    color: #fff;
}

.stepper-item.done {
    color: var(--primary-dark);
}

.stepper-item.done b {
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1.5px var(--primary);
    color: var(--primary-dark);
}

.stepper-item.done:not(:last-child)::after {
    background: var(--primary);
}

.process-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 420px);
    gap: 20px;
    align-items: stretch;
    min-height: calc(100vh - 300px);
}

.wizard-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
}

.wizard-card .status-note {
    text-align: center;
}

.dropzone {
    display: grid;
    flex: 1;
    align-content: center;
    justify-items: center;
    gap: 6px;
    min-height: 360px;
    padding: 40px 24px;
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--subtle);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.dropzone::before {
    content: "↑";
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: 0 0 0 1px var(--line-strong);
    color: var(--ink-soft);
    font-size: 22px;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.dropzone.has-file {
    border-style: solid;
    border-color: var(--primary);
    background: var(--primary-soft);
}

.dropzone.has-file::before {
    content: "✓";
    background: var(--primary);
    box-shadow: none;
    color: #fff;
}

.dropzone-title {
    font-size: 17px;
    font-weight: 700;
}

.dropzone-copy {
    color: var(--muted);
    font-size: 13px;
    word-break: break-all;
}

#fileInput {
    display: none;
}

.col-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-weight: 500;
}

.col-list li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.col-list b {
    padding: 0 8px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 12px;
}

.col-list .optional {
    color: var(--muted);
}

.col-list .optional b {
    background: var(--region-soft);
    color: var(--muted);
}

/* ---------- 映射规则页 ---------- */

.rules-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.rules-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tabs {
    display: flex;
    gap: 22px;
}

.tab {
    margin-bottom: -1px;
    padding: 10px 0;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

.tab:hover {
    color: var(--ink);
}

.tab.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

.tab-count {
    margin-left: 4px;
    padding: 0 7px;
    border-radius: var(--radius-sm);
    background: var(--region-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.tab.active .tab-count {
    background: var(--primary);
    color: #fff;
}

.rules-search {
    width: 180px;
}

.rules-toolbar .rules-search {
    min-height: 32px;
}

.rules-hint {
    margin: 12px 0 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.rule-scroll {
    max-height: calc(100vh - 300px);
    min-height: 240px;
    margin-top: 10px;
    padding: 3px 6px 3px 3px;
    overflow-y: auto;
}

.mapping-list {
    display: grid;
    gap: 8px;
}

.mapping-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.mapping-row[hidden] {
    display: none;
}

.mapping-row .mapping-value {
    background: var(--primary-soft);
    border-color: var(--primary-line);
    color: var(--primary-dark);
    font-weight: 600;
}

.mapping-row.invalid input.mapping-key {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.mapping-row.hit input {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
}

.arrow {
    color: var(--faint);
}

.remove-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--faint);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.remove-btn:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.tester-panel {
    position: sticky;
    top: 24px;
    display: grid;
    gap: 12px;
}

.tester-panel .rules-hint {
    margin: 0;
}

.test-result {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
}

.test-result[hidden] {
    display: none;
}

.test-result.ok {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.test-result.miss {
    background: var(--danger-soft);
    color: var(--danger);
}

.test-label {
    font-size: 12px;
    font-weight: 700;
}

.test-region {
    font-size: 20px;
    line-height: 1.3;
}

.test-detail {
    font-size: 13px;
    opacity: 0.85;
    word-break: break-all;
}

.priority {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    flex-wrap: wrap;
}

.priority li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 4px;
    border-radius: var(--radius-sm);
    background: var(--subtle);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: 13px;
    font-weight: 600;
}

.priority b {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--ink);
    color: #fff;
    font-size: 11px;
}

/* ---------- 地区与顺序 ---------- */

.region-row {
    display: grid;
    grid-template-columns: 20px 56px minmax(120px, 1fr) minmax(140px, 1.3fr) auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 2px;
    border-radius: var(--radius-md);
}

.region-row[hidden] {
    display: none;
}

.region-row.dragging {
    opacity: 0.45;
}

.region-row.drop-before {
    box-shadow: 0 -2px 0 var(--primary);
}

.region-row.hit input {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
}

.region-row.invalid input {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.drag-handle {
    color: var(--faint);
    font-size: 14px;
    letter-spacing: -2px;
    text-align: center;
    cursor: grab;
    user-select: none;
}

.region-pos {
    padding: 0 6px;
    text-align: center;
}

.region-name {
    font-weight: 600;
}

.move-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.move-btn:hover {
    background: var(--subtle);
    color: var(--ink);
}

/* ---------- 学生查询 ---------- */

.student-search {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.student-search-form {
    display: flex;
    gap: 10px;
}

.student-search-form input {
    min-height: 44px;
    font-size: 16px;
}

.student-search-form .btn {
    min-width: 96px;
    min-height: 44px;
}

.student-result {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr);
    gap: 20px;
    align-items: start;
}

.student-classes {
    grid-column: 1 / -1;
}

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

.student-title h2 {
    font-size: 22px;
}

.state-tag {
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.state-tag.ok {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.state-tag.off {
    background: var(--danger-soft);
    color: var(--danger);
}

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

.info-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.info-item dt {
    color: var(--muted);
    font-size: 14px;
}

.info-item dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    word-break: break-all;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat {
    display: grid;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--subtle);
    text-align: center;
}

.stat strong {
    font-size: 26px;
    line-height: 1.2;
}

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

.class-list {
    display: grid;
    gap: 8px;
}

.class-item {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.class-item.off {
    background: var(--subtle);
    color: var(--muted);
}

.class-main,
.class-teacher {
    display: grid;
    min-width: 0;
}

.class-item small {
    color: var(--muted);
    font-size: 12px;
}

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

.btn-danger-text {
    color: var(--danger);
}

.btn-danger-text:hover:not(:disabled) {
    background: var(--danger-soft);
    color: var(--danger);
}

.modal-wide {
    width: min(680px, calc(100% - 32px));
}

.del-loading {
    display: grid;
    gap: 12px;
    padding: 12px 0;
}

.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--region-soft);
    overflow: hidden;
}

.progress-bar {
    width: 8%;
    height: 100%;
    background: var(--primary);
    transition: width 0.4s;
}

#delError {
    white-space: pre-line;
}

.del-who {
    margin: 14px 0 10px;
}

.del-group {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.del-group summary {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
}

.del-group.money {
    border-color: #f1c5c1;
    background: var(--danger-soft);
}

.del-group.money summary {
    color: var(--danger);
}

.del-table {
    margin: 0;
    font-size: 13px;
}

.del-table td {
    padding: 4px 12px;
    border-bottom: 1px solid var(--line);
}

.del-table td:last-child {
    width: 90px;
    text-align: right;
}

.del-confirm {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.del-confirm-field {
    display: grid;
    gap: 6px;
    font-size: 14px;
}

.modal-small {
    width: min(480px, calc(100% - 32px));
}

/* ---------- 弹窗与正则教程 ---------- */

.modal {
    width: min(720px, calc(100% - 32px));
    max-height: min(86vh, 800px);
    padding: 0;
    border: none;
    border-radius: var(--radius-lg);
    background: #fff;
    color: var(--ink);
    box-shadow: 0 16px 48px rgba(16, 24, 40, 0.25);
    overflow: hidden;
}

.modal[open] {
    display: flex;
    flex-direction: column;
}

.modal::backdrop {
    background: rgba(16, 24, 40, 0.45);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--subtle);
    color: var(--ink);
}

.guide-body {
    padding: 8px 24px 24px;
    overflow-y: auto;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.7;
}

.guide-steps {
    margin: 12px 0;
    padding-left: 20px;
}

.guide-table {
    margin: 12px 0;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 13px;
}

.guide-table th,
.guide-table td,
.guide-table th:nth-child(n + 3),
.guide-table td:nth-child(n + 3) {
    padding: 8px 12px;
    text-align: left;
    width: auto;
    vertical-align: top;
}

.guide-table th {
    position: static;
    background: var(--subtle);
    color: var(--muted);
}

.guide-table tbody tr:hover {
    background: transparent;
}

.guide-body code {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--region-soft);
    color: var(--ink);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
}

.guide-example {
    margin-left: 6px;
    padding: 1px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--primary-dark);
    font-size: 12px;
    cursor: pointer;
}

.guide-example:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

.guide-tips-title {
    margin-top: 14px;
    font-weight: 700;
}

.guide-tips {
    margin: 6px 0 0;
    padding-left: 20px;
}

/* ---------- 结果页 ---------- */

.alert-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid #f1c5c1;
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-md);
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-banner div {
    display: grid;
}

.alert-banner span {
    color: var(--ink-soft);
    font-size: 13px;
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.table-toolbar .rules-search {
    width: 240px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-soft);
    font-size: 14px;
    cursor: pointer;
}

.toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.table-shell {
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
}

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

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

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--subtle);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

th:nth-child(n + 3),
td:nth-child(n + 3) {
    width: 110px;
    text-align: right;
}

.table-shell th:nth-child(3) {
    color: var(--edu);
    background: var(--edu-soft);
}

.table-shell th:nth-child(4) {
    color: var(--contest);
    background: var(--contest-soft);
}

.table-shell td:nth-child(3) {
    color: var(--edu);
    font-weight: 700;
}

.table-shell td:nth-child(4) {
    color: var(--contest);
    font-weight: 700;
}

tbody tr:hover {
    background: var(--subtle);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr[hidden] {
    display: none;
}

.table-shell .unknown {
    background: var(--danger-soft);
}

.table-shell .unknown td {
    color: var(--danger);
    font-weight: 600;
}

.table-shell .total-row td {
    position: sticky;
    bottom: 0;
    border-top: 2px solid var(--ink);
    background: #fff;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.mini-link {
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--line-strong);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.mini-link:hover {
    background: var(--primary);
    box-shadow: none;
    color: #fff;
}

/* ---------- 日志页 ---------- */

.log-list {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    overflow: hidden;
}

.log-list > .empty-panel {
    border: none;
    box-shadow: none;
}

.log-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 20px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.log-item:last-child {
    border-bottom: none;
}

.log-item:hover {
    background: var(--subtle);
}

.log-title {
    font-size: 15px;
    font-weight: 700;
    word-break: break-all;
}

.log-time {
    color: var(--muted);
    font-size: 13px;
}

.log-stats {
    display: flex;
    gap: 8px;
}

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

/* ---------- 登录页 ---------- */

.login-layout {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 72px);
}

.login-panel {
    width: min(360px, 100%);
    padding: 36px 28px 28px;
    box-shadow: var(--shadow-md);
}

.login-panel h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
}

.login-form {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.login-form input {
    min-height: 44px;
}

.login-form .btn {
    min-height: 44px;
    margin-top: 4px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1100px) {
    .student-result {
        grid-template-columns: 1fr;
    }

    .rules-layout,
    .process-grid,
    .dashboard {
        grid-template-columns: 1fr;
    }

    .tester-panel {
        position: static;
    }

    .process-grid {
        min-height: 0;
    }
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        flex-direction: row;
        align-items: center;
        height: auto;
        padding: 10px 16px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
    }

    .brand {
        margin: 0 8px 0 0;
    }

    .side-nav {
        display: flex;
        flex: 1;
        gap: 4px;
    }

    .side-title {
        display: none;
    }

    .side-link {
        white-space: nowrap;
    }

    .side-user-name {
        display: none;
    }

    .app .page-shell {
        padding: 20px 16px 56px;
    }

    .log-item,
    .recent-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .log-stats,
    .log-actions {
        grid-column: 1 / -1;
    }

    .recent-item .chip {
        display: none;
    }
}

@media (max-width: 720px) {
    .info-grid,
    .class-item {
        grid-template-columns: 1fr;
    }

    .student-search-form {
        flex-direction: column;
    }

    .page-shell {
        width: calc(100% - 32px);
    }

    .page-head {
        flex-direction: column;
        align-items: flex-start;
    }

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

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

    .stepper-item span {
        display: none;
    }

    .stepper-item:not(:last-child)::after {
        width: 24px;
        margin: 0 8px;
    }

    .mapping-row {
        grid-template-columns: 1fr auto;
    }

    .mapping-row .arrow {
        display: none;
    }

    .mapping-row .mapping-key {
        grid-column: 1 / -1;
    }

    .region-row {
        grid-template-columns: 20px 52px minmax(0, 1fr) auto auto;
    }

    .region-row .region-keywords {
        grid-column: 3 / -1;
    }
}
