* { box-sizing: border-box; }

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --line: #e6e9f0;
    --line-soft: #f0f2f7;
    --text: #1c2230;
    --muted: #7a8296;
    --brand: #2f6fed;
    --brand-dark: #1e56c8;
    --brand-soft: #eaf1fe;
    --green: #17936b;
    --green-soft: #e6f6f0;
    --red: #d94a4a;
    --red-soft: #fdecec;
    --amber: #b7791f;
    --amber-soft: #fdf3e2;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

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

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6fa;
    background-image: radial-gradient(circle at 15% 20%, #e8effc 0, transparent 45%), radial-gradient(circle at 85% 80%, #e9f4ef 0, transparent 40%);
    padding: 24px;
}

.login-card {
    width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 36px 34px 28px;
    box-shadow: 0 18px 50px rgba(28, 34, 48, 0.07);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 11px; }

.login-card h1 { font-size: 20px; font-weight: 500; margin: 18px 0 6px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 26px; line-height: 1.6; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="search"], select, textarea {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
    outline: none;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

textarea { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }

input:focus, select:focus, textarea:focus {
    border-color: #a9c6f7;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.1);
}

.login-error { min-height: 18px; font-size: 12.5px; color: var(--red); margin: 2px 0 8px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: #cfd6e4; background: #fafbfe; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c03d3d; }
.btn-block { width: 100%; height: 40px; }

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

.login-hint {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
}

/* --------------------------------------------------------------- 布局 */

.layout { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }

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

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.sidebar-brand strong { display: block; font-size: 14px; font-weight: 500; }
.sidebar-brand em { display: block; font-size: 11.5px; color: var(--muted); font-style: normal; margin-top: 2px; }

.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    color: #4a5266;
    font-size: 13.5px;
    text-align: left;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: #f5f7fb; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 500; }
.nav-item.active .ico { stroke: var(--brand-dark); }

.sidebar-foot {
    border-top: 1px solid var(--line-soft);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.who strong { display: block; font-size: 13px; font-weight: 500; }
.who em { display: block; font-size: 11.5px; color: var(--muted); font-style: normal; }

.avatar {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    flex: none;
}

.icon-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: #f2f4f9; color: var(--text); }

.main { padding: 0 28px 40px; min-width: 0; }

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 26px 0 20px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 8;
}

.topbar h2 { font-size: 19px; font-weight: 500; }
.topbar p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.topbar-actions { display: flex; gap: 8px; }

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.card.pad { padding: 20px; border-radius: 12px; }
.card-title { font-size: 14px; font-weight: 500; margin-bottom: 16px; }

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 10px;
}
.card-head h3 { font-size: 13.5px; font-weight: 500; }
.card-head .muted { font-size: 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }

.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
}
.kpi .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 27px; font-weight: 500; margin-top: 8px; letter-spacing: -0.5px; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kpi .foot b { color: var(--green); font-weight: 500; }

.split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; margin-bottom: 14px; }
.split.even { grid-template-columns: 1fr 1fr; }

/* --------------------------------------------------------------- 条形 */

.bars { padding: 6px 18px 18px; display: flex; flex-direction: column; gap: 13px; }
.bars.compact { gap: 10px; }

