:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eaf2ff;
  --cyan: #0ea5e9;
  --ink: #121826;
  --muted: #6b7280;
  --line: #e5eaf3;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --wash: #edf4fb;
  --shadow: 0 18px 45px rgba(37, 99, 235, .10);
  --good: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; height: 100vh; overflow: hidden; background: #edf1f7; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.eyebrow { color: var(--blue); font-size: 12px; letter-spacing: .12em; margin: 0 0 8px; font-weight: 800; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #f8fbff 0%, #e8f1fb 100%); }
.login-card { width: min(100%, 430px); background: rgba(255,255,255,.88); border: 1px solid rgba(255,255,255,.78); border-radius: 24px; padding: 38px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff; font-weight: 900; font-size: 23px; border-radius: 14px; box-shadow: 0 12px 26px rgba(37, 99, 235, .24); }
.brand-mark.small { width: 32px; height: 32px; font-size: 16px; border-radius: 11px; box-shadow: none; }
.login-card h1 { color: var(--ink); line-height: 1.35; font-size: 28px; margin: 14px 0 8px; text-align: center; }
.login-card .muted { text-align: center; }
.stack-form, .form-grid, .filter-grid { display: grid; gap: 16px; }
.stack-form { margin-top: 28px; }
label { display: grid; gap: 7px; color: #374151; font-weight: 800; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.92); border-radius: 12px; color: var(--ink); padding: 11px 12px; outline: none; transition: border-color .18s, box-shadow .18s, background .18s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37,99,235,.12); background: #fff; }

.primary-button, .secondary-button, .action-button, .text-button, .danger-button, .mini-button { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 800; transition: transform .16s, box-shadow .16s, background .16s; }
.primary-button { color: white; background: linear-gradient(135deg, var(--blue), #3b82f6); box-shadow: 0 10px 22px rgba(37,99,235,.22); }
.primary-button:hover, .secondary-button:hover, .action-button:hover, .mini-button:hover, .danger-button:hover { transform: translateY(-1px); }
.primary-button:hover { background: linear-gradient(135deg, var(--blue-dark), var(--blue)); }
.secondary-button, .action-button, .mini-button { color: var(--blue); background: var(--blue-soft); }
.text-button { background: transparent; color: var(--blue); padding: 7px; }
.danger-button { background: #fee2e2; color: var(--bad); }
/* 科目管理：状态列 iOS 风开关 */
.ios-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font: inherit; border: 0; background: transparent; padding: 0; }
.ios-switch-track { width: 46px; height: 26px; background: #fff; border: 1px solid #d1d5db; border-radius: 999px; position: relative; transition: background .22s, border-color .22s; box-sizing: content-box; }
.ios-switch-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #cbd5e1; border-radius: 50%; transition: left .22s, background .22s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.ios-switch.is-on .ios-switch-track { background: #22c55e; border-color: #22c55e; }
.ios-switch.is-on .ios-switch-knob { left: 23px; background: #fff; }
.ios-switch-label { font-size: 12px; font-weight: 700; color: #9ca3af; min-width: 28px; }
.ios-switch.is-on .ios-switch-label { color: #16a34a; }
.ios-switch[disabled] { opacity: .55; cursor: not-allowed; }
.error-text { color: var(--bad); min-height: 20px; }
.success-text { color: var(--good); min-height: 20px; }

.topbar { background: rgba(255,255,255,.72); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(18px); flex-shrink: 0; }
.topbar-inner { height: 60px; padding: 0 24px; display: flex; align-items: center; gap: 12px; }
.brand-title { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 900; }
.user-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.icon-button { display: none; border: 0; background: transparent; color: var(--blue); font-size: 23px; padding: 4px; }
.app-shell { display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 226px 1fr; }
.sidebar { padding: 18px 12px 12px; background: #edf1f7; display: flex; flex-direction: column; overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.nav-group-title { font-size: 11px; color: #9aa6b8; font-weight: 800; letter-spacing: .8px; padding: 4px 14px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; color: #526173; padding: 11px 14px; border-radius: 12px; font-weight: 800; text-decoration: none; }
.nav-item::before { content: attr(data-icon); display: grid; place-items: center; width: 22px; height: 22px; color: #7b8798; font-size: 16px; font-weight: 900; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.92); color: var(--blue); box-shadow: 0 10px 28px rgba(37,99,235,.08); }
.nav-item.active::before, .nav-item:hover::before { color: var(--blue); }
.content { margin: 14px 16px 16px 0; padding: 26px 30px; min-width: 0; min-height: 0; overflow-y: auto; background: rgba(255,255,255,.94); border: 1px solid rgba(229,234,243,.9); border-radius: 20px; box-shadow: 0 16px 40px rgba(37,99,235,.08); }
.sidebar-footer { margin-top: auto; padding: 12px 6px 4px; }
.sidebar-user { display: flex; gap: 10px; align-items: center; padding: 6px 6px; }
.sidebar-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 14px; flex-shrink: 0; }
.sidebar-user-meta { min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 800; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: #7b8798; }
.table-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 40px; padding: 4px 0 10px; }
.table-toolbar-info { font-size: 13px; font-weight: 700; color: #b91c1c; background: #fff1f2; border: 1px solid #fecaca; padding: 5px 12px; border-radius: 999px; }
.batch-delete-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; font-weight: 800; font-size: 13px; padding: 8px 16px; border-radius: 999px; box-shadow: 0 8px 20px rgba(220, 38, 38, .28); transition: transform .12s ease, box-shadow .12s ease; }
.batch-delete-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(220, 38, 38, .36); }
.batch-delete-btn:active { transform: translateY(0); }
.batch-delete-icon { font-size: 14px; }
.image-toolbar { display: flex; gap: 8px; margin-bottom: 8px; }
.image-preview { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; border: 1px solid rgba(229,234,243,.9); margin-bottom: 10px; object-fit: contain; background: #f6f8fc; }
.image-table-wrap { max-height: 220px; overflow-y: auto; border: 1px solid rgba(229,234,243,.7); border-radius: 10px; margin-bottom: 10px; }
.image-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.image-table th, .image-table td { padding: 6px 4px; border-bottom: 1px solid rgba(229,234,243,.5); text-align: center; }
.image-table thead th { background: rgba(241,245,250,.7); position: sticky; top: 0; font-weight: 800; }
.image-table .img-cell { width: 100%; border: 0; background: transparent; padding: 4px 2px; text-align: center; font: inherit; }
.image-table .img-cell:focus { background: rgba(37,99,235,.06); outline: 1px solid rgba(37,99,235,.3); border-radius: 4px; }
.image-table .img-del { color: #b91c1c; font-weight: 800; }
.image-actions { display: flex; gap: 8px; justify-content: space-between; }
.image-import-layout { display: grid; grid-template-columns: minmax(260px, 5fr) 7fr; gap: 16px; align-items: start; }
.image-import-left .image-toolbar { margin-bottom: 10px; }
.image-import-preview { display: block; max-width: 100%; max-height: 420px; border-radius: 12px; border: 1px solid rgba(229,234,243,.9); object-fit: contain; background: #f6f8fc; margin-bottom: 10px; }
.image-import-right .image-table-wrap { max-height: 360px; }
@media (max-width: 1100px) { .image-import-layout { grid-template-columns: 1fr; } }
#scoresBody td:first-child, #scoresBody th:first-child { text-align: center; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-heading-action { align-items: flex-end; }
.page-heading-action > button, .page-heading-action > a { margin-top: 18px; }
h2 { font-size: 28px; color: var(--ink); margin: 0; letter-spacing: -.03em; }
h3 { margin: 0 0 5px; color: var(--ink); }

.dashboard-summary-panel { background: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.dashboard-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.summary-tile { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.summary-tile small { display: block; color: var(--muted); font-weight: 800; margin-bottom: 5px; }
.summary-tile strong { font-size: 24px; color: var(--ink); }
.tile-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--blue); background: #e8efff; font-weight: 900; }
.tile-icon.green { color: #15803d; background: #dcfce7; }
.tile-icon.orange { color: #b45309; background: #fef3c7; }
.tile-icon.purple { color: #7c3aed; background: #ede9fe; }
.metric, .section-band, .chart-panel, .analysis-card, .table-wrap, .form-card { background: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: var(--shadow); }
.metric { padding: 20px; display: grid; gap: 10px; min-height: 124px; }
.metric span { font-size: 13px; color: var(--muted); font-weight: 800; }
.metric strong { color: var(--ink); font-size: 34px; line-height: 1; letter-spacing: -.04em; }
.metric small { color: var(--good); font-weight: 800; }
.metric:nth-child(2) small { color: var(--blue); }
.metric:nth-child(4) small { color: var(--warn); }
.section-band { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 22px; margin-bottom: 18px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .9fr); gap: 18px; align-items: start; }
.dashboard-side { display: grid; gap: 18px; }
.chart-panel { padding: 20px; min-height: 280px; }
.chart-panel.slim { min-height: 250px; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.panel-title h3 { margin: 0; }
.chart-box { width: 100%; height: 310px; }
.chart-panel.slim .chart-box { height: 230px; }

.filter-grid { grid-template-columns: repeat(6, minmax(100px, 1fr)); align-items: end; margin-bottom: 18px; }
.filter-action-button { justify-self: end; align-self: end; min-width: 110px; }
.analysis-filter-row { align-items: end; column-gap: 8px; row-gap: 10px; }
.analysis-filter-row label { max-width: 230px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 900px; margin-bottom: 28px; }
.form-card { padding: 22px; }
.score-entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.score-entry-main { max-width: none; margin-bottom: 0; }
.score-entry-side { display: grid; gap: 16px; }
.side-card { display: grid; gap: 12px; }
.side-card h3 { margin-bottom: 0; }
.side-card p { line-height: 1.6; }
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 12px; }
.inline-controls label { display: inline-flex; grid-template-columns: none; align-items: center; gap: 6px; font-weight: 800; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; }
.inline-controls input[type="radio"] { width: auto; }
.inline-controls select, .export-actions select { width: 180px; }
.export-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.export-panel { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 16px; align-items: end; max-width: 920px; }
.export-panel .primary-button { min-height: 46px; }
.export-actions select { width: 210px; }
.voice-recording { background: #fee2e2 !important; color: var(--bad) !important; }
.empty-state { display: grid; place-items: center; min-height: 180px; color: var(--muted); background: #f8fbff; border: 1px dashed var(--line); border-radius: 16px; font-weight: 800; }

.table-wrap { overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 780px; }
.table-wrap th, .table-wrap td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #edf2f7; font-size: 13px; white-space: nowrap; }
.table-wrap th { color: var(--muted); background: #f8fbff; font-weight: 900; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: #f8fbff; }
.status-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px; border-radius: 50%; font-size: 13px; font-weight: 900; line-height: 1; }
.status-icon-improved { color: #15803d; background: #dcfce7; }
.status-icon-declined { color: #b91c1c; background: #fee2e2; }
.status-icon-unchanged { color: #64748b; background: #e2e8f0; }
.status-icon-no_history { color: #64748b; background: #f1f5f9; }
.status-improved { color: var(--good); font-weight: 900; }
.status-declined { color: var(--bad); font-weight: 900; }
.status-unchanged, .status-no_history { color: var(--muted); }

.analysis-tabs { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.analysis-tab-list { display: flex; flex-wrap: wrap; gap: 8px; }
.analysis-toolbar { margin-top: 4px; }
.analysis-tab { border: 1px solid var(--line); background: rgba(255,255,255,.9); color: var(--muted); padding: 10px 14px; border-radius: 999px; font-weight: 900; }
.analysis-tab.active { color: #fff; background: linear-gradient(135deg, var(--blue), #3b82f6); border-color: transparent; box-shadow: 0 10px 20px rgba(37,99,235,.18); }
.analysis-filter { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.analysis-summary { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.analysis-card { padding: 16px; display: grid; gap: 6px; }
.analysis-card span, .analysis-card small { color: var(--muted); }
.analysis-card strong { color: var(--ink); font-size: 24px; letter-spacing: -.03em; }

.grade-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; padding: 4px 10px; border-radius: 999px; font-weight: 900; border: 1px solid transparent; }
.grade-fail { color: #b91c1c; background: #fee2e2; border-color: #fecaca; }
.grade-pass { color: #15803d; background: #dcfce7; border-color: #bbf7d0; }
.grade-good { color: #a16207; background: #fef3c7; border-color: #fde68a; }
.grade-excellent { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
.link-button { border: 0; padding: 0; background: transparent; color: var(--blue); font-weight: 900; text-decoration: none; }
.link-button:hover { text-decoration: underline; }
.detail-shell { display: grid; gap: 18px; }
.detail-card { max-width: 920px; }

@media (max-width: 1100px) {
  .metric-grid, .analysis-summary, .dashboard-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { display: none; position: fixed; top: 68px; left: 0; bottom: 0; width: 250px; z-index: 4; background: rgba(255,255,255,.95); box-shadow: 8px 0 24px rgba(37,99,235,.16); }
  .sidebar.open { display: block; }
  .icon-button { display: block; }
  .content { padding: 22px 16px; margin: 0; min-height: auto; border-radius: 0; border: 0; box-shadow: none; }
  .score-entry-layout { grid-template-columns: 1fr; }
  .export-panel { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid .primary-button.master-only { justify-self: stretch; }
  .filter-action-button { justify-self: stretch; width: 100%; }
  .section-band { display: block; }
  .quick-actions { margin-top: 18px; }
}
@media (max-width: 560px) {
  .topbar-inner { padding: 0 14px; }
  .brand-title span:last-child { font-size: 13px; }
  .user-actions span { display: none; }
  .login-card { padding: 26px 22px; border-radius: 20px; }
  .login-card h1 { font-size: 23px; }
  .content { padding: 18px 12px; }
  h2 { font-size: 23px; }
  .metric-grid, .analysis-summary, .dashboard-summary-grid { grid-template-columns: 1fr; }
  .metric { min-height: auto; display: flex; justify-content: space-between; align-items: center; }
  .filter-grid, .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .table-wrap th, .table-wrap td { padding: 11px 10px; }
  .page-heading { align-items: center; }
}
.lookup-segment { font-size: 13px; font-weight: 800; color: var(--blue); background: var(--blue-soft); border: 1px solid #d6e6ff; border-radius: 10px; padding: 8px 10px; margin-bottom: 4px; }
.reference-wrap { margin-top: 6px; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.reference-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.reference-table th, .reference-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.reference-table thead th { position: sticky; top: 0; background: var(--surface-soft); color: var(--muted); font-weight: 800; }
.reference-table .ref-grade { font-weight: 900; color: var(--blue); width: 64px; }
.reference-table tbody tr:nth-child(even) { background: #fafcff; }
.computed-box { margin-top: 8px; font-size: 14px; font-weight: 800; color: var(--ink); background: #eafaf0; border: 1px solid #bfe9cd; border-radius: 12px; padding: 10px 12px; }
.grade-score { margin-left: 8px; font-size: 13px; font-weight: 800; color: #2563eb; white-space: nowrap; }
.standards-filter { grid-template-columns: 1fr 140px; max-width: 520px; }
.std-cell { width: 76px; padding: 6px 6px; text-align: center; font-size: 13px; }
#standardsBody td, #standardsHead th { text-align: center; }
#standardsBody td:first-child { text-align: left; font-weight: 800; white-space: nowrap; }

@media print {
  .topbar, .sidebar, .page-heading button, .filter-grid { display: none !important; }
  .content { padding: 0; }
  .page:not(#scoresPage) { display: none !important; }
  .table-wrap { border: 0; box-shadow: none; }
}
/* 训练计划页：班级计划 / AI个人计划 切换 */
.seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg-btn { padding: 7px 18px; border-radius: 16px; border: 1px solid #d8dfe8; background: #fff;
  color: #556; font-size: 13px; cursor: pointer; }
.seg-btn.on { background: #0ca678; border-color: #0ca678; color: #fff; font-weight: 600; }

/* AI 训练计划页：站长替队员生成 */
.ai-gen-btn { margin-left: 8px; padding: 4px 12px; font-size: 12px;
  background: linear-gradient(135deg, #0ca678, #1e9fe0); color: #fff !important;
  border: none; border-radius: 8px; cursor: pointer; vertical-align: middle; }
.ai-gen-btn:disabled { opacity: .65; cursor: wait; }
.ai-gen-regen { background: #f0f4f8; color: #0ca678 !important; border: 1px solid #bfe6d8; }
