:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e5e9f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --sidebar: #0f172a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border: none; border-radius: 6px; background: var(--primary); color: #fff; font-weight: 500; }
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #eef2ff; color: var(--primary); }
.btn.secondary:hover { background: #e0e7ff; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; color: var(--primary); }
.topbar-controls { display: flex; gap: 8px; }

.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar { width: 170px; background: var(--sidebar); padding: 12px 0; flex-shrink: 0; }
.sidebar a { display: block; padding: 11px 20px; color: #cbd5e1; text-decoration: none;
  cursor: pointer; border-left: 3px solid transparent; }
.sidebar a:hover { background: #1e293b; color: #fff; }
.sidebar a.active { color: #fff; background: #1e293b; border-left-color: var(--primary); }

.content { flex: 1; padding: 20px; min-width: 0; }
.section { display: none; }
.section.active { display: block; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; white-space: nowrap; background: #fafbfc; }
tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
tr.clickable { cursor: pointer; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge.blue { background: #e0e7ff; color: var(--primary-dark); }
.badge.green { background: #dcfce7; color: var(--ok); }
.badge.red { background: #fee2e2; color: var(--danger); }
.badge.gray { background: #f1f5f9; color: var(--muted); }
.badge.amber { background: #fef3c7; color: var(--warn); }
.badge.gold { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; color: var(--primary-dark);
  border-radius: 12px; padding: 2px 8px; font-size: 12px; margin: 2px 4px 2px 0; }
.tag-chip button { background: none; border: none; color: inherit; cursor: pointer; font-size: 12px; padding: 0; }

/* 课时汇总表：分组表头 + 冻结首列 + 合计行 */
.summary-table { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
.summary-table th, .summary-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.summary-table thead th { background: #f1f5f9; position: sticky; top: 0; z-index: 3; text-align: center; }
.summary-table thead th.group { border-bottom: 2px solid var(--line); letter-spacing: 1px; }
.summary-table thead tr:first-child th { border-top: 1px solid var(--line); }
.summary-table td.num, .summary-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.summary-table .pin-left { position: sticky; left: 0; z-index: 2; background: #fff; box-shadow: 2px 0 0 var(--line); }
.summary-table thead .pin-left { background: #f1f5f9; z-index: 4; }
.summary-table tbody tr:hover td { background: #f6f9ff; }
.summary-table tbody tr:hover td.pin-left { background: #f6f9ff; }
.summary-table tr.total-row td { border-top: 2px solid var(--line); background: #fafbfc; font-weight: 700; }
.summary-table tr.total-row td.pin-left { background: #fafbfc; }
.summary-table tr.total-row td:first-child { position: sticky; left: 0; }

/* 待审核课时页：待审核高亮 / 已审核淡化 */
tr.pending-row td { background: #fefce8; }
tr.pending-row:hover td { background: #fef9c3; }
tr.done-row td { opacity: 0.75; }
tr.done-row:hover td { opacity: 1; background: #f8fafc; }

/* 上下半区：上半区=试听审核(蓝调) / 下半区=其他课时审核(紫调) */
.half-zone { border-radius: 12px; padding: 14px 16px; margin: 14px 0; border: 1px solid var(--line); }
.half-zone.trial { background: #eff6ff; border-color: #bfdbfe; }
.half-zone.other { background: #f5f3ff; border-color: #ddd6fe; }
.sub-zone-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px;
  font-weight: 600; font-size: 14px; }
.sub-zone-head::after { content: ''; flex: 1; border-bottom: 1px dashed var(--line); }

/* 学科条形统计图：纵轴=学科名称，横轴=数量 */
.hbar-chart { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-name { width: 56px; text-align: right; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.hbar-track { flex: 1; background: #eef2f7; border-radius: 6px; height: 20px; overflow: hidden; position: relative; }
.hbar-fill { height: 100%; border-radius: 6px; min-width: 2px; transition: width .3s; }
.hbar-meta { width: 200px; font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.hbar-axis-row { display: flex; align-items: flex-start; gap: 10px; }
.hbar-axis { display: flex; justify-content: space-between; align-items: flex-start;
  background: none; border-top: 1px solid var(--line); border-radius: 0; height: auto;
  padding-top: 3px; font-size: 11px; color: var(--muted); }
.hbar-axis span { transform: translateX(50%); }
.hbar-axis span:first-child { transform: none; }
.hbar-axis span:last-child { transform: translateX(100%); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat.clickable:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,99,235,.15); }
.stat .value.amber { color: var(--warn); }
.stat .value.red { color: var(--danger); }
.stat .value.gray { color: var(--muted); }
.stat .value.pos { color: var(--ok); font-size: 18px; }
.stat .value.neg { color: var(--danger); }

/* 结算进度条 */
.progress-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.progress-row > span:first-child { width: 130px; flex-shrink: 0; }
.progress-track { flex: 1; background: #eef2f7; border-radius: 6px; height: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; }
.progress-fill.blue { background: #60a5fa; }
.progress-fill.amber { background: #f59e0b; }
.progress-fill.green { background: var(--ok); }

/* 工作台：待确定事项 / 待办事项 */
.work-zone { border-left: 4px solid var(--line); }
.work-zone.decide { border-left-color: var(--warn); }
.work-zone.todo { border-left-color: var(--primary); }
.work-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px;
  border-bottom: 1px dashed var(--line); }
.work-item:last-child { border-bottom: none; }
.work-main { flex: 1; min-width: 0; }
.work-title { font-weight: 600; }
.work-desc { font-size: 12px; margin-top: 2px; }
.work-item .btn { flex-shrink: 0; }

/* 侧边栏分组 */
.side-group { padding: 14px 20px 5px; color: #64748b; font-size: 11px; letter-spacing: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }

.empty { color: var(--muted); text-align: center; padding: 30px; }

.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: 520px; max-width: 92vw;
  background: #fff; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; }
.drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.close { border: none; background: none; font-size: 22px; color: var(--muted); }
.hidden { display: none !important; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; }

.login-box { position: absolute; left: 50%; top: 45%; transform: translate(-50%,-50%);
  width: 340px; background: #fff; border-radius: 12px; padding: 26px;
  box-shadow: 0 4px 24px rgba(0,0,0,.2); }
.login-box h3 { margin: 0 0 14px; text-align: center; }
.login-box .field { margin-bottom: 10px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; }
pre.json { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px;
  overflow: auto; max-height: 400px; font-size: 12px; }

.fatal { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 9999;
  background: #fecaca; color: #b91c1c; border: 1px solid #ef4444; border-radius: 8px;
  padding: 10px 16px; max-width: 90%; font-size: 13px; }

/* ─── 教师端「我的工资单」 ─── */
.pay-hero { background: linear-gradient(135deg, #1d4ed8, #3b82f6); border: none; color: #fff; }
.pay-hero .pay-amount { font-size: 40px; font-weight: 800; line-height: 1.15; }
.pay-hero .pay-amount .num { font-size: inherit; }
.pay-hero .muted { color: rgba(255,255,255,.85); }
.pay-hero .badge.gray { background: rgba(255,255,255,.18); color: #fff; }
.pay-hero .badge.amber { background: #fef3c7; }
.pay-hero .badge.green { background: #bbf7d0; }
.pay-hero .badge.blue { background: #bfdbfe; }
.trend-chart { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding-top: 4px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bar { width: 60%; max-width: 44px; background: #c7d2fe; border-radius: 6px 6px 0 0; min-height: 2px; }
.trend-bar.now { background: var(--primary); }
.trend-val { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.trend-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.trend-label.now { color: var(--primary); font-weight: 700; }
.scroll-x { overflow-x: auto; }

/* ─── 移动端适配（教师/发放员常用手机查看） ─── */
@media (max-width: 760px) {
  .topbar { padding: 0 10px; min-height: 52px; height: auto; flex-wrap: wrap; padding-bottom: 8px; }
  .topbar-controls { flex-wrap: wrap; }
  .content { padding: 10px; }
  #teacherApp .content, #payoutApp .content { padding: 10px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 19px; }
  .pay-hero .pay-amount { font-size: 30px; }
  .card { padding: 12px; }
  table { font-size: 12px; }
  th, td { padding: 6px 6px; }
}