.bar-row { display: grid; grid-template-columns: 1fr; gap: 6px; }
.bar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; }
.bar-top .name { color: #333a4a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-top .num { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

.track { height: 7px; border-radius: 4px; background: #f0f3f8; overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); transition: width .4s ease; }
.track > i.full { background: var(--amber); }

/* --------------------------------------------------------------- 表格 */

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 128px; height: 36px; background: #fff; }

.search { position: relative; flex: 1; max-width: 320px; }
.search.narrow { max-width: 240px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; height: 36px; background: #fff; }

.table-card { padding: 4px 0 0; }
.table { width: 100%; border-collapse: collapse; }

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfe;
    white-space: nowrap;
}
.table th.right, .table td.right { text-align: right; }

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
    vertical-align: middle;
}
.table tbody tr:hover { background: #fafbfe; }
.table tbody tr:last-child td { border-bottom: 0; }

.cell-title { display: flex; align-items: center; gap: 11px; }
.thumb {
    width: 54px; height: 34px;
    border-radius: 6px;
    background: linear-gradient(135deg, #eef2f9, #e2e9f5);
    flex: none;
    object-fit: cover;
    border: 1px solid var(--line);
}
.cell-title strong { display: block; font-weight: 500; font-size: 13px; }
.cell-title em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.nowrap { white-space: nowrap; }
#course-table th:last-child, #course-table td:last-child { min-width: 174px; }
#course-table th:nth-child(3) { min-width: 128px; }

.tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11.5px;
    background: #f2f4f9;
    color: #5a6379;
    margin-right: 4px;
    line-height: 1.6;
}

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.off { background: #f2f4f9; color: #6b7385; }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }

.progress-cell { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.progress-cell .track { height: 6px; }
.progress-text { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-text b { color: var(--text); font-weight: 500; }

.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.link-btn { color: var(--brand); font-size: 12.5px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.link-btn:hover { background: var(--brand-soft); }
.link-btn.danger { color: var(--red); }
.link-btn.danger:hover { background: var(--red-soft); }
.link-btn:disabled { color: #b9c0cf; cursor: not-allowed; background: none; }

.remark-input {
    width: 100%;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    padding: 0 8px;
    font-size: 12.5px;
    transition: border-color .15s, background .15s;
}
.remark-input:hover { border-color: var(--line); background: #fff; }
.remark-input:focus { border-color: #a9c6f7; background: #fff; box-shadow: none; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.pager .info { font-size: 12.5px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }
.page-btn { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; color: #4a5266; }
.page-btn:hover:not(:disabled) { border-color: #cfd6e4; }
.page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

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

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    padding: 10px 0 4px;
    cursor: pointer;
}
.switch-row input { width: 16px; height: 16px; accent-color: var(--brand); }

.form-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 6px 0 0; }

.field-list { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }

.field-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line-soft);
}
.field-item:last-child { border-bottom: 0; }
.field-item .meta strong { display: block; font-weight: 500; font-size: 13px; }
.field-item .meta em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.field-item .controls { display: flex; align-items: center; gap: 14px; }
.field-item label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.field-item input[type="checkbox"] { accent-color: var(--brand); width: 15px; height: 15px; }

/* ------------------------------------------------------------- 抽屉 */

.drawer-mask {
    position: fixed; inset: 0;
    background: rgba(22, 28, 41, 0.32);
    z-index: 40;
}

.drawer {
    position: fixed;
    top: 0; right: 0;
    width: 460px;
    max-width: 92vw;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--line);
    z-index: 41;
    display: flex;
    flex-direction: column;
    box-shadow: -14px 0 40px rgba(22, 28, 41, 0.09);
    animation: slide-in .22s ease;
}

@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } to { transform: translateX(0); opacity: 1; } }

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.drawer-head h3 { font-size: 15px; font-weight: 500; }

.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    position: sticky;
    bottom: -20px;
    margin: 10px -20px -20px;
    padding: 14px 20px;
    background: var(--surface);
    border-top: 1px solid var(--line-soft);
}

/* ------------------------------------------------------------- 弹窗/tip */

.modal-mask {
    position: fixed; inset: 0;
    background: rgba(22, 28, 41, 0.32);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    width: 360px;
    background: var(--surface);
    border-radius: 14px;
    padding: 22px 22px 18px;
    box-shadow: 0 20px 50px rgba(22, 28, 41, 0.18);
}
.modal h3 { font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.modal p { font-size: 13px; color: #525b70; line-height: 1.7; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    background: #1f2534;
    color: #fff;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 9px;
    z-index: 80;
    box-shadow: 0 10px 30px rgba(22, 28, 41, 0.2);
    animation: toast-in .2s ease;
}
.toast.error { background: #a83232; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1080px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav-item span { display: none; }
    .main { padding: 0 16px 30px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .table th:nth-child(2), .table td:nth-child(2) { display: none; }
}

.modal-error { min-height: 16px; font-size: 12.5px; color: var(--red); margin: 6px 0 0; }
#form-mask .field:last-child { margin-bottom: 0; }

#log-table th:nth-child(1), #log-table td:nth-child(1) { width: 138px; white-space: nowrap; }
#log-table th:nth-child(2), #log-table td:nth-child(2) { width: 86px; white-space: nowrap; }
#log-table th:nth-child(3), #log-table td:nth-child(3) { width: 76px; white-space: nowrap; }
#log-table th:nth-child(4), #log-table td:nth-child(4) { width: 92px; white-space: nowrap; }
#log-table th:nth-child(5), #log-table td:nth-child(5) { width: 170px; }
#log-table td:nth-child(6) { color: var(--muted); }

/* ------------------------------------------------------------- 封面上传 */

.cover-field { margin-bottom: 18px; }
.cover-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }

.cover-box {
    position: relative;
    width: 100%;
    aspect-ratio: 750 / 420;
    border-radius: 10px;
    border: 1px dashed #cfd7e6;
    background: #fafbfe;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.cover-box:hover { border-color: #a9c6f7; background: #f7faff; }
.cover-box img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cover-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    text-align: center;
}
.cover-empty .ico { width: 22px; height: 22px; color: #9aa6bd; }
.cover-empty strong { font-size: 12.5px; font-weight: 500; color: #5a6478; }
.cover-empty em { font-style: normal; font-size: 11.5px; color: #9aa2b4; }

.cover-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.86);
    font-size: 12.5px;
    color: var(--brand-dark);
}

.cover-actions { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.cover-actions .link-btn { padding-left: 0; }
