/* ============================================================
   班级考勤系统 · 设计系统
   ------------------------------------------------------------
   结构：
     1. 设计令牌（颜色 / 间距 / 圆角 / 阴影 / 字体）
     2. 基础重置与排版
     3. 布局骨架（顶栏 / 标签页 / 主区）
     4. 通用组件（按钮 / 表单 / 卡片 / 徽标 / 提示）
     5. 数据表格（Excel 风格密集网格）
     6. 业务组件（考勤格子 / 状态选择器 / 导出面板）
     7. 浮层（弹窗 / 轻提示）
     8. 暗色模式
     9. 响应式与打印
   ============================================================ */

/* ============================================================
   1. 设计令牌
   ============================================================ */

:root {
  /* ---- 中性色阶 ---- */
  --c-0:   #ffffff;
  --c-25:  #fcfdfe;
  --c-50:  #f7f9fb;
  --c-100: #eef2f6;
  --c-150: #e4e9ef;
  --c-200: #d8dee6;
  --c-300: #b9c2ce;
  --c-400: #8b95a4;
  --c-500: #667085;
  --c-600: #4a5565;
  --c-700: #344054;
  --c-800: #1f2937;
  --c-900: #111827;

  /* ---- 品牌色 ---- */
  --brand-50:  #eff5ff;
  --brand-100: #dbe8fe;
  --brand-200: #bfd7fe;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;

  /* ---- 语义色 ---- */
  --ok-50: #ecfdf5;  --ok-200: #a7f3d0;  --ok-600: #059669;  --ok-700: #047857;
  --warn-50: #fffbeb; --warn-200: #fde68a; --warn-600: #d97706; --warn-700: #b45309;
  --danger-50: #fef2f2; --danger-200: #fecaca; --danger-600: #dc2626; --danger-700: #b91c1c;
  --violet-50: #f5f3ff; --violet-200: #ddd6fe; --violet-600: #7c3aed; --violet-700: #6d28d9;

  /* ---- 语义映射 ---- */
  --bg: var(--c-100);
  --surface: var(--c-0);
  --surface-2: var(--c-50);
  --surface-3: var(--c-25);
  --line: var(--c-150);
  --line-strong: var(--c-200);
  --text: var(--c-800);
  --text-2: var(--c-600);
  --text-3: var(--c-500);
  --text-4: var(--c-400);

  /* ---- 考勤状态 ---- */
  --st-leave-bg: #fef3c7;  --st-leave-fg: #92400e;  --st-leave-line: #fcd34d;
  --st-back-bg:  #d1fae5;  --st-back-fg:  #047857;  --st-back-line:  #6ee7b7;
  --st-absent-bg:#fee2e2;  --st-absent-fg:#991b1b;  --st-absent-line:#fca5a5;
  --st-late-bg:  #ffedd5;  --st-late-fg:  #9a3412;  --st-late-line:  #fdba74;
  --st-early-bg: #ede9fe;  --st-early-fg: #5b21b6;  --st-early-line: #c4b5fd;

  /* ---- 圆角 ---- */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 999px;

  /* ---- 阴影 ---- */
  --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --sh-md: 0 2px 4px -1px rgba(16, 24, 40, .06), 0 4px 10px -2px rgba(16, 24, 40, .1);
  --sh-lg: 0 8px 24px -4px rgba(16, 24, 40, .14), 0 2px 6px -1px rgba(16, 24, 40, .08);
  --sh-xl: 0 20px 48px -8px rgba(16, 24, 40, .22);

  /* ---- 动效 ---- */
  --ease: cubic-bezier(.2, .8, .3, 1);
  --t-fast: .12s;
  --t-base: .18s;

  /* ---- 尺寸 ---- */
  --topbar-h: 58px;
  --tabs-h: 44px;
  --row-h: 32px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          "Noto Sans CJK SC", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

/* ============================================================
   2. 基础重置与排版
   ============================================================ */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.01em; }

