:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1c2333;
  --muted: #6b7486;
  --line: #e3e8f0;
  --primary: #2456d6;
  --primary-weak: #e8eefc;
  --gold: #c9a227;
  --green: #1e9e6a;
  --red: #d8434b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 22px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 30px; }
.brand h1 { font-size: 17px; }
.brand p { font-size: 11px; color: var(--muted); }
#mainNav { display: flex; gap: 4px; margin-left: auto; }
#mainNav a { padding: 8px 14px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
#mainNav a:hover { background: var(--primary-weak); }
#mainNav a.active { background: var(--primary); color: #fff; }
.userbox { font-size: 13px; display: flex; gap: 8px; align-items: center; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 16px 30px; }
.foot-note { display: inline-block; max-width: 100%; margin: 0 auto 12px; padding: 7px 14px; border: 1px solid #f0e0b4; background: #fff9e8; color: #8a6a1c; border-radius: 10px; font-size: 12.5px; line-height: 1.65; }
.foot-line { line-height: 1.9; word-break: break-word; }
.foot .designer { display: inline-block; margin-left: 10px; padding: 2px 10px; border-radius: 12px; background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.foot-stat { margin-top: 12px; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.foot-stat span { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 14px; background: #f4f6fb; border: 1px solid var(--line); }
.foot-stat span.sep { padding: 0; border: 0; background: none; }
.foot-stat b { color: var(--primary); font-size: 14px; margin: 0 2px; }
.foot-beian { margin-top: 10px; font-size: 12px; }
.foot-beian a { color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; }
.foot-beian a:hover { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- generic ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
select, input[type=text], input[type=password], input[type=number] { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; color: var(--ink); }
select:focus, input:focus { outline: 2px solid var(--primary-weak); border-color: var(--primary); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters-row { display: contents; }   /* 桌面端所有筛选项排一行；手机端由下方媒体查询改为两行 */
@media (max-width: 700px) {
  .res-filters { flex-direction: column; align-items: stretch; }
  .res-filters .filters-row { display: flex; gap: 6px; align-items: center; }
  .res-filters label { flex: 0 0 auto; display: inline-block; line-height: 34px; }
  .res-filters select { flex: 1 1 110px; min-width: 0; }
  .res-filters button { flex: 0 0 auto; margin-left: auto; }
}
/* 赛项数据：项目按钮（替代下拉） */
.ev-tabs { display: flex; flex-direction: column; gap: 8px; }
.ev-row { display: flex; align-items: flex-start; gap: 8px; }
.ev-lb { flex: 0 0 auto; font-size: 12px; color: var(--muted); line-height: 30px; width: 34px; }
.ev-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-chip { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 16px; padding: 5px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ev-chip:hover { border-color: var(--primary); color: var(--primary); }
.ev-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
/* 全部赛项实时排名：两列小表 */
.ev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.ev-block h4 { font-size: 13px; margin-bottom: 6px; padding-left: 2px; }
@media (max-width: 700px) {
  .ev-grid { grid-template-columns: 1fr; }
  .ev-chip { font-size: 12.5px; padding: 4px 10px; }
}
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: var(--primary-weak); color: var(--primary); margin-right: 6px; }.tag.gray { background: #eef0f4; color: var(--muted); }
.tag.rec { background: #fdecec; color: var(--red); font-weight: 600; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.tbl th { background: #f7f9fd; font-weight: 600; }
.tbl tr:hover td { background: #fafcff; }
.tbl td.left { text-align: left; }
.tbl .rank1 { color: var(--gold); font-weight: 700; }
.tbl .rank2 { color: #888; font-weight: 700; }
.tbl .rank3 { color: #b0703c; font-weight: 700; }
.rec-val { color: var(--red); font-weight: 700; } /* 破纪录成绩标红（不再用备注列） */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
/* 首页主区：左列（比赛日程，较宽） + 右列（观众 / 录入员 上下） */
.home-main { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; align-items: stretch; }
.home-side { display: flex; flex-direction: column; gap: 14px; }
/* 左列两卡等分高度，合计（含间距）与右侧日程卡一致 */
.home-side > .card { flex: 1 1 0; min-height: 148px; display: flex; flex-direction: column; }
.home-side > .card .btn-row { margin-top: auto; }
.home-sch { display: flex; flex-direction: column; }
.home-sch .sch-table { flex: 1; }
/* 窄屏单列：入口（观众 / 录入员）在前，日程排后 */
@media (max-width: 900px) {
  .home-main { grid-template-columns: 1fr; }
  .home-sch { order: 2; }
}
/* 日程表：时间列紧凑，内容列自适应 */
.sch-table td { padding: 6px 6px; }
.sch-table td.sch-time { width: 96px; white-space: nowrap; font-size: 12.5px; }
/* 全校赛况：标题行 + 手动刷新 */
.sch-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sch-head h3 { margin: 0; }
.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pill-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 16px; cursor: pointer; font-size: 13px; }
.pill-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.note-strip { background: #fffbe8; border: 1px solid #f0e2a0; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.ok-strip { background: #ecfaf3; border: 1px solid #bfe8d4; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 22, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: #fff; border-radius: 14px; padding: 22px; width: 360px; }
.modal-card h3 { margin-bottom: 6px; }
.modal-card input { width: 100%; }
.photo-full { max-width: 92vw; max-height: 92vh; position: relative; }
.photo-full img { max-width: 92vw; max-height: 88vh; border-radius: 8px; display: block; }
.photo-close { position: absolute; top: -34px; right: 0; color: #fff; cursor: pointer; font-size: 14px; }

/* photo thumb */
.photo-thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: #f0f2f6; }

/* ---------- admin entry grid ---------- */
.entry-grid input { width: 90px; text-align: center; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-cards .card { margin: 0; text-align: center; }
.stat-cards b { font-size: 26px; color: var(--primary); display: block; }
.stat-cards span { color: var(--muted); font-size: 12px; }

/* ---------- 表格宽度自适应内容（不再强制撑宽，超宽时才横向滚动） ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px 0; }
.table-scroll > table.tbl { min-width: max-content; }
.table-scroll > table.entry-grid { width: max-content; min-width: 0; }
.entry-grid .nameIn { width: 110px; }
.entry-grid .clsIn { width: 150px; }
/* 已按名单（参赛人员信息表 / 秩序册）校正的字段 */
.entry-grid input.fixIn { background: #fffbe6; border-color: #ecd28a; box-shadow: inset 0 0 0 1px rgba(236, 210, 138, .55); }
.fixDot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: #fffbe6; border: 1px solid #ecd28a; vertical-align: -1px; margin-right: 4px; }

/* class chart */
.chart-wrap { position: relative; overflow-x: auto; }
#classChart, #schoolChart { min-width: 900px; }
hr { border: none; border-top: 1px solid var(--line); }

/* 全校赛况：滚动战报 + 得分明细标签 */
.news-marquee { overflow: hidden; position: relative; background: #f7f9fd; border: 1px solid var(--line); border-radius: 8px; padding: 11px 0; white-space: nowrap; }
/* 默认速度放慢（实际时长由 JS 按内容宽度按固定 px/秒 计算，保证长短内容速度一致） */
.news-track { display: inline-block; padding-left: 100%; animation: marquee 120s linear infinite; }
.news-marquee:hover .news-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.news-item { font-size: 13px; margin: 0 8px; }
.news-item em { color: var(--primary); font-style: normal; font-weight: 700; }
.news-sep { color: var(--line); }
.seg-chip { display: inline-block; background: #eef2fb; border: 1px solid #dbe4f7; border-radius: 6px; padding: 2px 8px; margin: 2px 5px 2px 0; font-size: 12px; color: var(--ink); }
.seg-chip b { color: var(--primary); }
/* 得分明细表：得分项目列自动换行（固定布局，不再按最长单行撑宽表格） */
.table-scroll > table.tbl.wrap-tbl { min-width: 0; width: 100%; table-layout: fixed; }
table.wrap-tbl th:nth-child(1) { width: 54px; }
table.wrap-tbl th:nth-child(2) { width: 120px; }
table.wrap-tbl th:nth-child(3) { width: 78px; }
table.wrap-tbl td:nth-child(4) { white-space: normal; word-break: break-word; overflow-wrap: anywhere; line-height: 1.7; }
table.wrap-tbl .seg-chip { max-width: 100%; }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 300; padding: 10px 18px; border-radius: 10px; font-size: 13px; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.ok { background: #1e9e6a; }
.toast.bad { background: #d8434b; }

.tip { position: fixed; background: rgba(20, 26, 44, .92); color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 12px; pointer-events: none; z-index: 200; max-width: 260px; display: none; }

/* ---------- print report ---------- */
.report-page { background: #fff; border: 1px solid var(--line); margin: 0 auto 22px; padding: 26px 30px; width: 1050px; max-width: 100%; }
.report-page h2 { text-align: center; font-size: 22px; letter-spacing: 6px; margin-bottom: 6px; }
.report-sub { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 12px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th, .report-table td { border: 1.5px solid #333; padding: 8px 6px; text-align: center; }
.report-table th { background: #f2f2f2; }
.report-sign { display: flex; justify-content: flex-end; gap: 60px; margin-top: 18px; font-size: 14px; }
.report-record { color: var(--red); font-weight: 700; }

/* 教师友谊赛榜单：手机端隐藏批次列，保证一屏放得下 */
@media (max-width: 700px) {
  .tea-batch { display: none; }
  /* 得分明细：窄屏改为卡片式，每班一块，得分项目独占整行 */
  table.wrap-tbl, table.wrap-tbl tbody { display: block; }
  table.wrap-tbl tr:first-child { display: none; }
  table.wrap-tbl tr:not(:first-child) { display: grid; grid-template-columns: 44px 1fr 78px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 10px; background: #fff; }
  table.wrap-tbl tr:not(:first-child) td { display: block; border: none; padding: 2px 0; }
  table.wrap-tbl td:nth-child(2) { text-align: left; font-weight: 600; }
  table.wrap-tbl td:nth-child(3) { text-align: right; }
  table.wrap-tbl td:nth-child(3)::before { content: '总分 '; font-size: 11px; color: var(--muted); font-weight: 400; }
  table.wrap-tbl td:nth-child(1)::after { content: ' 名'; font-size: 11px; color: var(--muted); font-weight: 400; }
  table.wrap-tbl td:nth-child(4) { grid-column: 1 / -1; border-top: 1px dashed var(--line); margin-top: 7px; padding-top: 8px; }
  table.wrap-tbl .seg-chip { font-size: 12px; padding: 3px 8px; margin: 2px 6px 2px 0; }
}

/* ---------- 手机端适配 ---------- */
@media (max-width: 700px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand h1 { font-size: 15px; }
  .brand p { display: none; }
  .brand img { height: 36px !important; width: 36px !important; }
  #mainNav { margin-left: 0; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #mainNav a { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .userbox { font-size: 12px; }
  main { padding: 12px 10px 50px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .card h3 { font-size: 14px; }
  .filters { gap: 6px; }
  .filters select, .filters input { flex: 1 1 130px; min-width: 110px; }
  .filters button { flex: 0 0 auto; }
  .btn { padding: 7px 11px; font-size: 12px; }
  .btn-row { flex-wrap: wrap; justify-content: flex-start !important; }
  .btn-row .btn { flex: 1 1 auto; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .stat-cards b { font-size: 22px; }
  /* 分组录入：手机端改为卡片式，宽度完全自适应屏幕 */
  .table-scroll > table.entry-grid { width: 100%; min-width: 0; display: block; }
  .table-scroll > table.entry-grid thead,
  .table-scroll > table.entry-grid tr:first-child { display: none; }
  .table-scroll > table.entry-grid tbody { display: block; }
  .table-scroll > table.entry-grid tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; align-items: center;
    border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fff;
  }
  .table-scroll > table.entry-grid tr:hover td { background: transparent; }
  .table-scroll > table.entry-grid td { border: none; padding: 0; display: flex; align-items: center; gap: 6px; text-align: left; }
  .table-scroll > table.entry-grid td[data-label]::before { content: attr(data-label); flex: 0 0 32px; color: var(--muted); font-size: 12px; }
  .table-scroll > table.entry-grid td:last-child { justify-content: flex-end; }
  .entry-grid input { width: 100%; min-width: 0; }
  .entry-grid .nameIn, .entry-grid .clsIn { width: 100%; }
  .entry-grid .laneSel { max-width: 100%; }
  .modal-card { width: calc(100vw - 32px); padding: 16px; }
  .photo-thumb { width: 90px; height: 68px; }
  .report-page { padding: 14px; width: auto; }
  .report-sub { flex-direction: column; gap: 4px; font-size: 12px; }
  .report-sign { flex-direction: column; gap: 8px; align-items: flex-end; font-size: 12px; }
  .news-track { animation-duration: 100s; }   /* 手机端兜底值，实际由 JS 按宽度换算 */
}

@media print {
  body { background: #fff; }
  .topbar, #mainNav, .foot, .no-print, .filters, .pill-tabs { display: none !important; }
  main { padding: 0; max-width: none; }
  .report-page { border: none; width: auto; margin: 0; page-break-after: always; }
  @page { size: A4 landscape; margin: 10mm; }
}
