/* 腾达乒乓球馆 · 点名系统
   视觉来源：馆标的红色斜笔画、黑色梯形与白色乒乓球。
   规则：红色只用于品牌标识与「缺席/未到」；黑色是主操作与「已到」；其余保持安静。 */
:root {
  --red: #F20000;        /* 馆标红：大面积色块 */
  --red-ink: #D00000;    /* 白底上的红字，保证对比度 */
  --red-wash: #FFECEC;
  --black: #000000;
  --paper: #FFFFFF;
  --table: #EEEFF1;      /* 页面底色：偏冷的浅灰 */
  --line: #DCDDE1;
  --muted: #62666E;
  --late: #A15C00;  --late-wash: #FFF1DC;
  --leave: #2F5597; --leave-wash: #E6EDF8;
  --num: "DIN Alternate", "DIN Condensed", Bahnschrift, "Roboto Condensed", "Arial Narrow", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--black);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--table); }
body { min-height: 100vh; font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
:focus-visible { outline: 2.5px solid var(--black); outline-offset: 2px; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }

/* ---------- 顶栏：白底 + 馆标 + 红黑斜切品牌条 ---------- */
.shell { max-width: 720px; margin: 0 auto; padding-bottom: calc(88px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--paper);
  padding: calc(10px + var(--safe-t)) 16px 14px;
  display: flex; align-items: center; gap: 10px;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(115deg, var(--red) 0 62%, var(--paper) 62% 63.2%, var(--black) 63.2%);
}
.brand-logo { width: 38px; height: 38px; flex-shrink: 0; }
.tb-title { flex: 1; min-width: 0; }
.tb-title h1 { font-size: 17px; line-height: 1.25; margin: 0; font-weight: 800; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { padding: 18px 16px; }
.page-title { display: flex; align-items: center; gap: 8px; margin: 2px 0 14px; }
.page-title h2 { font-size: 22px; margin: 0; flex: 1; font-weight: 800; }
.page-title h2 .count { font-family: var(--num); font-weight: 700; color: var(--muted); font-size: 16px; margin-left: 4px; }

/* ---------- 底部导航：黑色，像球台网下的阴影 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--black); padding-bottom: var(--safe-b);
  display: flex; justify-content: center;
}
.tabbar-inner { display: flex; width: 100%; max-width: 720px; }
.tabbar a {
  flex: 1; text-align: center; padding: 9px 0 8px; text-decoration: none; color: #8C8F95;
  font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: #fff; font-weight: 700; }
.tabbar a.on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--red); }

/* ---------- 通用组件 ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.card.link { cursor: pointer; display: block; text-decoration: none; color: inherit; }
.card.link:active { background: #F7F7F8; }
.row { display: flex; align-items: center; gap: 12px; }
.row > svg { color: #A9ACB2; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack > * + * { margin-top: 10px; }
.section-label { font-size: 13px; color: var(--muted); margin: 20px 2px 8px; font-weight: 700; }

/* 空状态：一颗乒乓球 */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; line-height: 1.7; }
.mark { display: block; width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff 0 45%, #ECE9F0 100%); box-shadow: 0 6px 0 -2px rgba(0,0,0,.08), inset 0 0 0 1px #E2DEE8; }
.empty a:not(.btn) { color: var(--black); font-weight: 700; }

.btn {
  border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
  background: var(--black); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.secondary { background: var(--paper); color: var(--black); box-shadow: inset 0 0 0 1.5px var(--black); }
.btn.ghost { background: transparent; color: var(--black); padding: 8px 10px; min-height: 38px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 13px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn svg { width: 17px; height: 17px; }
.icon-btn { background: none; border: 0; padding: 7px; border-radius: 8px; cursor: pointer; color: var(--black); display: inline-flex; }
.icon-btn svg { width: 23px; height: 23px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-width: 0; border: 1.5px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 12px; min-height: 46px; outline: none;
}
.input:focus { border-color: var(--black); }
input[type=date].input { -webkit-appearance: none; appearance: none; display: block; }
textarea.input { min-height: 120px; resize: vertical; }
.two { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.check-list { max-height: 260px; overflow: auto; border: 1.5px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 6px; cursor: pointer; }
.check-list label:hover { background: var(--table); }
.check-list input, .switch-row input { width: 20px; height: 20px; accent-color: var(--black); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 4px; background: var(--table); color: var(--muted); margin: 3px 4px 0 0; }
.tag.brand { background: #fff; color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.tag.warn { background: var(--red-wash); color: var(--red-ink); }

.pill { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 4px; white-space: nowrap; }
.pill.present { background: var(--black); color: #fff; }
.pill.late { background: var(--late-wash); color: var(--late); }
.pill.leave { background: var(--leave-wash); color: var(--leave); }
.pill.absent { background: var(--red); color: #fff; }

.search { position: relative; margin-bottom: 10px; }
.search input { padding-left: 40px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--table); color: var(--black); display: grid; place-items: center; font-weight: 800; font-size: 16px; flex-shrink: 0; }

/* ---------- 登录：放大的馆标几何从屏幕边缘切入 ---------- */
.auth { min-height: 100vh; background: var(--paper); display: flex; justify-content: center; align-items: center; position: relative; }
.auth::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px;
  background: linear-gradient(115deg, var(--red) 0 62%, var(--paper) 62% 63.2%, var(--black) 63.2%); }
.auth-art { width: 132px; margin-bottom: 26px; }
.auth-art svg { width: 100%; height: auto; display: block; overflow: visible; filter: drop-shadow(0 6px 10px rgba(0,0,0,.12)); }
/* 唯一的开场动效：红笔画、黑梯形就位，乒乓球落下弹一下 */
.auth-art .p-red { animation: inRed .55s cubic-bezier(.2,.8,.2,1) both; }
.auth-art .p-black { animation: inBlack .55s .1s cubic-bezier(.2,.8,.2,1) both; }
.auth-art .p-ball { animation: bounce .9s .45s both; }
@keyframes inRed { from { transform: translate(-160px, 260px); opacity: 0; } }
@keyframes inBlack { from { transform: translate(260px, 0); opacity: 0; } }
@keyframes bounce {
  0% { transform: translateY(-420px); opacity: 0; animation-timing-function: cubic-bezier(.5,0,1,.6); }
  40% { transform: translateY(0); opacity: 1; animation-timing-function: cubic-bezier(0,.4,.5,1); }
  65% { transform: translateY(-130px); animation-timing-function: cubic-bezier(.5,0,1,.6); }
  85% { transform: translateY(0); animation-timing-function: cubic-bezier(0,.4,.5,1); }
  93% { transform: translateY(-28px); animation-timing-function: cubic-bezier(.5,0,1,.6); }
  100% { transform: translateY(0); }
}
.auth-card { width: 100%; max-width: 400px; padding: 48px 24px 40px; position: relative; }
.auth h1 { font-size: 30px; line-height: 1.15; margin: 0; font-weight: 900; letter-spacing: .04em; }
.auth p.lead { margin: 6px 0 24px; color: var(--muted); font-size: 14.5px; }
.auth .hint { text-align: center; margin-top: 18px; }

/* ---------- 点名列表 ---------- */
.datebar { display: flex; align-items: center; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 5px; margin-bottom: 14px; }
.datebar .label { flex: 1; text-align: center; position: relative; padding: 2px 0; }
.datebar .label b { font-size: 16.5px; display: block; font-weight: 800; }
.datebar .label small { color: var(--muted); font-size: 12px; }
.datebar input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

.class-card { display: flex !important; padding: 0 !important; overflow: hidden; align-items: stretch; }
.cc-time { width: 76px; flex-shrink: 0; background: var(--black); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 0; }
.cc-time b { font-family: var(--num); font-size: 22px; line-height: 1; font-weight: 700; }
.cc-time span { font-family: var(--num); font-size: 13px; color: #A9ACB2; margin-top: 5px; }
.cc-time.none b { font-size: 14px; font-family: inherit; }
.cc-body { flex: 1; min-width: 0; padding: 13px 14px 12px; }
.cc-body .name { font-size: 17px; font-weight: 800; }
.cc-top { display: flex; align-items: flex-start; gap: 8px; }
.progress { height: 4px; background: var(--table); overflow: hidden; margin-top: 9px; }
.progress > i { display: block; height: 100%; background: var(--black); }
.state { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.state.todo { box-shadow: inset 0 0 0 1.5px var(--red); color: var(--red-ink); }
.state.done { background: var(--black); color: #fff; }
.state.part { background: var(--late-wash); color: var(--late); }

/* ---------- 点名：翻牌记分牌 ---------- */
.summary { position: sticky; top: calc(66px + var(--safe-t)); z-index: 5; background: var(--table); padding: 10px 0 8px; margin-top: -8px; }
.board { background: var(--black); color: #fff; border-radius: 12px; padding: 12px; display: flex; align-items: center; gap: 12px; }
.board-main { display: flex; align-items: center; gap: 6px; }
.flip { text-align: center; }
.flip b {
  display: block; min-width: 64px; padding: 4px 8px; border-radius: 6px; position: relative;
  font-family: var(--num); font-size: 42px; line-height: 1.05; font-weight: 700; font-variant-numeric: tabular-nums;
  background: linear-gradient(#232323 0 50%, #1A1A1A 50%);
}
.flip b::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1.5px; background: #000; }
.flip.hit b { color: #fff; }
.flip span { display: block; font-size: 11.5px; color: #A9ACB2; margin-top: 4px; }
.colon { font-family: var(--num); font-size: 30px; font-style: normal; color: #6B6E74; padding-bottom: 20px; }
.board-side { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.board-side div { display: flex; align-items: baseline; justify-content: space-between; font-size: 12.5px; color: #C4C6CA; border-bottom: 1px solid #262626; padding-bottom: 3px; }
.board-side b { font-family: var(--num); font-size: 19px; color: #fff; font-weight: 700; }
.board-side .absent b { color: #FF4040; }
.board-side .late b { color: #FFB547; }
.board-side .leave b { color: #8FB0EA; }
.missing { background: var(--paper); border-left: 4px solid var(--red); border-radius: 0 8px 8px 0; padding: 8px 12px; font-size: 13.5px; margin-top: 8px; }
.missing b { color: var(--red-ink); }
.missing .lv b { color: var(--leave); }
.missing.ok { border-left-color: var(--black); }
.missing.ok b { color: var(--black); }

.student-row { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 9px 9px 14px; margin-bottom: 7px; position: relative; overflow: hidden; }
.student-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.student-row.present::before { background: var(--black); }
.student-row.late::before { background: #E0900F; }
.student-row.leave::before { background: var(--leave); }
.student-row.absent::before { background: var(--red); }
.student-row.absent { background: #FFF6F6; border-color: #F6CACA; }
.student-row .nm { flex: 1; min-width: 0; font-weight: 700; font-size: 16.5px; }
.student-row .nm small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: flex; gap: 4px; flex-shrink: 0; }
.seg button { border: 1.5px solid var(--line); background: #fff; border-radius: 7px; min-width: 44px; height: 42px; padding: 0 6px; font-size: 13.5px; font-weight: 700; color: #7A7E85; cursor: pointer; }
.seg button.present { min-width: 52px; }
.seg button.on.present { background: var(--black); border-color: var(--black); color: #fff; }
.seg button.on.late { background: #E0900F; border-color: #E0900F; color: #fff; }
.seg button.on.leave { background: var(--leave); border-color: var(--leave); color: #fff; }
.seg button.on.absent { background: var(--red); border-color: var(--red); color: #fff; }
.seg button.on { animation: tap .16s ease-out; }
@keyframes tap { 50% { transform: scale(.92); } }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--paper); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + var(--safe-b)); }
.savebar-inner { max-width: 720px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }

/* ---------- 家长 ---------- */
.child { padding: 0; overflow: hidden; }
.child-head { display: flex; align-items: center; gap: 12px; padding: 16px; }
.child-head .avatar { width: 48px; height: 48px; font-size: 20px; background: var(--black); color: #fff; }
.latest { padding: 14px 16px; display: flex; align-items: center; gap: 12px; color: #fff; background: var(--black); }
.latest.absent { background: var(--red); }
.latest.late { background: #C77800; }
.latest.leave { background: var(--leave); }
.latest .big { font-size: 24px; font-weight: 900; line-height: 1.2; }
.latest .small { opacity: .85; }
.child-body { padding: 4px 16px 10px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stats div { text-align: center; padding: 8px 0 6px; background: #fff; }
.stats div + div { border-left: 1px solid var(--line); }
.stats b { display: block; font-family: var(--num); font-size: 22px; line-height: 1.1; font-weight: 700; }
.stats span { font-size: 11.5px; color: var(--muted); }
.stats .s-absent b { color: var(--red-ink); }
.stats .s-late b { color: var(--late); }
.stats .s-leave b { color: var(--leave); }
.rec { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.month { font-size: 13px; font-weight: 800; margin: 16px 0 2px; }
.month + .rec { border-top: 0; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { background: var(--paper); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 0 18px calc(18px + var(--safe-b)); animation: up .2s ease-out; }
.modal::before { content: ""; display: block; height: 4px; margin: 0 -18px 16px; background: linear-gradient(115deg, var(--red) 0 62%, var(--paper) 62% 63.2%, var(--black) 63.2%); }
@media (min-width: 640px) { .modal-backdrop { align-items: center; } .modal { border-radius: 14px; } }
.modal-head { display: flex; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 19px; flex: 1; font-weight: 800; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }

#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%) translateY(16px); background: var(--black); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 200; max-width: 88vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

.cred { background: var(--table); border-radius: 8px; padding: 12px 14px; font-size: 14.5px; white-space: pre-wrap; user-select: all; }
.menu { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.menu li + li { border-top: 1px solid var(--line); }
.menu li button { width: 100%; text-align: left; background: #fff; border: 0; padding: 15px 16px; cursor: pointer; font-size: 15px; }
.menu li button.danger { color: var(--red-ink); font-weight: 700; }

@media (max-width: 380px) {
  .seg button, .seg button.present { min-width: 38px; font-size: 12.5px; padding: 0 4px; }
  .flip b { min-width: 52px; font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