::selection { background: var(--brand-200); color: var(--brand-800); }

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

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--c-300) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--c-200);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--c-300); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ============================================================
   3. 布局骨架
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  /* 先给不透明底色兜底，再叠半透明（老浏览器忽略 color-mix 时不会变透明） */
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.logo {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--brand-500), var(--brand-700));
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  box-shadow: 0 1px 3px rgba(37, 99, 235, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.brand-text { min-width: 0; }

.brand h1 {
  font-size: 15px;
  font-weight: 640;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand .sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }

/* ---- 标签页 ---- */
.tabs {
  position: sticky;
  top: var(--topbar-h);
  z-index: 39;
  display: flex;
  gap: 2px;
  height: var(--tabs-h);
  align-items: stretch;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 520;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.tab::after {
  content: '';
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-600);
  opacity: 0;
  transform: scaleX(.6);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand-600); font-weight: 600; }
.tab.is-active::after { opacity: 1; transform: none; }

/* ---- 主区 ---- */
.view {
  padding: 18px 20px 56px;
  max-width: 100%;
  animation: viewIn .22s var(--ease);
}
@keyframes viewIn { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

.loading, .empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
}

.loading::before {
  content: '';
  display: block;
  width: 22px; height: 22px;
  margin: 0 auto 14px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.empty { color: var(--text-4); line-height: 1.9; }

/* ============================================================
   4. 通用组件
   ============================================================ */

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 520;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--sh-xs);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--c-300); }
.btn:active:not(:disabled) { transform: translateY(.5px); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: var(--brand-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .3), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
}

.btn-danger {
  background: linear-gradient(180deg, #ef4444, var(--danger-600));
  border-color: var(--danger-600);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-700); border-color: var(--danger-700); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--c-100); color: var(--text); border-color: transparent; }

.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: var(--r-xs); }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--c-100); color: var(--text); }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  text-align: left;
  transition: color var(--t-fast);
}
.link-btn:hover { color: var(--brand-600); }
.link-btn.xs { font-size: 12px; font-weight: 500; color: var(--brand-600); }
.link-btn.xs:hover { text-decoration: underline; }

/* ---- 顶栏状态徽标 ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 540;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}
.pill-ok    { background: var(--ok-50);     color: var(--ok-700);     border-color: var(--ok-200); }
.pill-fail  { background: var(--danger-50); color: var(--danger-700); border-color: var(--danger-200); }
.pill-muted { background: var(--c-100);     color: var(--text-3);     border-color: var(--line); }

/* ---- 面板 ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

.panel + .panel { margin-top: 16px; }
.stack > .panel + .panel { margin-top: 16px; }
.stack { margin-top: 16px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-3);
}
.panel-head h2 { font-size: 13.5px; font-weight: 620; }
.panel-head .hint { font-size: 12px; color: var(--text-3); }
.panel-body { padding: 14px 16px; }
.panel-body.scroll-y { max-height: 340px; overflow-y: auto; }

/* ---- 工具栏 ---- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.toolbar .spacer { flex: 1 1 auto; }
.toolbar .group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-xs);
}
.toolbar .label { font-size: 12.5px; color: var(--text-3); }

/* ---- 表单控件 ---- */
input[type="text"], input[type="date"], input[type="number"], input[type="time"],
input[type="datetime-local"], input[type="password"], input[type="search"],
select, textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 76px; line-height: 1.6; }
select { cursor: pointer; padding-right: 26px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: var(--c-300);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 16%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }

.search-input { min-width: 200px; }

.chk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 5px 2px;
}
.chk input, .radio-row input, .chip input {
  margin: 0;
  width: 15px; height: 15px;
  cursor: pointer;
  accent-color: var(--brand-600);
}

