/* ==========================================================================
   兼职教练课时收集 · 设计系统
   一套变量 + 组件类，教练端（移动优先）与管理端（桌面优先）共用
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg:            #f4f5f9;
  --surface:       #ffffff;
  --surface-2:     #fafbfd;
  --surface-3:     #f2f4f8;

  --text:          #16181d;
  --text-2:        #5b6270;
  --text-3:        #98a0b0;

  --line:          #e6e8ef;
  --line-2:        #eef0f6;

  --brand:         #4f46e5;
  --brand-ink:     #3f37cf;
  --brand-soft:    #eef0ff;
  --brand-ring:    rgba(79, 70, 229, .18);
  --on-brand:      #ffffff;

  --ok:            #0d9f6e;
  --ok-soft:       #e6f7f1;
  --danger:        #dc2626;
  --danger-soft:   #fdecec;
  --on-danger:     #ffffff;

  --radius-lg: 20px;
  --radius:    14px;
  --radius-sm: 10px;

  --shadow-1: 0 1px 2px rgba(20, 23, 35, .05);
  --shadow-2: 0 1px 3px rgba(20, 23, 35, .05), 0 14px 34px rgba(20, 23, 35, .07);
  --shadow-3: 0 12px 40px rgba(20, 23, 35, .16);

  --pad: 18px;
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101216;
    --surface:   #191c22;
    --surface-2: #1e232b;
    --surface-3: #232832;

    --text:      #e8eaef;
    --text-2:    #a2aab8;
    --text-3:    #767f8f;

    --line:      #292e38;
    --line-2:    #232833;

    --brand:     #8f8bff;
    --brand-ink: #a5a1ff;
    --brand-soft:#242a3f;
    --brand-ring: rgba(143, 139, 255, .25);
    --on-brand:   #14161c;

    --ok:        #34d399;
    --ok-soft:   #16302a;
    --danger:    #f87171;
    --danger-soft:#331d1d;
    --on-danger: #2a1113;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 1px 3px rgba(0, 0, 0, .4), 0 14px 34px rgba(0, 0, 0, .35);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

/* --------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }
.num, .tabular { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------- 布局骨架 */

.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 20px 16px 120px;
}
.page.wide { max-width: 1240px; padding: 0 20px 56px; }

/* ---------------------------------------------------------- 顶部栏 */

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-2);
}
.appbar-inner {
  max-width: 620px;
  margin: 0 auto;
  min-height: 56px;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
  flex: none;
}
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }

/* 右上角只读的教练名（不可点击，就是个标牌） */
.whochip {
  margin-left: auto;
  display: flex; align-items: center;
  max-width: 62%;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12.5px; font-weight: 600;
  min-width: 0;
}
.whochip-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------------------------------------------- 标题区 */

.intro { padding: 14px 4px 22px; }
.intro h1 {
  font-size: 25px; font-weight: 720; letter-spacing: -.022em; line-height: 1.25;
}
.intro p { margin-top: 7px; color: var(--text-2); font-size: 14px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: var(--pad);
  margin-bottom: var(--gap);
}

.card-head {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 14px;
}
.card-head h2 {
  font-size: 15px; font-weight: 650; letter-spacing: -.01em;
}
.card-desc {
  margin: -8px 0 14px;
  color: var(--text-2); font-size: 13px;
}
.badge {
  flex: none;
  width: 21px; height: 21px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 11.5px; font-weight: 700;
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.card-head .spacer { flex: 1; }
.card-head .aside { font-size: 12.5px; color: var(--text-3); font-weight: 500; }

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

.field { display: block; margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }

.label {
  display: block;
  font-size: 13px; font-weight: 550; color: var(--text-2);
  margin-bottom: 7px;
}
.label-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 7px;
}
.label-row .label { margin-bottom: 0; }
.label-hint { font-size: 12px; color: var(--text-3); }

.req {
  font-style: normal; font-size: 11px; font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 5px;
}

input[type="text"], input[type="url"], input[type="number"],
input[type="date"], input[type="time"], input[type="password"], select {
  width: 100%;
  padding: 12px 13px;
  font: inherit;
  font-size: 16px;              /* 16px：iOS 聚焦不自动放大 */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: var(--text-3); }
