/* 跨境支付沙盘 v2.0 · 呈现层样式（令乙首件段）
   零框架、零构建，纯静态；浅色经营仪表盘风格。 */

:root {
  /* WP-B 彭博深色风变量层（英语沙盘色板逐字照抄，主窗拍板）：
     --bg/--panel(--card)/--panel2/--line/--cyan(--brand)/--mint(--ok)/--amber(--warn)/--red(--danger)。
     文字色为暗底配套亮色（色板未含文字色，回执注明）；语义类名与状态绑定一根手指不动。 */
  --bg: var(--bg-page);
  --card: var(--bg-panel);
  --panel2: var(--bg-elevated);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --line: var(--border-subtle);
  --brand-dark: var(--brand-hover);
  --radius: 6px;
  --shadow: none;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 48px; }

/* —— 头部 —— */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand .sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 10px; }
.badge {
  font-size: 12px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px;
}
.state-pill {
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  background: var(--brand-bg); color: var(--brand);
}
.state-pill.settled { background: var(--ok-bg); color: var(--ok); }
.state-pill.pending { background: var(--warn-bg); color: var(--warn); }

/* —— 登录 —— */
.login-card {
  max-width: 420px; margin: 80px auto 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 28px;
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .hint { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }

/* C16：hidden 属性全局生效——.btn 等的 display 定义会覆盖 UA 的 [hidden] 规则，
   导致「超管专区」「开局」等按 hidden 控制的按钮对非授权角色/有局班级仍可见。 */
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 12px 16px; font-size: 15px; font-weight: 600;
  color: var(--on-brand); background: var(--brand); border: none; border-radius: 8px;
  cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.ghost {
  background: transparent; color: var(--brand); border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--panel2); }

.err {
  margin-top: 14px; padding: 10px 12px; font-size: 13px;
  background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bg);
  border-radius: 8px; display: none;
}
.err.show { display: block; }
.ok-msg {
  margin-top: 14px; padding: 10px 12px; font-size: 13px;
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok);
  border-radius: 8px; display: none;
}
.ok-msg.show { display: block; }