/* ---- 卡片 ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  position: relative;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand-400);
  opacity: .85;
}
.card .k { font-size: 12px; color: var(--text-3); font-weight: 500; }
.card .v {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 660;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}
.card .u { font-size: 12px; font-weight: 450; color: var(--text-4); margin-left: 3px; }
.card.c-danger::before { background: var(--danger-600); }
.card.c-danger .v { color: var(--danger-600); }
.card.c-warn::before { background: var(--warn-600); }
.card.c-warn .v { color: var(--warn-600); }
.card.c-ok::before { background: var(--ok-600); }
.card.c-ok .v { color: var(--ok-600); }

/* ---- 徽标 ---- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 560;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-pending  { background: var(--st-leave-bg);  color: var(--st-leave-fg);  border-color: var(--st-leave-line); }
.badge-returned { background: var(--st-back-bg);   color: var(--st-back-fg);   border-color: var(--st-back-line); }
.badge-cat      { background: var(--c-100);        color: var(--text-2);       border-color: var(--line); }
.badge-off      { background: var(--c-100);        color: var(--text-4);       border-color: var(--line); }

.rate {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 580;
  font-variant-numeric: tabular-nums;
}
.rate-ok   { background: var(--ok-50);     color: var(--ok-700); }
.rate-warn { background: var(--warn-50);   color: var(--warn-700); }
.rate-bad  { background: var(--danger-50); color: var(--danger-700); }

.danger-text { color: var(--danger-600); }

/* ---- 条形图 ---- */
.bars { padding: 2px 0; }
.bar-row {
  display: grid;
  grid-template-columns: 70px 1fr 108px;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  font-size: 12.5px;
}
.bar-row .bar-label { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { height: 18px; background: var(--c-100); border-radius: var(--r-xs); overflow: hidden; }
.bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  min-width: 3px;
  transition: width .4s var(--ease);
}
.bar-row .bar-val { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---- 图例 ---- */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--text-2);
  box-shadow: var(--sh-xs);
}
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  flex: none;
}
.legend .sw-present { background: var(--c-0); }
.legend .sw-leave   { background: var(--st-leave-bg);  border-color: var(--st-leave-line); }
.legend .sw-back    { background: var(--st-back-bg);   border-color: var(--st-back-line); }
.legend .sw-absent  { background: var(--st-absent-bg); border-color: var(--st-absent-line); }
.legend .sw-late    { background: var(--st-late-bg);   border-color: var(--st-late-line); }
.legend .sw-early   { background: var(--st-early-bg);  border-color: var(--st-early-line); }

/* ---- 表单栅格 ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 12.5px; font-weight: 560; color: var(--text-2); }
.field .tip { font-size: 11.5px; color: var(--text-4); line-height: 1.5; }
.field input, .field select, .field textarea { width: 100%; }

.radio-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding-top: 2px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* ---- 浅提示块 ---- */
.leave-preview {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  color: var(--brand-700);
  font-size: 12.5px;
  line-height: 1.6;
}
.leave-preview:empty { display: none; }
.leave-preview.is-error {
  background: var(--danger-50);
  border-color: var(--danger-200);
  color: var(--danger-700);
}

.cell-detail {
  padding: 10px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-500);
  font-size: 13px;
  line-height: 1.65;
}
.cell-detail strong { font-weight: 640; }

/* ============================================================
   5. 数据表格（Excel 风格密集网格）
   ============================================================ */

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.table-wrap.flush {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  max-height: 300px;
}

table.sheet {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}

table.sheet th, table.sheet td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0 9px;
  height: var(--row-h);
  text-align: left;
  white-space: nowrap;
}
table.sheet th:last-child, table.sheet td:last-child { border-right: 0; }
table.sheet tbody tr:last-child td { border-bottom: 0; }

table.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  user-select: none;
  box-shadow: inset 0 -1px 0 var(--line-strong);
}
table.sheet thead th.sortable { cursor: pointer; transition: background var(--t-fast); }
table.sheet thead th.sortable:hover { background: var(--brand-50); color: var(--brand-700); }
.sort-arrow { color: var(--brand-600); font-weight: 700; }

table.sheet tbody tr { transition: background var(--t-fast) var(--ease); }
table.sheet tbody tr:nth-child(even) td { background: var(--surface-3); }
table.sheet tbody tr:hover td { background: var(--brand-50); }