input:hover { border-color: var(--text-3); }
input:focus, select:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--brand-ring);
}
input[type="date"], input[type="time"] { min-height: 47px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- 胶囊选择 */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:not(:last-child) { margin-bottom: 10px; }

.chip {
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 8px 15px;
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all .13s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 650;
}
.chip:active { transform: scale(.96); }

/* ---------------------------------------------------------- 按钮 */

.btn {
  font: inherit; font-size: 14.5px; font-weight: 600;
  padding: 11px 17px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .14s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 1px 2px rgba(79, 70, 229, .3);
}
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}
.btn.danger-solid:hover { background: color-mix(in srgb, var(--danger) 85%, #000); border-color: currentColor; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn.block { display: block; width: 100%; }
.btn.lg { min-height: 50px; font-size: 16px; border-radius: var(--radius); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }

/* ---------------------------------------------------------- 底部提交条 */

.submitbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 35;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line-2);
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
}
.submitbar-inner {
  max-width: 620px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.submitbar-hint {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.submitbar-hint.ready { color: var(--ok); font-weight: 650; }
.submitbar .btn { flex: none; padding-left: 22px; padding-right: 22px; }
@media (max-width: 420px) {
  .submitbar-hint { display: none; }
  .submitbar .btn { width: 100%; }
}

/* ---------------------------------------------------------- 折叠区 */

.disclosure {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--text-2);
  background: none; border: 0; padding: 0;
  cursor: pointer;
  text-align: left;
}
.disclosure .caret {
  margin-left: auto;
  color: var(--text-3);
  font-size: 12px;
  transition: transform .18s;
}
.disclosure.open .caret { transform: rotate(180deg); }
.disclosure .count {
  font-variant-numeric: tabular-nums;
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
}

.record {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line-2);
  margin-top: 12px;
}
.record:first-child { margin-top: 14px; }
.record-body { flex: 1; min-width: 0; }
.record-title { font-size: 14.5px; font-weight: 600; }
.record-title .hrs {
  color: var(--brand-ink); font-variant-numeric: tabular-nums;
}
.record-meta {
  font-size: 12px; color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------------------------------------------- 空状态 */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 30px 20px;
  text-align: center;
  color: var(--text-2); font-size: 14px;
}
.empty-icon {
  width: 46px; height: 46px; border-radius: 15px;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-size: 20px;
}
.empty .sub { font-size: 12.5px; color: var(--text-3); max-width: 30ch; }

/* ---------------------------------------------------------- toast */

/* toast：顶部条状提示。放顶部是为了不和底部提交条打架，
   也避免被误认成第二个按钮。 */
