:root {
  --brand: #2f6f4e;
  --brand-dark: #23553c;
  --brand-light: #e8f1ec;
  --danger: #b3372f;
  --warn: #b07a12;
  --text: #1f2421;
  --muted: #6b746e;
  --line: #dfe5e0;
  --bg: #f4f6f4;
  --card: #ffffff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  padding-bottom: 76px;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 600; font-size: 16px; }
.topbar .who { font-size: 13px; opacity: .92; display: flex; align-items: center; gap: 10px; }
.topbar form button {
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.nav {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  overflow: visible;
  gap: 4px;
  padding: 0 10px;
  position: sticky;
  top: 53px;
  z-index: 19;
}
.nav a {
  padding: 12px 12px 10px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; text-decoration: none; }
.nav-group { position: relative; }
.nav-group > summary {
  padding: 12px 12px 10px; font-size: 14px; color: var(--muted);
  white-space: nowrap; cursor: pointer; list-style: none; border-bottom: 2px solid transparent;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group.open > summary, .nav-group[open] > summary, .nav-group:has(a.active) > summary { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.nav-group[open] { z-index: 30; }
.nav-sub {
  position: absolute; top: 100%; left: 0; min-width: 128px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.12);
  padding: 6px; display: flex; flex-direction: column; z-index: 30;
}
.nav-sub-title { color: var(--muted); font-size: 11px; padding: 8px 10px 3px; }
.nav-sub-title:first-child { padding-top: 4px; }
.nav-sub a { padding: 8px 10px; border-bottom: none; border-radius: 7px; }
.nav-sub a.active { background: #eef7f1; }

main { padding: 16px; max-width: 1120px; margin: 0 auto; }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card.tight { padding: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; border: 1px solid; }
.flash.success { background: #eaf6ee; border-color: #b9e0c6; color: #1f5c3c; }
.flash.error { background: #fbeceb; border-color: #efc3bf; color: #8d2b24; }
.flash.info { background: #eef3fb; border-color: #c7d7ef; color: #22497b; }
.flash.warn { background: #fdf4e0; border-color: #ecd9a8; color: #7c5606; }

.banner { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.banner.danger { background: #fbeceb; color: #8d2b24; border: 1px solid #efc3bf; }
.banner.warn { background: #fdf4e0; color: #7c5606; border: 1px solid #ecd9a8; }
.banner.info { background: #eef3fb; color: #22497b; border: 1px solid #c7d7ef; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border-radius: 10px; padding: 10px 16px; font-size: 14px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  cursor: pointer; min-height: 42px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; }
.btn.danger { background: #fff; border-color: #e0b4b0; color: var(--danger); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.students { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }

.metric { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.metric .label { font-size: 12px; color: var(--muted); }
.metric .value { font-size: 24px; font-weight: 700; color: var(--brand-dark); line-height: 1.2; }
.metric .hint { font-size: 12px; color: var(--muted); }

.student-chip {
  position: relative; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 8px 6px; text-align: center; cursor: pointer;
  font-size: 15px; line-height: 1.25; min-height: 62px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 0; overflow: hidden; font-family: inherit; color: var(--text);
}
.student-chip .nm { font-weight: 600; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.student-chip .no { font-size: 10px; color: #7b8794; letter-spacing: .3px; }
.student-chip .meta { font-size: 11px; color: var(--muted); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-chip .meal-dot {
  position: absolute; top: 3px; right: 4px; font-size: 9px; line-height: 1.3;
  background: #eef3fb; color: #22497b; border-radius: 4px; padding: 0 3px;
}
.student-chip.absent { border-color: #d98f88; background: #fdf0ee; color: #8d2b24; }
.student-chip.absent::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #c0392b;
}
.student-chip.absent .meta { color: #8d2b24; font-weight: 600; }

/* 点名页手机工具条 */
.stu-toolbar {
  position: sticky; top: 104px; z-index: 18; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 2px 10px rgba(20, 30, 24, .06);
}
.stu-search {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 12px; font-size: 15px; font-family: inherit; background: #fafbfa;
}
.stu-search:focus { outline: none; border-color: var(--brand); background: #fff; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 8px 0; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; font-size: 13px; color: var(--muted); cursor: pointer;
  font-family: inherit; min-height: 36px;
}
.seg button.active {
  background: var(--brand-light); border-color: var(--brand);
  color: var(--brand-dark); font-weight: 600;
}
.stu-hint { font-size: 11px; color: var(--muted); text-align: center; }

/* 底部弹层：类别按钮与操作区 */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.cat-option {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 11px 10px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
  color: var(--text); background: #fff; cursor: pointer; min-height: 46px;
}
.cat-option input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.cat-option.sel { border-color: var(--brand); background: var(--brand-light); }
.modal-error { display: none; color: var(--danger); font-size: 13px; margin-top: 8px; }
.sheet-actions {
  position: sticky; bottom: -24px; background: #fff; padding: 10px 0 0;
  display: flex; gap: 10px; margin-top: 10px;
}
.sheet-actions .btn { flex: 1; min-height: 44px; }

.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--brand-light); color: var(--brand-dark); }
.tag.warn { background: #fdf4e0; color: #7c5606; }
.tag.danger { background: #fbeceb; color: #8d2b24; }
.tag.gray { background: #eef0ee; color: #5c655f; }
.tag.good { background: #e8f1ec; color: #245c41; }
.tag.meal { background: #eef3fb; color: #22497b; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-size: 13px; padding: 12px 0; text-align: center; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f7f9f7; font-weight: 600; white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; font-size: 15px; background: #fff; color: var(--text);
  font-family: inherit;
}
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.inline-field { display: flex; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); margin: 6px 0; }
.check input { width: 18px; height: 18px; }

.modal {
  position: fixed; inset: 0; background: rgba(17, 24, 20, .48);
  display: none; align-items: flex-end; justify-content: center; z-index: 60;
}
.modal.open { display: flex; }
.sheet {
  background: #fff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0;
  padding: 18px 18px 24px; max-height: 92vh; overflow-y: auto;
}
@media (min-width: 720px) {
  .modal { align-items: center; }
  .sheet { border-radius: 16px; max-height: 88vh; }
}

.footer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line); backdrop-filter: blur(6px);
  display: flex; gap: 10px; align-items: center; padding: 10px 14px; z-index: 30;
}
.footer-bar .info { font-size: 13px; color: var(--muted); flex: 1; }
.footer-bar .btn { flex-shrink: 0; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding: 6px 0 8px; z-index: 30;
}
.bottom-nav a { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 10px; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav { display: none; }

.chart { width: 100%; }
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }

.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 24px; border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(24,44,33,.06); }
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card .page-sub { text-align: center; }

.public-page { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; }
.public-head { text-align: center; margin: 10px 0 20px; }

.proof-thumb { width: 100%; max-width: 150px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.file-line { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.file-line .grow { flex: 1; min-width: 0; }

.role-note { font-size: 12px; color: var(--muted); }
.warning-item { padding: 10px 12px; border-radius: 9px; margin-bottom: 8px; border: 1px solid var(--line); }
.warning-item.danger { background: #fdf1ef; border-color: #f0c9c4; }
.warning-item.warning { background: #fdf8e9; border-color: #eadcae; }
.warning-item .t { font-weight: 600; }
.warning-item .d { font-size: 13px; color: var(--muted); }

details summary { cursor: pointer; color: var(--brand-dark); font-size: 13px; }

@media (max-width: 560px) {
  main { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .nav { top: 47px; }
  h1 { font-size: 18px; }
}

/* ---------- 工作日历 ---------- */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-head div { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-day {
  position: relative; margin: 0; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; display: block; overflow: hidden;
}
.cal-day .cal-btn {
  width: 100%; min-height: 64px; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 3px; font-family: inherit; color: inherit;
}
.cal-day .num { font-size: 17px; font-weight: 700; line-height: 1.1; }
.cal-day .cal-tag { font-size: 10px; color: #57606a; text-align: center; line-height: 1.2; }
.cal-day .cal-state {
  font-size: 10px; font-weight: 600; color: #fff; border-radius: 999px;
  padding: 0 7px; margin-top: 1px;
}
.cal-day .cal-flag {
  position: absolute; top: 3px; right: 4px; font-size: 9px; line-height: 1.4;
  padding: 0 3px; border-radius: 4px; background: #ffb703; color: #3b2a00;
}

/* 工作日：绿色实底 */
.cal-day.workday { background: #e6f6ec; border-color: #b6dfc4; }
.cal-day.workday .num { color: #135235; }
.cal-day.workday .cal-state { background: #2f7d55; }

/* 节假日 / 停课：红色实底 */
.cal-day.holiday { background: #fde5e1; border-color: #efb0a6; }
.cal-day.holiday .num { color: #9d2117; }
.cal-day.holiday .cal-state { background: #c0392b; }

/* 周末：灰色实底 */
.cal-day.weekend { background: #eceff3; border-color: #d3d9df; }
.cal-day.weekend .num { color: #55606b; }
.cal-day.weekend .cal-state { background: #8b97a3; }

/* 今天 */
.cal-day.is-today { box-shadow: 0 0 0 3px var(--brand); }
/* 手动调整：虚线框 */
.cal-day.manual { border-style: dashed; border-width: 2px; }

.cal-empty { visibility: hidden; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--line); }
.legend .l-work::before { background: #e6f6ec; border-color: #b6dfc4; }
.legend .l-holiday::before { background: #fde5e1; border-color: #efb0a6; }
.legend .l-weekend::before { background: #eceff3; border-color: #d3d9df; }
.legend .l-manual::before { background: #fff; border: 1px dashed #b07d00; }
.cal-cell-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* 点名门禁提示 */
.gate-banner { margin: 10px 0 0; font-size: 14px; }
.gate-line { margin-top: 6px; }
.gate-line a { margin-right: 8px; font-weight: 600; }


/* 页脚备案号 */
.site-footer { text-align: center; padding: 18px 16px 26px; color: #8a938d;
  font-size: 12px; line-height: 1.8; }
.site-footer a { color: #6b746e; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