/* 冻结列 */
table.sheet .freeze-1 { position: sticky; left: 0; z-index: 2; }
table.sheet .freeze-2 { position: sticky; left: 52px; z-index: 2; }
table.sheet thead .freeze-1, table.sheet thead .freeze-2 { z-index: 5; background: var(--surface-2); }
table.sheet tbody .freeze-1, table.sheet tbody .freeze-2 { background: var(--surface); }
table.sheet tbody tr:nth-child(even) .freeze-1,
table.sheet tbody tr:nth-child(even) .freeze-2 { background: var(--surface-3); }
table.sheet tbody tr:hover .freeze-1,
table.sheet tbody tr:hover .freeze-2 { background: var(--brand-50); }
table.sheet .freeze-2 { box-shadow: 1px 0 0 var(--line); }

.col-seat { width: 52px; min-width: 52px; text-align: center !important; color: var(--text-3); font-variant-numeric: tabular-nums; }
.col-name { width: 96px; min-width: 96px; font-weight: 560; }
.col-sum  { width: 58px; min-width: 58px; text-align: center !important; }
.col-idx  { width: 42px; min-width: 42px; text-align: center !important; color: var(--text-4); font-size: 11.5px; }
.col-act  { width: 160px; min-width: 160px; }

.period-head { display: flex; flex-direction: column; line-height: 1.15; padding: 2px 0; }
.period-head small { font-size: 10.5px; color: var(--text-4); font-weight: 400; font-variant-numeric: tabular-nums; }

.date-head { font-size: 12.5px; font-weight: 640; }
.date-head small { display: block; font-size: 10.5px; color: var(--text-4); font-weight: 400; }

/* ---- 考勤格子 ---- */
td.cell {
  width: 40px;
  min-width: 40px;
  text-align: center;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 640;
  padding: 0;
  transition: box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
td.cell:hover {
  box-shadow: inset 0 0 0 2px var(--brand-500);
  filter: brightness(.96);
  position: relative;
  z-index: 1;
}
td.cell:active { filter: brightness(.9); }

td.cell.st-present { color: var(--text-4); background: var(--surface); }
td.cell.st-leave   { background: var(--st-leave-bg)  !important; color: var(--st-leave-fg); }
td.cell.st-back    { background: var(--st-back-bg)   !important; color: var(--st-back-fg); }
td.cell.st-absent  { background: var(--st-absent-bg) !important; color: var(--st-absent-fg); }
td.cell.st-late    { background: var(--st-late-bg)   !important; color: var(--st-late-fg); }
td.cell.st-early   { background: var(--st-early-bg)  !important; color: var(--st-early-fg); }

td.cell.is-blank { color: transparent; }
td.cell.is-blank::after { content: '·'; color: var(--c-200); font-weight: 400; }
td.cell.is-blank:hover::after { color: var(--text-4); }

/* 周视图更紧凑 */
table.sheet.compact th, table.sheet.compact td { height: 28px; padding: 0 3px; }
table.sheet.compact td.cell { width: 26px; min-width: 26px; font-size: 11.5px; }

/* ---- 状态选择器 ---- */
.status-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.sp-btn {
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13px;
  font-weight: 620;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), outline-color var(--t-fast);
  outline: 2px solid transparent;
  outline-offset: -1px;
}
.sp-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-sm); }
.sp-btn:active { transform: none; }
.sp-btn.is-current { outline-color: var(--brand-500); }
.sp-present { background: var(--surface); }
.sp-leave   { background: var(--st-leave-bg);  color: var(--st-leave-fg);  border-color: var(--st-leave-line); }
.sp-back    { background: var(--st-back-bg);   color: var(--st-back-fg);   border-color: var(--st-back-line); }
.sp-absent  { background: var(--st-absent-bg); color: var(--st-absent-fg); border-color: var(--st-absent-line); }
.sp-late    { background: var(--st-late-bg);   color: var(--st-late-fg);   border-color: var(--st-late-line); }
.sp-early   { background: var(--st-early-bg);  color: var(--st-early-fg);  border-color: var(--st-early-line); }

.batch-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   6. 导出配置面板
   ============================================================ */

.export-form { display: flex; flex-direction: column; gap: 16px; }

.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input { flex: 1; }
.range-sep { font-size: 12.5px; color: var(--text-3); flex: none; }