/* —— 指示卡 —— */
.grid { display: grid; gap: 14px; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.card .k-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .k-value { font-size: 24px; font-weight: 700; letter-spacing: .3px; }
.card .k-unit { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.card .k-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.section-title {
  font-size: 15px; font-weight: 700; margin: 26px 0 12px;
  display: flex; align-items: center; gap: 8px;
}

.market-panel { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.market-panel .card .chain-tag {
  display: inline-block; font-size: 12px; font-weight: 600;
  background: var(--brand-bg); color: var(--brand); padding: 3px 9px; border-radius: var(--radius); margin-bottom: 8px;
}
.market-panel .card .chain-tag.l3 { background: var(--panel2); color: var(--brand); }

.empty {
  padding: 40px 20px; text-align: center; color: var(--muted);
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
}
.spin { color: var(--muted); text-align: center; padding: 40px; }

.footer { margin-top: 32px; font-size: 12px; color: var(--muted); text-align: center; }

/* —— 教师工作台 —— */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 9px 16px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: transparent; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: var(--panel2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); background: var(--brand-bg); }
.tab-body { display: none; }
.tab-body.active { display: block; }

.tbl { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { padding: 9px 12px; font-size: 13px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: var(--panel2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.form-row .field { margin-bottom: 0; min-width: 140px; flex: 1; }
.field textarea {
  width: 100%; padding: 10px 12px; font-size: 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--text); outline: none; resize: vertical; font-family: inherit; line-height: 1.5;
}
.field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }

/* v1.8-fix6 修2：学生回看本人提交原文（只读框） */
.q-ro-box label { display: block; font-size: 12px; margin-bottom: 6px; }
.q-ro-box .ro-text {
  white-space: pre-wrap; word-break: break-word; padding: 10px 12px; font-size: 13px;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg); color: var(--muted); line-height: 1.6;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13px; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger); }
.btn.ghost-sm {
  width: auto; padding: 6px 10px; font-size: 12px; background: transparent; color: var(--brand);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.btn.ghost-sm:hover { background: var(--panel2); }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.muted { background: var(--bg-elevated); color: var(--muted); }
.pill.info { background: var(--brand-bg); color: var(--brand); }

.panel-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel-box + .panel-box { margin-top: 14px; }
.panel-box h3 { font-size: 14px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.gap8 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* —— 学生端 A6 事件/诊断/历史月 —— */
.event-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.5; }
.event-list .evt { padding: 8px 10px; background: var(--bg-panel); border-radius: 8px; }
.event-list .evt .muted { margin-top: 2px; font-size: 12px; }
.diag-card { display: flex; flex-direction: column; gap: 8px; }
.diag-label { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.diag-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.diag-row:last-child { border-bottom: none; }
.diag-row b { font-variant-numeric: tabular-nums; }
.history-rows { justify-content: flex-start; font-size: 14px; }
.history-rows b { font-variant-numeric: tabular-nums; color: var(--brand); }

/* —— 学生端 A1 决策包 —— */
.baseline-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; }
.baseline-opt {
  display: flex; flex-direction: column; gap: 6px; padding: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.baseline-opt .muted { font-size: 12px; line-height: 1.4; }
.baseline-opt.sel { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }

.dfield-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; }
.dfield { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.dfield-label { font-size: 13px; color: var(--text); }
.dfield-ctl select, .dfield-ctl input[type="number"] {
  min-width: 170px; max-width: 230px; padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); outline: none;
}
.dfield-ctl select:focus, .dfield-ctl input[type="number"]:focus { border-color: var(--brand); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { display: none; }
.switch .track { width: 40px; height: 22px; background: var(--border-strong); border-radius: 999px; position: relative; transition: background .2s; }
.switch .track::after { content: ''; position: absolute; width: 18px; height: 18px; background: var(--on-brand); border-radius: 50%; top: 2px; left: 2px; transition: left .2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { left: 20px; }

.adv-group summary {
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted);
  padding: 4px 0; list-style: none;
}
.adv-group summary::-webkit-details-marker { display: none; }
.adv-group[open] summary { color: var(--text); margin-bottom: 10px; }

@media (max-width: 560px) {
  .login-card { margin-top: 40px; padding: 24px 20px; }
  .grid.kpis { grid-template-columns: repeat(2, 1fr); }
}

/* C30① 输入色阶：输入字柔和浅灰（var(--text-secondary)），placeholder 更暗一档（两档差）；全端生效 */
input, select, textarea { color: var(--text-secondary); }
/* C34③ 全局下拉深色化（教师端＋学生端）：深灰底（--panel2，不刺眼）、浅灰字（var(--text-secondary)）；
   原生 option 弹层随 color-scheme:dark 转深，无需自定义组件。 */
:root { color-scheme: dark; }
select {
  background: var(--panel2);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
select option { background: var(--panel2); color: var(--text-secondary); }
.dfield-ctl select { background: var(--panel2); }
/* C36① 选中态深色化（学生侧＋教师侧）：下拉选中项/单选/多选/选中框，白色一律改柔和深蓝灰（低对比、能看清） */
option:checked { background: var(--opt-selected); color: var(--text-primary); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--opt-selected); }
select:focus, input:focus { accent-color: var(--opt-selected); }
/* 题目选项卡选中态（大白条改深蓝灰；task.js 用 .q-opt.sel，基线包用 .baseline-opt.sel） */
.q-opt.sel, .baseline-opt.sel { background: var(--opt-selected) !important; color: var(--text-primary) !important; border-color: var(--border-strong) !important; }
::placeholder { color: var(--text-muted); opacity: 1; }
/* C30② 教师登录 autofill 漏覆盖：强制暗底暗字，与学生侧统一 */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text-secondary);
  -webkit-box-shadow: 0 0 0 1000px var(--card) inset;
  caret-color: var(--text-secondary);
  transition: background-color 9999s ease-in-out 0s;
}
/* C32⑥⑦ 登录页/弹层输入提亮（暗底上的主文字档） */
.login-card input, #modal-root input { color: var(--text-primary); }

/* C36-4 成绩簿矩阵列对准：colgroup 单一宽度源（table-layout:fixed），单元格居中、超出省略不撑宽 */
.matrix-fixed { table-layout: fixed; width: 100%; }
.matrix-fixed th, .matrix-fixed td { text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-fixed td.num { text-align: center; }


/* C36-9④ 改错作答排版：勾选框与题型名紧邻、整组左对齐；输入框紧随其后间距统一 */
.q-opt, .q-check-row { display: flex; align-items: baseline; gap: 8px; text-align: left; }
.q-opt > input, .q-check-row > input { flex: none; margin: 0; }
.q-opt > span, .q-check-row > span { flex: 1 1 auto; min-width: 0; }


/* C36-11① 改错作答真修：q-check 行（勾选框＋题型名紧邻左对齐，输入框紧随其后间距统一） */
.q-check { display: flex; align-items: baseline; gap: 8px; text-align: left; }
.q-check > input[type='checkbox'] { flex: none; margin: 0; }
.q-check > span { flex: 1 1 auto; min-width: 0; }
.q-field[data-atype] input[data-a-cor] { margin-top: 4px; width: 100%; }


/* C36-13① 改错排版二次真修：选项行紧凑块布局（复选框与文字同行相邻、整组左对齐收拢，禁竖排溢出） */
.q-field[data-atype] { display: block; margin-top: 6px; }
.q-check { display: flex; align-items: flex-start; gap: 8px; text-align: left; margin: 0; line-height: 1.4; }
.q-check > input[type='checkbox'] { flex: none; margin: 2px 0 0; }
.q-check > span { flex: 1 1 auto; min-width: 0; word-break: break-word; }


/* C36-14 改错作答行 scoped 布局（与 task.html 内联同规则，双保险） */
.af-row { display: block; margin-top: 8px; text-align: left; }
.af-line { display: flex; align-items: center; gap: 8px; text-align: left; line-height: 1.5; }
.af-line > input[type='checkbox'] { flex: none; margin: 0; width: auto; padding: 0; border: none; background: none; }
.af-text { min-width: 0; word-break: break-word; }
.af-row > input[data-a-cor] { margin-top: 4px; width: 100%; }