.toast {
  position: fixed;
  left: 50%;
  top: calc(66px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-10px);
  z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  max-width: min(90vw, 420px);
  padding: 11px 17px;
  border-radius: 13px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px; font-weight: 550;
  text-align: center;
  box-shadow: var(--shadow-3);
  opacity: 0;
  animation: toast-in .22s cubic-bezier(.2, .9, .3, 1) forwards;
}
.toast .ti {
  flex: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: #fff;
}
.toast.ok .ti { background: var(--ok); }
.toast.bad .ti { background: var(--danger); }
@keyframes toast-in {
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 管理端顶部有标题+页签，较高；它没有底部提交条，所以 toast 仍走底部 */
body.admin .toast {
  top: auto;
  bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  animation-name: toast-in-up;
}
@keyframes toast-in-up {
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==========================================================================
   时间筛选（两端共用 CoachRange）
   ========================================================================== */

.rangebar {
  display: flex; align-items: center; gap: 8px 10px;
  flex-wrap: wrap;
}
.rangebar-title {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  cursor: help;
}
.range-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.range-chips .chip { font-size: 12.5px; padding: 5px 12px; min-height: 30px; }

.rangebar .range-dates { display: flex; align-items: center; gap: 6px; }
.rangebar .range-dates .tilde { color: var(--text-3); font-size: 12px; }
/* 覆盖全局 input 的 width:100%，否则日期框会撑满整行 */
.rangebar .range-dates input {
  width: auto;
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

/* 教练端：放在标题与表格之间 */
.sheet-range { margin-bottom: 12px; }

/* 管理端：筛选条做成一张卡，命中数右对齐 */
.filterbar {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.filter-hit {
  margin-left: auto;
  font-size: 12.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.filter-hit.on {
  color: var(--brand-ink);
  font-weight: 600;
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 5px 13px;
}

/* ==========================================================================
   确认弹窗（两端共用 CoachDialog）
   ========================================================================== */

body.dlg-open { overflow: hidden; }

.dlg-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;                     /* 高于 toast(90) / 吸顶栏(30) / 表格吸顶(3) */
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10, 12, 18, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: dlg-fade .14s ease-out;
}
@keyframes dlg-fade { from { opacity: 0 } to { opacity: 1 } }

.dlg {
  width: min(430px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  padding: 22px 22px 18px;
  text-align: center;
  animation: dlg-pop .18s cubic-bezier(.2, .9, .3, 1);
}
@keyframes dlg-pop {
  from { opacity: 0; transform: translateY(10px) scale(.97) }
  to { opacity: 1; transform: none }
}

.dlg-icon {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.dlg-danger .dlg-icon { background: var(--danger-soft); color: var(--danger); }

.dlg-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.dlg-message { margin-top: 6px; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

.dlg-detail {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-2);
  text-align: left;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dlg-actions { display: flex; gap: 10px; margin-top: 18px; }
.dlg-actions .btn { flex: 1 1 0; min-height: 44px; }

/* --- 表单型弹窗（编辑记录） --- */
.dlg-form { text-align: left; width: min(560px, 100%); }
.dlg-form .dlg-actions { margin-top: 16px; }
.dlg-title-left { text-align: center; }
.dlg-note {
  margin: 6px 0 14px;
  padding: 9px 12px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}

.dlg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}
.dlg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dlg-field.span2 { grid-column: 1 / -1; }
.dlg-field-label { font-size: 12px; font-weight: 550; color: var(--text-2); }
.dlg-field input,
.dlg-field select {
  width: 100%;
  padding: 9px 11px;
  font: inherit; font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
}
.dlg-field select { cursor: pointer; }
.dlg-field input:focus,
.dlg-field select:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.dlg-field.need input,
.dlg-field.need select {
  border-color: var(--danger);
  background: var(--danger-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
}

.dlg-error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
}

/* 填写行里没填的格子标红 */
table.sheet-table tr.entry td.need { background: var(--danger-soft); box-shadow: inset 0 0 0 2px var(--danger); }
table.sheet-table tr.entry td.need input { color: var(--danger); }

@media (max-width: 420px) {
  .dlg-overlay { padding: 16px; align-items: flex-end; }
  .dlg { padding: 20px 18px 16px; }
  .dlg-form { max-height: calc(100vh - 32px); }
  .dlg-grid { grid-template-columns: 1fr; gap: 10px; }
  .dlg-field.span2 { grid-column: auto; }
}

/* 行内小输入（课时自定义） */
.inline-field { display: flex; align-items: center; gap: 9px; }
.inline-field .inline-label,
.inline-field .inline-unit { font-size: 13px; color: var(--text-3); flex: none; }
.inline-field input { width: 104px; flex: none; padding: 9px 11px; }

/* ==========================================================================
   管理端
   ========================================================================== */

.adminhead {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 20px;
}
.adminhead-inner {
  max-width: 1240px; margin: 0 auto;
  padding: 18px 20px 0;
  display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap;
}
.adminhead h1 {
  font-size: 21px; font-weight: 700; letter-spacing: -.02em;
}
.adminhead p { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.adminhead-actions {
  margin-left: auto;
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-bottom: 2px;
}
.tabbar {
  max-width: 1240px; margin: 0 auto;
  padding: 14px 20px 0;
  display: flex; gap: 4px; flex-wrap: wrap;
}
.tab {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 4px 11px;
  margin-right: 18px;
  border: 0; border-bottom: 2.5px solid transparent;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand-ink); border-bottom-color: var(--brand); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 15px 16px;
}
.stat .k {
  font-size: 12.5px; color: var(--text-2); font-weight: 550;
  display: flex; align-items: center; gap: 6px;
}
.stat .k i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand); flex: none;
}
.stat .v {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  margin-top: 5px; font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: 14px; font-weight: 600; color: var(--text-3); margin-left: 3px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.panel-head-main {
  display: flex; align-items: baseline; gap: 10px;
  flex-wrap: wrap; min-width: 0; flex: 1 1 auto;
}
.panel-head-side {
  display: flex; align-items: center; gap: 9px;
  flex: 0 1 auto; margin-left: auto;
}
.panel-head h2 { font-size: 15px; font-weight: 650; }
.panel-head .sub { font-size: 12.5px; color: var(--text-3); }
.scroll-hint { display: none; }

/* 窄屏：标题与说明各占一行，控件独占一行，避免被挤成竖排 */
@media (max-width: 760px) {
  .panel-head { padding: 14px; }
  .panel-head-main { flex-direction: column; align-items: flex-start; gap: 3px; }
  .panel-head-side { flex: 1 0 100%; margin-left: 0; }
  .mini-select { flex: 1 1 auto; width: auto; max-width: none; }
  .scroll-hint { display: inline; }
}
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

.scroll { overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}
table.grid th, table.grid td {
  padding: 10px 13px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-2);
}
table.grid thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600; font-size: 12px;
  letter-spacing: .02em;
  border-bottom: 1px solid var(--line);
}
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: 1px solid var(--line); }
table.grid tfoot td {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 700;
  border-bottom: 0;
  border-top: 1px solid var(--line);
}
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.dim { color: var(--brand-ink); font-weight: 700; }
table.grid tr.dimrow td {
  background: var(--surface-3);
  font-weight: 650;
  border-top: 1px solid var(--line);
}
table.grid tr.dimrow:hover td { background: var(--surface-3); }
table.grid tr.grandrow td {
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 700;
}
table.grid tr.grandrow:hover td { background: var(--brand-soft); }
table.grid td.muted { color: var(--text-3); }
table.grid a {
  display: inline-block;
  max-width: 210px;
  overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
  color: var(--brand-ink); text-decoration: none;
}
table.grid a:hover { text-decoration: underline; }
table.grid td.op { width: 1%; padding-left: 8px; padding-right: 12px; }
table.grid td.muted, table.grid td.op { white-space: nowrap; }

/* 总表条形 */
.barcell { position: relative; }
.barcell .bar {
  position: absolute; left: 13px; right: 13px; top: 6px; bottom: 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  transform-origin: right center;
}
@media (prefers-color-scheme: dark) { .barcell .bar { background: rgba(143,139,255,.16); } }
.barcell .v { position: relative; }
/* 数值列收窄，条形才像迷你柱状图而不是一条长带 */
table.grid.master td.num, table.grid.master th.num { width: 172px; }

/* 教练链接 */
.linkrow {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.linkrow:first-of-type { border-top: 0; }
.linkrow .who { font-weight: 600; font-size: 13.5px; flex: 0 0 auto; }
.linkrow code {
  flex: 1 1 300px; min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.mini-select {
  width: auto; min-width: 158px; max-width: 280px;
  padding: 6px 11px; font-size: 13px; min-height: 34px;
  background: var(--surface-2); border-radius: 9px;
}

h3.sub { font-size: 12.5px; font-weight: 600; color: var(--text-3); margin: 16px 0 2px; }

/* 批量导入教练名单 */
.bulk-input {
  width: 100%;
  min-height: 152px;
  padding: 11px 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  white-space: pre;
  overflow: auto;
}
.bulk-input::placeholder { color: var(--text-3); }
.bulk-input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.bulk-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px;
}
.filebtn { display: inline-flex; align-items: center; cursor: pointer; }
.bulk-idx { color: var(--text-3); font-variant-numeric: tabular-nums; }
.bulk-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* 合并后的「教练专属链接」面板内部分块 */
.bulk-block {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--line);
}
.bulk-block:last-of-type { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.bulk-label {
  font-size: 13px; font-weight: 650; color: var(--text-2);
  margin-bottom: 9px;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.bulk-label .opt { font-weight: 400; font-size: 12px; color: var(--text-3); }

.bulk-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.bulk-section-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.bulk-section-title { font-size: 14px; font-weight: 650; }
.bulk-empty { padding: 14px 0 4px; color: var(--text-3); font-size: 13px; }

/* 课程类型设置 */
.course-new {
  flex: 1 1 240px;
  width: auto;
  max-width: 400px;
  padding: 9px 12px;
  font-size: 15px;
}
.course-edit {
  width: 100%;
  min-width: 140px;
  padding: 7px 10px;
  font: inherit; font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: none;
  appearance: none;
}
.course-edit:hover { border-color: var(--line); }
.course-edit:focus {
  border-color: var(--brand);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* 填报表里的下拉：课程类型只能从后台定义的选项里选 */
table.sheet-table td select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 24px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2398a0b0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 9px 6px;
}

/* 口令页 */
.gate { max-width: 420px; margin: 14vh auto; padding: 0 20px; }
.gate .intro { text-align: center; }

.foot {
  text-align: center; color: var(--text-3); font-size: 12px;
  padding: 18px 0 0;
}

/* ==========================================================================
   教练端：横排填报表
   表头吸顶 + 常驻输入行吸顶 + 已保存行按顺序累计在下面
   ========================================================================== */

.page.sheet-page { max-width: 1500px; padding: 18px 16px 40px; }

.sheet-head {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.sheet-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.sheet-head p { color: var(--text-3); font-size: 12.5px; margin-top: 4px; }
.sheet-stats { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: baseline; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 15px;
  font-size: 12.5px; color: var(--text-2);
}
.pill b {
  font-size: 17px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pill-brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.pill-brand b { color: var(--brand-ink); }

.sheet-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.sheet {
  overflow: auto;
  max-height: 100vh;
  max-height: calc(100dvh - 215px);
  min-height: 240px;
  -webkit-overflow-scrolling: touch;
}

table.sheet-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  /* 宽度由 coach.js 按列的声明宽度算出来（--sheet-w / --sheet-w-noid），
     这里给个兜底值，避免 CSS 和 JS 各写一份而漂移 */
  width: var(--sheet-w, 1460px);
  font-size: 13px;
}
table.sheet-table th,
table.sheet-table td {
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
}
table.sheet-table th:last-child,
table.sheet-table td:last-child { border-right: 0; }

table.sheet-table thead th {
  position: sticky; top: 0; z-index: 3;
  height: 38px; padding: 0 11px;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600; font-size: 12px; letter-spacing: .02em;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

/* 常驻输入行：吸在表头下面 */
table.sheet-table tbody tr.entry td {
  position: sticky; top: 38px; z-index: 2;
  height: 46px;
  background: var(--brand-soft);
  border-bottom: 1px solid var(--brand);
}

table.sheet-table tbody tr.data td { height: 42px; background: var(--surface); }
table.sheet-table tbody tr.data:hover td { background: var(--surface-2); }
/* 已保存的行现在是纯文本（编辑走弹窗），要把内边距补回来 */
table.sheet-table tbody tr.data td:not(.op) { padding: 0 11px; }
table.sheet-table tbody tr.data td.fixed { color: var(--text-2); }
table.sheet-table tbody tr.data td.n { text-align: right; }
table.sheet-table td .sheet-link {
  display: block;
  color: var(--brand-ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.sheet-table td .sheet-link:hover { text-decoration: underline; }

table.sheet-table td input,
table.sheet-table td select {
  display: block;
  width: 100%; height: 100%;
  border: 0; border-radius: 0;
  padding: 0 11px;
  font: inherit; font-size: 13px;
  color: var(--text);
  background: transparent;
  outline: none;
  appearance: none;
}
table.sheet-table td input::placeholder { color: var(--text-3); }
table.sheet-table td select { cursor: pointer; }
table.sheet-table td input:focus,
table.sheet-table td select:focus {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--brand);
}
table.sheet-table td.n input { text-align: right; font-variant-numeric: tabular-nums; }

table.sheet-table tfoot td {
  position: sticky; bottom: 0; z-index: 3;
  height: 42px; padding: 0 11px;
  background: var(--surface-3);
  color: var(--brand-ink);
  font-weight: 700;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
table.sheet-table tfoot td.n { text-align: right; font-variant-numeric: tabular-nums; }

table.sheet-table td.op {
  text-align: center;
  padding: 0 6px;
  border-right: 0;
}
/* 填写行有两个按钮，必须平分格子；之前统一 width:100% 会把「同上」挤出表格 */
table.sheet-table td.op .opwrap { display: flex; gap: 6px; }
table.sheet-table td.op .opwrap .btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  padding-left: 4px;
  padding-right: 4px;
}
/* 已保存的行只有一个删除按钮，占满整格 */
table.sheet-table tbody tr.data td.op .btn { width: 100%; }

/* 窄屏：教练身份已经知道时，把 3 个身份列收起来。
   手机首屏 390px，三列身份（值还都一样）会白占 328px，
   真正要填的学生名/日期全被挤到屏幕外。桌面端始终全列显示。 */
@media (max-width: 760px) {
  table.sheet-table.hide-identity { width: var(--sheet-w-noid, 1124px); }
  table.sheet-table.hide-identity col.col-id,
  table.sheet-table.hide-identity th.col-id,
  table.sheet-table.hide-identity td.col-id { display: none; }
}

/* 底部轻提示 */
.sheet-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12.5px; color: var(--text-3);
}
.sheet-note kbd {
  font: inherit; font-size: 11.5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-2);
}