.quick-ranges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.export-section {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.export-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text-2);
}
.export-groups { display: flex; flex-direction: column; }
.export-group { padding: 10px 13px; }
.export-group + .export-group { border-top: 1px dashed var(--line); }
.export-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 580;
  color: var(--text-3);
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--c-300); background: var(--surface-2); }
.chip:has(input:checked) {
  background: var(--brand-50);
  border-color: var(--brand-400);
  color: var(--brand-700);
  font-weight: 560;
}
.chip input { flex: none; }

.export-hint {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
}
.export-hint.is-error {
  background: var(--danger-50);
  border-color: var(--danger-200);
  color: var(--danger-700);
  font-weight: 520;
}

/* ============================================================
   7. 浮层
   ============================================================ */

#modal-host[hidden] { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .16s var(--ease);
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  overflow: hidden;
  animation: pop .2s var(--ease);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.985) }
  to   { opacity: 1; transform: none }
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 14.5px; font-weight: 640; }

.modal-body { padding: 16px; overflow: auto; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-3);
}
.modal-foot:empty { display: none; }

.confirm-msg { margin: 0; font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; }

/* ---- 轻提示 ---- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  max-width: min(90vw, 560px);
  padding: 10px 17px;
  border-radius: var(--r-full);
  background: var(--c-800);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: var(--sh-lg);
  opacity: 0;
  transform: translateY(12px) scale(.97);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast-ok  { background: linear-gradient(180deg, #059669, #047857); }
.toast-err { background: linear-gradient(180deg, #dc2626, #b91c1c); }

/* ============================================================
   8. 暗色模式
   ============================================================ */

:root[data-theme="dark"] {
  --c-0:   #161b22;
  --c-25:  #1a2029;
  --c-50:  #1e2530;
  --c-100: #0f141a;
  --c-150: #2a323d;
  --c-200: #333c48;
  --c-300: #4a5565;
  --c-400: #6b7684;
  --c-500: #8b95a4;
  --c-600: #a8b2bf;
  --c-700: #c5ccd6;
  --c-800: #e6eaf0;
  --c-900: #f4f7fa;

  --brand-50:  #17243d;
  --brand-100: #1c2c4a;
  --brand-200: #24406e;

  --ok-50: #10261f;     --ok-200: #1e4d3c;
  --warn-50: #2a2113;   --warn-200: #5c4318;
  --danger-50: #2c1618; --danger-200: #6b2626;
  --violet-50: #211c34; --violet-200: #453a6b;

  --st-leave-bg: #4a3410;  --st-leave-fg: #fcd34d;  --st-leave-line: #6b4a12;
  --st-back-bg:  #0f3d2e;  --st-back-fg:  #6ee7b7;  --st-back-line:  #1a5c45;
  --st-absent-bg:#4a1d1d;  --st-absent-fg:#fca5a5;  --st-absent-line:#6b2828;
  --st-late-bg:  #4a2c12;  --st-late-fg:  #fdba74;  --st-late-line:  #6b3f1a;
  --st-early-bg: #2f2352;  --st-early-fg: #c4b5fd;  --st-early-line: #43336f;

  --sh-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --sh-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --sh-md: 0 2px 8px rgba(0, 0, 0, .45);
  --sh-lg: 0 8px 24px rgba(0, 0, 0, .5);
  --sh-xl: 0 20px 48px rgba(0, 0, 0, .6);
}

:root[data-theme="dark"] .logo {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .18);
}
:root[data-theme="dark"] .overlay { background: rgba(0, 0, 0, .62); }
:root[data-theme="dark"] .toast { background: var(--c-50); color: var(--c-900); }
:root[data-theme="dark"] .toast-ok { background: linear-gradient(180deg, #047857, #065f46); color: #ecfdf5; }
:root[data-theme="dark"] .toast-err { background: linear-gradient(180deg, #b91c1c, #991b1b); color: #fef2f2; }
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95a4' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .bar-track { background: var(--c-150); }

/* ============================================================
   9. 工具类 / 响应式 / 打印
   ============================================================ */

.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.mt-14 { margin-top: 14px; }

@media (max-width: 760px) {
  .view { padding: 14px 12px 48px; }
  .topbar { padding: 0 12px; height: 54px; }
  :root { --topbar-h: 54px; }
  .tabs { padding: 0 12px; }
  .brand .sub { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .status-picker { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { max-height: calc(100vh - 250px); }
  .toolbar .group { flex-wrap: wrap; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .bar-row { grid-template-columns: 56px 1fr 88px; gap: 8px; }
  .modal { max-height: calc(100vh - 24px); }
  .overlay { padding: 12px; }
}

/* 打印：把界面元素收起来，只留表格 */
@media print {
  .topbar, .tabs, .toolbar, .legend, .toast-host, #modal-host { display: none !important; }
  .view { padding: 0; }
  .table-wrap, .panel { border: 0; box-shadow: none; max-height: none; overflow: visible; }
  body { background: #fff; }
  table.sheet thead th { position: static; }
  table.sheet .freeze-1, table.sheet .freeze-2 { position: static; }
  .card { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   10. 校历
   ============================================================ */

.cal-wrap { padding: 14px 16px 18px; }

.cal-weekhead {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.cal-weekhead span {
  text-align: center;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 620;
  color: var(--text-3);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 64px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.cal-cell:hover {
  border-color: var(--brand-400);
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
  z-index: 1;
}
.cal-cell.is-outside { opacity: .3; }
.cal-cell.is-holiday { background: var(--c-100); }
.cal-cell.is-makeup { background: var(--st-leave-bg); border-color: var(--st-leave-line); }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--brand-500); }
.cal-cell.is-marked { box-shadow: inset 0 0 0 2px var(--brand-200); }
.cal-cell.is-marked.is-today { box-shadow: inset 0 0 0 2px var(--brand-500); }

.cal-day {
  font-size: 15px;
  font-weight: 620;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.cal-cell.is-today .cal-day { color: var(--brand-600); }
.cal-cell.is-holiday .cal-day { color: var(--text-4); }

.cal-name {
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cal-cell.is-makeup .cal-name { color: var(--st-leave-fg); font-weight: 600; }

.legend .sw-muted  { background: var(--c-100); }
.legend .sw-makeup { background: var(--st-leave-bg); border-color: var(--st-leave-line); }

/* ============================================================
   11. 课表
   ============================================================ */

.tt-wrap { overflow: auto; max-height: calc(100vh - 300px); }

.tt-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.tt-table th, .tt-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.tt-table tr > *:last-child { border-right: 0; }
.tt-table tbody tr:last-child > * { border-bottom: 0; }

.tt-period {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 98px;
  min-width: 98px;
  padding: 8px 6px;
  background: var(--surface-2);
  text-align: center;
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text-2);
}
.tt-period small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.tt-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 9px 8px;
  background: var(--surface-2);
  text-align: center;
  font-size: 13px;
  font-weight: 620;
  color: var(--text-2);
}
.tt-head.is-today { background: var(--brand-50); color: var(--brand-700); }
.tt-head.is-holiday { background: var(--c-100); color: var(--text-4); }
.tt-head-tag {
  display: block;
  margin-top: 1px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-4);
}
.tt-head.is-today .tt-head-tag { color: var(--brand-600); }

.tt-cell {
  height: 58px;
  min-width: 112px;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
  background: var(--surface);
  cursor: pointer;
  transition: box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
.tt-cell:hover { box-shadow: inset 0 0 0 2px var(--brand-500); z-index: 1; }
.tt-cell.is-holiday { background: var(--c-100); }

.tt-add { color: var(--c-200); font-size: 16px; line-height: 1; }
.tt-cell.is-empty:hover .tt-add { color: var(--brand-500); }

.tt-subject { display: block; font-size: 13.5px; font-weight: 640; line-height: 1.25; }
.tt-sub { display: block; margin-top: 2px; font-size: 11px; opacity: .72; line-height: 1.25; }

/* 科目配色：按名字哈希到 10 个色板 */
.subj-0 { --sb: #dbeafe; --sf: #1e40af; }
.subj-1 { --sb: #dcfce7; --sf: #166534; }
.subj-2 { --sb: #fef3c7; --sf: #92400e; }
.subj-3 { --sb: #fce7f3; --sf: #9d174d; }
.subj-4 { --sb: #ede9fe; --sf: #5b21b6; }
.subj-5 { --sb: #ccfbf1; --sf: #115e59; }
.subj-6 { --sb: #ffe4e6; --sf: #9f1239; }
.subj-7 { --sb: #e0e7ff; --sf: #3730a3; }
.subj-8 { --sb: #fef9c3; --sf: #854d0e; }
.subj-9 { --sb: #e2e8f0; --sf: #334155; }

.tt-cell[class*="subj-"] { background: var(--sb); }
.tt-cell[class*="subj-"] .tt-subject { color: var(--sf); }
.tt-cell[class*="subj-"] .tt-sub { color: var(--sf); }

.chip[class*="subj-"] {
  background: var(--sb);
  color: var(--sf);
  border-color: transparent;
  font-weight: 560;
}
.chip[class*="subj-"]:hover { filter: brightness(.97); }

:root[data-theme="dark"] .subj-0 { --sb: #1e3a5f; --sf: #bfdbfe; }
:root[data-theme="dark"] .subj-1 { --sb: #14392a; --sf: #86efac; }
:root[data-theme="dark"] .subj-2 { --sb: #42320f; --sf: #fcd34d; }
:root[data-theme="dark"] .subj-3 { --sb: #43142e; --sf: #f9a8d4; }
:root[data-theme="dark"] .subj-4 { --sb: #2e2352; --sf: #c4b5fd; }
:root[data-theme="dark"] .subj-5 { --sb: #0f3d3a; --sf: #5eead4; }
:root[data-theme="dark"] .subj-6 { --sb: #43141c; --sf: #fda4af; }
:root[data-theme="dark"] .subj-7 { --sb: #232a5c; --sf: #a5b4fc; }
:root[data-theme="dark"] .subj-8 { --sb: #3d340f; --sf: #fde047; }
:root[data-theme="dark"] .subj-9 { --sb: #26303d; --sf: #cbd5e1; }

/* 可点击 / 只读的胶囊 */
.chip.is-btn { cursor: pointer; }
.chip.is-btn.is-active {
  background: var(--brand-50);
  border-color: var(--brand-500);
  color: var(--brand-700);
  font-weight: 620;
}
.chip.is-static { cursor: default; }
.chip.is-static .muted { font-size: 11px; opacity: .8; }

/* ============================================================
   12. 提示条 / 考勤表头的科目
   ============================================================ */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 15px;
  margin-bottom: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.6;
}
.notice b { flex: none; font-weight: 640; }
.notice span { color: var(--text-3); }

.notice-holiday {
  background: var(--st-leave-bg);
  border-color: var(--st-leave-line);
  color: var(--st-leave-fg);
}
.notice-holiday span { color: inherit; opacity: .85; }

/* 提醒条：区间外还有未销假的待办 */
.notice-warn {
  background: var(--warn-50);
  border-color: var(--warn-200);
  color: var(--warn-700);
}
.notice-warn span { color: inherit; opacity: .85; }
.notice-warn .btn { margin-left: auto; flex: none; }

/* 第 N 节下面那行小字：这节课上什么 */
.ph-subject {
  display: block;
  font-size: 11px;
  font-weight: 640;
  line-height: 1.25;
  color: var(--brand-600);
}

/* 按校历放假的那一列 */
.date-head.is-holiday { background: var(--c-100); color: var(--text-4); }
td.cell.is-holiday-col { background: var(--c-100); }
td.cell.is-holiday-col.is-blank::after { color: var(--c-300); }

@media (max-width: 760px) {
  .cal-cell { min-height: 52px; padding: 5px 6px; }
  .cal-day { font-size: 13px; }
  .cal-name { display: none; }
  .cal-wrap { padding: 10px; }
  .tt-period { width: 74px; min-width: 74px; font-size: 11.5px; }
  .tt-cell { min-width: 84px; height: 50px; }
  .tt-subject { font-size: 12px; }
  .tt-sub { display: none; }
}
